/*! * \brief TextDoc::setName sets the text file name on its tab * \param Name_ text file name to be set */ void TextDoc::setName (const QString& Name_) { DocName = Name_; setLanguage (DocName); QFileInfo Info (DocName); DataSet = Info.baseName (true) + ".dat"; DataDisplay = Info.baseName (true) + ".dpl"; if(Info.extension(false) == "m" || Info.extension(false) == "oct") SimTime = "1"; }
// --------------------------------------------------- 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"; }
/*************************************************************************** * 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; }
DocEntry *DocMetaInfo::scanMetaInfoDir(const QString &dirName, DocEntry *parent) { QDir dir(dirName); if(!dir.exists()) return 0; const QFileInfoList_qt3 *entryList = dir.entryInfoList_qt3(); QFileInfoListIterator it(*entryList); QFileInfo *fi; for(; (fi = it.current()); ++it) { DocEntry *entry = 0; if(fi->isDir() && fi->fileName() != "." && fi->fileName() != "..") { DocEntry *dirEntry = addDirEntry(QDir(fi->absFilePath()), parent); entry = scanMetaInfoDir(fi->absFilePath(), dirEntry); } else if(fi->extension(false) == "desktop") { entry = addDocEntry(fi->absFilePath()); if(parent && entry) parent->addChild(entry); } } return 0; }
void AppLnkSet::findChildren(const QString &dr, const QString& typ, const QString& typName, int depth) { depth++; if ( depth > 10 ) return; QDir dir( dr ); QString typNameLocal = typName; if ( dir.exists( ".directory" ) ) { Config config( dr + "/.directory", Config::File ); config.setGroup( "Desktop Entry" ); typNameLocal = config.readEntry( "Name", typNameLocal ); if ( !typ.isEmpty() ) { d->typPix.insert( typ, new AppLnkImagePrivate( config.readEntry( "Icon", "AppsIcon" ) ) ); d->typName.insert(typ, new QString(typNameLocal)); } } const QFileInfoList *list = dir.entryInfoList(); if ( list ) { QFileInfo* fi; bool cadded=FALSE; for ( QFileInfoListIterator it(*list); (fi=*it); ++it ) { QString bn = fi->fileName(); // qDebug("findChildren "+bn); if ( bn[0] != '.' && bn != "CVS" ) { if ( fi->isDir() ) { QString c = typ.isNull() ? bn : typ+"/"+bn; QString d = typNameLocal.isNull() ? bn : typNameLocal+"/"+bn; findChildren(fi->filePath(), c, d, depth ); } else { if ( fi->extension(FALSE) == "desktop" ) { AppLnk* app = new AppLnk( fi->filePath() ); #ifdef QT_NO_QWS_MULTIPROCESS if ( !Global::isBuiltinCommand( app->exec() ) ) delete app; else #endif { if ( !typ.isEmpty() ) { if ( !cadded ) { typs.append(typ); cadded = TRUE; } app->setType(typ); } add(app); } } } } } } }
void DocLnkSet::findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth) { depth++; if ( depth > 10 ) return; QDir dir( dr ); /* Opie got a different approach * I guess it's geek vs. consumer * in this case to be discussed */ if ( dir.exists( ".Qtopia-ignore" ) ) return; const QFileInfoList *list = dir.entryInfoList(); if ( list ) { QFileInfo* fi; for ( QFileInfoListIterator it(*list); (fi=*it); ++it ) { QString bn = fi->fileName(); if ( bn[0] != '.' ) { if ( fi->isDir() ) { if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) findChildren(fi->filePath(), mimeFilters, reference, depth); } else { if ( fi->extension(FALSE) == "desktop" ) { DocLnk* dl = new DocLnk( fi->filePath() ); QFileInfo fi2(dl->file()); bool match = FALSE; if ( !fi2.exists() ) { dir.remove( dl->file() ); } if ( mimeFilters.count() == 0 ) { add( dl ); match = TRUE; } else { for( QValueList<QRegExp>::ConstIterator it = mimeFilters.begin(); it != mimeFilters.end(); ++ it ) { if ( (*it).match(dl->type()) >= 0 ) { add(dl); match = TRUE; } } } if ( !match ) delete dl; } else { if ( !reference.find(fi->fileName()) ) reference.insert(fi->filePath(), (void*)2); } } } } } }
// --------------------------------------------------- void TextDoc::setLanguage (const QString& FileName) { QFileInfo Info (FileName); QString ext = Info.extension (false); if (ext == "vhd" || ext == "vhdl") setLanguage (LANG_VHDL); else if (ext == "v") setLanguage (LANG_VERILOG); else if (ext == "va") setLanguage (LANG_VERILOGA); else if (ext == "m" || ext == "oct") setLanguage (LANG_OCTAVE); else setLanguage (LANG_NONE); }
static void FillComboWithDir( QComboBox * combo, const char * sDirectory, const char * ext ) { // Look in the current directory QDir dir(sDirectory); if( !dir.exists() ) { fprintf( stderr, "Warning: Directory not found (%s).\n", sDirectory ); fprintf( stderr, "Action: Run rars from his home directory\n" ); return; } dir.setFilter( QDir::Files | QDir::NoSymLinks ); const QFileInfoList * fileinfolist = dir.entryInfoList(); QFileInfoListIterator it (*fileinfolist); QFileInfo *fi; while( (fi=it.current()) ) { if( strcmp( fi->extension(), ext )==0 ) { combo->insertItem( fi->fileName() ); } ++it; } }
QString QucsDoc::fileSuffix (const QString& Name) { QFileInfo Info (Name); return Info.extension (false); }