// Try to find the project files in a project directory with some smartness static QFileInfoList findProjectFiles(const QDir &projectDir, QString *errorMessage) { const QStringList projectFilePatterns = ProjectExplorer::ProjectExplorerPlugin::projectFilePatterns(); // Project directory QFileInfoList projectFiles = projectDir.entryInfoList(projectFilePatterns, QDir::Files|QDir::NoDotAndDotDot|QDir::Readable); if (!projectFiles.empty()) return projectFiles; // Try a 'src' directory QFileInfoList srcDirs = projectDir.entryInfoList(QStringList(QLatin1String("src")), QDir::Dirs|QDir::NoDotAndDotDot|QDir::Readable); if (srcDirs.empty()) { *errorMessage = msgNoProjectFiles(projectDir, projectFilePatterns); return QFileInfoList(); } const QDir srcDir = QDir(srcDirs.front().absoluteFilePath()); projectFiles = srcDir.entryInfoList(projectFilePatterns, QDir::Files|QDir::NoDotAndDotDot|QDir::Readable); if (projectFiles.empty()) { *errorMessage = msgNoProjectFiles(srcDir, projectFilePatterns); return QFileInfoList(); } return projectFiles; }
PictoreShrinkerController::PictoreShrinkerController(QObject *parent) : QObject(parent), _path(QString()), _savePath(QString()), _widthPercent(100), _heightPercent(100), _actualPicture(0), _pictures(0), _list(QFileInfoList()) { this->_mutex = new QMutex(); }
QUrl PouarQuick::randomfile(QUrl url) { QDir dir(url.toLocalFile()); QFileInfoList dirs = QFileInfoList(dir.entryInfoList(QDir::Files)); if(dirs.size()>0) { dir.setPath(dirs.at(arc4random_uniform(dirs.size())).filePath()); url.setUrl("file://"+dir.absolutePath()); } else url.setUrl("file:///dev/null"); return url; }
bool ModPlusOMCtrl::compile(const QFileInfoList & moDeps, const QFileInfoList filesToCopy) { InfoSender::sendCurrentTask("Open Modelica : Compiling model "+_ModelPlus->modelName()); // compile QString logFile = _ModelPlus->mmoFolder().absolutePath()+_ModelPlus->modelName()+".log"; bool success = OpenModelica::compile(_moomc,_modModelPlus->moFilePath(),_ModelPlus->modelName(),_ModelPlus->mmoFolder(), moDeps,QFileInfoList() << _ModelPlus->neededFiles() << filesToCopy, _ModelPlus->neededFolders()); // Inform if(success) InfoSender::instance()->send(Info(ListInfo::MODELCOMPILATIONSUCCESS,_ModelPlus->modelName(),logFile)); else InfoSender::instance()->send(Info("Model "+_ModelPlus->modelName()+" failed to compile. See OMC log tab for details.",ListInfo::ERROR2)); InfoSender::instance()->eraseCurrentTask(); return success; }
bool Drive::recalculate(QList<Tag *> tags) { if(this->results_.size() > 0) { beginRemoveRows(QModelIndex(), 0, this->results_.size()-1); this->results_ = QFileInfoList(); endRemoveRows(); } QFileInfoList newResults; if(tags.size() == 0) { this->parent_->setExpressionLabel(tr("All Files")); newResults = this->directory_->entryInfoList(QDir::Files); } else { QString expressionLabel = ""; QSet<QString> fileNames = tags[0]->allFiles(); for (int i = 0; i < tags.size(); i += TAG_TREE_COLUMNS) { expressionLabel.append(tags[i]->data(0).toString()); fileNames = fileNames.intersect(tags[i]->allFiles()); if (i < tags.size() - TAG_TREE_COLUMNS) expressionLabel.append(tr(" ∩ ")); } this->parent_->setExpressionLabel(expressionLabel); for(auto i = fileNames.begin(); i != fileNames.end(); ++i) { newResults.append(QFileInfo(*i)); } } if(newResults.size() > 0) { beginInsertRows(QModelIndex(), 0, newResults.size()-1); this->results_ = newResults; endInsertRows(); } this->sort(this->sortColumn_,this->sortOrder_); emit(doneCalculating()); return true; }
Result* OneSimulation::launch(ProblemConfig config) { // Creating a variables instance containing updated variables Variables updatedVariables(*_overwritedVariables); OneSimResult* result = new OneSimResult(_omProject,_ModelPlus,*this); result->setName(this->name()+" result"); // check if has modependencies (only for modmodelplus) QFileInfoList moDeps; ModModelPlus* modModelPlus = dynamic_cast<ModModelPlus*>(_ModelPlus); if(modModelPlus) moDeps.append(modModelPlus->moDependencies()); // loop indexes on scannVariables QList<int> indexes,maxIndexes; Variable* clonedVar; ScannedVariable *scannedVar; for(int iScanV=0; iScanV < _scannedVariables->size(); iScanV++) { indexes.push_back(0); scannedVar = _scannedVariables->at(iScanV); maxIndexes.push_back(scannedVar->nbScans()-1); clonedVar = new Variable(*(dynamic_cast<Variable*>(scannedVar))); updatedVariables.addItem(clonedVar); } MOVector<Variable> curVariables(true); bool allSimSuccess=true; bool curSimSuccess; int iScan=0; do { // Update values VariablesManip::updateScanValues(&updatedVariables,_scannedVariables,indexes); // Simulate curVariables.clear(); curSimSuccess = ctrl()->simulate(_project->tempPath(), &updatedVariables, &curVariables, QFileInfoList() << _ModelPlus->neededFiles() << _filesToCopy,moDeps); allSimSuccess = allSimSuccess && curSimSuccess; if(allSimSuccess) { // Add values double curValue; //if it is first scan, finalvariables is an empy vector -> fill with curVariables if(result->finalVariables()->isEmpty()) { for(int i=0;i<curVariables.size();i++) { result->finalVariables()->addItem(new VariableResult(*curVariables.at(i))); curValue = curVariables.at(i)->getFieldValue(Variable::VALUE).toDouble(); result->finalVariables()->at(i)->setFinalValue(iScan,0,curValue,true); } } else { // append scan values Variable *curVar; for(int i=0;i<result->finalVariables()->size();i++) { curVar = curVariables.findItem(result->finalVariables()->at(i)->name()); if(curVar) { curValue = curVar->doubleValue(); result->finalVariables()->at(i)->setFinalValue(iScan,0,curValue,true); } else result->finalVariables()->at(i)->setFinalValue(iScan,0,-1,false); } } } indexes = LowTools::nextIndex(indexes,maxIndexes); iScan++; } while(!indexes.isEmpty() && allSimSuccess); curVariables.clear(); //qDebug(result->finalVariables()->toCSV().toLatin1().data()); result->setSuccess(allSimSuccess); return result; }