本文整理汇总了C++中QFileInfo::baseName方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfo::baseName方法的具体用法?C++ QFileInfo::baseName怎么用?C++ QFileInfo::baseName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileInfo
的用法示例。
在下文中一共展示了QFileInfo::baseName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setName
// ---------------------------------------------------
void TextDoc::setName (const QString& Name_)
{
DocName = Name_;
setLanguage (DocName);
QFileInfo Info (DocName);
if (App)
App->DocumentTab->setTabLabel (this, Info.fileName ());
DataSet = Info.baseName (true) + ".dat";
DataDisplay = Info.baseName (true) + ".dpl";
if(Info.extension(false) == "m" || Info.extension(false) == "oct")
SimTime = "1";
}
示例2: loadAlbums
void Controller::loadAlbums()
{
QDir dir;
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
dir.setSorting(QDir::Name);
dir.setCurrent(m_pParser->getDirectory());
QFileInfoList list = dir.entryInfoList();
for(int i = 0; i < list.count(); ++i)
{
QFileInfo fileInfo = list.at(i);
m_pParser->setFile(fileInfo.baseName());
m_listAlbums.insert(fileInfo.baseName(),new Album(m_pParser->getAlbumFromFile(fileInfo.baseName())));
}
}
示例3: 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);
}
}
}
示例4: QPushButton
BrowserIcon::BrowserIcon(QFileInfo f, QString url, QWidget *parent) :
QPushButton(QIcon::fromTheme(f.baseName()), "", parent) {
setIconSize(QSize(ICONSIZE, ICONSIZE));
setFixedSize(QSize(ICONSIZE,ICONSIZE));
exec = findExec(f, url);
}
示例5: tf
PrinterAPI::PrinterAPI() : QObject(COLLECTOR)
{
qDebug() << "PrinterAPI loaded";
setObjectName("printer");
printer = QString("File");
cmd = QString("");
color = true;
useICC = false;
mph = false;
mpv = false;
ucr = true;
copies = true;
QString tf(ScCore->primaryMainWindow()->doc->pdfOptions().fileName);
if (tf.isEmpty())
{
QFileInfo fi = QFileInfo(ScCore->primaryMainWindow()->doc->DocName);
tf = fi.path()+"/"+fi.baseName()+".pdf";
}
file = tf;
int num = 0;
if (ScCore->primaryMainWindow()->HaveDoc)
num = ScCore->primaryMainWindow()->doc->Pages->count();
for (int i = 0; i<num; i++)
{
pages.append(i+1);
}
separation = "No";
}
示例6: parseDirectories
void SubComponentManager::parseDirectories()
{
if (!m_filePath.isEmpty()) {
const QString file = m_filePath.toLocalFile();
QFileInfo dirInfo = QFileInfo(QFileInfo(file).path());
if (dirInfo.exists() && dirInfo.isDir())
parseDirectory(dirInfo.canonicalFilePath());
foreach (const QString &subDir, QDir(QFileInfo(file).path()).entryList(QDir::Dirs | QDir::NoDot | QDir::NoDotDot)) {
parseDirectory(dirInfo.canonicalFilePath() + "/" + subDir, true, subDir.toUtf8());
}
}
foreach (const Import &import, m_imports) {
if (import.isFileImport()) {
QFileInfo dirInfo = QFileInfo(m_filePath.resolved(import.file()).toLocalFile());
if (dirInfo.exists() && dirInfo.isDir())
parseDirectory(dirInfo.canonicalFilePath(), true, dirInfo.baseName().toUtf8());
} else {
QString url = import.url();
url.replace(QLatin1Char('.'), QLatin1Char('/'));
QFileInfo dirInfo = QFileInfo(url);
foreach (const QString &path, importPaths()) {
QString fullUrl = path + QLatin1Char('/') + url;
dirInfo = QFileInfo(fullUrl);
if (dirInfo.exists() && dirInfo.isDir()) {
//### todo full qualified names QString nameSpace = import.uri();
parseDirectory(dirInfo.canonicalFilePath(), false);
}
}
}
}
示例7: showConfigurationInterface
void IconApplet::showConfigurationInterface()
{
KPropertiesDialog *dialog = m_dialog.data();
m_configTarget = m_url;
if (m_hasDesktopFile) {
const QFileInfo fi(m_url.toLocalFile());
if (!fi.isWritable()) {
const QString suggestedName = fi.baseName();
m_configTarget = KService::newServicePath(false, suggestedName);
KIO::Job *job = KIO::file_copy(m_url, m_configTarget);
job->exec();
}
}
if (dialog) {
KWindowSystem::setOnDesktop(dialog->winId(), KWindowSystem::currentDesktop());
dialog->show();
KWindowSystem::activateWindow(dialog->winId());
} else {
dialog = new KPropertiesDialog(m_configTarget, 0 /*no parent widget*/);
m_dialog = dialog;
connect(dialog, SIGNAL(applied()), this, SLOT(acceptedPropertiesDialog()));
connect(dialog, SIGNAL(canceled()), this, SLOT(cancelledPropertiesDialog()));
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
dialog->setWindowTitle(i18n("%1 Icon Settings", m_configTarget.fileName()));
dialog->show();
}
}
示例8: registeredUsers
/***************************************************************************
* Returns a list of all the registered users of kinkatta. By this, it means all
* users that have a settings file under ~/.kde/share/apps/kinkatta/
***************************************************************************/
QStringList setup::registeredUsers(){
QString buddy = "";
QString extension = "";
QFileInfo fileInfo;
QStringList l;
QString homeDirr = KINKATTA_DIR;
if(!QFile::exists(homeDirr)) {
return l; //no registered users, return empty StringList
}
QDir home(homeDirr);
home.setFilter( QDir::Files | QDir::NoSymLinks );
if ( home.exists() ){
for (unsigned int i = 0; i < home.count(); i++){
fileInfo.setFile(home[i]);
buddy = fileInfo.baseName().lower();
extension = fileInfo.extension( FALSE );
if ( (extension == "xml") && buddy != "settings"){ //settings.xml is the global settings file
if(l.contains(buddy) == 0) //make them unique
l.append(buddy);
}
}
}
return l;
}
示例9: data
QVariant ImageList::data(const QModelIndex &index, int role) const
{
Image *img = at(index.row());
QFileInfo fi = QFileInfo(img->getPath());
if (role == Qt::DisplayRole) {
switch (index.column()) {
case 0:
return fi.baseName();
case 1:
return fi.suffix().toLower();
case 2:
return QString("%1 kB").arg(fi.size() / 1024.0, 0, 'f', 2);
case 3:
if (img->isLoaded()) return img->getSourceMat().channels();
case 4:
if (img->isLoaded()) return img->getSourceMat().cols;
case 5:
if (img->isLoaded()) return img->getSourceMat().rows;
}
}
else if (role ==Qt::TextAlignmentRole) {
switch (index.column()) {
case 4:
return Qt::AlignRight;
default:
return Qt::AlignLeft;
}
}
return QVariant();
}
示例10: Set_Previous_Icon_Path
void Select_Icon_Window::Set_Previous_Icon_Path( const QString& path )
{
// Analise path...
if( path[0] == ':' ) // AQEMU Default Icons
{
if( path.contains("linux", Qt::CaseInsensitive) ) ui.RB_Icon_Linux->setChecked( true );
else if( path.contains("windows", Qt::CaseInsensitive) ) ui.RB_Icon_Windows->setChecked( true );
else ui.RB_Icon_Other->setChecked( true );
}
else if( path.indexOf(QDir::toNativeSeparators(Settings.value("AQEMU_Data_Folder", "").toString() + "/os_icons/")) == 0 ) // AQEMU Icons Folder
{
ui.RB_All_System_Icons->setChecked( true );
QFileInfo fl = QFileInfo( path );
for( int ix = 0; ix < ui.All_Icons_List->count(); ++ix )
{
if( ui.All_Icons_List->item(ix)->text() == fl.baseName() )
{
ui.All_Icons_List->setCurrentRow( ix );
// This hack :)
ui.All_Icons_List->setViewMode( QListView::ListMode );
ui.All_Icons_List->setViewMode( QListView::IconMode );
return;
}
}
}
else // Other Path
{
ui.RB_User_Icons->setChecked( true );
ui.Edit_Other_Icon_Path->setText( path );
}
}
示例11: it
AbstractMainWindow::AbstractMainWindow(int _screenIndex, QWidget *parent) :
QWidget(parent),
screenIndex(_screenIndex)
{
/*
* Enlist all image files from /usr/share/backgrounds or
* the directory set from ini file
* and map them as -
* baseName --> absolutePath
*/
AbstractMainWindow::imageFileMap.insert(DEF_IMG_BASE_NAME,
DEF_IMG_ABS_PATH);
QDirIterator it(AbstractMainWindow::settings.value(KEY_IMG_DIR,DEF_IMG_DIR).toString(),
QStringList() << "*.jpg" << "*.png" << "*.jpeg",
QDir::Files, QDirIterator::Subdirectories);
while(it.hasNext())
{
//qDebug()<<it.next();//mandatory to iterate :-<
QString tmp = it.next();
QFileInfo info = it.fileInfo();
AbstractMainWindow::imageFileMap.insert(info.baseName(),
info.absoluteFilePath());
}
qDebug()<<"Total " << imageFileMap.count() << " images found";
/*
* Set Object name and Geometry according to the monitor index
*/
this->setObjectName(QString("LoginWindow_%1").arg(screenIndex));
this->setGeometry(QApplication::desktop()->screenGeometry(screenIndex));
}
示例12: LoadFonts
/**
* \brief Loads the fonts in font files within the given directory structure
*
* Recursively scans all directories under directory looking for TrueType
* (.ttf) and OpenType (.otf) font files or TrueType font collections (.ttc)
* and loads the fonts to make them available to the application.
*
* \param directory The directory to scan
* \param registeredFor The user of the font. Used with releaseFonts() to
* unload the font if no longer in use (by any users)
* \param maxDirs The maximum number of subdirectories to scan
*/
void MythFontManager::LoadFonts(const QString &directory,
const QString ®isteredFor, int *maxDirs)
{
if (directory.isEmpty() || directory == "/" || registeredFor.isEmpty())
return;
(*maxDirs)--;
if (*maxDirs < 1)
{
LOG(VB_GENERAL, LOG_WARNING, LOC +
"Reached the maximum directory depth "
"for a font directory structure. Terminating font scan.");
return;
}
// Load the font files from this directory
LoadFontsFromDirectory(directory, registeredFor);
// Recurse through subdirectories
QDir dir(directory);
QFileInfoList files = dir.entryInfoList();
QFileInfo info;
for (QFileInfoList::const_iterator it = files.begin();
((it != files.end()) && (*maxDirs > 0)); ++it)
{
info = *it;
// Skip '.' and '..' and other files starting with "." by checking
// baseName()
if (!info.baseName().isEmpty() && info.isDir())
LoadFonts(info.absoluteFilePath(), registeredFor, maxDirs);
}
}
示例13: exportModels
// Export all currently loaded models in the referenced format
void Aten::exportModels()
{
Messenger::enter("Aten::exportModels");
QFileInfo fileInfo;
QString newFilename;
// Loop over loaded models
for (Model* m = models_.first(); m != NULL; m = m->next)
{
// Set current model
setCurrentModel(m);
// Generate new filename for model, with new suffix
fileInfo.setFile(m->filename());
newFilename = fileInfo.dir().absoluteFilePath(fileInfo.baseName() + "." + exportModelPlugin_->extensions().first());
QFileInfo newFileInfo(newFilename);
// Make sure that the new filename is not the same as the old filename
if (fileInfo == newFileInfo)
{
Messenger::print("Exported file would overwrite the original (%s) - not converted.", qPrintable(m->filename()));
continue;
}
if (exportModel(m, newFilename, exportModelPlugin_, FilePluginStandardImportOptions(), exportModelPluginOptions_)) Messenger::print("Model '%s' saved to file '%s' (%s)", qPrintable(m->name()), qPrintable(newFilename), qPrintable(exportModelPlugin_->name()));
else Messenger::print("Failed to save model '%s'.", qPrintable(m->name()));
m->enableUndoRedo();
}
Messenger::exit("Aten::exportModels");
}
示例14: QApplication
// +-----------------------------------------------------------
ft::FtApplication::FtApplication(int argc, char* argv[]): QApplication(argc, argv)
{
m_pMainWindow = NULL;
// Information used to store the program settings
QCoreApplication::setOrganizationName("Flat");
QCoreApplication::setOrganizationDomain("https://github.com/luigivieira/Facial-Landmarks-Annotation-Tool.git");
QCoreApplication::setApplicationName("Data");
QString sAppFile = QCoreApplication::applicationFilePath();
QString sDocPath = QDir::toNativeSeparators(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)) + QDir::separator();
QFileInfo oFile = QFileInfo(sAppFile);
QString sLogFile = QString("%1%2.log").arg(sDocPath).arg(oFile.baseName());
m_oLogFile.open(qPrintable(sLogFile), ios::app);
if (!m_oLogFile.is_open())
{
cerr << QString("Could not open the file [%1] for writing. No log will be created.").arg(sLogFile).toStdString();
exit(-1);
}
qInstallMessageHandler(&ft::FtApplication::handleLogOutput);
qDebug() << QCoreApplication::applicationFilePath().toStdString().c_str() << "started.";
}
示例15: pluginLibrary
foreach( const QFileInfo& f, list )
{
QLibrary pluginLibrary( f.absoluteFilePath() );
if( pluginLibrary.load() == false ||
pluginLibrary.resolve( "lmms_plugin_main" ) == NULL )
{
continue;
}
QString descriptorName = f.baseName() + "_plugin_descriptor";
if( descriptorName.left( 3 ) == "lib" )
{
descriptorName = descriptorName.mid( 3 );
}
Descriptor* pluginDescriptor = (Descriptor *) pluginLibrary.resolve( descriptorName.toUtf8().constData() );
if( pluginDescriptor == NULL )
{
qWarning() << tr( "LMMS plugin %1 does not have a plugin descriptor named %2!" ).
arg( f.absoluteFilePath() ).arg( descriptorName );
continue;
}
pluginDescriptors += *pluginDescriptor;
}