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


C++ QFileInfo::filePath方法代码示例

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


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

示例1: save

bool Polyhedron_demo_polylines_io_plugin::save(const Scene_item* item, QFileInfo fileinfo)
{
  const Scene_polylines_item* poly_item = 
    qobject_cast<const Scene_polylines_item*>(item);

  if(!poly_item)
    return false;

  std::ofstream out(fileinfo.filePath().toUtf8());

  out.precision(17);

  if(!out) {
    std::cerr << "Error! Cannot open file " << (const char*)fileinfo.filePath().toUtf8() << std::endl;
    return false;
  }

  typedef Scene_polylines_item::Polylines_container Polylines_container;
  typedef Polylines_container::value_type Polyline;
  typedef Polyline::value_type Point_3;

  QStringList metadata = item->property("polylines metadata").toStringList();

  BOOST_FOREACH(const Polyline& polyline, poly_item->polylines) {
    out << polyline.size();
    BOOST_FOREACH(const Point_3& p, polyline) {
      out << " " << p.x() << " " << p.y() << " " << p.z();
    }
    if(!metadata.isEmpty()) {
      out << " " << qPrintable(metadata.front());
      metadata.pop_front();
    }
    out << std::endl;
  }
  return (bool) out;
}
开发者ID:vimarshc,项目名称:cgal,代码行数:36,代码来源:Polyhedron_demo_polylines_io_plugin.cpp

示例2: renameFile

void FileSystemWidget::renameFile()
{
    QFileInfo info = contextFileInfo();
    if (!info.isFile()) {
        return;
    }
    QString fileName = QInputDialog::getText(m_liteApp->mainWindow(),
                                             tr("Rename File"),tr("New Name:"),
                                             QLineEdit::Normal,info.fileName());
    if (!fileName.isEmpty() && fileName != info.fileName()) {
        QDir dir = contextDir();
#ifdef Q_OS_WIN
        if (!MoveFileW(info.filePath().toStdWString().c_str(),QFileInfo(dir,fileName).filePath().toStdWString().c_str())) {
            QMessageBox::information(m_liteApp->mainWindow(),tr("Rename File"),
                                     tr("Failed to rename the file!"));
        }
#else
        if (!QFile::rename(info.filePath(),QFileInfo(dir,fileName).filePath())) {
            QMessageBox::information(m_liteApp->mainWindow(),tr("Rename File"),
                                     tr("Failed to rename the file!"));
        }
#endif
    }
}
开发者ID:DeanSinaean,项目名称:liteide,代码行数:24,代码来源:filesystemwidget.cpp

示例3: onFileItemDoubleClicked

/*
 *	If a file is double-clicked,
 *	process it if it is an ROI image.
 */
void dc_viewer::onFileItemDoubleClicked(QModelIndex idx)
{
	QFileInfo fileInfo = this->fileModel->fileInfo(idx);

	QString prefix;
	if ( this->isValidROIImage(fileInfo, prefix)) {
		QFileInfo fi;
		fi.setFile(fileInfo.path(), prefix);
		this->filePrefix = fi.filePath();
		loadFiles();
		setDepthLookupTable();
		calculate3DData();
		refreshAllLabels();
	}	
}
开发者ID:gulimujyujyu,项目名称:xlzhuathku,代码行数:19,代码来源:dc_viewer.cpp

示例4: parseFile

void parseFile(const QFileInfo& file, bool force_update=false)
{
    if(!file.exists())return;
    if(file.isSymLink())return;
    //skip files in skiplist
    if(skip_paths.contains(file.fileName()))return;
    //force update on our files
    if(!force_update)force_update=our_paths.contains(file.filePath());

    if(file.isDir())
    {
        QString name=file.baseName();
        //ignore system dirs
        if(name.length()==0 || name.at(0)==QChar('.'))return;

        QDir dir(file.absoluteFilePath());
        QFileInfoList list = dir.entryInfoList(
            QDir::NoDotAndDotDot|QDir::Readable|QDir::Dirs|QDir::Files,
            QDir::DirsFirst|QDir::Name);
        QFileInfoList::const_iterator iter=list.constBegin();
        for(;iter!=list.constEnd(); ++iter)
        {
            qDebug()<<"... "<<iter->filePath();

            parseFile(*iter,force_update);
        }
        return;
    }
    if(file.isFile())
    {
        filereported=false;//reset flag
        QStringList exts;
        exts<<"cpp"<<"c"<<"hpp"<<"h"<<"java"<<"qml";
        QString ext=file.completeSuffix().toLower();
        if(exts.contains(ext))
        {
            qDebug()<<"Parsing "<<file.baseName();
            processCXXFile(file.absoluteFilePath(),force_update);
        }
        else
        if(file.baseName().toLower()=="makefile")
        {
            qDebug()<<"Parsing "<<file.baseName();
            processMakeFile(file.absoluteFilePath(),force_update);
        }
    }

}
开发者ID:Vanuan,项目名称:iviLink,代码行数:48,代码来源:main.cpp

示例5: saveAs

/// Save the document under a new file name
bool Document::saveAs(void)
{
    getMainWindow()->showMessage(QObject::tr("Save document under new filename..."));

    QString exe = qApp->applicationName();
    QString fn = QFileDialog::getSaveFileName(getMainWindow(), QObject::tr("Save %1 Document").arg(exe), 
                 FileDialog::getWorkingDirectory(), QObject::tr("%1 document (*.FCStd)").arg(exe));
    if (!fn.isEmpty()) {
        FileDialog::setWorkingDirectory(fn);
        QString file = fn.toLower();
        if (!file.endsWith(QLatin1String(".fcstd"))) {
            fn += QLatin1String(".fcstd");
            QFileInfo fi;
            fi.setFile(fn);
            if (fi.exists()) {
                // if we auto-append the extension make sure that we don't override an existing file
                int ret = QMessageBox::question(getMainWindow(), QObject::tr("Save As"), 
                    QObject::tr("%1 already exists.\n"
                                "Do you want to replace it?").arg(fn),
                                QMessageBox::Yes|QMessageBox::Default,
                                QMessageBox::No|QMessageBox::Escape); 
                if (ret != QMessageBox::Yes)
                    fn = QString();
            }
        }
    }

    if (!fn.isEmpty()) {
        QFileInfo fi;
        fi.setFile(fn);
        QString bn = fi.baseName();

        const char * DocName = App::GetApplication().getDocumentName(getDocument());

        // save as new file name
        Gui::WaitCursor wc;
        Command::doCommand(Command::Doc,"App.getDocument(\"%s\").saveAs('%s')"
                                       , DocName, (const char*)fn.toUtf8());
        setModified(false);

        getMainWindow()->appendRecentFile(fi.filePath());
        return true;
    }
    else {
        getMainWindow()->showMessage(QObject::tr("Saving aborted"), 2000);
        return false;
    }
}
开发者ID:jaywarrick,项目名称:FreeCAD_sf_master,代码行数:49,代码来源:Document.cpp

示例6: getFinalVariablesFromDsFile

bool Dymola::getFinalVariablesFromDsFile(QString fileName_, MOVector<Variable> *variables,QString modelName)
{
    variables->clear();
    QFileInfo fileinfo = QFileInfo(fileName_);
    bool result = false;
    if (fileinfo.exists())
    {
        QFile file(fileinfo.filePath());
        file.open(QIODevice::ReadOnly);
        QTextStream* in = new QTextStream(&file);
        result = getFinalVariablesFromDsFile(in, variables,modelName);
        file.close();
        delete in;
    }
    return result;
}
开发者ID:cephdon,项目名称:OMOptim,代码行数:16,代码来源:Dymola.cpp

示例7: slotAddPredefined

void KisCustomBrushWidget::slotAddPredefined()
{
    // Save in the directory that is likely to be: ~/.kde/share/apps/krita/brushes
    // a unique file with this brushname
    QString dir = KGlobal::dirs()->saveLocation("data", "krita/brushes");
    QString extension;

    if (brushStyle->currentIndex() == 0) {
        extension = ".gbr";
    } else {
        extension = ".gih";
    }

    QString name = nameLineEdit->text();
    QString tempFileName;
    {
        QFileInfo fileInfo;
        fileInfo.setFile(dir + name + extension);

        int i = 1;
        while (fileInfo.exists()) {
            fileInfo.setFile(dir + name + QString("%1").arg(i) + extension);
            i++;
        }

        tempFileName = fileInfo.filePath();
    }

    // Add it to the brush server, so that it automatically gets to the mediators, and
    // so to the other brush choosers can pick it up, if they want to
    if (m_rServerAdapter) {
        KisGbrBrush * resource = static_cast<KisGbrBrush*>( m_brush.data() )->clone();
        resource->setFilename(tempFileName);

        if (nameLineEdit->text().isEmpty()){
            resource->setName(QDateTime::currentDateTime().toString("yyyy-MM-ddThh:mm"));
        }else{
            resource->setName( name );
        }

        if (colorAsMask->isChecked()){
            resource->makeMaskImage();
        }

        m_rServerAdapter->addResource( resource );
    }
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:47,代码来源:kis_custom_brush_widget.cpp

示例8: setRecipeFile

void QERecipe::setRecipeFile(QString pValue)
{

    QDomElement rootElement;
    QFile *file;
    QString data;
    bool flag;


    recipeFile = pValue;
    document.clear();

    if (recipeFile.isEmpty())
    {
        QFileInfo fileInfo;
        fileInfo.setFile( defaultFileLocation(), QString( "QERecipe.xml" ) );
        filename = fileInfo.filePath();
    }
    else
    {
        filename = recipeFile;
    }

    file = openQEFile( filename, (QIODevice::OpenModeFlag)((int)(QFile::ReadOnly | QFile::Text)) );
    if (file)
    {
        data = file->readAll();
        file->close();
        flag = document.setContent(data);
    }
    else
    {
        flag = false;
    }

    if (flag)
    {
        refreshRecipeList();
    }
    else
    {
        rootElement = document.createElement("epicsqt");
        document.appendChild(rootElement);
    }

}
开发者ID:andrewrhyder,项目名称:epicsqt,代码行数:46,代码来源:QERecipe.cpp

示例9: dir

const QPixmap
Skin::getPixmap (const QString& file, const QString &path)
{
	QDir dir (path);
	dir.setFilter (QDir::Files|QDir::NoDotAndDotDot);

	QFileInfoList list = dir.entryInfoList();
	for (int i = 0; i < list.size(); ++i) {
		QFileInfo fileInfo = list.at(i);
		QString fname = fileInfo.fileName().toLower();
		if (fname.section(".", 0, 0) == file) {
			return QPixmap (fileInfo.filePath());
		}
	}

	return QPixmap ();
}
开发者ID:dsvensson,项目名称:promoe,代码行数:17,代码来源:skin.cpp

示例10: renameFile

void GopathBrowser::renameFile()
{
    QFileInfo info = contextFileInfo();
    if (!info.isFile()) {
        return;
    }
    QString fileName = QInputDialog::getText(m_liteApp->mainWindow(),
                                             tr("Rename File"),tr("File Name"),
                                             QLineEdit::Normal,info.fileName());
    if (!fileName.isEmpty() && fileName != info.fileName()) {
        QDir dir = contextDir();
        if (!QFile::rename(info.filePath(),QFileInfo(dir,fileName).filePath())) {
            QMessageBox::information(m_liteApp->mainWindow(),tr("Rename File"),
                                     tr("Failed to rename the file!"));
        }
    }
}
开发者ID:hfeeki,项目名称:liteide,代码行数:17,代码来源:gopathbrowser.cpp

示例11: save

bool Polyhedron_demo_ply_to_xyz_plugin::save(const Scene_item* item, QFileInfo fileinfo)
{
  // Check extension (quietly)
  std::string extension = fileinfo.suffix().toUtf8().data();
  if (extension != "ply" && extension != "PLY")
    return false;

  // This plugin supports point sets
  const Scene_points_with_normal_item* point_set_item =
    qobject_cast<const Scene_points_with_normal_item*>(item);
  if(!point_set_item)
    return false;

  // Save point set as .xyz
  std::ofstream out(fileinfo.filePath().toUtf8().data());
  return point_set_item->write_ply_point_set(out);
}
开发者ID:alexfridlyand,项目名称:cgal,代码行数:17,代码来源:Polyhedron_demo_ply_to_xyz_plugin.cpp

示例12: removeFile

void FileBrowser::removeFile()
{
    QFileInfo info = contextFileInfo();
    if (!info.isFile()) {
        return;
    }

    int ret = QMessageBox::question(m_liteApp->mainWindow(),tr("Delete File"),
                          tr("Are you sure that you want to permanently delete this file?"),
                          QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
    if (ret == QMessageBox::Yes) {
        if (!QFile::remove(info.filePath())) {
            QMessageBox::information(m_liteApp->mainWindow(),tr("Delete File"),
                                     tr("Failed to delete the file!"));
        }
    }
}
开发者ID:DFRobot,项目名称:liteide,代码行数:17,代码来源:filebrowser.cpp

示例13: rename

void ChannelConfigurationsWidget::rename()
{
	QItemSelection selection = ui->configs->selectionModel()->selection();
	if(selection.indexes().size() != 1) return;
	QModelIndex index = selection.indexes()[0];
	
	QFileInfo file = m_model->fileInfo(index);
	KeyboardDialog keyboard(tr("Rename %1").arg(file.fileName()));
	keyboard.setInput(file.baseName());
	RootController::ref().presentDialog(&keyboard);
	if(!QFile::rename(file.filePath(),
		file.path() + "/" + keyboard.input() + "." + file.completeSuffix())) {
		qWarning() << "Failed to change name";
		// TODO: Make this error user visible
		return;
	}
}
开发者ID:LinkJVM,项目名称:botui,代码行数:17,代码来源:ChannelConfigurationsWidget.cpp

示例14: removeFile

void FileSystemWidget::removeFile()
{
    QFileInfo info = contextFileInfo();
    if (!info.isFile()) {
        return;
    }

    int ret = QMessageBox::question(m_liteApp->mainWindow(),tr("Remove File"),
                          tr("Confirm remove the file and continue"),
                          QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::No);
    if (ret == QMessageBox::Yes) {
        if (!QFile::remove(info.filePath())) {
            QMessageBox::information(m_liteApp->mainWindow(),tr("Remove File"),
                                     tr("Failed to remove the file!"));
        }
    }
}
开发者ID:screscent,项目名称:liteide,代码行数:17,代码来源:filesystemwidget.cpp

示例15: fileClick

void ProjectExplorer::fileClick()
{
	int row = -1;
	QString rootpath = m_FileSystemModel->rootPath() + QString("/");
	QModelIndexList indexlist = m_TreeView->selectionModel()->selectedIndexes();
	foreach(QModelIndex index, indexlist)
	{
		if(index.row() != row && index.column() == 0)
		{
			QFileInfo fileInfo = m_FileSystemModel->fileInfo(index);
			QString absoultepath = fileInfo.filePath();
			QString file = absoultepath.remove(rootpath);
			row = index.row();
			emit fileClicked(file);
		}
	}
}
开发者ID:swaechter,项目名称:cdevstudio,代码行数:17,代码来源:ProjectExplorer.cpp


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