本文整理汇总了C++中QStringList::takeFirst方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::takeFirst方法的具体用法?C++ QStringList::takeFirst怎么用?C++ QStringList::takeFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringList
的用法示例。
在下文中一共展示了QStringList::takeFirst方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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);
}
}
}
示例2: parseSyntax
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;
}
示例3: QString
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;
}
示例4: init_buff
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;
}
示例5: findObject
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();
}
示例6: initResPlugins
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++;
}
}
}
示例7: loadScriptEngine
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));
}
示例8: readStdout
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 ) );
}
示例9: slotConnectionEstablished
/**
* @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;
}
}
示例10: on_actionRole_assign_table_triggered
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);
}
示例11: taskify
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--;
}
}
示例12: uriFor
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;
}
示例13: requestfromini
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;
}
示例14: message
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);
}
示例15: run
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);
}