/** given a text line containing fex [alpha beta "gamm ma" delta] * split into a list of ["alpha", "beta" ,"gamm ma", "delta"] */ QStringList splitStringContaingQuotes(QString line) { QStringList base = line.split(" "); QStringList retval; for (int i=0; i<base.size(); ++i) { if (base[i].startsWith("\"") && !base[i].endsWith("\"")) { QString s; do { s += base[i]; if ((i+1)<base.size() && !base[i].endsWith("\"")) s += " "; ++i; } while (i<base.size() && !base[i].endsWith("\"")); if (i<base.size()) s += base[i]; retval.push_back(s); } else { retval.push_back(base[i]); } retval.back() = retval.back().remove("\""); } retval.removeAll(""); return retval; }
//---------------------------------------------------------------------------- void ctkPluginFrameworkContext::init() { log() << "initializing"; if (firstInit && ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT == props[ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN]) { deleteFWDir(); firstInit = false; } // Pre-load libraries // This may speed up installing new plug-ins if they have dependencies on // one of these libraries. It prevents repeated loading and unloading of the // pre-loaded libraries during caching of the plug-in meta-data. if (props[ctkPluginConstants::FRAMEWORK_PRELOAD_LIBRARIES].isValid()) { QStringList preloadLibs = props[ctkPluginConstants::FRAMEWORK_PRELOAD_LIBRARIES].toStringList(); QLibrary::LoadHints loadHints; QVariant loadHintsVariant = props[ctkPluginConstants::FRAMEWORK_PLUGIN_LOAD_HINTS]; if (loadHintsVariant.isValid()) { loadHints = loadHintsVariant.value<QLibrary::LoadHints>(); } foreach(QString preloadLib, preloadLibs) { QLibrary lib; QStringList nameAndVersion = preloadLib.split(":"); QString libraryName; if (nameAndVersion.count() == 1) { libraryName = nameAndVersion.front(); lib.setFileName(nameAndVersion.front()); } else if (nameAndVersion.count() == 2) { libraryName = nameAndVersion.front() + "." + nameAndVersion.back(); lib.setFileNameAndVersion(nameAndVersion.front(), nameAndVersion.back()); } else { qWarning() << "Wrong syntax in" << preloadLib << ". Use <lib-name>[:version]. Skipping."; continue; } lib.setLoadHints(loadHints); log() << "Pre-loading library" << lib.fileName() << "with hints [" << static_cast<int>(loadHints) << "]"; if (!lib.load()) { qWarning() << "Pre-loading library" << lib.fileName() << "failed:" << lib.errorString() << "\nCheck your library search paths."; } }
int CodeEditer::format() { const QString code = this->toPlainText(); //const QString code = this->textCursor().selectedText(); if (code == QString::null) return 1; QStringList program = code.split(QLatin1Char('\n'), QString::KeepEmptyParts); while (!program.isEmpty()) { if (!program.back().trimmed().isEmpty()) break; program.pop_back(); } QStringList p; QString out; const QChar colon = QLatin1Char(':'); const QChar blank = QLatin1Char(' '); const QChar newLine = QLatin1Char('\n'); QStringList::const_iterator cend = program.constEnd(); for (QStringList::const_iterator it = program.constBegin(); it != cend; ++it) { p.push_back(*it); QString &line = p.back(); QChar typedIn = Indenter::instance().firstNonWhiteSpace(line); if (p.last().endsWith(colon)) typedIn = colon; const int indent = Indenter::instance().indentForBottomLine(it, p.constBegin(), p.constEnd(), typedIn); const QString trimmed = line.trimmed(); // Indent the line in the list so that the formatter code sees the indented line. if (!trimmed.isEmpty()) { line = QString(indent, blank); line += trimmed; } out += line; out += newLine ; } while (out.endsWith(newLine)) out.truncate(out.length() - 1 ); //fputs(out.toUtf8().constData(), stdout); this->setPlainText(out); return 0; }
void CellRange::init(const QString &range) { // TODO can be range from one sheet to another, ex: "Sheet1:Sheet4!A1:A5" or "Sheet1:Sheet4!A1" // TODO can be '!' or ':' symbol in sheet name QStringList sp = range.split(QLatin1Char('!')); QString cellRange = range; if (sp.size() > 1) { _sheet = sp.front(); if (_sheet.startsWith(QLatin1String("'")) && _sheet.endsWith(QLatin1String("'"))) _sheet = _sheet.mid(2, _sheet.length() - 2); cellRange = sp.back(); } QStringList rs = cellRange.split(QLatin1Char(':')); if (rs.size() == 2) { CellReference start(rs[0]); CellReference end(rs[1]); top = start.row(); left = start.column(); bottom = end.row(); right = end.column(); } else { CellReference p(rs[0]); top = p.row(); left = p.column(); bottom = p.row(); right = p.column(); } }
void AddSessionDialog::submitJobs() { QSet<int> jobIds; foreach(const QString &r, wJobRange->text().split(',')) { QStringList range = r.split('-'); if(range.size() == 2) { int low = range.front().toInt(); int high = range.back().toInt(); for(int jobId = low; jobId <= high; jobId++) { jobIds.insert(jobId); } } else if(range.size() == 1) { jobIds.insert(range.front().toInt()); } } emit jobs_submitted(jobIds, wImagePath->text(), wNumCPUs->text().toInt(), wMemory->text(), wJobName->text(), wStartupScript->toPlainText()); accept(); }
bool Finder::rowCount(QXlsx::Document &schedule,int & lastRow) { for (int row=7; row<65536; ++row) { bool abort = m_abort; if (abort) { removeCopiedFiles(); emit finished(false); return false; } if(QXlsx::Cell *cell=schedule.cellAt(row, 6)) { if(cell->value() == QVariant("Masa")) { lastRow = row - 2; break; } } if(m_searchCriterion == "Others") { if(QXlsx::Cell *cell=schedule.cellAt(row, 10)) if(!cell->value().toString().isEmpty()){ QStringList list = cell->value().toString().split(" "); if(list.back()!="")m_copartnerSet.insert(cell->value().toString().toLower()); else m_copartnerSet.insert(cell->value().toString().toLower().replace(" ","")); } } } return true; }
void OscapScannerRemoteSsh::splitTarget(const QString& in, QString& target, unsigned short& port) { // NB: We dodge a bullet here because the editor will always pass a port // as the last component. A lot of checking and parsing does not need // to be done. // // 'in' is in the format of username@hostname:port, the port always // being there and always being the last component. // FIXME: Ideally, this should split from the right side and stop after one split QStringList split = in.split(':'); const QString portString = split.back(); split.removeLast(); { bool status = false; const unsigned short portCandidate = portString.toUShort(&status, 10); // FIXME: Error reporting? port = status ? portCandidate : 22; } target = split.join(":"); }
/// Fill the menu with plugin names and make connections foreach(FilterPlugin* plugin, pluginManager()->filterPlugins()){ QAction* action = plugin->action(); QString pluginName = plugin->name(); QMenu * assignedMenu = mainWindow()->filterMenu; // Check for categories if(pluginName.contains("|")){ QStringList pluginNames = pluginName.split("|"); action->setText( pluginNames.back() ); // Try to locate exciting submenu QString catName = pluginNames.front(); QMenu * m = assignedMenu->findChild<QMenu*>( catName ); if(!m) m = mainWindow()->filterMenu->addMenu(catName); assignedMenu = m; } assignedMenu->addAction(action); // Action refers to this filter, so we can retrieve it later // QAction* action = new QAction(plugin->name(),plugin); /// Does the filter have an icon? Add it to the toolbar /// @todo add functionality to ModelFilter if(!action->icon().isNull()) mainWindow()->filterToolbar->addAction(action); /// Connect after it has been added connect(action,SIGNAL(triggered()),this,SLOT(startFilter())); }
QString CommentFormatter::formatComment( const QString& comment ) { QString ret; int i = 0; if( i > 1 ) { ret = comment.mid( i ); } else { ///remove the star in each line QStringList lines = comment.split( "\n", QString::KeepEmptyParts ); if( lines.isEmpty() ) return ret; QStringList::iterator it = lines.begin(); QStringList::iterator eit = lines.end(); if( it != lines.end() ) { for( ; it != eit; ++it ) { strip( "//", *it ); strip( "**", *it ); rStrip( "/**", *it ); } if( lines.front().trimmed().isEmpty() ) lines.pop_front(); if( !lines.isEmpty() && lines.back().trimmed().isEmpty() ) lines.pop_back(); } ret = lines.join( "\n" ); } return ret; }
void Model::duplicateActiveNodeViz(QString duplicationOp) { if(activeNode == nullptr) return; tempNodes.clear(); // Check for grouping option QStringList params = duplicationOp.split(",", QString::SkipEmptyParts); if(params.empty()) return; auto dups = makeDuplicates(activeNode, duplicationOp); for(auto n : dups) { // Distinguish new nodes auto color = n->vis_property["color"].value<QColor>(); color = color.lighter(50); n->vis_property["color"].setValue(color); tempNodes.push_back(QSharedPointer<Structure::Node>(n)); } // Hide previous group during visualization for(auto g : groupsOf(activeNode->id)){ for(auto nid : g){ if(nid == activeNode->id) continue; getNode(nid)->vis_property["isHidden"].setValue(params.back() == "group"); } } }
void QuickOpenFunctionDialog::slotTextChangedDelayed() { QString text = nameEdit->text(); QString txt = text; QStringList parts = QStringList::split("::", text); if(text.endsWith("::") || parts.isEmpty()) { txt = ""; }else{ txt = parts.back(); parts.pop_back(); } QValueList<QRegExp> regExpParts; for( QStringList::const_iterator it = parts.begin(); it != parts.end(); ++it ) { regExpParts << QRegExp( *it, false, true ); } QString scope = parts.join("::"); if( m_scope != scope ) { if( !scope.startsWith(m_scope) ) { ///Not a specialization, so reload all function-definitions fillItemList(); } if(!parts.isEmpty()) { FunctionList accepted; QStringList acceptedItems; FunctionList::iterator it = m_functionDefList.begin(); while(it != m_functionDefList.end()) { QStringList scope = (*it)->scope(); QValueList<QRegExp>::iterator mit = regExpParts.begin(); QStringList::iterator sit = scope.begin(); bool fail = false; while(mit != regExpParts.end()) { while(sit != scope.end() && !(*mit).exactMatch( *sit ) ) ++sit; if(sit == scope.end()) { fail = true; break; } ++mit; } if(!fail) { accepted.append(*it); acceptedItems << (*it)->name(); } ++it; } m_functionDefList = accepted; m_items = acceptedItems; QStringList_unique( m_items ); } m_scope = scope; } itemList->clear(); itemList->insertStringList( wildCardCompletion( txt ) ); itemList->setCurrentItem(0); }
bool OperationMetaData::prepare(const IOOptions&opt) { QString pcount = resource()["inparameters"].toString(); if ( pcount != "") { QStringList parts = pcount.split("|"); _minInputCountParameters = parts.first().toInt(); quint16 maxCountParameters = parts.back().toInt(); parmfromResource(maxCountParameters,"pin"); } pcount = resource()["outparameters"].toString(); if ( pcount != "") { QStringList parts = pcount.split("|"); _minOutputCountParameters = parts.first().toInt(); quint16 maxCountParameters = parts.back().toInt(); parmfromResource(maxCountParameters,"pout"); } return true; }
QString DataLocations::getRootConfigPath() { QStringList paths = getRootConfigPaths(); if (paths.empty()) return ""; // Those who ask for a single (legacy) config path need // the default CX path, not the override. return paths.back(); }
void MainWindow::parameterEstimationAll() { ParameterEstimationDialog dlg; if (!dlg.exec()) return; loadCNNs(); QString segmentation_output_dir = dlg.ui.lineEditSegmentationOutputDirectory->text(); if (!QDir(segmentation_output_dir).exists()) { QDir().mkdir(segmentation_output_dir); } QString initial_output_dir = dlg.ui.lineEditInitialOutputDirectory->text(); if (!QDir(initial_output_dir).exists()) { QDir().mkdir(initial_output_dir); } QString final_output_dir = dlg.ui.lineEditOutputDirectory->text(); if (!QDir(final_output_dir).exists()) { QDir().mkdir(final_output_dir); } QDir image_dir(dlg.ui.lineEditTestDataDirectory->text()); QStringList image_files = image_dir.entryList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst); printf("Predicting: "); for (int i = 0; i < image_files.size(); i++) { printf("\rPredicting: %d", i + 1); QStringList strs = image_files[i].split("."); if (strs.back() != "png" && strs.back() != "jpg") continue; std::vector<float> x_splits; std::vector<float> y_splits; std::vector<std::vector<fs::WindowPos>> win_rects; cv::Mat segmentation_result; cv::Mat initial_result; cv::Mat final_result; parseFacade(dlg.ui.lineEditTestDataDirectory->text() + "/" + image_files[i], x_splits, y_splits, win_rects, segmentation_result, initial_result, final_result); cv::imwrite((segmentation_output_dir + "/" + strs[0] + ".png").toUtf8().constData(), segmentation_result); cv::imwrite((initial_output_dir + "/" + strs[0] + ".png").toUtf8().constData(), initial_result); cv::imwrite((final_output_dir + "/" + strs[0] + ".png").toUtf8().constData(), final_result); } printf("\n"); }
void VertexBasedSegmenter::openMeshFile(string mname){ mesh = Mesh<Vertex3D, Triangle>(); QString qmn = QString::fromStdString(mname); QStringList qsl = qmn.split("."); if(!qsl.back().compare("tri")) Reader::readMeshFile(mesh, mname); else if(!qsl.back().compare("off")) Reader::readOFFMesh(mesh, mname); else{ cout<<"Not a valid file format (it must be .tri or .off)"<<endl; exit(0); } mesh.build(); cout<<"Build mesh with "<<mesh.getNumVertex()<<" vertices and "<<mesh.getTopSimplexesNum()<<" triangles "<<endl; }
void points_loader::create_point( QStringList obsrv_tokens, QStringList points_tokens ){ // Create the point. // model_point point; // Get the point's class. // // The database won't accept '-'. // { QString s = obsrv_tokens.back(); s.replace( "-", "_" ); point._attribute_class = s; } // Get the point's class values. // // The database won't accept '-'. // for( int ii=0; ii<obsrv_tokens.size() - 1; ii++ ) { QString s = obsrv_tokens.at(ii); s.replace( "-", "_" ); point._attribute_values.push_back( s ); } // Get the point's x,y coordinates. // QString x = points_tokens.front(); QString y = points_tokens.back(); point._position.setX( x.toFloat() ); point._position.setY( y.toFloat() ); // Get the point's probability values. // // Save. // _temp_points.push_back( point ); }
bool DynamicObjectImp::setAttributeByPath(QStringList pathComponents, DataVariant& value, bool swap) { if (!value.isValid()) { return false; } QString finalName = pathComponents.back(); pathComponents.pop_back(); string loopType = "DynamicObject"; DynamicObject* pLoopObj = dynamic_cast<DynamicObject*>(this); DynamicObject* pCurObj = pLoopObj; for (QStringList::const_iterator iter = pathComponents.begin(); iter != pathComponents.end(); ++iter) { if (pLoopObj == NULL || loopType != "DynamicObject") { return false; } pCurObj = pLoopObj; DataVariant& attrValue = pCurObj->getAttribute(iter->toStdString()); loopType = attrValue.getTypeName(); pLoopObj = attrValue.getPointerToValue<DynamicObject>(); if ((pLoopObj != NULL) && (loopType != "DynamicObject")) { return false; } if (pLoopObj == NULL) { FactoryResource<DynamicObject> pNewObj; if (pCurObj != NULL) { pCurObj->setAttribute(iter->toStdString(), *pNewObj.get()); DataVariant& currentValue = pCurObj->getAttribute(iter->toStdString()); loopType = currentValue.getTypeName(); pLoopObj = currentValue.getPointerToValue<DynamicObject>(); } } } if (pLoopObj == NULL || loopType != "DynamicObject") { return false; } pCurObj = pLoopObj; DynamicObjectImp* const pCurObjImp = dynamic_cast<DynamicObjectImp*>(pCurObj); VERIFY(pCurObjImp != NULL); return pCurObjImp->setAttribute(finalName.toStdString(), value, swap); }
QString Project::save_Cloud(QString path) { pcl::PointCloud<pcl::PointXYZI>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZI>); pcl::io::loadPCDFile(path.toUtf8().constData(),*cloud); QStringList name = path.split("\\"); QString file = name.back(); QStringList ext = file.split("."); return save_Cloud(ext.front(),cloud); }
void Spectro::on_actionOpenFile_triggered() { QStringList filenames = QFileDialog::getOpenFileNames(this,"Open spectrum file",lastDir,tr("JCampDX (*.dx)")); if(!filenames.isEmpty()) { for(int i=0; i<filenames.length();i++){ Tjcampdx spectrum; spectrum.Open(filenames[i].toStdString()); addSpectrum(spectrum); } lastDir=QFileInfo(filenames.back()).absolutePath(); } }
void MainWindow::open(QString fileName = QString("")) { QStringList fileNames; if (fileName.isEmpty()) { fileNames = QFileDialog::getOpenFileNames(this, "Select one or more files to open", (openFiles.size() > 0 && !getCurFileObj()->path.isEmpty()) ? getCurFileObj()->path : lastDir); } else { fileNames.push_front(fileName); } while (fileNames.count()) { if (!fileNames.back().isEmpty()) { bool alreadyOpen = false; QList<QsciteEditor *> openTabs = openFiles.keys(); QList<QsciteEditor *>::iterator tab; for (tab = openTabs.begin(); tab != openTabs.end(); ++tab) { if (fileNames.front() == openFiles[*tab].fullName) { alreadyOpen = true; if (fileNames.count() == 1) { changeTabs(*tab); } qDebug() << "file is already open"; } } if (alreadyOpen) { fileNames.pop_front(); continue; } if ((!tabWidget->count()) || (!getCurFileObj()->baseName.isEmpty()) || getCurDoc()->isModified()) { createDocument(); } loadFile(fileNames.front()); setCurrentTabTitle(); addRecentFile(fileNames.front()); } fileNames.pop_front(); } if (!openFiles.empty()) { getCurDoc()->setFocus(); lastDir = getCurFileObj()->path; } }
static QStringList split( const QString & newLine, QString & old ) { // when done right, this would need to use QTextCodec... const QString str = old + newLine; QStringList l = str.split( '\n' ); if ( l.empty() ) return l; if ( str.endsWith( '\n' ) ) { old.clear(); } else { old = l.back(); l.pop_back(); } return l; }
void BasicKeywordsModelTests::removeKeywordsFromSetTest() { Artworks::BasicMetadataModel basicModel(m_SpellCheckInfo); QStringList originalKeywords; originalKeywords << "keyword1" << "keyword2" << "keyword3 Test"; basicModel.appendKeywords(originalKeywords); const bool caseSensitive = false; bool removed = basicModel.removeKeywords(QSet<QString>() << "keyword1" << "keyword2" << "keyword3", caseSensitive); QVERIFY(removed); QCOMPARE(basicModel.getKeywordsCount(), 1); QCOMPARE(basicModel.getKeywordAt(0), originalKeywords.back()); }
void Model::duplicateActiveNode(QString duplicationOp) { if(activeNode == nullptr) return; // Remove visualizations tempNodes.clear(); // Check for grouping option QStringList params = duplicationOp.split(",", QString::SkipEmptyParts); if(params.empty()) return; // Remove any previous groups if(params.back() == "group"){ for(auto g : groupsOf(activeNode->id)){ for(auto nid : g){ if(nid == activeNode->id) continue; removeNode(nid); } } } // Create duplicate nodes auto dups = makeDuplicates(activeNode, duplicationOp); // Add nodes to graph and to a new group QVector<QString> nodesInGroup; nodesInGroup << activeNode->id; for(auto n : dups) { addNode(n); nodesInGroup << n->id; } if(params.back() == "group") addGroup(nodesInGroup); }
void ICPWidget::outputObj(void) { QFileDialog fd(this,tr("Choose Output Path"), "./","" ); fd.setFileMode(QFileDialog::DirectoryOnly); fd.setViewMode(QFileDialog::Detail); QStringList fileNamesList; if(fd.exec()) // ok { fileNamesList=fd.selectedFiles(); }else return; if(fileNamesList.empty())return; currentPath = ( fileNamesList.back() + "/" ).toStdString() ; outputObjBox(); outputObjModel(); }
MuHttpServer::Response ImageHandler::getRequest(const QString& uri, const QString& contentType, const QString& body, const FormValueMap& form) { Response r; QStringList splitUri = uri.split("."); QString format = "PNG"; if (!splitUri.isEmpty()) { format = splitUri.back().toUpper(); } splitUri.pop_back(); if (format == "JPG") { format = "JPEG"; } bool success = !format.isEmpty(); if (success) { QString itemId = QUrl::fromPercentEncoding(splitUri.join(".").toAscii()); SessionItem* pItem = Service<SessionManager>()->getSessionItem(itemId.toStdString()); r.mOctets.resize(MAX_ENCODED_IMAGE_SIZE); QBuffer buffer(&r.mOctets); int band = -1; FormValueMap::const_iterator it; if ((it = form.find("band")) != form.end() || (it = form.find("frame")) != form.end()) { band = StringUtilities::fromXmlString<int>(it->second.m_sBody); } success = getSessionItemImage(pItem, buffer, format, band); if (success == true) { r.mCode = HTTPRESPONSECODE_200_OK; r.mHeaders["content-type"] = QString("image/%1").arg(format.toLower()); r.mOctets.truncate(buffer.pos()+1); r.mEncoding = Response::OCTET; } } if (!success) { r.mCode = HTTPRESPONSECODE_404_NOTFOUND; r.mHeaders["content-type"] = "text/html"; r.mBody = "<html><body><h1>Not found</h1>The requested document can not be located or the requested image " "format is not supported.</body></html>"; } return r; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QString RimWellLogFileCurve::createCurveAutoName() { QStringList name; QString unit; bool channelNameAvailable = false; if (m_wellPath) { name.push_back(wellName()); name.push_back("LAS"); if (!m_wellLogChannnelName().isEmpty()) { name.push_back(m_wellLogChannnelName); channelNameAvailable = true; } RigWellLogFile* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogFileData() : nullptr; if (wellLogFile) { if (channelNameAvailable) { RimWellLogPlot* wellLogPlot; firstAncestorOrThisOfType(wellLogPlot); CVF_ASSERT(wellLogPlot); QString unitName = wellLogFile->wellLogChannelUnitString(m_wellLogChannnelName, wellLogPlot->depthUnit()); if (!unitName.isEmpty()) { name.back() += QString(" [%1]").arg(unitName); } } QString date = wellLogFile->date(); if (!date.isEmpty()) { name.push_back(wellLogFile->date()); } } return name.join(", "); } return "Empty curve"; }
bool GetDefault( QPointer<QWidget> parent, QStringList &files, QByteArray &remoteContent, const QString &caption, const QString &filter, FileDialog::internal::Type type, QString startFile = QString()) { if (cDialogLastPath().isEmpty()) { Platform::FileDialog::InitLastPath(); } remoteContent = QByteArray(); if (startFile.isEmpty() || startFile.at(0) != '/') { startFile = cDialogLastPath() + '/' + startFile; } QString file; if (type == Type::ReadFiles) { files = QFileDialog::getOpenFileNames(Messenger::Instance().getFileDialogParent(), caption, startFile, filter); QString path = files.isEmpty() ? QString() : QFileInfo(files.back()).absoluteDir().absolutePath(); if (!path.isEmpty() && path != cDialogLastPath()) { cSetDialogLastPath(path); Local::writeUserSettings(); } return !files.isEmpty(); } else if (type == Type::ReadFolder) { file = QFileDialog::getExistingDirectory(Messenger::Instance().getFileDialogParent(), caption, startFile); } else if (type == Type::WriteFile) { file = QFileDialog::getSaveFileName(Messenger::Instance().getFileDialogParent(), caption, startFile, filter); } else { file = QFileDialog::getOpenFileName(Messenger::Instance().getFileDialogParent(), caption, startFile, filter); } if (file.isEmpty()) { files = QStringList(); return false; } if (type != Type::ReadFolder) { // Save last used directory for all queries except directory choosing. auto path = QFileInfo(file).absoluteDir().absolutePath(); if (!path.isEmpty() && path != cDialogLastPath()) { cSetDialogLastPath(path); Local::writeUserSettings(); } } files = QStringList(file); return true; }
void ValgrindPart::receivedString( const QString& str ) { QString rmsg = lastPiece + str; QStringList lines = QStringList::split( "\n", rmsg ); // kdDebug() << "got: " << QString::fromLocal8Bit( msg, len ) << endl; if ( !rmsg.endsWith( "\n" ) ) { // the last message is trucated, we'll receive // the rest in the next call lastPiece = lines.back(); lines.pop_back(); } else { lastPiece = QString::null; } appendMessages( lines ); }
QString handleNewAppInstance(QtSingleApplication *singleApp, int argc, char **argv, const QString &newInstanceArg) { if (singleApp->isRunning()) { QStringList args; bool newInstance = false; for (int i = 1; i < argc; ++i) { args << argv[i]; if (args.back().endsWith(newInstanceArg)) { newInstance = true; } } if (newInstance) { QString path; if (!createTemporaryDir(path)) { qCritical("Could not create temporary storage path for new application instance."); exit(EXIT_FAILURE); } qWarning("Forcing new application instance. The application data will be written to a temporary directory."); return path; } else { QByteArray ba; QDataStream msg(&ba, QIODevice::WriteOnly); msg << QString("$cmdLineArgs"); // This message contains command line arguments msg << args; if (singleApp->sendMessage(ba)) { exit(EXIT_SUCCESS); } else { qCritical("The running application seems to be frozen."); exit(EXIT_FAILURE); } } } return QString(); }
/** * Add column for a log to the table for the case of multiple fits. * Have to check multiple values are not returned * @param table :: [input, output] Table to write to * @param paramsByLabel :: [input] Map of <label name, <workspace name, * <parameter, value>>> * @param log :: [input] the log we are going to add to the table */ void MuonAnalysisResultTableCreator::addColumnToResultsTable( ITableWorkspace_sptr &table, const QMap<QString, WSParameterList> ¶msByLabel, const QString &log) const { // if its a single fit we know its a double if (!m_multiple) { addColumnToTable(table, "double", log.toStdString(), PLOT_TYPE_X); return; } const auto &labelName = m_items[0]; QStringList valuesPerWorkspace; for (const auto &wsName : paramsByLabel[labelName].keys()) { const auto &logValues = m_logValues->value(wsName); const auto &val = logValues[log]; // Special case: if log is time in sec, subtract the first start time if (log.endsWith(" (s)")) { auto seconds = val.toDouble() - static_cast<double>(m_firstStart_ns) * 1.e-9; valuesPerWorkspace.append(QString::number(seconds)); } else if (MuonAnalysisHelper::isNumber(val.toString()) && !log.endsWith(" (text)")) { valuesPerWorkspace.append(QString::number(val.toDouble())); } else { valuesPerWorkspace.append(logValues[log].toString()); } } valuesPerWorkspace.sort(); auto dashIndex = valuesPerWorkspace.front().toStdString().find_first_of("-"); if (dashIndex != std::string::npos && dashIndex != 0) { addColumnToTable(table, "str", log.toStdString(), PLOT_TYPE_X); return; } const auto &min = valuesPerWorkspace.front().toDouble(); const auto &max = valuesPerWorkspace.back().toDouble(); if (min == max) { addColumnToTable(table, "double", log.toStdString(), PLOT_TYPE_X); return; } addColumnToTable(table, "str", log.toStdString(), PLOT_TYPE_X); }