本文整理汇总了C++中QFileInfo::completeBaseName方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfo::completeBaseName方法的具体用法?C++ QFileInfo::completeBaseName怎么用?C++ QFileInfo::completeBaseName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileInfo
的用法示例。
在下文中一共展示了QFileInfo::completeBaseName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPid
int QBookDevel::getPid(const char *exe) {
static struct dirent *ent;
DIR *dir = opendir("/proc");
if (!dir)
return 0;
while( (ent = readdir(dir)) ) {
if(!ent || !ent->d_name) {
closedir(dir);
return 0;
}
if(*ent->d_name < '0' || *ent->d_name > '9')
continue;
QString *path = new QString();
path->append("/proc/");
path->append(ent->d_name);
path->append("/exe");
qDebug () << *path;
QFileInfo f = QFileInfo(*path);
if (f.isSymLink()) {
QFileInfo l = QFileInfo (f.symLinkTarget());
if (l.completeBaseName() == exe) {
closedir(dir);
return atoi(ent->d_name);
}
}
// We need to check also cmdline as a lot of binaries are links to busybox
path = new QString();
path->append("/proc/");
path->append(ent->d_name);
path->append("/cmdline");
QFile *file = new QFile(*path);
delete path;
if (!file->open(QIODevice::ReadOnly))
continue;
QTextStream stream(file);
QString line = stream.readLine();
file->close();
delete file;
QStringList args = line.split((QChar)0); // cmdline is separated with NULLs!
if (args.size() > 0) {
f = QFileInfo (args.at(0));
if (f.completeBaseName() == exe) {
closedir(dir);
return atoi(ent->d_name);
}
}
}
closedir(dir);
return 0;
}
示例2: parseFile
void ExifWrapper::parseFile( ExifData& data )
{
// prepare data
QFileInfo info (data.FilePath);
// skip known extensions
if (isUnsupportedFileType(info.suffix())) {
data.Extention = info.suffix();
data.FileName = info.completeBaseName();
return;
}
// decide what tool to use, we want exiv2 only for jpg
if (isEqual(info.suffix(), "jpg") ) {
data = doParse(EXIV2, data.FilePath);
if (data.CreateDate.isInvalid()) {
qWarning() << "Parsing failed once, retrying.";
data = doParse(EXIFTOOL, data.FilePath);
if (data.CreateDate.isInvalid()) {
qWarning() << "Parsing failed again, giving up on file" << data.FilePath;
}
}
}
else {
data = doParse(EXIFTOOL, data.FilePath);
}
}
示例3: saveSubtitles
void TabDivePhotos::saveSubtitles()
{
QVector<QString> selectedPhotos;
if (!ui->photosView->selectionModel()->hasSelection())
return;
QModelIndexList indexes = ui->photosView->selectionModel()->selectedRows();
if (indexes.count() == 0)
indexes = ui->photosView->selectionModel()->selectedIndexes();
selectedPhotos.reserve(indexes.count());
for (const auto &photo: indexes) {
if (photo.isValid()) {
QString fileUrl = photo.data(Qt::DisplayPropertyRole).toString();
if (!fileUrl.isEmpty()) {
QFileInfo fi = QFileInfo(fileUrl);
QFile subtitlefile;
subtitlefile.setFileName(QString(fi.path()) + "/" + fi.completeBaseName() + ".ass");
int offset = photo.data(Qt::UserRole + 1).toInt();
int duration = photo.data(Qt::UserRole + 2).toInt();
// Only videos have non-zero duration
if (!duration)
continue;
struct membuffer b = { 0 };
save_subtitles_buffer(&b, &displayed_dive, offset, duration);
char *data = detach_buffer(&b);
subtitlefile.open(QIODevice::WriteOnly);
subtitlefile.write(data, strlen(data));
subtitlefile.close();
free(data);
}
}
}
}
示例4: detectBaseName
QString AddToArchive::detectBaseName(const QStringList &paths) const
{
QFileInfo fileInfo = QFileInfo(paths.first());
QDir parentDir = fileInfo.dir();
QString base = parentDir.absolutePath() + QLatin1Char('/');
if (paths.size() > 1) {
if (!parentDir.isRoot()) {
// Use directory name for the new archive.
base += parentDir.dirName();
}
} else {
// Strip filename of its extension, but only if present (see #362690).
if (!QMimeDatabase().mimeTypeForFile(fileInfo.fileName(), QMimeDatabase::MatchExtension).isDefault()) {
base += fileInfo.completeBaseName();
} else {
base += fileInfo.fileName();
}
}
// Special case for compressed tar archives.
if (base.right(4).toUpper() == QLatin1String(".TAR")) {
base.chop(4);
}
if (base.endsWith(QLatin1Char('/'))) {
base.chop(1);
}
return base;
}
示例5: loadLibrary
QLibrary* RazorPluginInfo::loadLibrary(const QString& libDir) const
{
QString baseName, path;
QFileInfo fi = QFileInfo(fileName());
path = fi.canonicalPath();
baseName = value("X-Razor-Library", fi.completeBaseName()).toString();
QString soPath = QString("%1/lib%2.so").arg(libDir, baseName);
QLibrary* library = new QLibrary(soPath);
if (!library->load())
{
qWarning() << QString("Can't load plugin lib \"%1\"").arg(soPath) << library->errorString();
delete library;
return 0;
}
QString locale = QLocale::system().name();
QTranslator* translator = new QTranslator(library);
translator->load(QString("%1/%2/%2_%3.qm").arg(path, baseName, locale));
qApp->installTranslator(translator);
return library;
}
示例6: RecurseDirectory
void RecurseDirectory(const QString dir, bool recursion)
{
QDir dirEnt(dir);
QFileInfoList list = dirEnt.entryInfoList();
for(int i = 0; i < list.count(); i++)
{
QFileInfo info = list[i];
QString filePath = info.filePath();
QString fileExt = info.suffix().toLower();
QString name = dir + QDir::separator();
if(recursion && info.isDir())
{
// recursive
if(info.fileName() != ".." && info.fileName() != ".")
{
RecurseDirectory(filePath, recursion);
}
}
else
if(imageExtensions.contains(fileExt))
{
if(!QFile::exists(name + info.completeBaseName() + QString(".atlas")))
{
packerData *data = new packerData;
data->path = info.absoluteFilePath();
data->file = filePath.replace(topImageDir, "");
// qDebug() << "Packing " << data->path << "...";
mainPacker->addItem(data->path, data);
}
}
}
}
示例7: sourceImage
foreach (QFileInfo sourceInfo, sourceInfoList) {
QImage sourceImage(sourceInfo.absoluteFilePath());
QImage scaledSourceImage = sourceImage.scaled(225,225,Qt::KeepAspectRatio);
int sourceWidth = sourceImage.width();
int destWidth = scaledSourceImage.width();
double scaleBackFactor = (double)sourceWidth/destWidth; // as we keep aspect ratio, this is sufficient to scale rectangle back
qDebug() << sourceInfo.fileName();
QList<QRect> destRects;
QFileInfo destFileInfo = makeDestFileInfo(sourceDir, sourceInfo, destDir);
if (faceCropper->crop(scaledSourceImage,destRects)) {
// facelookupTable.addFile(sourceInfo, destRects, destFileInfo, scaleBackFactor);
if (destRects.count()>1) {
for (int i=0; i< destRects.count(); ++i) {
QRect destRect = destRects.at(i);
QRect destRectScaled(destRect.topLeft()*scaleBackFactor, destRect.bottomRight()*scaleBackFactor);
QImage destImage = sourceImage.copy(destRectScaled);
QString destString = destFileInfo.absolutePath();
destString.append(QDir::separator());
destDir.mkpath(destString);
destString.append(destFileInfo.completeBaseName());
destString.append("_");
destString.append(QString::number(i));
destString.append(".");
destString.append(destFileInfo.suffix());
destImage.save(destString);
}
} else if (destRects.count()==1){
QRect destRect = destRects.first();
QRect destRectScaled(destRect.topLeft()*scaleBackFactor, destRect.bottomRight()*scaleBackFactor);
QImage destImage = sourceImage.copy(destRectScaled);
destDir.mkpath(destFileInfo.absolutePath());
destImage.save(destFileInfo.absoluteFilePath());
}
}
}
示例8: refreshListFiles
void MainWindow::refreshListFiles(){
ui->menuFichiers_r_cents->clear();
disconnect(ui->menuFichiers_r_cents, SIGNAL(triggered(QAction*)),
this, SLOT(test(QAction*)));
QList<QFileInfo*>* files = core->getList();
if(files->isEmpty()){
ui->menuFichiers_r_cents->setEnabled(false);
}else{
ui->menuFichiers_r_cents->setEnabled(true);
for(QList<QFileInfo*>::const_iterator it = files->begin();
it != files->end(); it++){
QFileInfo* file = static_cast<QFileInfo *>(*it);
QAction * action = new QAction(this);
if(file && action){
action->setData(file->absoluteFilePath());
action->setText(file->completeBaseName());
ui->menuFichiers_r_cents->addAction(action);
}
}
QAction * action = new QAction(this);
if(action){
action->setText("Effacer");
ui->menuFichiers_r_cents->addSeparator();
ui->menuFichiers_r_cents->addAction(action);
}
connect(ui->menuFichiers_r_cents, SIGNAL(triggered(QAction*)),
this, SLOT(test(QAction*)));
}
}
示例9: setCurrentName
void LanguageManager::setCurrentName( const QString & name )
{
if ( name == currentName_ )
return;
if ( !currentName_.isNull() )
{
LanguageInfo & languageInfo = languageInfoForName_[ currentName_ ];
for ( QListIterator<QTranslator*> it( languageInfo.translators ); it.hasNext(); )
QCoreApplication::instance()->removeTranslator( it.next() );
qDeleteAll( languageInfo.translators );
languageInfo.translators.clear();
}
currentName_ = name;
if ( !currentName_.isNull() )
{
LanguageInfo & languageInfo = languageInfoForName_[ currentName_ ];
if ( !languageInfo.isTranslatorFileNamesUpdated )
{
languageInfo.isTranslatorFileNamesUpdated = true;
QDir langDir( QmDirPath );
for ( QListIterator<QFileInfo> it( langDir.entryInfoList(
QStringList() << QmLanguageTemplate.arg( currentName_ ), QDir::Files | QDir::CaseSensitive ) ); it.hasNext(); )
{
const QFileInfo qmFileInfo = it.next();
QString moduleName;
QString suffix;
if ( !_splitFileName( qmFileInfo.completeBaseName(), &moduleName, &suffix ) )
continue;
Q_ASSERT( suffix == currentName_ );
languageInfo.translatorFileNames << qmFileInfo.filePath();
}
}
for ( QStringListIterator fileNameIt( languageInfo.translatorFileNames ); fileNameIt.hasNext(); )
{
const QString & fileName = fileNameIt.next();
QTranslator * moduleTranslator = new QTranslator( this );
if ( !moduleTranslator->load( fileName ) )
{
delete moduleTranslator;
continue;
}
languageInfo.translators << moduleTranslator;
QCoreApplication::instance()->installTranslator( moduleTranslator );
}
}
}
示例10: batchTransform
void MainWindow::batchTransform()
{
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::ExistingFiles);
QStringList fileNames;
if (dialog.exec())
fileNames = dialog.selectedFiles();
else
return;
QString prefix = QInputDialog::getText(this, tr("Replacement Workspace"),
tr("Enter a prefix for the new files:"));
QString suffix = QInputDialog::getText(this, tr("Replacement Workspace"),
tr("Enter a suffix for the new files:"));
GetListFromTable();
for (int i = 0; i < fileNames.length(); i++)
{
QString extension;
QFile file(fileNames.at(i));
QFileInfo *info = new QFileInfo(file);
if (info->suffix().length() == 0)
extension = "";
else
extension = "." + info->suffix();
QString newFilename = info->absolutePath() + "/" + prefix
+ info->completeBaseName() + suffix + extension;
mRe->processFile( fileNames.at(i) , newFilename );
}
}
示例11: getViews
void ViewTableListWidget::getViews()
{
QDir rootdir("view//");
rootdir.setFilter(rootdir.filter()|QDir::NoDotAndDotDot);
QStringList strings;
strings<<"*";
list = rootdir.entryInfoList(strings);
qDebug()<<list.length();
//QFileInfoList list = rootdir.entryInfoList(strings);
// qDebug()<<*list.begin();
QFileInfoList::iterator i = list.begin();
QFileInfo tempinfo;
while(i != list.end())
{
tempinfo = *i;
if(tempinfo.completeBaseName()==QString(tr("纯C程序题")))
{
//qDebug()<<tr("相等");
// rename("view//asdsagashg","view//newfilename");
// tempinfo.setFile("haha");
}
// qDebug()<<tempinfo.completeBaseName();
i++;
}
/* list.clear();
qDebug()<<list.length();*/
}
示例12: HashSet
SearchFile::SearchFile( SearchTreeItem* parent,
const QueryHit* const pHit, const QFileInfo& fileInfo ) :
SearchTreeItem( parent ),
m_vHashes( HashSet( pHit->m_vHashes ) )
{
m_eType = SearchFileType;
m_pItemData[FILE] = fileInfo.completeBaseName();
m_pItemData[EXTENSION] = fileInfo.suffix();
m_pItemData[SIZE] = formatBytes( pHit->m_nObjectSize );
m_pItemData[RATING] = "";
m_pItemData[STATUS] = "";
m_pItemData[HOSTCOUNT] = 1;
m_pItemData[SPEED] = "";
m_pItemData[CLIENT] = "";
m_pItemData[COUNTRY] = "";
const Hash* const * const pHashes = &m_vHashes[0];
for ( quint8 i = 0, nSize = m_vHashes.size(); i < nSize; ++i )
{
if ( pHashes[i] )
{
( ( TreeRoot* )m_pParentItem )->registerHash( *pHashes[i], this );
}
}
}
示例13: formatBytes
SearchHit::SearchHit( SearchTreeItem* parent,
QueryHit* pHit, const QFileInfo& fileInfo ) :
SearchTreeItem( parent )
{
m_eType = SearchHitType;
m_pItemData[FILE] = fileInfo.completeBaseName();
m_pItemData[EXTENSION] = fileInfo.suffix();
m_pItemData[SIZE] = formatBytes( pHit->m_nObjectSize );
m_pItemData[RATING] = "";
m_pItemData[STATUS] = "";
m_pItemData[HOSTCOUNT] = pHit->m_pHitInfo.data()->m_oNodeAddress.toString();
m_pItemData[SPEED] = "";
m_pItemData[CLIENT] = vendorCodeToName( pHit->m_pHitInfo.data()->m_sVendor );
m_pItemData[COUNTRY] = pHit->m_pHitInfo.data()->m_oNodeAddress.countryName();
QString sCountry = pHit->m_pHitInfo.data()->m_oNodeAddress.country();
m_oHitData.iNetwork = NetworkIconProvider::icon( DiscoveryProtocol::G2 );
m_oHitData.iCountry = NetworkIconProvider::icon( sCountry );
m_oHitData.pQueryHit = QueryHitSharedPtr( pHit );
// properly initialize filter data
delete m_pFilter;
m_pFilter = new SearchFilter::HitFilter( pHit );
}
示例14: langDir
LanguageManager::LanguageManager()
{
// lookup qm files under the :/lang dir
QDir langDir( QmDirPath );
for ( QListIterator<QFileInfo> it( langDir.entryInfoList(
QStringList() << QmTemplate.arg( QmInfoPrefix ), QDir::Files | QDir::CaseSensitive ) ); it.hasNext(); )
{
const QFileInfo qmFileInfo = it.next();
QString moduleName;
QString suffix;
if ( !_splitFileName( qmFileInfo.completeBaseName(), &moduleName, &suffix ) )
continue;
Q_ASSERT( moduleName == QmInfoPrefix );
Q_ASSERT( !languageInfoForName_.contains( suffix ) );
QTranslator * infoTranslator = new QTranslator( this );
if ( !infoTranslator->load( qmFileInfo.filePath() ) )
{
delete infoTranslator;
continue;
}
LanguageInfo languageInfo;
languageInfo.isNull = false;
languageInfo.name = suffix;
languageInfo.englishName = infoTranslator->translate( "LanguageManager", LanguageNameInEnglish );
languageInfo.nativeName = infoTranslator->translate( "LanguageManager", LanguageNameInNative );
languageInfoForName_[ languageInfo.name ] = languageInfo;
names_ << languageInfo.name;
}
QString defaultName;
const QLocale currentLocale;
if ( languageInfoForName_.contains( currentLocale.name() ) )
{
defaultName = currentLocale.name();
}
else
{
const QString localeLangName = currentLocale.name().left( currentLocale.name().indexOf( QLatin1Char( '_' ) ) );
if ( languageInfoForName_.contains( localeLangName ) )
{
defaultName = localeLangName;
}
else
{
if ( languageInfoForName_.contains( DefaultLanguageName ) )
defaultName = DefaultLanguageName;
}
}
if ( !defaultName.isNull() )
setCurrentName( defaultName );
}
示例15: getSeqPaddedFrameNumber
QString RotoCanvas::getSeqPaddedFrameNumber(QFileInfo frameFI)
{
QString baseName=frameFI.completeBaseName();
int digitCount=RotoCanvas::getSeqDigitCount(frameFI);
//qInfo()<<"getSeqPaddedFrameNumber digitCount:"<<digitCount;
QString result=baseName.right(digitCount);
return result;
}