当前位置: 首页>>代码示例>>C++>>正文


C++ QStringList::mid方法代码示例

本文整理汇总了C++中QStringList::mid方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::mid方法的具体用法?C++ QStringList::mid怎么用?C++ QStringList::mid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QStringList的用法示例。


在下文中一共展示了QStringList::mid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getElement

QDomElement StyleNode::getElement(QStringList path)
{
    if (path.size() < 1 || path.first() != elem.tagName() ) return QDomElement();

    if ( path.size() == 1) return elem;

    // Try to find this element among the children
    QDomElement e;
    int index = 0;
    while ( e.isNull() && index < children.size() )
    {
        e = children[index]->getElement(path.mid(1));
        index++;
    }
    if (!e.isNull() ) return e;

    // Try to find this element among the prototypes
    index = 0;
    while ( e.isNull() && index < prototypes.size() )
    {
        QStringList newPath = path.mid(1);
        newPath.prepend("style");
        e = prototypes[index]->getElement(newPath);
        index++;
    }

    return e;
}
开发者ID:helandre,项目名称:Envision,代码行数:28,代码来源:StyleNode.cpp

示例2: splitWordList

void JourneySearchParser::splitWordList( const QStringList& wordList, int splitWordPos,
        QString* leftOfSplitWord, QString* rightOfSplitWord, int excludeWordsFromleft )
{
    *leftOfSplitWord = ((QStringList)wordList.mid(excludeWordsFromleft,
            splitWordPos - excludeWordsFromleft)).join(" ");
    *rightOfSplitWord = ((QStringList)wordList.mid(splitWordPos + 1,
                wordList.count() - splitWordPos)).join(" ");
}
开发者ID:KDE,项目名称:publictransport,代码行数:8,代码来源:journeysearchparser.cpp

示例3: mergeLists

static QStringList mergeLists (const QStringList &labels, const QStringList &ids) {
	if (labels.size () < ids.size ()) {
		return labels + (ids.mid (labels.size ()));
	} else if (labels.size () > ids.size ()) {
		return (labels.mid (0, ids.size ()));
	}
	return labels;
}
开发者ID:KDE,项目名称:rkward,代码行数:8,代码来源:rkvalueselector.cpp

示例4: parseCommand

IrcCommand* CommandParser::parseCommand(const QString& receiver, const QString& text)
{
    if (text.startsWith("//") || text.startsWith("/ ") || !text.startsWith('/')) {
        QString message = text;
        if (message.startsWith('/'))
            message.remove(0, 1);
        return IrcCommand::createMessage(receiver, message.trimmed());
    } else {
        typedef IrcCommand*(*ParseFunc)(const QString&, const QStringList&);

        static QHash<QString, ParseFunc> parseFunctions;
        if (parseFunctions.isEmpty()) {
            parseFunctions.insert("ADMIN", &CommandParser::parseAdmin);
            parseFunctions.insert("AWAY", &CommandParser::parseAway);
            parseFunctions.insert("INFO", &CommandParser::parseInfo);
            parseFunctions.insert("INVITE", &CommandParser::parseInvite);
            parseFunctions.insert("KICK", &CommandParser::parseKick);
            parseFunctions.insert("KNOCK", &CommandParser::parseKnock);
            parseFunctions.insert("LIST", &CommandParser::parseList);
            parseFunctions.insert("ME", &CommandParser::parseMe);
            parseFunctions.insert("MODE", &CommandParser::parseMode);
            parseFunctions.insert("MOTD", &CommandParser::parseMotd);
            parseFunctions.insert("NAMES", &CommandParser::parseNames);
            parseFunctions.insert("NICK", &CommandParser::parseNick);
            parseFunctions.insert("NOTICE", &CommandParser::parseNotice);
            parseFunctions.insert("PART", &CommandParser::parsePart);
            parseFunctions.insert("PING", &CommandParser::parsePing);
            parseFunctions.insert("QUIT", &CommandParser::parseQuit);
            parseFunctions.insert("QUOTE", &CommandParser::parseQuote);
            parseFunctions.insert("STATS", &CommandParser::parseStats);
            parseFunctions.insert("TIME", &CommandParser::parseTime);
            parseFunctions.insert("TOPIC", &CommandParser::parseTopic);
            parseFunctions.insert("TRACE", &CommandParser::parseTrace);
            parseFunctions.insert("USERS", &CommandParser::parseUsers);
            parseFunctions.insert("VERSION", &CommandParser::parseVersion);
            parseFunctions.insert("WHO", &CommandParser::parseWho);
            parseFunctions.insert("WHOIS", &CommandParser::parseWhois);
            parseFunctions.insert("WHOWAS", &CommandParser::parseWhowas);
        }

        const QString expanded = expandAlias(receiver, text.mid(1));
        const QStringList words = expanded.split(" ", QString::SkipEmptyParts);
        const QString command = words.value(0).toUpper();
        ParseFunc parseFunc = parseFunctions.value(command);
        if (parseFunc) {
            IrcCommand* cmd = parseFunc(receiver, words.mid(1));
            if (cmd)
                return cmd;
        } else if (command_syntaxes().contains(command.toUpper())) {
            return parseCustomCommand(command, words.mid(1), command_syntaxes().value(command.toUpper()));
        }
    }

    // unknown command
    return 0;
}
开发者ID:aboduo,项目名称:quazaa,代码行数:56,代码来源:commandparser.cpp

示例5: make_tuple

static QGpgMEKeyListJob::result_type list_keys(Context *ctx, QStringList pats, bool secretOnly)
{
    if (pats.size() < 2) {
        std::vector<Key> keys;
        const KeyListResult r = do_list_keys(ctx, pats, keys, secretOnly);
        return std::make_tuple(r, keys, QString(), Error());
    }

    // The communication channel between gpgme and gpgsm is limited in
    // the number of patterns that can be transported, but they won't
    // say to how much, so we need to find out ourselves if we get a
    // LINE_TOO_LONG error back...

    // We could of course just feed them single patterns, and that would
    // probably be easier, but the performance penalty would currently
    // be noticeable.

    unsigned int chunkSize = pats.size();
retry:
    std::vector<Key> keys;
    keys.reserve(pats.size());
    KeyListResult result;
    do {
        const KeyListResult this_result = do_list_keys(ctx, pats.mid(0, chunkSize), keys, secretOnly);
        if (this_result.error().code() == GPG_ERR_LINE_TOO_LONG) {
            // got LINE_TOO_LONG, try a smaller chunksize:
            chunkSize /= 2;
            if (chunkSize < 1)
                // chunks smaller than one can't be -> return the error.
            {
                return std::make_tuple(this_result, keys, QString(), Error());
            } else {
                goto retry;
            }
        } else if (this_result.error().code() == GPG_ERR_EOF) {
            // early end of keylisting (can happen when ~/.gnupg doesn't
            // exist). Fakeing an empty result:
            return std::make_tuple(KeyListResult(), std::vector<Key>(), QString(), Error());
        }
        // ok, that seemed to work...
        result.mergeWith(this_result);
        if (result.error().code()) {
            break;
        }
        pats = pats.mid(chunkSize);
    } while (!pats.empty());
    return std::make_tuple(result, keys, QString(), Error());
}
开发者ID:gpg,项目名称:gpgme,代码行数:48,代码来源:qgpgmekeylistjob.cpp

示例6: index

QModelIndex QFileSystemModelEx::index(const QString &path, int column) const
{
	QFileInfo info(path);
	if(info.exists() && info.isDir())
	{
		QString fullPath = QDir::fromNativeSeparators(info.canonicalFilePath());
		QStringList parts = fullPath.split('/', QString::SkipEmptyParts);
		for(int i = 2; i <= parts.count(); i++)
		{
			QFileInfo currentPath(((QStringList) parts.mid(0, i)).join("/"));
			if((!currentPath.exists()) || (!currentPath.isDir()) || currentPath.isHidden())
			{
				return QModelIndex();
			}
		}
		QModelIndex index = QFileSystemModel::index(fullPath, column);
		if(index.isValid())
		{
			QModelIndex temp = index;
			while(temp.isValid())
			{
				removeFromCache(filePath(temp).toLower());
				temp = temp.parent();
			}
			return index;
		}
	}
	return QModelIndex();
}
开发者ID:BackupTheBerlios,项目名称:lamexp,代码行数:29,代码来源:Model_FileSystem.cpp

示例7: ShowConnectDialog

void MainWindow::ShowConnectDialog()
{
  const QUrl url("http://autosong.ninjam.com/serverlist.php");
  ConnectDialog connectDialog;
  QSettings settings;
  QStringList hosts = settings.value("connect/hosts").toStringList();

  connectDialog.resize(600, 500);
  connectDialog.loadServerList(url);
  connectDialog.setRecentHostsList(hosts);
  connectDialog.setUser(settings.value("connect/user").toString());
  connectDialog.setIsPublicServer(settings.value("connect/public", true).toBool());

  if (connectDialog.exec() != QDialog::Accepted) {
    return;
  }

  hosts.prepend(connectDialog.host());
  hosts.removeDuplicates();
  hosts = hosts.mid(0, 16); /* limit maximum number of elements */

  settings.setValue("connect/hosts", hosts);
  settings.setValue("connect/user", connectDialog.user());
  settings.setValue("connect/public", connectDialog.isPublicServer());

  QString user = connectDialog.user();
  if (connectDialog.isPublicServer()) {
    user.prepend("anonymous:");
  }

  Connect(connectDialog.host(), user, connectDialog.pass());
}
开发者ID:balgarath,项目名称:wahjam,代码行数:32,代码来源:MainWindow.cpp

示例8: LookUpPort

PortInfo Firewall::LookUpPort(int port, QString type)
{


    //Make sure that the port is valid
    if (port < 0 || port > 65535)
    {
        PortInfo returnValue;
        returnValue.Port = -1;
        returnValue.Description = "Port out of bounds";
        return returnValue;
    }

    if(portStrings.isEmpty()){ readServicesFile(); }

    PortInfo returnValue;
    //the port number is valid so set it
    returnValue.Port = port;

    //make sure that the portType is cased in lower to match the service file and
    //then store it in the returnValue, since there isn't a huge point in checking
    //the validitiy of the type since /etc/services lists more than udp/tcp
    type = type.toLower();
    returnValue.Type =  type;

    //Check to see if it's a recommended port
    returnValue.Recommended = false;
    for(int recommendedPort : recommendedPorts)
    {
        if (port == recommendedPort)
        {
            returnValue.Recommended = true;
        }
    }

   //Check to see if the port number is listed. The format in the file
   // is portname/portType. ex.: 22/tcp

   QStringList portList = portStrings.filter( QRegExp("\\s"+QString::number(port)+"/"+type+"\\s") );
   if(portList.size() > 0)
   {
       //grab the first one, there may be duplicates due to colliding ports in the /etc/services file
       //but those are listed after the declaration for what the port officially should be used for
       QString line = portList.at(0);

       //Split across spaces since it's whitespace delimited
       QStringList lineList = line.split(' ');

       //the keyword associated with the port is the first element in a line
       returnValue.Keyword = lineList.at(0);

       //if the size of the list is less than 3 then there is no description
       if(lineList.size() > 2){
           returnValue.Description = lineList.mid(2,-1).join(" ");
       }
   }

   return returnValue;

}
开发者ID:c3d2,项目名称:sysadm,代码行数:60,代码来源:sysadm-firewall.cpp

示例9: invokeMatch

bool Nuria::RestfulHttpNode::invokePath (const QString &path, const QStringList &parts,
					 int index, Nuria::HttpClient *client) {
	delayedRegisterMetaObject ();
	
	// 
	if (client->verb () == HttpClient::InvalidVerb ||
	    !allowAccessToClient (path, parts, index, client)) {
		client->killConnection (403);
		return false;
	}
	
	// 
	QString interestingPart = QStringList (parts.mid (index)).join (QLatin1Char ('/'));
	
	// Reverse walk over the QMap, so we first check longer paths.
	auto it = this->d_ptr->methods.end ();
	auto end = this->d_ptr->methods.begin ();
	do {
		it--;
		Internal::RestfulHttpNodeSlotData &cur = *it;
		QRegularExpressionMatch match = cur.path.match (interestingPart);
		if (match.hasMatch ()) {
			return invokeMatch (cur, match, client);
		}
		
	} while (it != end);
	
	// 
	return HttpNode::invokePath (path, parts, index, client);
	
}
开发者ID:NuriaProject,项目名称:Network,代码行数:31,代码来源:restfulhttpnode.cpp

示例10: iceblock_parse

static IceOffer iceblock_parse(const QStringList &in)
{
	IceOffer out;
	if(in.count() < 3 || in[0] != "-----BEGIN ICE-----" || in[in.count()-1] != "-----END ICE-----")
		return IceOffer();

	QStringList body = lines_unwrap(in.mid(1, in.count() - 2)).split(';');
	if(body.count() < 2)
		return IceOffer();

	QStringList parts = body[0].split(',');
	if(parts.count() != 2)
		return IceOffer();
	bool ok;
	out.user = urlishDecode(parts[0], &ok);
	if(!ok || out.user.isEmpty())
		return IceOffer();
	out.pass = urlishDecode(parts[1], &ok);
	if(!ok || out.pass.isEmpty())
		return IceOffer();

	for(int n = 1; n < body.count(); ++n)
	{
		XMPP::Ice176::Candidate c = line_to_candidate(body[n]);
		if(c.type.isEmpty())
			return IceOffer();
		out.candidates += c;
	}
	return out;
}
开发者ID:mblsha,项目名称:iris,代码行数:30,代码来源:main.cpp

示例11: KUrl

void
SqlPlaylist::loadTracks()
{
    QString query = "SELECT playlist_id, track_num, url, title, album, artist, length FROM "
                    "playlist_tracks WHERE playlist_id=%1 ORDER BY track_num";
    query = query.arg( QString::number( m_dbId ) );

    QStringList result = CollectionManager::instance()->sqlStorage()->query( query );

    int resultRows = result.count() / 7;

    for( int i = 0; i < resultRows; i++ )
    {
        QStringList row = result.mid( i*7, 7 );
        KUrl url = KUrl( row[2] );

        MetaProxy::Track *proxyTrack = new MetaProxy::Track( url );

        proxyTrack->setName( row[3] );
        proxyTrack->setAlbum( row[4] );
        proxyTrack->setArtist( row[5] );
        Meta::TrackPtr trackPtr = Meta::TrackPtr( proxyTrack );
        //subscribed to force a save to db on any change (such as AFT file move)
        subscribeTo( trackPtr );
        m_tracks << trackPtr;
    }

    m_tracksLoaded = true;
}
开发者ID:ErrAza,项目名称:amarok,代码行数:29,代码来源:SqlPlaylist.cpp

示例12: paintPrintText

void GwtCallback::paintPrintText(QPrinter* printer)
{
    QPainter painter;
    painter.begin(printer);

    // look up the system fixed font
    QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
    fixedFont.setPointSize(10);
    painter.setFont(fixedFont);

    // break up the text into pages and draw each page
    QStringList lines = printText_.split(QString::fromUtf8("\n"));
    int i = 0;
    while (i < lines.size())
    {
       // split off next chunk of lines and draw them
       int end = std::min(i + 60, lines.size());
       QStringList pageLines(lines.mid(i, 60));
       painter.drawText(50, 50, 650, 900, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap,
                        pageLines.join(QString::fromUtf8("\n")));

       // start a new page if there are more lines
       if (end < lines.size())
          printer->newPage();

       // move to next line group
       i += 60;
    }

    painter.end();
}
开发者ID:justacec,项目名称:rstudio,代码行数:31,代码来源:DesktopGwtCallback.cpp

示例13: parse

Status StatusParser::parse(QString data) {
    data = stripResponseHeader(data);
    QStringList playerList = data.split("\n");

    QString variableData = playerList.first();
    playerList.removeFirst();
    QStringList variableList = variableData.split("\\", QString::SkipEmptyParts);
    QStringListIterator it(variableList);
    Status status;
    while (it.hasNext()) {
        QString key = it.next();
        if(it.hasNext()) {
            QString value = it.next();
            status.variables.insert(key, value);
        }
    }

    QStringListIterator itP(playerList);
    while (itP.hasNext()) {
        QString line = itP.next();
        QStringList playerData = line.split(" ");
        if(playerData.size() >= 3) {
            QString playerName = QStringList(playerData.mid(2)).join(" ");
            playerName.chop(1); // remove first "
            playerName.remove(0, 1); // remove last "
            status.players.append(std::move(Player(playerName,
                                                   playerData[0].toInt(),
                                                   playerData[1].toInt())));
        }
    }

    return status;
}
开发者ID:M-itch,项目名称:qtercon,代码行数:33,代码来源:statusparser.cpp

示例14: GetFilename

	QString HandlerChoiceDialog::GetFilename () const
	{
		QString name = Buttons_->checkedButton ()->
			property ("PluginName").toString ();

		QString result;
		if (Ui_.LocationsBox_->currentIndex () == 0)
		{
			if (Suggestion_.isEmpty ())
				Suggestion_ = GetPluginSavePaths (name).value (0, QDir::homePath ());

			result = QFileDialog::getExistingDirectory (0,
					tr ("Select save location"),
					Suggestion_,
					QFileDialog::Option (~QFileDialog::ShowDirsOnly));
			if (result.isEmpty ())
				return QString ();
		}
		else
			result = Ui_.LocationsBox_->currentText ();

		QSettings settings (QCoreApplication::organizationName (),
				QCoreApplication::applicationName ());
		settings.setValue ("PreviousEntitySavePath", result);

		settings.beginGroup ("SavePaths");
		QStringList pluginTexts = settings.value (name).toStringList ();
		pluginTexts.removeAll (result);
		pluginTexts.prepend (result);
		pluginTexts = pluginTexts.mid (0, 20);
		settings.setValue (name, pluginTexts);
		settings.endGroup ();

		return result;
	}
开发者ID:grio,项目名称:leechcraft,代码行数:35,代码来源:handlerchoicedialog.cpp

示例15: HandleTextFrame

bool WebSocketMythEvent::HandleTextFrame(const WebSocketFrame &frame)
{
    QString message = QString(frame.payload);

    if (message.isEmpty())
        return false;

    QStringList tokens = message.split(" ", QString::SkipEmptyParts);

    if (tokens[0] == "WS_EVENT_ENABLE") // Only send events if asked
    {
        m_sendEvents = true;
        LOG(VB_HTTP, LOG_NOTICE, "WebSocketMythEvent: Enabled");
    }
    else if (tokens[0] == "WS_EVENT_DISABLE")
    {
        m_sendEvents = false;
        LOG(VB_HTTP, LOG_NOTICE, "WebSocketMythEvent: Disabled");
    }
    else if (tokens[0] == "WS_EVENT_SET_FILTER")
    {
        m_filters.clear();

        if (tokens.length() == 1)
            return true;

        m_filters = tokens.mid(1);

        QString filterString = m_filters.join(", ");
        LOG(VB_HTTP, LOG_NOTICE, QString("WebSocketMythEvent: Updated filters (%1)").arg(filterString));
    }

    return false;
}
开发者ID:garybuhrmaster,项目名称:mythtv,代码行数:34,代码来源:websocket_mythevent.cpp


注:本文中的QStringList::mid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。