void QGAppTracker::startApp(const QString& cmdline, bool waitEnd) { // Ensure that the process is runnable. if (_state != READY) return; QStringList list = cmdline.split(" "); _process->start(list.takeFirst(), list, QIODevice::ReadWrite); _process->waitForStarted(); if(_process->state() == QProcess::NotRunning) { _state = UNRUNNABLE; _process->kill(); _obs->startError(); } else { _state = RUNNING; _obs->start(); // Block the application until the process is finished if (waitEnd) { _process->waitForFinished(-1); } } }
IrcCommandInfo IrcCommandParserPrivate::parseSyntax(IrcCommand::Type type, const QString& syntax) { IrcCommandInfo cmd; QStringList tokens = syntax.split(QLatin1Char(' '), QString::SkipEmptyParts); if (!tokens.isEmpty()) { cmd.type = type; cmd.command = tokens.takeFirst().toUpper(); cmd.syntax = tokens.join(QLatin1String(" ")); cmd.max = tokens.count(); IrcParameterInfo param; for (int i = 0; i < tokens.count(); ++i) { const QString& token = tokens.at(i); param.optional = isOptional(token); param.channel = isChannel(token); param.current = isCurrent(token); param.multi = isMultiWord(token); if (!param.optional) ++cmd.min; if (param.optional && param.channel) ++cmd.min; const bool last = (i == tokens.count() - 1); if (last && param.multi) cmd.max = INT_MAX; cmd.params += param; } } return cmd; }
QString qucs2spice::convert_diode(QString line,bool xyce) { QString s=""; QStringList lst = line.split(" ",QString::SkipEmptyParts); QString name = lst.takeFirst(); int idx = name.indexOf(':'); name = name.right(name.count()-idx-1); // name QString K = lst.takeFirst(); QString A = lst.takeFirst(); s += QString("D%1 %2 %3 DMOD_%4 \n").arg(name).arg(A).arg(K).arg(name); QString mod_params = lst.join(" "); mod_params.remove('\"'); if (xyce) s += QString(".MODEL DMOD_%1 D(LEVEL=2 %2) \n").arg(name).arg(mod_params); else s += QString(".MODEL DMOD_%1 D(%2) \n").arg(name).arg(mod_params); return s; }
void Countries::init_buff() { if( p->inited ) return; QFile file(FILE_PATH); if( !file.open(QFile::ReadOnly) ) return; QString data = file.readAll(); QStringList splits = data.split("\n",QString::SkipEmptyParts); if( splits.isEmpty() ) return; QStringList heads = splits.takeFirst().split(";",QString::SkipEmptyParts); foreach( const QString & s, splits ) { const QStringList & parts = s.split(";",QString::SkipEmptyParts); for( int i=0; i<parts.count(); i++ ) { const QString & prt = parts.at(i); p->data[parts.first()][heads.at(i)] = prt; } } p->inited = true; }
QModelIndex QDBusModel::findObject(const QDBusObjectPath &objectPath) { QStringList path = objectPath.path().split(QLatin1Char('/'), QString::SkipEmptyParts); QDBusItem *item = root; int childIdx = -1; while (item && !path.isEmpty()) { const QString branch = path.takeFirst() + QLatin1Char('/'); childIdx = -1; // do a linear search over all the children for (int i = 0; i < item->children.count(); ++i) { QDBusItem *child = item->children.at(i); if (child->type == PathItem && child->name == branch) { item = child; childIdx = i; // prefetch the found branch if (!item->isPrefetched) addPath(item); break; } } // branch not found - bail out if (childIdx == -1) return QModelIndex(); } // found the right item if (childIdx != -1 && item && path.isEmpty()) return createIndex(childIdx, 0, item); return QModelIndex(); }
void initResPlugins() { static ResPlugin *array[128]; resplugins = array; #ifdef Q_OS_WIN QDir pluginsDir = QDir(Settings::path); pluginsDir.cd("plugins"); QStringList list = pluginsDir.entryList(QDir::Files, QDir::Name); #else QDir pluginsDir = QDir("/usr/share/moonplayer/plugins"); QStringList list = pluginsDir.entryList(QDir::Files, QDir::Name); pluginsDir = QDir::home(); pluginsDir.cd(".moonplayer"); pluginsDir.cd("plugins"); list += pluginsDir.entryList(QDir::Files, QDir::Name); #endif while (!list.isEmpty()) { QString filename = list.takeFirst(); if (filename.startsWith("res_") && filename.endsWith(".py")) { array[n_resplugins] = new ResPlugin(filename.section('.', 0, 0)); n_resplugins++; } } }
void ScriptablePrivate::loadScriptEngine() { if(_scriptLoaded || !_parent) return; _scriptLoaded = true; QStringList scriptList; // load scripts by class heirarchy name const QMetaObject *m = _parent->metaObject(); while(m) { scriptList.prepend(m->className()); m = m->superClass(); } // load scripts by object name QStringList parts = _parent->objectName().split(" "); QStringList search_parts; QString oName; while(!parts.isEmpty()) { search_parts.append(parts.takeFirst()); oName = search_parts.join(" "); scriptList.append(oName); } scriptList.removeDuplicates(); for (int i = 0; i < scriptList.size(); ++i) loadScript(scriptList.at(i)); }
void OcaOctaveController::readStdout() { char buf[ 1024 ]; //fprintf( stderr, "OcaOctaveController::readStdout $$$ %d (%d)\n", result, m_pipeFd ); int result = -1; do { result = read( m_pipeFd, buf, 1023 ); if( 0 < result ) { //fprintf( stderr, "OcaOctaveController::readStdout\n" ); //fwrite( buf, 1, result, stderr ); //fprintf( stderr, "OcaOctaveController::readStdout - END\n" ); buf[ result ] = 0; m_stdoutBuf += QString::fromLocal8Bit( buf ); QStringList lines = m_stdoutBuf.split( '\n' ); m_stdoutBuf = lines.takeLast(); //Q_ASSERT( ! lines.isEmpty() ); /* if( '\n' != m_stdoutBuf[ m_stdoutBuf.length() - 1 ] ) { m_stdoutBuf = lines.takeLast(); } else { m_stdoutBuf.clear(); QString s = lines.takeLast(); Q_ASSERT( s.isEmpty() ); } */ while( ! lines.isEmpty() ) { QString s = lines.takeFirst(); //fprintf( stderr, "readStdout: %s\n", s.toLocal8Bit().data() ); emit outputReceived( s, 0 ); } } } while( ( 1023 == result ) && ( e_StateReady == m_state ) ); }
/** * @brief Executed when new instance connect command is sent to LocalServer */ void Rshare::slotConnectionEstablished() { QLocalSocket *socket = localServer->nextPendingConnection(); socket->close(); delete socket; QSharedMemory newArgs; newArgs.setKey(QString(TARGET) + "_newArgs"); if (!newArgs.attach()) { std::cerr << "(EE) Rshare::slotConnectionEstablished() Unable to attach to shared memory segment." << newArgs.errorString().toStdString() << std::endl; return; } QBuffer buffer; QDataStream in(&buffer); QStringList args; newArgs.lock(); buffer.setData((char*)newArgs.constData(), newArgs.size()); buffer.open(QBuffer::ReadOnly); in >> args; newArgs.unlock(); newArgs.detach(); emit newArgsReceived(args); while (!args.empty()) { std::cerr << "Rshare::slotConnectionEstablished args:" << QString(args.takeFirst()).toStdString() << std::endl; } }
void MainWindow::on_actionRole_assign_table_triggered() { QString content; QStringList headers; headers << tr("Count") << tr("Lord") << tr("Loyalist") << tr("Rebel") << tr("Renegade"); foreach(QString header, headers) content += QString("<th>%1</th>").arg(header); content = QString("<tr>%1</tr>").arg(content); QStringList rows; rows << "2 1 0 1 0" << "3 1 0 1 1" << "4 1 0 2 1" << "5 1 1 2 1" << "6 1 1 3 1" << "6d 1 1 2 2" << "7 1 2 3 1" << "8 1 2 4 1" << "8d 1 2 3 2" << "9 1 3 4 1" << "10 1 3 4 2"; foreach(QString row, rows){ QStringList cells = row.split(" "); QString header = cells.takeFirst(); if(header.endsWith("d")){ header.chop(1); header += tr(" (double renegade)"); } QString row_content; row_content = QString("<td>%1</td>").arg(header); foreach(QString cell, cells){ row_content += QString("<td>%1</td>").arg(cell); }
void QuickTask::taskify(){ QString text=this->editor.toPlainText(); QRegExp rx("((\n|^)?\\s*[\\*-].+(\n[-\\*]?|$))"); rx.setMinimal(true); QStringList list; int pos = 0; while ((pos = rx.indexIn(text, pos)) != -1) { QString string =rx.cap(1); list << string; qDebug()<< string; //if we have 2 task, seperate them! if(list.length()>1){ QTextEdit *edit=new QTextEdit(this); edit->setText(list.takeFirst()); //this->editor.setText(text.mid(pos)); //this->layout.removeWidget(&this->editor); //this->layout.addWidget(edit); //this->layout.addWidget(&this->editor); this->editor.moveCursor(QTextCursor::End); } pos += rx.matchedLength(); if(text.at(pos-1)=='-' || text.at(pos-1)=='*')pos--; } }
QUrl Context::uriFor(Action *action, const QStringList &captures, const QStringList &args, const ParamsMultiMap &queryValues) const { Q_D(const Context); QUrl uri; Action *localAction = action; if (!localAction) { localAction = d->action; } QStringList localArgs = args; QStringList localCaptures = captures; Action *expandedAction = d->dispatcher->expandAction(this, action); if (expandedAction->numberOfCaptures() > 0) { while (localCaptures.size() < expandedAction->numberOfCaptures() && localArgs.size()) { localCaptures.append(localArgs.takeFirst()); } } else { QStringList localCapturesAux = localCaptures; localCapturesAux.append(localArgs); localArgs = localCapturesAux; localCaptures = QStringList(); } const QString path = d->dispatcher->uriForAction(localAction, localCaptures); if (path.isEmpty()) { qCWarning(CUTELYST_CORE) << "Can not find action for" << localAction << localCaptures; return uri; } uri = uriFor(path, localArgs, queryValues); return uri; }
QNetworkRequest inihandlerclass::requestfromini(const QString &inistring) { QFile f; f.setFileName(QApplication::applicationDirPath() + QDir::separator() + "snpini" + QDir::separator() + file); if (!f.open(QIODevice::ReadOnly)) { qDebug() << "snpini/netini is missing!"; } QTextStream ts(&f); while (ts.readLine() != inistring && !ts.atEnd()) ; if (ts.atEnd()) { qDebug() << "your netini file is corrupt! " << inistring << " can not be found, but is important."; } QNetworkRequest r; QStringList sl; QString s(ts.readLine()); while (!s.startsWith("[") && !ts.atEnd()) { if(!s.startsWith("//") && s!=""){ sl = s.split(" "); QString s1=sl.takeFirst(); QString s2=sl.join(" "); r.setRawHeader(s1.toAscii(), s2.toAscii()); } s = ts.readLine(); } return r; }
void ChatClient::message(const QStringList &args) { if (m_conn->status() != QtJsonDb::QJsonDbConnection::Connected) { fprintf(stderr, "Not connected to JSONDB\n"); return; } QStringList messageArgs = args; QtJsonDb::QJsonDbObject message; message.insert(QLatin1String("_type"), QLatin1String("ChatMessage")); message.insert(QLatin1String("from"), m_username); message.insert(QLatin1String("to"), messageArgs.takeFirst()); if (message.value(QLatin1String("from")) == message.value(QLatin1String("to"))) { fprintf(stderr, "Talking to oneself is not supported\n"); return; } message.insert(QLatin1String("message"), messageArgs.join(QLatin1String(" "))); message.insert(QLatin1String("time"), QDateTime::currentDateTime().toString("ddMMyyyy hh:mm:ss")); QtJsonDb::QJsonDbWriteRequest *request = new QtJsonDb::QJsonDbCreateRequest(message, this); connect(request, SIGNAL(finished()), request, SLOT(deleteLater())); connect(request, SIGNAL(error(QtJsonDb::QJsonDbRequest::ErrorCode,QString)), this, SLOT(error(QtJsonDb::QJsonDbRequest::ErrorCode,QString))); m_conn->send(request); }
void LibFritzInit::run() { emit ready(false); bool locationSettingsDetected; std::string countryCode = KSettings::countryCode().toStdString(); std::string areaCode = KSettings::areaCode().toStdString(); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->isSet("log-personal-info")) { INF("Warning: Logging personal information requested!") } // start libfritz++ fritz::Config::Setup(KSettings::hostname().toStdString(), username.toStdString(), password.toStdString(), args->isSet("log-personal-info")); fritz::Config::SetupConfigDir(KStandardDirs::locateLocal("data", KGlobal::mainComponent().aboutData()->appName()+'/').toStdString()); std::vector<std::string> vFonbook; QStringList phonebookList = KSettings::phonebookList(); while (phonebookList.count()) vFonbook.push_back(phonebookList.takeFirst().toStdString()); fritz::FonbookManager::CreateFonbookManager(vFonbook, "", false); bool validPassword = fritz::Config::Init(&locationSettingsDetected, &countryCode, &areaCode); if (!validPassword) { emit invalidPassword(); return; } if (locationSettingsDetected) { KSettings::setCountryCode(QString(countryCode.c_str())); KSettings::setAreaCode(QString(areaCode.c_str())); KSettings::self()->writeConfig(); } std::vector<std::string> vMsn; QStringList msnList = KSettings::mSNFilter(); while (msnList.count()) vMsn.push_back(msnList.takeFirst().toStdString()); fritz::Config::SetupMsnFilter(vMsn); fritz::Listener::CreateListener(eventHandler); fritz::CallList::CreateCallList(); emit ready(true); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); /* These are used for the configuration file - do not change! */ a.setOrganizationName(QLatin1String("bluecherry")); a.setOrganizationDomain(QLatin1String("bluecherrydvr.com")); a.setApplicationName(QLatin1String("bluecherry")); a.setApplicationVersion(QLatin1String(VERSION)); #ifdef Q_OS_WIN /* Use explorer style for fancier toolbars */ if (a.style()->inherits("QWindowsXPStyle")) a.setStyle(new ExplorerStyle); /* Don't use the registry. */ QSettings::setDefaultFormat(QSettings::IniFormat); #endif { QStringList args = a.arguments(); args.takeFirst(); if (args.size() >= 1 && args[0] == QLatin1String("--crash")) { CrashReportDialog dlg((args.size() >= 2) ? args[1] : QString()); dlg.exec(); if (dlg.result() != QDialog::Accepted) return 0; } } #ifdef USE_BREAKPAD initBreakpad(); #endif if (!QGLFormat::hasOpenGL()) { QMessageBox::critical(0, a.tr("Error"), a.tr("This application is designed to utilize OpenGL " "acceleration, which is not supported by your system. " "The application may not function correctly.\n\n" "For help, contact [email protected]."), QMessageBox::Ok); } bcApp = new BluecherryApp; if (QImageReader::supportedImageFormats().contains("jpeg-turbo")) { jpegFormatName = "jpeg-turbo"; qDebug("Using qjpeg-turbo"); } LiveStream::init(); MainWindow w(bcApp->serverRepository()); w.show(); return a.exec(); }
void MainWindow::genPkgList(QString cat) { ui->pkg->clear(); QStringList packages = pkgsrc.packageList(cat,ui->search->text()); for (int i = 0; i < packages.size(); ++i) { QString value = packages.at(i); QString package; QString category; QString desc; if (value.contains("|")) { QStringList values = value.split("|",QString::SkipEmptyParts); if (!values.isEmpty()) { category = values.takeFirst(); if (!values.isEmpty()) { package = values.takeFirst(); } if (!values.isEmpty()) { desc = values.takeFirst(); } } } else { package = value; } if (!package.isEmpty()) { if (!pkgsrcPkgInstalled(package)) { QListWidgetItem *newItem = new QListWidgetItem(package); newItem->setIcon(QIcon(":/files/package.png")); if (ui->search->text().isEmpty()){ newItem->setData(5,cat); } else { if (!category.isEmpty()) { newItem->setData(5,category); } } if (!desc.isEmpty()) { newItem->setData(3,desc); } ui->pkg->addItem(newItem); } } } }
QString CommandLineOption::getArgument(const QString &representation, QStringList &input) { if (input.isEmpty()) { throw ErrorInfo(Tr::tr("Invalid use of option '%1': Missing argument.\nUsage: %2") .arg(representation, description(command()))); } return input.takeFirst(); }
/** * @fn convertOptionName */ QPair<QString, QString> QueuedPluginManager::convertOptionName(const QString &_key) { qCDebug(LOG_PL) << "Convert option name" << _key; QStringList fields = _key.split('.'); if (fields.count() < 3) { qCWarning(LOG_PL) << "Invalid option name" << _key; return {"", ""}; } // Plugin. fields.takeFirst(); // plugin name QString plugin = fields.takeFirst(); QString option = fields.join('.'); return {plugin, option}; }
void SettingsDirOption::doParse(const QString &representation, QStringList &input) { if (input.isEmpty()) { throw ErrorInfo(Tr::tr("Invalid use of option '%1: Argument expected.\n" "Usage: %2").arg(representation, description(command()))); } m_settingsDir = input.takeFirst(); }
void DaemonUi::init() { QStringList args = QApplication::arguments(); args.takeFirst(); arguments(args); onStart(); }
void TransferForm::kill(QStringList& list) { if (m_server) { while (!list.isEmpty()) m_server->kill(list.takeFirst()); } }
void ScriptDebuggerPrivate::interactive() { setCurrentFrameIndex(0); QString qsdbgPrompt = QString::fromLatin1("(qsdbg) "); QString dotPrompt = QString::fromLatin1(".... "); QString prompt = qsdbgPrompt; QString code; forever { *m_outputStream << prompt; m_outputStream->flush(); QString line = readLine(); if (code.isEmpty() && (line.isEmpty() || line.startsWith(m_commandPrefix))) { if (line.isEmpty()) line = m_lastInteractiveCommand; else m_lastInteractiveCommand = line; QStringList parts = line.split(QLatin1Char(' '), QString::SkipEmptyParts); if (!parts.isEmpty()) { QString command = parts.takeFirst().mid(1); if (executeCommand(command, parts)) break; } } else { if (line.isEmpty()) continue; code += line; code += QLatin1Char('\n'); if (line.trimmed().isEmpty()) { continue; } else if (! engine()->canEvaluate(code)) { prompt = dotPrompt; } else { setMode(Run); QScriptValue result = engine()->evaluate(code, QLatin1String("typein")); code.clear(); prompt = qsdbgPrompt; if (! result.isUndefined()) { errorMessage(result.toString()); engine()->clearExceptions(); } } } } }
void Wizard::slotUpdateCaptureParameters() { QString device = m_capture.v4l_devices->itemData(m_capture.v4l_devices->currentIndex()).toString(); if (!device.isEmpty()) KdenliveSettings::setVideo4vdevice(device); QString formats = m_capture.v4l_devices->itemData(m_capture.v4l_devices->currentIndex(), Qt::UserRole + 1).toString(); m_capture.v4l_formats->blockSignals(true); m_capture.v4l_formats->clear(); QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/profiles/"); if (!dir.exists()) { dir.mkpath("."); } if (dir.exists("video4linux")) { MltVideoProfile profileInfo = ProfilesDialog::getVideoProfile(dir.absoluteFilePath("video4linux")); m_capture.v4l_formats->addItem(i18n("Current settings (%1x%2, %3/%4fps)", profileInfo.width, profileInfo.height, profileInfo.frame_rate_num, profileInfo.frame_rate_den), QStringList() << QString("unknown") <<QString::number(profileInfo.width)<<QString::number(profileInfo.height)<<QString::number(profileInfo.frame_rate_num)<<QString::number(profileInfo.frame_rate_den)); } QStringList pixelformats = formats.split('>', QString::SkipEmptyParts); QString itemSize; QString pixelFormat; QStringList itemRates; for (int i = 0; i < pixelformats.count(); ++i) { QString format = pixelformats.at(i).section(':', 0, 0); QStringList sizes = pixelformats.at(i).split(':', QString::SkipEmptyParts); pixelFormat = sizes.takeFirst(); for (int j = 0; j < sizes.count(); ++j) { itemSize = sizes.at(j).section('=', 0, 0); itemRates = sizes.at(j).section('=', 1, 1).split(',', QString::SkipEmptyParts); for (int k = 0; k < itemRates.count(); ++k) { QString formatDescription = '[' + format + "] " + itemSize + " (" + itemRates.at(k) + ')'; if (m_capture.v4l_formats->findText(formatDescription) == -1) m_capture.v4l_formats->addItem(formatDescription, QStringList() << format << itemSize.section('x', 0, 0) << itemSize.section('x', 1, 1) << itemRates.at(k).section('/', 0, 0) << itemRates.at(k).section('/', 1, 1)); } } } if (!dir.exists("video4linux")) { if (m_capture.v4l_formats->count() > 9) slotSaveCaptureFormat(); else { // No existing profile and no autodetected profiles MltVideoProfile profileInfo; profileInfo.width = 320; profileInfo.height = 200; profileInfo.frame_rate_num = 15; profileInfo.frame_rate_den = 1; profileInfo.display_aspect_num = 4; profileInfo.display_aspect_den = 3; profileInfo.sample_aspect_num = 1; profileInfo.sample_aspect_den = 1; profileInfo.progressive = 1; profileInfo.colorspace = 601; ProfilesDialog::saveProfile(profileInfo, dir.absoluteFilePath("video4linux")); m_capture.v4l_formats->addItem(i18n("Default settings (%1x%2, %3/%4fps)", profileInfo.width, profileInfo.height, profileInfo.frame_rate_num, profileInfo.frame_rate_den), QStringList() << QString("unknown") <<QString::number(profileInfo.width)<<QString::number(profileInfo.height)<<QString::number(profileInfo.frame_rate_num)<<QString::number(profileInfo.frame_rate_den)); } } m_capture.v4l_formats->blockSignals(false); }
void IRCClient::readAndProcess(){ while(socket.canReadLine()){ QString line = socket.readLine(); QRegularExpressionMatch parsedLine = parser.match(line); if(parsedLine.hasMatch()){ QString prefix = parsedLine.captured(1); QString nick = parsedLine.captured(2); QString username = parsedLine.captured(3); QString hostname = parsedLine.captured(4); QString command = parsedLine.captured(5); QStringList params = parsedLine.captured(6).split(" "); params.takeFirst(); if(!parsedLine.captured(7).isEmpty()) params.append(parsedLine.captured(7).trimmed()); params.last() = params.last().trimmed(); if(command.compare("PING", Qt::CaseInsensitive) == 0) socket.write(("PONG " + params.last() + "\r\n").toUtf8()); else if(command.compare("JOIN", Qt::CaseInsensitive) == 0){ if(nick.compare(this->nickname, Qt::CaseSensitive) == 0) emit joinedChannel(params.first()); else{ if(!userTable.contains(params.first())) userTable[params.first()] = QStringList(nick); else userTable[params.first()].append(nick); emit updateUserList(params.first(), userTable[params.first()]); emit textChanged(nick + " has joined " + params.first() + "\r\n", params.first()); } } else if(command.compare("353") == 0){ if(!userTable.contains(params.at(2))) userTable[params.at(2)] = params.last().split(" "); else userTable[params.at(2)].append(params.last().split(" ")); emit updateUserList(params.at(2), userTable[params.at(2)]); } else if(command.compare("NOTICE", Qt::CaseInsensitive) == 0){ emit textChanged("[" + nick + "] " + params.last() + "\r\n"); } else if(command.compare("PRIVMSG", Qt::CaseInsensitive) == 0){ if(params.first().compare(this->nickname, Qt::CaseSensitive) == 0) emit textChanged("<" + nick + " -> " + params.first() + "> " + params.last() + "\r\n"); else emit textChanged("<" + nick + "> " + params.last() + "\r\n", params.first()); } else if(command.compare("QUIT", Qt::CaseInsensitive) == 0){ if(params.isEmpty()) emit textChanged(nick + " has disconnected from the server\r\n"); else emit textChanged(nick + " has disconnected from the server\r\n"); } else emit textChanged(line); } else qDebug() << line; } }
AbstractImageProcessor *FilterProcessor::fromString(const QString& str) const { QStringList list = str.split(' ', QString::SkipEmptyParts); if (list.size() < 4) return NULL; FilterType type = (FilterType)list.takeFirst().toInt(); int width = list.takeFirst().toInt(); int height = list.takeFirst().toInt(); Area area = Area::fromString(list.takeFirst()); QVector<int> matrix; int divisor = 1; int offset = 0; if (type == Convolution) { if (list.size() != width * height + 2) return NULL; divisor = list.takeFirst().toInt(); offset = list.takeFirst().toInt(); for (int i = 0; i < width * height; ++i) matrix.push_back(list.takeFirst().toInt()); } FilterProcessor *result = new FilterProcessor(); result->_type = type; result->_width = width; result->_height = height; result->_convolutionMatrix = matrix; result->_convolutionDivisor = divisor; result->_convolutionOffset = offset; result->_area = area; return result; }
/** * Performs application initialisation, after the event loop was started. */ void Application::init() { setupEngines(); // Parse command-line arguments. // TODO: Need to think some more about the options. QString path; QStringList args = arguments(); while (!args.isEmpty()) { QString arg = args.takeFirst(); if (arg.startsWith("-")) { switch (arg.at(1).toLatin1()) { case 'f': path = args.takeFirst(); mainWnd_->openFile(path); return; case 'p': path = args.takeFirst(); ProjectManager::load<Cscope::ManagedProject>(path); return; } } } // Get the path of the last active project. path = QSettings().value("Session/LastProject", "").toString(); if (path.isEmpty()) return; // Get the project's name. QString name = Cscope::ManagedProject(path).name(); if (name.isEmpty()) return; // Prompt the user for opening the last project. // TODO: Want more options on start-up (list of last projects, create new, // do nothing). if (QMessageBox::question(NULL, tr("Open Last Project"), tr("Would you like to reload '%1'?").arg(name), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { ProjectManager::load<Cscope::ManagedProject>(path); } }
Area Area::fromString(const QString& str) { Area result; QStringList list = str.split(',', QString::SkipEmptyParts); if (list.isEmpty()) return result; AreaTypeFlag type = (AreaTypeFlag) list.takeFirst().toInt(); switch (type) { case TypeRectangle: if (list.size() != 4) break; { int values[4]; values[0] = list.takeFirst().toInt(); values[1] = list.takeFirst().toInt(); values[2] = list.takeFirst().toInt(); values[3] = list.takeFirst().toInt(); result = Area(QRect(values[0], values[1], values[2], values[3])); } break; case TypePolygon: { int size = list.takeFirst().toInt(); if (list.size() != 2 * size) break; QPolygon poly; for (int i = 0;i < size;++i) { int values[2]; values[0] = list.takeFirst().toInt(); values[1] = list.takeFirst().toInt(); poly.append(QPoint(values[0], values[1])); } result = Area(poly); } break; case TypeEllipse: if (list.size() != 4) break; { int values[4]; values[0] = list.takeFirst().toInt(); values[1] = list.takeFirst().toInt(); values[2] = list.takeFirst().toInt(); values[3] = list.takeFirst().toInt(); result = Area(Ellipse(QPoint(values[0], values[1]), values[2], values[3])); } break; default: break; } return result; }
AbstractImageProcessor *BoundProcessor::fromString(const QString& str) const { QStringList list = str.split(' ', QString::SkipEmptyParts); if (list.size() != 1) return NULL; BoundProcessor *result = new BoundProcessor(); result->type = (BoundType) list.takeFirst().toInt(); return result; }
AbstractImageProcessor *HistogramMatchProcessor::fromString(const QString& str) const { QStringList list = str.split(' ', QString::SkipEmptyParts); if (list.size() != 1) return NULL; HistogramMatchProcessor *result = new HistogramMatchProcessor(); result->_path = list.takeFirst().replace(QChar('*'), QChar(' '));; return result; }