当前位置: 首页>>代码示例>>C++>>正文


C++ QDir::absPath方法代码示例

本文整理汇总了C++中QDir::absPath方法的典型用法代码示例。如果您正苦于以下问题:C++ QDir::absPath方法的具体用法?C++ QDir::absPath怎么用?C++ QDir::absPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDir的用法示例。


在下文中一共展示了QDir::absPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadOptions

/**
 * Loads the application options.
 * Loads the options from $HOME/.qfsm/qfsmrc into @a opt.
 */
int FileIO::loadOptions(Options* opt)
{
  int result=0;
  QDir dir = QDir::home();
  QMap<QString, QString> _map;
  QString key, value;

#ifdef WIN32
  QFile file(dir.absPath()+"/Application Data/qfsm/qfsmrc");
#else
  QFile file(dir.absPath()+"/.qfsm/qfsmrc");
#endif

  if (!file.open(QIODevice::ReadOnly))
  {
    qDebug("options not loaded");
    return 1;
  }

  Q3TextStream fin(&file);

  fin >> key >> value;

  while (!fin.eof())
  {
    _map.insert(key, value);
    fin >> key >> value;
    if (value==getEmptyFieldString())
      value="";
  }

  setOptions(&_map, opt);

  return result;
}
开发者ID:Kampbell,项目名称:qfsm,代码行数:39,代码来源:FileIO.cpp

示例2: createDirectory

void CodeManager::createDirectory(const QDir &path)
{
    if (!path.exists()) {
        if (!path.mkdir(path.absPath())) {
            throw PoaException
	      (QString(qApp->translate("codemanager","Could not create directory: %1")).arg(path.absPath()));
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:poa,代码行数:9,代码来源:codemanager.cpp

示例3: readDir

void QtFileIconView::readDir( const QDir &dir )
{
    if ( !dir.isReadable() )
        return;

    if ( isRoot( dir.absPath() ) )
        emit disableUp();
    else
        emit enableUp();

    clear();

    emit directoryChanged( dir.absPath() );

    const QFileInfoList *filist = dir.entryInfoList( QDir::DefaultFilter, QDir::DirsFirst | QDir::Name );

    emit startReadDir( filist->count() );

    QFileInfoListIterator it( *filist );
    QFileInfo *fi;
    bool allowRename = FALSE, allowRenameSet = FALSE;
    while ( ( fi = it.current() ) != 0 ) {
        ++it;
        if ( fi && fi->fileName() == ".." && ( fi->dirPath() == "/" || fi->dirPath().isEmpty() ) )
            continue;
        emit readNextDir();
        QtFileIconViewItem *item = new QtFileIconViewItem( this, new QFileInfo( *fi ) );
        if ( fi->isDir() )
            item->setKey( QString( "000000%1" ).arg( fi->fileName() ) );
        else
            item->setKey( fi->fileName() );
        if ( !allowRenameSet ) {
            if ( !QFileInfo( fi->absFilePath() ).isWritable() ||
                    item->text() == "." || item->text() == ".." )
                allowRename = FALSE;
            else
                allowRename = TRUE;
            if ( item->text() == "." || item->text() == ".." )
                allowRenameSet = FALSE;
            else
                allowRenameSet = TRUE;
        }
        item->setRenameEnabled( allowRename );
    }

    if ( !QFileInfo( dir.absPath() ).isWritable() )
        emit disableMkdir();
    else
        emit enableMkdir();

    emit readDirDone();
}
开发者ID:natros,项目名称:qt-mac-free-3.3.8,代码行数:52,代码来源:qfileiconview.cpp

示例4: copyLnkFiles

void PMenu::copyLnkFiles(QDir base_dir)
{
  PMenuItem *item;
  for( item = list.first(); item != 0; item = list.next() )
    {
      if( item->entry_type == submenu )
	{
	  QDir sub_dir(base_dir);
	  if( item->old_name.isEmpty() )
	    {
	      if( item->real_name.isEmpty() )
		item->real_name = item->text_name;
	      base_dir.mkdir(item->real_name);
	      if( !sub_dir.cd(item->real_name) )
		continue;
	    }
	  else
	    {
	      if( !base_dir.exists( item->old_name ) )
		{
		  base_dir.mkdir(item->old_name);
		  if( base_dir.exists( item->dir_path + '/' + item->old_name + "/.directory") )
		    copyFiles( item->dir_path + '/' + item->old_name + "/.directory",
			       base_dir.absPath() + '/' + item->old_name + "/.directory" );
		}
	      if( !sub_dir.cd(item->old_name) )
		continue;
	    }
	  item->sub_menu->copyLnkFiles( sub_dir );
	}
    }
  for( item = list.first(); item != 0; item = list.next() )
    {
      if( item->entry_type == separator || item->old_name.isEmpty() )
	continue;
      if( item->entry_type != submenu )
	{
	  if( base_dir.exists( item->old_name ) )
	    continue;
	  else
	    {
	      if( base_dir.exists( item->dir_path + '/' + item->old_name ) )
		copyFiles( item->dir_path + '/' + item->old_name,
			    base_dir.absPath() + '/' + item->old_name );
	    }
	}
    }  
}
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:48,代码来源:pmenu.cpp

示例5: save

void Engine::save() throw(PersistingException*)
{
    tracer->invoked(__func__);

    if (m_dirty) {
        tracer->sdebug(__func__) << "engine is dirty --> saving it..." << endl;

        // rename current file
        QDir path = m_fileAlbum->dirPath(true);
        QString oldFileName = m_fileAlbum->fileName();

        // create new filename
        QString basename = QFileInfo(oldFileName).baseName(true);
        QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd-hhmmsszzz");
        QString newFileName = QString("%1-%2.%3").arg(basename).arg(timestamp).arg(Constants::FILE_EXTENSION);

        tracer->sdebug(__func__) << "backing up file in directory '" << path.absPath() << "': '" << oldFileName << "' --> '" << newFileName << "'..." << endl;

        if (!path.rename(oldFileName, newFileName, false)) {
            QString msg = QString("Could not move old file '%1/%2' to '%3/%4'. Not saving file. Use 'Save As'.").arg(path.absPath()).arg(oldFileName).arg(path.absPath()).arg(newFileName);
            throw new PersistingException(
                msg,
                ""
            );
        }

        // save
        XmlWriter writer = XmlWriter(*this);
        writer.store(new QFile(m_fileAlbum->absFilePath()));
    }

    m_dirty = false;
}
开发者ID:BackupTheBerlios,项目名称:kphotobook-svn,代码行数:33,代码来源:engine.cpp

示例6: scanDir

/**
 * Recursively scans a directory for a files matching the current filter.
 * @param	dir	A directory object set to the folder from which files are
 *			added
 * @return	The total number of files added
 */
int DirScanner::scanDir(QDir& dir)
{
	QString sCanon;
	QStringList slDirFiles, slDirs;
	QStringList::const_iterator itr;
	QString sFile;
	int nFiles = 0;

	if (m_bCancel)
		return -1;
		
	// Make sure this directory has not been previously visited (e.g., through a
	// symbolic link)
	sCanon = dir.canonicalPath();
	if (m_setScanned.exists(sCanon))
		return 0;
	
	m_setScanned.insert(sCanon);
	
	// Add all files in this directory
	slDirFiles = dir.entryList(m_sNameFilter, QDir::Files);
	for (itr = slDirFiles.begin(); itr != slDirFiles.end(); ++itr) {
		sFile = dir.absPath() + "/" + *itr;

		// Make sure an entry for this file does not exist
		if (m_pDicFiles->find(sFile) == NULL) {
			m_slFiles.append(sFile);
			nFiles++;
		}
	}

	QApplication::postEvent(m_pEventReceiver,
		new DirScanEvent(nFiles, false));
	
	// Recurse into sub-directories, if requested
	if (!m_bRecursive)
		return nFiles;

	slDirs = dir.entryList(QDir::Dirs);

	// Iterate the list of sub-directories
	for (itr = slDirs.begin(); itr != slDirs.end(); ++itr) {
		if (m_bCancel)
			return -1;
			
		// Skip the "." and ".." directories
		if (*itr == "." || *itr == "..")
			continue;

		// Add the files in each sub-directory
		QDir dirSub(dir);
		if (dirSub.cd(*itr))
			nFiles += scanDir(dirSub);
	}

	return nFiles;
}
开发者ID:VicHao,项目名称:kkscope,代码行数:63,代码来源:dirscanner.cpp

示例7:

void SkyBackgroundPluginForm::on_Preset3_4PushButton_clicked()
{
	QDir dir = skyDir;
	dir.cd(presetDirs[2].path());
	dir.cd("19");
	setupSkyBackground(dir, zUpCheckBox->isChecked());
	directoryLineEdit->setText(dir.absPath());
	enableCheckBox->setChecked(true);
}
开发者ID:ufz-vislab,项目名称:vislab,代码行数:9,代码来源:SkyBackgroundPluginForm.cpp

示例8: writeConfig

void PMenuItem::writeConfig( QDir dir )
{
  if( read_only || entry_type == separator )
    return;
  QString file = dir.absPath();
  dir_path = file.copy();
  file += ( (QString) "/" + real_name ); //+ ".kdelnk" );
  QFile config(file);
  if( !config.open(IO_ReadWrite) ) 
    return;
  config.close();
  KConfig kconfig(file);
  kconfig.setGroup("KDE Desktop Entry");
  kconfig.writeEntry("Comment", comment, TRUE, FALSE, TRUE );
  kconfig.writeEntry("Icon", big_pixmap_name );
  kconfig.writeEntry("MiniIcon", pixmap_name );
  kconfig.writeEntry("Name", text_name, TRUE, FALSE, TRUE );
  switch( (int) entry_type ) {
  case (int) swallow_com:
    kconfig.writeEntry("SwallowExec", swallow_exec );
    kconfig.writeEntry("SwallowTitle", swallow_title );
    //break;
  case (int) unix_com:
    if( entry_type == unix_com )
      {
	kconfig.writeEntry("SwallowExec", "" );
	kconfig.writeEntry("TerminalOptions", term_opt );
      }
    kconfig.writeEntry("Exec", command_name );
    kconfig.writeEntry("Path", exec_path );
    if( use_term )
      kconfig.writeEntry("Terminal", 1 );
    else
      kconfig.writeEntry("Terminal", 0 );
    kconfig.writeEntry("BinaryPattern", pattern);
    kconfig.writeEntry("Protocols", protocols);
    kconfig.writeEntry("MimeType", extensions);
    kconfig.writeEntry("Type", "Application");
    break;
  case (int) url:
    kconfig.writeEntry("URL", url_name);
    kconfig.writeEntry("Type", "Link");
    break;
  case (int) device:
    kconfig.writeEntry("Dev", dev_name);
    kconfig.writeEntry("MountPoint", mount_point);
    kconfig.writeEntry("FSType", fs_type);
    kconfig.writeEntry("UnmountIcon", umount_pixmap_name);
    kconfig.writeEntry("ReadOnly", dev_read_only);
    kconfig.writeEntry("Type", "FSDevice");
    break;
  };
  kconfig.sync();
}
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:54,代码来源:pmenu.cpp

示例9: createFolder

void KJotsMain::createFolder()
{
  AskFileName *ask = new AskFileName(this);
  if( ask->exec() == QDialog::Rejected )
    return;
  QString name = ask->getName();
  delete ask;
  if( folder_list.contains(name) )
    {
      QMessageBox::message(klocale->translate("Warning"), 
			   klocale->translate("A book with this name already exists."), 
			   klocale->translate("OK"), this);
      return;
    }
  saveFolder();
  entrylist.clear();
  folderOpen = TRUE;
  me_text->setEnabled(TRUE);
  le_subject->setEnabled(TRUE);
  me_text->setFocus();
  me_text->clear();
  me_text->deselect();
  TextEntry *new_entry = new TextEntry;
  entrylist.append(new_entry);
  new_entry->subject = "";
  current = 0;
  s_bar->setRange(0,0);
  s_bar->setValue(0);
  emit folderChanged(&entrylist);
  emit entryMoved(current);
  le_subject->setText(entrylist.first()->subject);

  folder_list.append(name);
  if( folders->text(folders->idAt(0)) == 0 )
    folders->removeItemAt(0);
  folders->insertItem(name, unique_id++);
  //QDir dir = QDir::home();
  //dir.cd(".kde/share/apps/kjots");
  QDir dir = QDir( KApplication::localkdedir().data() );
  dir.cd("share/apps/kjots");
  current_folder_name = dir.absPath();
  current_folder_name += '/';
  current_folder_name += name;
  KConfig *config = KApplication::getKApplication()->getConfig();
  config->setGroup("kjots");
  config->writeEntry( "Folders", folder_list );
  config->sync();
  l_folder->setText(name);
  QPushButton *but;
  for( but = button_list.first(); but != 0; but = button_list.next() )
    but->setOn(FALSE);
}
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:52,代码来源:KJotsMain.cpp

示例10: slotSwitchToView

void RubySupportPart::slotSwitchToView()
{
    KParts::Part *activePart = partController()->activePart();
    if (!activePart)
        return;
    KParts::ReadOnlyPart *ropart = dynamic_cast<KParts::ReadOnlyPart*>(activePart);
    if (!ropart)
        return;
    QFileInfo file(ropart->url().path());
    if (!file.exists())
        return;
    QString ext = file.extension();
    QString name = file.baseName();
    QString switchTo = "";

    if (ext == "rjs" || ext == "rxml" || ext == "rhtml" || ext == "js.rjs" || ext == "xml.builder" || ext == "html.erb")
    {
        //this is a view already, let's show the list of all views for this model
        switchTo = file.dir().dirName();
    }
    else if (ext == "rb")
        switchTo = name.remove(QRegExp("_controller$")).remove(QRegExp("_controller_test$")).remove(QRegExp("_test$"));

    if (switchTo.isEmpty())
        return;

    if (switchTo.endsWith("s"))
        switchTo = switchTo.mid(0, switchTo.length() - 1);

    KURL::List urls;
    QDir viewsDir;
    QDir viewsDirS = QDir(project()->projectDirectory() + "/app/views/" + switchTo);
    QDir viewsDirP = QDir(project()->projectDirectory() + "/app/views/" + switchTo + "s");
    if (viewsDirS.exists())
        viewsDir = viewsDirS;
    else if (viewsDirP.exists())
        viewsDir = viewsDirP;
    else
        return;

    QStringList views = viewsDir.entryList();

    for (QStringList::const_iterator it = views.begin(); it != views.end(); ++it)
    {
        QString viewName = *it;
        if ( !(viewName.endsWith("~") || viewName == "." || viewName == "..") )
            urls << KURL::fromPathOrURL(viewsDir.absPath() + "/" + viewName);
    }
    KDevQuickOpen *qo = extension<KDevQuickOpen>("KDevelop/QuickOpen");
    if (qo)
        qo->quickOpenFile(urls);
}
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:52,代码来源:rubysupport_part.cpp

示例11: go

void MainWindow::go() {
  Photo  *photo;
  Image   img;
  int     num, diff, offset;
  QDir    dir = QDir::home();
  DCOPRef desktop;

  desktop.setRef( "kdesktop", "KBackgroundIface" );   // turns out DCOP is the easiest way
  dir.cd( "images" );
  if (!dir.exists("flickr"))
    dir.mkdir("flickr");
  dir.cd( "flickr" );

  for (photo = photos.first(); photo; photo = photos.next()) {
    num = photo->desktop; 
    if (num == 0)
      continue;

    qDebug("width: %d; height: %d; ratio: %f", photo->width, photo->height, photo->ratio);

    KURL destUrl( QString("file://%1/%2").arg(dir.absPath()).arg(photo->url.fileName()) );
    qDebug( destUrl.url() );
    qDebug( photo->url.url() );
    if (KIO::NetAccess::file_copy(photo->url, destUrl, -1, false)) {
      img.read(destUrl.path());    
      
      if (photo->ratio < dratio) {
        // height needs to be changed
        diff   = (int)roundf(photo->height - (photo->width / dratio));
        offset = diff / 2;
        img.chop(Geometry(0, offset));
        img.crop(Geometry(photo->width, photo->height - diff));
      }
      else if (photo->ratio > dratio) {
        // width needs to be changed
        diff   = (int)roundf(photo->width - (photo->height * dratio));
        offset = diff / 2;
        img.chop(Geometry(offset, 0));
        img.crop(Geometry(photo->width - diff, photo->height));
      }

      img.scale(Geometry(dwidth, dheight));
      img.write(destUrl.path());
    }
    desktop.call( "setWallpaper", num, destUrl.path(), 1 );
  }
}
开发者ID:viking,项目名称:kawalla,代码行数:47,代码来源:window.cpp

示例12: load_module_ex

void myQLoader::load_module_ex(const QString& name, bool module, const QString& nameModule, const QPixmap& pix)
{
  if(!module)
	{
	  worker->clearArguments();
	   //add code run program
	   
	  QStringList str = QStringList::split(" ",name);
	  
	   worker->setArguments(str);
	   
	   if(!worker->start());
	   		 
	}
	else
	{
		QLibrary lib(name);
		//add code run module
		
		QSettings settings;
		
		QString ApplicationPath; // = qApp->applicationDirPath();
		setAplDir(ApplicationPath);
	  
		QDir d = QDir::home();
  
		QString s1 = d.absPath();
	 
		settings.removeSearchPath( QSettings::Unix, s1+"/.qt");
		settings.insertSearchPath( QSettings::Unix, s1+"/.SCT" );
   
		QString slang = settings.readEntry("/SCT/Language_UI","en"); 
		
		QTranslator myapp( 0 );
		myapp.load( nameModule + "_" + slang, ApplicationPath+"/lang");
		qApp->installTranslator( &myapp );
	  	typedef  void (*showW)(const QPixmap& );
		showW shw = (showW)lib.resolve( "run_module" );
                		if ( shw )
                                  shw(pix);
		else
		  ;//QMessageBox::about(this,tr("Error"),tr("Can't load module"));
				
    	        lib.unload();
		//qApp->removeTranslator(&myapp);
	}
}
开发者ID:peterkomar,项目名称:sct,代码行数:47,代码来源:myqloader.cpp

示例13: extractDirectory

// ---------------------------------------------------------------
int PackageDialog::extractDirectory(QFile& PkgFile, Q_UINT32 Count, QDir& currDir)
{
  char *p = (char*)malloc(Count);
  PkgFile.readBlock(p, Count);

  if(currDir.cd(QString(p))) { // directory exists ?
    MsgText->append(tr("ERROR: Project directory \"%1\" already exists!").arg(QString(p)));
    return -1;
  }

  if(!currDir.mkdir(QString(p))) {
    MsgText->append(tr("ERROR: Cannot create directory \"%1\"!").arg(QString(p)));
    return -2;
  }
  currDir.cd(QString(p));
  MsgText->append(tr("Create and enter directory \"%1\"").arg(currDir.absPath()));

  free(p);
  return 1;
}
开发者ID:AMDmi3,项目名称:qucs,代码行数:21,代码来源:packagedialog.cpp

示例14:

/*! convert path name into the url in the hypertext generated by htags.
 *  \param path path name
 *  \returns URL NULL: not found.
 */
QCString Htags::path2URL(const QCString &path)
{
  QCString url,symName=path;
  QCString dir = g_inputDir.absPath().utf8();
  int dl=dir.length();
  if ((int)symName.length()>dl+1)
  {
    symName = symName.mid(dl+1);
  }
  if (!symName.isEmpty())
  {
    QCString *result = g_symbolDict[symName];
    //printf("path2URL=%s symName=%s result=%p\n",path.data(),symName.data(),result);
    if (result)
    {
      url = "HTML/" + *result;
    }
  }
  return url;
}
开发者ID:Constellation,项目名称:doxygen,代码行数:24,代码来源:htags.cpp

示例15: openFolder

void KJotsMain::openFolder(int id)
{
  QPushButton *but;
  for( but = button_list.first(); but != NULL; but = button_list.next() )
    but->setOn(FALSE);
  but = (QPushButton *) bg_top->find(id);
  if( but )
    but->setOn(TRUE);
  //QDir dir = QDir::home();
  //dir.cd(".kde/share/apps/kjots");
  QDir dir = QDir( KApplication::localkdedir().data() );
  dir.cd("share/apps/kjots");
  QString file_name = dir.absPath();
  file_name += '/';
  file_name += folder_list.at( folders->indexOf(id) );
  if( current_folder_name == file_name )
    return;
  if( folderOpen )
    saveFolder();
  current_folder_name = file_name;
  if( readFile(current_folder_name) < 0)
    {
      folderOpen = FALSE;
      debug("Kjots: Unable to open folder");
      return;
    }
  current = 0;
  me_text->deselect();
  me_text->setText(entrylist.first()->text);
  emit folderChanged(&entrylist);
  emit entryMoved(current);
  le_subject->setText(entrylist.first()->subject);
  folderOpen = TRUE;
  l_folder->setText( folder_list.at(folders->indexOf(id)) );
  me_text->setEnabled(TRUE);
  le_subject->setEnabled(TRUE);
  me_text->setFocus();
  s_bar->setRange(0,entrylist.count()-1);
  s_bar->setValue(0);
}
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:40,代码来源:KJotsMain.cpp


注:本文中的QDir::absPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。