void ViStatistician::run(QString folder) { if(folder == "") { QDir dir("/home/visore/Visore Projects/Files/"); QStringList dirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); for(int i = 0; i < dirs.size(); ++i) addDir(dirs[i]); } else { addDir(folder); } nextFile(); }
void K2sendPlayList::addDir(const QString & path,K2sendPlayListItem * after ) { K2sendPlayListItem * new_item; K2sendPlayListItem * last_item; QDir dir(path); dir.setMatchAllDirs (TRUE); dir.setFilter( QDir::All ); dir.setSorting( QDir::Name | QDir::DirsFirst); const QFileInfoList *list = dir.entryInfoList(); QFileInfoListIterator it( *list ); QFileInfo *fi; int cnt = 0; last_item = after; while ( (fi = it.current()) != 0 ) { cnt++; if (fi->isDir()){ if (fi->fileName() != "." && fi->fileName() != "..") addDir(fi->filePath()); } else { if (!this->isDoubleEntry(fi->filePath())){ new_item = new K2sendPlayListItem((KListView*)this, fi->filePath()); if (new_item->valid()){ this->insertItem (new_item); new_item->moveItem(last_item); last_item = new_item; } else { this->removeItem (new_item); delete new_item; } } } ++it; } }
void CFileSystem::loadAllDirectories(const CString& directory, bool recursive) { CString dir = CString() << directory.remove(directory.findl(fSep)) << fSep; WIN32_FIND_DATAA filedata; HANDLE hFind = FindFirstFileA(directory.text(), &filedata); if (hFind != INVALID_HANDLE_VALUE) { do { if (filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (filedata.cFileName[0] != '.' && recursive) { // We need to add the directory to the directory list. CString newDir = CString() << dir << filedata.cFileName << fSep; newDir.removeI(0, server->getServerPath().length()); addDir(newDir, "*", true); } } else { // Grab the file name. CString file((char *)filedata.cFileName); fileList[file] = CString(dir) << filedata.cFileName; } } while (FindNextFileA(hFind, &filedata)); } FindClose(hFind); }
void ViNoiseBatcher::benchmark(QString folder) { if(folder == "") { QDir dir("/home/visore/Visore Projects/Files/"); QStringList dirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); for(int i = 0; i < dirs.size(); ++i) addDir(dirs[i]); } else { addDir(folder); } mTotalFiles = mFiles.size(); nextFile(); }
int PlayListWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QTreeWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: playListEmpty(); break; case 1: playItem((*reinterpret_cast< PlayListItem*(*)>(_a[1]))); break; case 2: addFile((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 3: addFile((*reinterpret_cast< QString(*)>(_a[1]))); break; case 4: addFile((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QMap<QString,QString>(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 5: addFile((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QMap<QString,QString>(*)>(_a[2]))); break; case 6: { int _r = addDir((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break; case 7: { int _r = addDir((*reinterpret_cast< QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break; case 8: removeSelected(); break; case 9: doubleClicked((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 10: scrollToActive(); break; case 11: deselect((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 12: clearPlayList(); break; case 13: { int _r = loadM3UPlayList((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break; case 14: { int _r = loadM3UPlayList((*reinterpret_cast< QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break; case 15: { int _r = loadPLSPlayList((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break; case 16: { int _r = loadPLSPlayList((*reinterpret_cast< QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break; case 17: saveM3UPlayList((*reinterpret_cast< QString(*)>(_a[1]))); break; case 18: savePLSPlayList((*reinterpret_cast< QString(*)>(_a[1]))); break; case 19: updateColumnWidth((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 20: updateColumnPosition((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 21: headerContextMenu((*reinterpret_cast< const QPoint(*)>(_a[1]))); break; case 22: setScroll(); break; case 23: hideSection(); break; case 24: showSection(); break; case 25: printPos((*reinterpret_cast< int(*)>(_a[1]))); break; default: ; } _id -= 26; } return _id; }
void K2sendPlayList::add(const QString & path,K2sendPlayListItem * after ) { QFileInfo file(path); if (file.isDir()){ addDir(path,after); } else if(file.isFile()){ addFile(path,after); } }
void MainWindow::addTiles() { QString dir = QFileDialog::getExistingDirectory(this, tr("Select tile directory"), topImageDir); if(dir.length() > 0) { addDir(dir); packerUpdate(); } }
// helper function to add and weight all plots in the subsamples void addDir(const std::string& path, const std::vector< std::pair< TFile*, double > >& files, TFile *target, int verbose) { // loop all objects in the file std::vector< std::pair< TFile*, double > >::const_iterator first=files.begin(); first->first->cd(path.c_str()); TIter nextkey(gDirectory->GetListOfKeys()); TKey *key=0; while ( (key = (TKey*)nextkey())) { // read object from first source file first->first->cd(path.c_str()); TObject *obj = key->ReadObj(); if ( obj->IsA()->InheritsFrom( "TH1" ) ) { // if descendant of TH1 -> mergeit TH1 *h1 = (TH1*)obj; h1->Sumw2(); h1->Scale(first->second); // loop over all source files and add the content of the // corresponding histogram to the one pointed to by "h1" for(std::vector< std::pair< TFile*, double > >::const_iterator file=first+1; file!=files.end(); ++file) { // make sure we are at the correct directory level by cd'ing to path file->first->cd(path.c_str()); TH1 *h2 = (TH1*)gDirectory->Get( h1->GetName() ); if ( h2 ) { h2->Sumw2(); h1->Add(h2,file->second); delete h2; // don't know if this is necessary, i.e. if // h2 is created by the call to gDirectory above. } } } else if (obj->IsA()->InheritsFrom( "TDirectory" ) ) { // for a subdirectory if(verbose>1) std::cout << "Found subdirectory " << obj->GetName() << std::endl; // create a new subdir of same name and title in the target file target->cd(); TDirectory *newdir = target->mkdir( obj->GetName(), obj->GetTitle() ); // newdir is now the starting point of another round of merging // newdir still knows its depth within the target file via // GetPath(), so we can still figure out where we are in the recursion addDir(newdir->GetName(),files,target, verbose); } if ( obj ) { target->cd(path.c_str()); obj->Write( key->GetName() ); } delete obj; } target->Write(); delete key; }
void CFileSystem::loadAllDirectories(const CString& directory, bool recursive) { CString path = CString() << directory.remove(directory.findl(fSep)) << fSep; CString wildcard = directory.subString(directory.findl(fSep) + 1); DIR *dir; struct stat statx; struct dirent *ent; // Try to open the directory. if ((dir = opendir(path.text())) == 0) return; // Read everything in it now. while ((ent = readdir(dir)) != 0) { if (ent->d_name[0] != '.') { CString dircheck = CString() << path << ent->d_name; stat(dircheck.text(), &statx); if ((statx.st_mode & S_IFDIR)) { if (recursive) { // We need to add the directory to the directory list. CString newDir = CString() << path << ent->d_name << fSep; newDir.removeI(0, server->getServerPath().length()); addDir(newDir, "*", true); } continue; } } else continue; // Grab the file name. CString file(ent->d_name); if (file.match(wildcard)) fileList[file] = CString(path) << file; } closedir(dir); }
void Desktopwidget::slotUpdateRepositoryList (QString &dirname, bool add_not_delete) { err_info *err = NULL; if (add_not_delete) err = addDir (dirname); else { QModelIndex index = _model->index (dirname, 0); if (index != QModelIndex ()) { _contents->removeDesk (dirname); _model->removeDirFromList (index); _contents->resetDirPath (); } else qDebug () << "slotUpdateRepositoryList: Could not find dirname" << dirname << "in model index: "; } if (!err_complain (err)) updateSettings (); }
void MainWindow::dropEvent(QDropEvent *event) { QList<QUrl> droppedUrls = event->mimeData()->urls(); int droppedUrlCnt = droppedUrls.size(); for(int i = 0; i < droppedUrlCnt; i++) { QString localPath = droppedUrls[i].toLocalFile(); QFileInfo fileInfo(localPath); if(fileInfo.isFile()) { ui->tilesList->addItem(fileInfo.fileName()); packerData * data = new packerData; data->listItem = ui->tilesList->item(ui->tilesList->count() - 1); data->path = fileInfo.absoluteFilePath(); packer.addItem(data->path, data); //QMessageBox::information(this, tr("Dropped file"), "Dropping files is not supported yet. Drad and drop directory here."); } else if(fileInfo.isDir()) { addDir(fileInfo.absoluteFilePath()); } } packerUpdate(); event->acceptProposedAction(); }
void OFileViewFileListView::reread( bool all ) { m_view->clear(); if (selector()->showClose() ) m_btnClose->show(); else m_btnClose->hide(); if (selector()->showNew() ) m_btnNew->show(); else m_btnNew->hide(); m_mimes = selector()->currentMimeType(); m_all = all; QDir dir( m_currentDir ); if (!dir.exists() ) return; dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); int filter; if (m_all ) filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; else filter = QDir::Files | QDir::Dirs | QDir::All; dir.setFilter( filter ); // now go through all files const QFileInfoList *list = dir.entryInfoList(); if (!list) { cdUP(); return; } QFileInfoListIterator it( *list ); QFileInfo *fi; while( (fi=it.current() ) ) { if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) { ++it; continue; } /* * It is a symlink we try to resolve it now but don't let us attack by DOS * */ if( fi->isSymLink() ) { QString file = fi->dirPath( true ) + "/" + fi->readLink(); for( int i = 0; i<=4; i++) { // 5 tries to prevent dos QFileInfo info( file ); if( !info.exists() ) { addSymlink( fi, TRUE ); break; } else if( info.isDir() ) { addDir( fi, TRUE ); break; } else if( info.isFile() ) { addFile( fi, TRUE ); break; } else if( info.isSymLink() ) { file = info.dirPath(true ) + "/" + info.readLink() ; break; } else if( i == 4) { // couldn't resolve symlink add it as symlink addSymlink( fi ); } } // off for loop for symlink resolving } else if( fi->isDir() ) addDir( fi ); else if( fi->isFile() ) addFile( fi ); ++it; } // of while loop m_view->sort(); }
void ProjectBrowser::openProject(ProjectSettings* settings) { FileType sourceType, includeType; StringTokenizer* strtok = new StringTokenizer(); settings->parse(); FXString project = settings->getStringValue("GENERAL", "name"); addProject(project); FXString source = settings->getStringValue("DIRECTORY", "sourceDir"); if (source != "") addDir(project, source, SOURCE); FXString include = settings->getStringValue("DIRECTORY", "includeDir"); if (include != "") addDir(project, include, INCLUDE); FXString ressource = settings->getStringValue("DIRECTORY", "ressourceDir"); if (ressource != "") addDir(project, ressource, RESSOURCE); FXString doc = settings->getStringValue("DIRECTORY", "docDir"); if (doc != "") addDir(project, doc, DOC); FXString type = settings->getStringValue("GENERAL", "type"); if (type == "C/C++") { sourceType = CPP_SOURCE; includeType = CPP_HEADER; } FXString sourceList = settings->getStringValue("FILES", "source"); if (sourceList != "") { strtok->reinit(sourceList, ProjectSettings::SEPARATOR); FXString token; while ((token = strtok->getNextToken()) != "") addFile(project, token, source, sourceType); } FXString includeList = settings->getStringValue("FILES", "include"); if (includeList != "") { strtok->reinit(includeList, ProjectSettings::SEPARATOR); FXString token; while ((token = strtok->getNextToken()) != "") addFile(project, token, include, includeType); } FXString ressourceList = settings->getStringValue("FILES", "ressource"); if (ressourceList != "") { strtok->reinit(ressourceList, ProjectSettings::SEPARATOR); FXString token; while ((token = strtok->getNextToken()) != "") addFile(project, token, ressource, RESSOURCE_FILE); } FXString docList = settings->getStringValue("FILES", "doc"); if (docList != "") { strtok->reinit(docList, ProjectSettings::SEPARATOR); FXString token; while ((token = strtok->getNextToken()) != "") addFile(project, token, doc, TEXT); } FXString rootList = settings->getStringValue("FILES", "root"); if (rootList != "") { strtok->reinit(rootList, ProjectSettings::SEPARATOR); FXString token; while ((token = strtok->getNextToken()) != "") addFile(project, token, "", TEXT); } settings->write(); // unparse delete strtok; }
void combineAllPlots(int sysTag, int sample, TString decayChannel, int verbose, TString inputFolderName, TString outputFolder){ // --- // check input // --- // a) check if sample input is valid if(!(sample==kQCD||sample==kDiBos||sample==kSTop||sample==kTTVjets)){ std::cout << "chosen input sample enumerator " << sample << " is invalid" << std::endl; std::cout << "please check the list of allowed sample inputs" << std::endl; exit(0); } // b) check if decayChannel input is valid if(!(decayChannel=="electron"||decayChannel=="muon")){ std::cout << "chosen decay channel " << decayChannel << " is invalid" << std::endl; std::cout << "has to be electron or muon" << std::endl; exit(0); } // --- // assign enumerator for subsamples // corresponding to "sample" // --- // (i) collect first and last enumerator corresponding // to enum samples in basicFunctions.h // a) single top int first=kSTops; int last =kSAToptW; // b) QCD electron channel // (muon channel excluded above) if(sample==kQCD){ first=kQCDEM1; last =kQCDBCE3; } // c) diboson samples else if(sample==kDiBos){ first=kWW; last =kZZ; } // TTV samples else if(sample==kTTVjets){ first=kTTGjets; last =kTTWjets; } // (ii) list subsamples in vector std::vector<int> subSamples_; for(int subsample=first; subsample<=last; ++subsample){ if((sysTag!=sysTopScaleUp&&sysTag!=sysTopScaleDown)||(subsample!=kSAToptW&&subsample!=kSToptW)) subSamples_.push_back(subsample); else{ // for single top scale samples Tw is splitted in 3 subsamples if(subsample==kSToptW){ subSamples_.push_back(kSToptW1); subSamples_.push_back(kSToptW2); subSamples_.push_back(kSToptW3); } else if(subsample==kSAToptW){ subSamples_.push_back(kSAToptW1); subSamples_.push_back(kSAToptW2); subSamples_.push_back(kSAToptW3); } } } // --- // input & output // --- // folder were subsamples can be found TString inputFolder = groupSpace+inputFolderName; // folder and name of the (combined) output file TString outputFilename= (outputFolder=="" ? inputFolder : outputFolder); outputFilename+="/"+TopFilename(sample, sysTag, std::string(decayChannel)); // --- // container for all subsample files and // their corresponding lumiweights // --- std::vector< std::pair< TFile*, double > > files_; // loop subsamples for(unsigned int subsample=0; subsample<subSamples_.size(); ++subsample){ // get subsample file name TString fileName = inputFolder+"/"+TopFilename(subSamples_[subsample], sysTag, std::string(decayChannel)); //std::cout << fileName << ": " << lumiweight(subSamples_[subsample], 1, sysTag, std::string(decayChannel)) << std::endl; // check existence & availability of file if((fileName!="no")&&(fileName!="")){ TFile* file = TFile::Open(fileName); if(file&&!(file->IsZombie())){ // N.B.: a luminosity of 1 pb is used, lumi normalization is done later in the main file files_.push_back(std::make_pair(file, lumiweight(subSamples_[subsample], 1, sysTag, std::string(decayChannel)))); } } } // check if all files are found if(subSamples_.size()!=files_.size()){ std::cout << "ERROR: not all subsamples could be found" << std::endl; exit(0); } // --- // print out all information about current combination // --- if(verbose>0){ std::cout << "combining MC subsamples for: " << std::endl; std::cout << " - " << sampleLabel(sample,(const std::string)decayChannel) << std::endl; std::cout << " - " << decayChannel << " channel " << std::endl; std::cout << " - " << "systematic variation " << sysLabel(sysTag) << std::endl; std::cout << " - " << "input folder:" << inputFolder << std::endl; std::cout << " - " << "input subSamples(weights without luminosity):"; for(unsigned int subsample=0; subsample<subSamples_.size(); ++subsample){ std::cout << std::endl << " " << sampleLabel(subSamples_[subsample],(const std::string)decayChannel) << " ( " << files_[subsample].second << " )"; } std::cout << std::endl; std::cout << " - " << " output file created: " << outputFilename << std::endl << std::endl; // wait for 1 second sleep(1); } // --- // create output file // --- TFile* output_file = TFile::Open(outputFilename, "recreate"); // open input files and weight them addDir("",files_,output_file, verbose); // close output files output_file->Close(); // close and delete input files for(std::vector< std::pair< TFile*, double > >::const_iterator file=files_.begin(); file!=files_.end(); ++file){ file->first->Close(); delete file->first; } }
void SettingsWindow::loadSettings() { m_settings->loadSettings(); // Stream Details ui->chkAutoLoadStreamDetails->setChecked(m_settings->autoLoadStreamDetails()); // Proxy ui->chkUseProxy->setChecked(m_settings->useProxy()); ui->proxyType->setCurrentIndex(m_settings->proxyType()); ui->proxyHost->setText(m_settings->proxyHost()); ui->proxyPort->setValue(m_settings->proxyPort()); ui->proxyUsername->setText(m_settings->proxyUsername()); ui->proxyPassword->setText(m_settings->proxyPassword()); onUseProxy(); ui->usePlotForOutline->setChecked(m_settings->usePlotForOutline()); ui->chkDownloadActorImages->setChecked(m_settings->downloadActorImages()); ui->chkIgnoreArticlesWhenSorting->setChecked(m_settings->ignoreArticlesWhenSorting()); ui->chkCheckForUpdates->setChecked(m_settings->checkForUpdates()); ui->chkEnableAdultScrapers->setChecked(m_settings->showAdultScrapers()); onShowAdultScrapers(); for (int i=0, n=ui->comboStartupSection->count() ; i<n ; ++i) { if (ui->comboStartupSection->itemData(i, Qt::UserRole) == m_settings->startupSection()) { ui->comboStartupSection->setCurrentIndex(i); break; } } // Directories ui->dirs->setRowCount(0); ui->dirs->clearContents(); QList<SettingsDir> movieDirectories = m_settings->movieDirectories(); for (int i=0, n=movieDirectories.count() ; i<n ; ++i) addDir(movieDirectories.at(i).path, movieDirectories.at(i).separateFolders, movieDirectories.at(i).autoReload, DirTypeMovies); QList<SettingsDir> tvShowDirectories = m_settings->tvShowDirectories(); for (int i=0, n=tvShowDirectories.count() ; i<n ; ++i) addDir(tvShowDirectories.at(i).path, tvShowDirectories.at(i).separateFolders, tvShowDirectories.at(i).autoReload, DirTypeTvShows); QList<SettingsDir> concertDirectories = m_settings->concertDirectories(); for (int i=0, n=concertDirectories.count() ; i<n ; ++i) addDir(concertDirectories.at(i).path, concertDirectories.at(i).separateFolders, concertDirectories.at(i).autoReload, DirTypeConcerts); QList<SettingsDir> downloadDirectories = m_settings->downloadDirectories(); for (int i=0, n=downloadDirectories.count() ; i<n ; ++i) addDir(downloadDirectories.at(i).path, false, false, DirTypeDownloads); dirListRowChanged(ui->dirs->currentRow()); // Exclude words ui->excludeWordsText->setPlainText(m_settings->excludeWords()); ui->useYoutubePluginUrls->setChecked(m_settings->useYoutubePluginUrls()); // XBMC ui->xbmcHost->setText(m_settings->xbmcHost()); if (m_settings->xbmcPort() != 0) ui->xbmcPort->setText(QString::number(m_settings->xbmcPort())); else ui->xbmcPort->clear(); ui->xbmcUser->setText(m_settings->xbmcUser()); ui->xbmcPassword->setText(m_settings->xbmcPassword()); // Movie set artwork for (int i=0, n=ui->comboMovieSetArtwork->count() ; i<n ; ++i) { if (ui->comboMovieSetArtwork->itemData(i).toInt() == m_settings->movieSetArtworkType()) { ui->comboMovieSetArtwork->setCurrentIndex(i); break; } } ui->movieSetArtworkDir->setText(m_settings->movieSetArtworkDirectory()); onComboMovieSetArtworkChanged(); foreach (QLineEdit *lineEdit, findChildren<QLineEdit*>()) { if (lineEdit->property("dataFileType").isNull()) continue; int dataFileType = lineEdit->property("dataFileType").toInt(); QList<DataFile> dataFiles = m_settings->dataFiles(dataFileType); QStringList filenames; foreach (DataFile dataFile, dataFiles) filenames << dataFile.fileName(); lineEdit->setText(filenames.join(",")); } QList<int> infos = QList<int>() << MovieScraperInfos::Title << MovieScraperInfos::Set << MovieScraperInfos::Tagline << MovieScraperInfos::Rating << MovieScraperInfos::Released << MovieScraperInfos::Runtime << MovieScraperInfos::Director << MovieScraperInfos::Writer << MovieScraperInfos::Certification << MovieScraperInfos::Trailer << MovieScraperInfos::Overview << MovieScraperInfos::Poster << MovieScraperInfos::Backdrop << MovieScraperInfos::Actors << MovieScraperInfos::Genres << MovieScraperInfos::Studios << MovieScraperInfos::Countries << MovieScraperInfos::Logo << MovieScraperInfos::ClearArt << MovieScraperInfos::CdArt << MovieScraperInfos::Banner << MovieScraperInfos::Thumb; ui->customScraperTable->clearContents(); ui->customScraperTable->setRowCount(0); foreach (const int &info, infos) { int row = ui->customScraperTable->rowCount(); ui->customScraperTable->insertRow(row); ui->customScraperTable->setItem(row, 0, new QTableWidgetItem(titleForMovieScraperInfo(info))); ui->customScraperTable->setCellWidget(row, 1, comboForMovieScraperInfo(info)); }
void CollectionScanner::Scanner::doJob() //SLOT { QFile xmlFile; xmlFile.open( stdout, QIODevice::WriteOnly ); QXmlStreamWriter xmlWriter( &xmlFile ); xmlWriter.setAutoFormatting( true ); // --- determine the directories we have to scan QStringList entries; // -- when restarting read them from the shared memory if( m_restart && m_scanningState.isValid() ) { m_scanningState.readFull(); QString lastEntry = m_scanningState.lastDirectory(); entries = m_scanningState.directories(); // remove the entries we already scanned while( entries.front() != lastEntry && !entries.empty() ) entries.pop_front(); } // -- else use m_folders and do recursive else { QSet<QString> entriesSet; foreach( const QString &dir, m_folders ) // krazy:exclude=foreach { if( dir.isEmpty() ) //apparently somewhere empty strings get into the mix //which results in a full-system scan! Which we can't allow continue; QString newdir( dir ); // Make sure that all paths are absolute, not relative if( QDir::isRelativePath( dir ) ) newdir = QDir::cleanPath( QDir::currentPath() + '/' + dir ); if( !dir.endsWith( '/' ) ) newdir += '/'; addDir( newdir, &entriesSet ); } entries = entriesSet.toList(); m_scanningState.setLastDirectory( QString() ); m_scanningState.setDirectories( entries ); } if( !m_restart ) { xmlWriter.writeStartDocument(); xmlWriter.writeStartElement("scanner"); xmlWriter.writeAttribute("count", QString::number( entries.count() ) ); if( m_incremental ) xmlWriter.writeAttribute("incremental", QString()); // write some information into the file and close previous tag xmlWriter.writeComment("Created by amarokcollectionscanner "AMAROK_VERSION" on "+QDateTime::currentDateTime().toString()); xmlFile.flush(); } // --- now do the scanning foreach( QString path, entries ) { CollectionScanner::Directory dir( path, &m_scanningState, m_incremental && !isModified( path ) ); xmlWriter.writeStartElement( "directory" ); dir.toXml( &xmlWriter ); xmlWriter.writeEndElement(); xmlFile.flush(); }
bool NetwalkWindow::connectClient( const int x, const int y, int dir ) { if ( (x < 0) || ( x >= pSizeX) ) return false; if ( (y < 0) || ( y >= pSizeY) ) return false; bool triedUp = false; bool triedDown = false; bool triedRight = false; bool triedLeft = false; if ( dir == 0 ) triedDown = true; else if ( dir == 1 ) triedLeft = true; else if ( dir == 2 ) triedUp = true; else if ( dir == 3 ) triedRight = true; int r; while ( (!triedUp) || (!triedDown) || (!triedLeft) || (!triedRight) ) { r = rand() % 4; if ( (r == 0) && (!triedUp) ) { if ( (!isClient( x, y-1 )) && ( y-1 >= 0) ) { if ( ( mapView.tiles(x, y-1).objectImage( 0 ) == -1 ) || ( mapView.tiles(x, y-1).objectImage( 0 ) > 13 ) ) { if ( ( addDir(x, y, r) ) && ( addDir(x, y-1, (r + 2) % 4) ) ) { if ( mapView.tiles(x, y-1).objectImage( 0 ) > 13 ) { //mapView.tiles(x, y).objectImage( 0 ) += 14; return true; } else { if ( connectClient( x, y-1, r) ) { //mapView.tiles(x, y).objectImage( 0 ) += 14; return true; } } } removeDir(x, y, r); removeDir(x, y-1, (r + 2) % 4); } } triedUp = true; } else if ( (r == 1) && (!triedRight) ) { if ( (!isClient( x+1, y )) && ( x+1 < pSizeX) ) { if ( ( mapView.tiles(x+1, y).objectImage( 0 ) == -1 ) || ( mapView.tiles(x+1, y).objectImage( 0 ) > 13 ) ) { if ( ( addDir(x, y, r) ) && ( addDir(x+1, y, (r + 2) % 4) ) ) { if ( mapView.tiles(x+1, y).objectImage( 0 ) > 13 ) { // mapView.tiles(x, y).objectImage( 0 ) += 14; return true; } else { if ( connectClient(x+1, y, r) ) { // mapView.tiles(x, y).objectImage( 0 ) += 14; return true; } } } removeDir(x, y, r); removeDir(x+1, y, (r + 2) % 4); } } triedRight = true; } else if ( (r == 2) && (!triedDown) ) { if ( (!isClient( x, y+1 )) && ( y+1 < pSizeY) ) { if ( ( mapView.tiles(x, y+1).objectImage( 0 ) == -1 ) || ( mapView.tiles(x, y+1).objectImage( 0 ) > 13 ) ) { if ( ( addDir(x, y, r) ) && ( addDir(x, y+1, (r + 2) % 4) ) ) { if ( mapView.tiles(x, y+1).objectImage( 0 ) > 13 ) { // mapView.tiles(x, y).objectImage( 0 ) += 14; return true; } else { if ( connectClient(x, y+1, r) ) { // mapView.tiles(x, y).objectImage( 0 ) += 14; return true; } } } removeDir(x, y, r); removeDir(x, y+1, (r + 2) % 4); } } triedDown = true; } else if ( (r == 3) && (!triedLeft) ) { if ( (!isClient( x-1, y )) && ( x-1 >= 0) ) { if ( ( mapView.tiles(x-1, y).objectImage( 0 ) == -1 ) || ( mapView.tiles(x-1, y).objectImage( 0 ) > 13 ) ) { if ( ( addDir(x, y, r) ) && ( addDir(x-1, y, (r + 2) % 4) ) ) { if ( mapView.tiles(x-1, y).objectImage( 0 ) > 13 ) { // mapView.tiles(x, y).objectImage( 0 ) += 14; return true; } else { if ( connectClient(x-1, y, r) ) { // mapView.tiles(x, y).objectImage( 0 ) += 14; return true; } } } removeDir(x, y, r); removeDir(x-1, y, (r + 2) % 4); } } triedLeft = true; } } return false; }