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


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

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


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

示例1: ExtractImage

 QImage FluidLauncher::ExtractImage(QFileInfo fileInfo) {
     QImage img;

     if (fileInfo.completeSuffix()=="pdf") {
         return QImage(":/core/pdfthumbnail.png");
     }

     if (fileInfo.completeSuffix()=="pml") {
         QFile file(fileInfo.fileName());

         file.open(QIODevice::ReadOnly);
         QXmlStreamReader xml;
         xml.setDevice(&file);
         while (!xml.atEnd()) {
             if (xml.readNextStartElement()) {
                 QString elt = xml.name().toString();
                 if (elt=="snapshot")  {
                     img.loadFromData(QByteArray::fromBase64(xml.readElementText().toAscii()),"PNG");
                     break;
                 }
             }
         }
         file.close();
     }
     return img;
 }
开发者ID:TheProjecter,项目名称:pockemul,代码行数:26,代码来源:fluidlauncher.cpp

示例2: hash

void
SoundSettings::suggestedTargetFilePath (
        const QString &filePath,
        QString       &baseDir,
        QString       &fileName,
        QString       &xmlFileName)
{
    QString            subDir;
    QFileInfo          fileInfo (filePath);
    QCryptographicHash hash(QCryptographicHash::Sha1);

    hash.addData (fileInfo.path().toUtf8());
    subDir = QString(hash.result().toHex());
    subDir.truncate (32);

    baseDir = userSaveDir() +
        QDir::separator() +
        subDir;

    fileName = fileInfo.baseName() + "." + fileInfo.completeSuffix();
    xmlFileName = fileInfo.baseName() + ".xml";

    SYS_DEBUG ("*** baseName()       = %s", SYS_STR(fileInfo.baseName()));
    SYS_DEBUG ("*** path()           = %s", SYS_STR(fileInfo.path()));
    SYS_DEBUG ("*** completeSuffix() = %s", SYS_STR(fileInfo.completeSuffix()));
}
开发者ID:deztructor,项目名称:meegotouch-controlpanelapplets,代码行数:26,代码来源:soundsettingsutils.cpp

示例3: operator

    bool operator()( pAbstractChild* left, pAbstractChild* right ) const
    {
        const QFileInfo leftInfos( left->filePath() );
        const QString leftBaseName = leftInfos.baseName().toLower();
        const QString leftSuffix = leftInfos.completeSuffix().toLower();
        const QFileInfo rightInfos( right->filePath() );
        const QString rightBaseName = rightInfos.baseName().toLower();
        const QString rightSuffix = rightInfos.completeSuffix().toLower();

        if ( leftSuffix == rightSuffix )
        {
            return leftBaseName < rightBaseName;
        }

        return leftSuffix < rightSuffix;
    }
开发者ID:pasnox,项目名称:monkeystudio2,代码行数:16,代码来源:pOpenedFileModel.cpp

示例4: sOpen

PyObject* Application::sOpen(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
{
    // only used to open Python files
    char* Name;
    if (!PyArg_ParseTuple(args, "et","utf-8",&Name))
        return NULL;
    std::string Utf8Name = std::string(Name);
    PyMem_Free(Name);
    PY_TRY {
        QString fileName = QString::fromUtf8(Utf8Name.c_str());
        QFileInfo fi;
        fi.setFile(fileName);
        QString ext = fi.completeSuffix().toLower();
        QList<EditorView*> views = getMainWindow()->findChildren<EditorView*>();
        for (QList<EditorView*>::Iterator it = views.begin(); it != views.end(); ++it) {
            if ((*it)->fileName() == fileName) {
                (*it)->setFocus();
                Py_Return;
            }
        }

        if (ext == QLatin1String("iv")) {
            if (!Application::Instance->activeDocument())
                App::GetApplication().newDocument();
            //QString cmd = QString("Gui.activeDocument().addAnnotation(\"%1\",\"%2\")").arg(fi.baseName()).arg(fi.absoluteFilePath());
            QString cmd = QString::fromLatin1(
                "App.ActiveDocument.addObject(\"App::InventorObject\",\"%1\")."
                "FileName=\"%2\"\n"
                "App.ActiveDocument.ActiveObject.Label=\"%1\"\n"
                "App.ActiveDocument.recompute()")
                .arg(fi.baseName()).arg(fi.absoluteFilePath());
            Base::Interpreter().runString(cmd.toUtf8());
        }
        else if (ext == QLatin1String("wrl") ||
                 ext == QLatin1String("vrml") ||
                 ext == QLatin1String("wrz")) {
            if (!Application::Instance->activeDocument())
                App::GetApplication().newDocument();
            //QString cmd = QString("Gui.activeDocument().addAnnotation(\"%1\",\"%2\")").arg(fi.baseName()).arg(fi.absoluteFilePath());
            QString cmd = QString::fromLatin1(
                "App.ActiveDocument.addObject(\"App::VRMLObject\",\"%1\")."
                "VrmlFile=\"%2\"\n"
                "App.ActiveDocument.ActiveObject.Label=\"%1\"\n"
                "App.ActiveDocument.recompute()")
                .arg(fi.baseName()).arg(fi.absoluteFilePath());
            Base::Interpreter().runString(cmd.toUtf8());
        }
        else if (ext == QLatin1String("py") || ext == QLatin1String("fcmacro") ||
                 ext == QLatin1String("fcscript")) {
            PythonEditor* editor = new PythonEditor();
            editor->setWindowIcon(Gui::BitmapFactory().pixmap("applications-python"));
            PythonEditorView* edit = new PythonEditorView(editor, getMainWindow());
            edit->open(fileName);
            edit->resize(400, 300);
            getMainWindow()->addWindow( edit );
        }
    } PY_CATCH;

    Py_Return;
}
开发者ID:H4llJ0rdan,项目名称:FreeCAD_sf_master,代码行数:60,代码来源:ApplicationPy.cpp

示例5: migrateResource

void ATPAssetMigrator::migrateResource(ResourceRequest* request) {
    // use an asset client to upload the asset
    auto assetClient = DependencyManager::get<AssetClient>();
    
    QFileInfo assetInfo { request->getUrl().fileName() };
    
    auto upload = assetClient->createUpload(request->getData(), assetInfo.completeSuffix());
    
    if (upload) {
        // add this URL to our hash of AssetUpload to original URL
        _originalURLs.insert(upload, request->getUrl());
        
        qCDebug(asset_migrator) << "Starting upload of asset from" << request->getUrl();
        
        // connect to the finished signal so we know when the AssetUpload is done
        QObject::connect(upload, &AssetUpload::finished, this, &ATPAssetMigrator::assetUploadFinished);
        
        // start the upload now
        upload->start();
    } else {
        // show a QMessageBox to say that there is no local asset server
        QString messageBoxText = QString("Could not upload \n\n%1\n\nbecause you are currently not connected" \
                                         " to a local asset-server.").arg(assetInfo.fileName());
        
        QMessageBox::information(_dialogParent, "Failed to Upload", messageBoxText);
    }
}
开发者ID:Giugiogia,项目名称:hifi,代码行数:27,代码来源:ATPAssetMigrator.cpp

示例6: PovrayHighlighter

/// open pov file
static PyObject *
open(PyObject *self, PyObject *args)
{
    // only used to open Povray files
    const char* Name;
    const char* DocName;
    if (!PyArg_ParseTuple(args, "s|s",&Name, &DocName))
        return NULL;
    PY_TRY {
        QString fileName = QString::fromUtf8(Name);
        QFileInfo fi;
        fi.setFile(fileName);
        QString ext = fi.completeSuffix().toLower();
        QList<Gui::EditorView*> views = Gui::getMainWindow()->findChildren<Gui::EditorView*>();
        for (QList<Gui::EditorView*>::Iterator it = views.begin(); it != views.end(); ++it) {
            if ((*it)->fileName() == fileName) {
                (*it)->setFocus();
                Py_Return;
            }
        }

        if (ext == QLatin1String("pov") || ext == QLatin1String("inc")) {
            Gui::TextEditor* editor = new Gui::TextEditor();
            editor->setSyntaxHighlighter(new PovrayHighlighter(editor));
            Gui::EditorView* edit = new Gui::EditorView(editor, Gui::getMainWindow());
            edit->open(fileName);
            edit->resize(400, 300);
            Gui::getMainWindow()->addWindow(edit);
        }
    } PY_CATCH;

    Py_Return;
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:34,代码来源:AppRaytracingGuiPy.cpp

示例7: icon

QIcon ImIconProvider::icon(const QFileInfo &fi) const
{
	QStringList allFormatsV = LoadSavePlugin::getExtensionsForImport(FORMATID_ODGIMPORT);
	QString ext = fi.suffix().toLower();
	if (ext.isEmpty())
		return QFileIconProvider::icon(fi);
	if (fmts.contains(ext, Qt::CaseInsensitive))
		return imagepm;
	else
	{
		ext = fi.completeSuffix().toLower();
		if (ext.endsWith("ps", Qt::CaseInsensitive))
			return pspm;
		else if (ext.endsWith("txt", Qt::CaseInsensitive))
			return txtpm;
		else if (ext.endsWith("scd", Qt::CaseInsensitive) || ext.endsWith("scd.gz", Qt::CaseInsensitive))
			return docpm;
		else if (ext.endsWith("sla", Qt::CaseInsensitive) || ext.endsWith("sla.gz", Qt::CaseInsensitive))
			return docpm;
		else if (ext.endsWith("pdf", Qt::CaseInsensitive))
			return pdfpm;
		else if (ext.endsWith("sxd", Qt::CaseInsensitive))
			return oosxdpm;
		else if (ext.endsWith("sxw", Qt::CaseInsensitive))
			return oosxwpm;
		else if (allFormatsV.contains(ext) || ext.endsWith("sce", Qt::CaseInsensitive) || ext.endsWith("sml", Qt::CaseInsensitive) || ext.endsWith("shape", Qt::CaseInsensitive))
			return vectorpm;
		else
			return QFileIconProvider::icon(fi);
	}
	return QIcon();
}
开发者ID:moceap,项目名称:scribus,代码行数:32,代码来源:customfdialog.cpp

示例8: sInsert

PyObject* Application::sInsert(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
{
    const char* Name;
    const char* DocName=0;
    if (!PyArg_ParseTuple(args, "s|s",&Name,&DocName))
        return NULL;

    PY_TRY {
        QString fileName = QString::fromUtf8(Name);
        QFileInfo fi;
        fi.setFile(fileName);
        QString ext = fi.completeSuffix().toLower();
        if (ext == QLatin1String("iv")) {
            App::Document *doc = 0;
            if (DocName)
                doc = App::GetApplication().getDocument(DocName);
            else
                doc = App::GetApplication().getActiveDocument();
            if (!doc)
                doc = App::GetApplication().newDocument(DocName);

            App::DocumentObject* obj = doc->addObject("App::InventorObject",
                (const char*)fi.baseName().toUtf8());
            obj->Label.setValue((const char*)fi.baseName().toUtf8());
            static_cast<App::PropertyString*>(obj->getPropertyByName("FileName"))
                ->setValue((const char*)fi.absoluteFilePath().toUtf8());
            doc->recompute();
        }
        else if (ext == QLatin1String("wrl") ||
                 ext == QLatin1String("vrml") ||
                 ext == QLatin1String("wrz")) {
            App::Document *doc = 0;
            if (DocName)
                doc = App::GetApplication().getDocument(DocName);
            else
                doc = App::GetApplication().getActiveDocument();
            if (!doc)
                doc = App::GetApplication().newDocument(DocName);

            App::DocumentObject* obj = doc->addObject("App::VRMLObject",
                (const char*)fi.baseName().toUtf8());
            obj->Label.setValue((const char*)fi.baseName().toUtf8());
            static_cast<App::PropertyFileIncluded*>(obj->getPropertyByName("VrmlFile"))
                ->setValue((const char*)fi.absoluteFilePath().toUtf8());
            doc->recompute();
        }
        else if (ext == QLatin1String("py") || ext == QLatin1String("fcmacro") ||
                 ext == QLatin1String("fcscript")) {
            PythonEditor* editor = new PythonEditor();
            editor->setWindowIcon(Gui::BitmapFactory().pixmap("python_small"));
            PythonEditorView* edit = new PythonEditorView(editor, getMainWindow());
            edit->open(fileName);
            edit->resize(400, 300);
            getMainWindow()->addWindow( edit );
        }
    } PY_CATCH;

    Py_Return;
}
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:59,代码来源:ApplicationPy.cpp

示例9: hasValidExtension

bool ComponentManager::hasValidExtension(const QFileInfo& file)
{
  if (m_componentFileExtensions.contains("*." + file.suffix())
      || m_componentFileExtensions.contains("*." + file.completeSuffix()))
    return true;
  else
    return false;
}
开发者ID:HydroCouple,项目名称:HydroCoupleComposer,代码行数:8,代码来源:componentmanager.cpp

示例10: copyFileToFolder

void FileManager::copyFileToFolder(QString originPath, QString originName,QString newPath,QString rename,int digits) {
    QFileInfo* info = new QFileInfo(originPath + "/" + originName);
    QString name = generateName(newPath,rename,info->completeSuffix(),digits);
    copyFileToFolder(originPath,originName, newPath, name);
    historyFromPath.push(originPath);
    historyFromName.push(originName);
    historyToPath.push(newPath);
    historyToName.push(name);
    historyType.push_back("folder");
    delete info;
}
开发者ID:brucehsu,项目名称:classiphy,代码行数:11,代码来源:filemanager.cpp

示例11: 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);
            removeExtraLines(file.absoluteFilePath());

        }
        else if(file.baseName().toLower()=="makefile")
        {
            qDebug()<<"Parsing "<<file.baseName();
            processMakeFile(file.absoluteFilePath(),force_update);
            removeExtraLines(file.absoluteFilePath());
        }

    }

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

示例12: TestFile

/*!
 \fn int FileLoader::TestFile()
 \author Franz Schmid
 \date
 \brief Tests if the file "FileName" exists and determines the type of the file.
 \retval int -1 if the file doesn't exist or any other error has occurred, 0 for the old Format, 1 for the new Format, 2 for EPS and PS files, 3 for SVG files and 4 for PDF files
 */
int FileLoader::TestFile()
{
	QFileInfo fi = QFileInfo(FileName);
	int ret = -1;
	if (!fi.exists())
		ret = -1;
	QString ext = fi.completeSuffix().toLower();

	QList<FileFormat> fileFormats(LoadSavePlugin::supportedFormats());
	QList<FileFormat>::const_iterator it(fileFormats.constBegin());
	QList<FileFormat>::const_iterator itEnd(fileFormats.constEnd());
	for ( ; it != itEnd ; ++it )
	{
		if ((*it).nameMatch.indexIn("."+ext)!=-1)
		{
//  		qDebug() << QString("Match :%1: :.%2: on %3").arg((*it).nameMatch.pattern()).arg(ext).arg((*it).trName);
			if ((*it).plug!=0)
			{
				if ((*it).plug->fileSupported(0, FileName))
				{
// 					qDebug(QString("File Supported With: %1").arg((*it).trName));
					ret=(*it).formatId;
					break;
				}
			}
		}
// 		else
// 			qDebug() << QString("No Match :%1: :.%2: on %3").arg((*it).nameMatch.pattern()).arg(ext).arg((*it).trName);
	}
	
// 	if (ret==-1)
// 	{
// 		if ((ext.endsWith("sla.gz")) || (ext.endsWith("sla")) || (ext.endsWith("scd.gz")) || (ext.endsWith("scd")))
// 			ret = CheckScribus();
// 		else 
// 		if (((ext.endsWith("ps")) || (ext.endsWith("eps"))) && (formatPS))
// 			ret = FORMATID_PSIMPORT;
// 		else if (((ext.endsWith("svg")) || (ext.endsWith("svgz"))) && (formatSVG))
// 			ret = FORMATID_SVGIMPORT;
// 		else if ((ext.endsWith("sxd")) && (formatSXD))
// 			ret = FORMATID_SXDIMPORT;
// 		else if ((ext.endsWith("odg")) && (formatODG))
// 			ret = FORMATID_ODGIMPORT;
// 	}
/*	if (ext == "pdf")
		ret = 4; */
	FileType = ret;
	return ret;
}
开发者ID:pvanek,项目名称:scribus-cuba-1.5.0,代码行数:56,代码来源:fileloader.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: DownloadFile

	void DriveManager::DownloadFile (const QString& filePath, const QUrl& url,
			TaskParameters tp, bool silent, bool open)
	{
		QString savePath;
		if (silent)
			savePath = QDesktopServices::storageLocation (QDesktopServices::TempLocation) +
					"/" + QFileInfo (filePath).fileName ();

		auto e = Util::MakeEntity (url, savePath, tp);
		QFileInfo fi (filePath);
		e.Additional_ ["Filename"] = QString ("%1_%2.%3")
				.arg (fi.baseName ())
				.arg (QDateTime::currentDateTime ().toTime_t ())
				.arg (fi.completeSuffix ());
		silent ?
			Core::Instance ().DelegateEntity (e, filePath, open) :
			Core::Instance ().SendEntity (e);
	}
开发者ID:SboichakovDmitriy,项目名称:leechcraft,代码行数:18,代码来源:drivemanager.cpp

示例15: MakeUnique

static QFileInfo MakeUnique(const QFileInfo &dest)
{
    QFileInfo newDest = dest;

    for (uint i = 0; newDest.exists(); i++)
    {
        QString basename = QString("%1_%2.%3")
            .arg(dest.baseName()).arg(i).arg(dest.completeSuffix());

        newDest.setFile(dest.dir(), basename);

        LOG(VB_GENERAL, LOG_ERR, LOC +
            QString("Need to find a new name for '%1' trying '%2'")
                .arg(dest.absoluteFilePath()).arg(newDest.absoluteFilePath()));
    }

    return newDest;
}
开发者ID:DaveDaCoda,项目名称:mythtv,代码行数:18,代码来源:galleryutil.cpp


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