本文整理汇总了C++中QStringList::takeLast方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::takeLast方法的具体用法?C++ QStringList::takeLast怎么用?C++ QStringList::takeLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringList
的用法示例。
在下文中一共展示了QStringList::takeLast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Connection
Connection::Connection(QString uri, QObject *parent) :
Connection(parent)
{
uri.remove(0, 5);//remove the prefix "ss://" from uri
QStringList resultList = QString(QByteArray::fromBase64(QByteArray(uri.toStdString().c_str()))).split(':');
profile.method = resultList.takeFirst().toUpper();
profile.serverPort = resultList.takeLast().toUShort();
QStringList ser = resultList.join(':').split('@');//there are lots of ':' in IPv6 address
profile.serverAddress = ser.takeLast();
profile.password = ser.join('@');//incase there is a '@' in password
}
示例2: findObject
QObject* Utils::findObject(const QString& path)
{
const QString separator("::");
QStringList parts = path.split(separator);
if (parts.isEmpty())
{
return NULL;
}
const QString name = parts.takeLast();
const QObject * parent = NULL;
if (parts.isEmpty())
{
{
const QString childObjectName = Utils::objectName(Application::instance());
if (childObjectName == name)
{
return Application::instance();
}
}
// Top level widget
Q_FOREACH(QObject * const object, Application::instance()->children())
{
const QString childObjectName = Utils::objectName(object);
if (childObjectName == name)
{
return object;
}
}
return NULL;
}
示例3: 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 ) );
}
示例4: testString
void testString(const QString &message)
{
qDebug() << Utils::normalizeMarkup(message, Utils::NoMarkup);
SnoreCore &snore = SnoreCore::instance();
QStringList backends = snore.pluginNames(SnorePlugin::Backend);
auto notify = [&backends, &snore, &message, this](Notification n) {
qDebug() << n << "closed";
qDebug() << backends.size();
if (backends.empty()) {
return;
}
QString old = snore.primaryNotificationBackend();
while (snore.primaryNotificationBackend() == old) {
QString p = backends.takeLast();
snore.setSettingsValue(QStringLiteral("PrimaryBackend"), p, LocalSetting);
SnoreCorePrivate::instance()->syncSettings();
if (snore.primaryNotificationBackend() == p) {
qDebug() << p;
snore.broadcastNotification(Notification(app, app.defaultAlert(), QStringLiteral("Title"), message, app.icon()));
}
}
};
auto con = connect(&snore, &SnoreCore::notificationClosed, notify);
notify(Notification());
while (!backends.empty()) {
QTest::qWait(100);
}
QTest::qWait(100);
disconnect(con);
}
示例5: configuraAmbienteROS
void AmbienteExternoROSBridge::configuraAmbienteROS()
{
bool ok;
QString endereco = QInputDialog::getText(0x0, QString("Configuracao ROSBridge"), QString("Endereco:"), QLineEdit::Normal, "ws://localhost:9090", &ok);
endereco = endereco.trimmed();
if (ok && !endereco.isEmpty())
{
string ip;
int porta;
if (endereco.contains(QRegExp(QLatin1String(":([0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{1,4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$"))))
{
QStringList splitted = endereco.split(':');
porta = splitted.takeLast().toUInt();
ip = splitted.join(":").toStdString();
}
else
{
ip = endereco.toStdString();
porta = 80;
}
cout << "IP: " << ip << " porta " << porta << endl;
m_ros.conecta(ip, porta);
}
}
示例6: tr
void
RestStateWidget::updatePlayerNames()
{
#ifdef WIN32
QStringList plugins = The::settings().allPlugins( false );
plugins.removeAll( "" );
if ( plugins.count() )
{
QString last_plugin = plugins.takeLast();
if ( plugins.count() )
{
QString text = tr( "or listen to your music in %1 or %2.",
"%1 is a list of plugins, eg. 'Foobar, Winamp, Windows Media Player'" );
ui.label2->setText( text.arg( plugins.join( ", " ) ).arg( last_plugin ) );
}
else
ui.label2->setText( tr( "or listen to your music in %1.", "%1 is a media player" ).arg( last_plugin ) );
}
else
ui.label2->setText( tr( "or install a player plugin to scrobble music from your media player." ) );
#endif
}
示例7: newMessage
void Server::newMessage()
{
if(QTcpSocket *c = dynamic_cast<QTcpSocket*> (sender())) {
data[c].append(c->readAll());
if(!data[c].contains(QChar(23)))
return;
QStringList l = data[c].split(QChar(23));
data[c] = l.takeLast();
foreach(QString s, l) {
string sss = s.toStdString();
stringstream ss(sss);
int a;
ss >> a;
if(a == 2 || a == 5 || a == 12) {
s.append(QChar(23));
c1->write(s.toLocal8Bit());
c2->write(s.toLocal8Bit());
}
else if(a == 7) { //team selection
if(num == 1 && t1 == "n") {
string str;
ss >> str;
t1 = QString::fromStdString(str);
QString s = "11";
s.append(QChar(23));
c1->write(s.toLocal8Bit());
}
else if(num == 2) {
示例8: traffic
QStringList CSite::traffic(quint16 &busy) const {
QStringList zeeiList = m_zeei.split("\n");
QStringList btsList = zeeiList.filter("BTS-");
busy = 0;
QStringList btss;
for (int i = 0; i < btsList.count(); i++) {
QStringList btsLine = btsList[i].split(" ");
btsLine.removeAll("");
QString state = btsLine[btsLine.indexOf(btsLine.filter("BTS-").first()) + 2];
if (state.contains("BL-")) {
btss << state;
continue;
}
QString fr = btsLine.takeLast();
QString hr = btsLine.takeLast();
quint8 btsBusy = fr.toUShort() + hr.toUShort();
if (!btsBusy)
btss << "EMPTY";
else if (i < m_caps.count() && btsBusy > m_caps[i] - BUSY_LIMIT)
btss << "FULL";
else
btss << QString::number(btsBusy);
busy += btsBusy;
}
return btss;
}
示例9: parseLinksFile
/*!
* parse a text file and return a links list in html format:
* left the names and right the contact address
* the html table can be "split" in sections
* @param QString fileName the file to be parsed
* @return QString the html table
*/
QString About::parseLinksFile(QString fileName)
{
QString result;
QString file;
QFile linksFile(fileName);
if (linksFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream inTS(&linksFile);
inTS.setCodec("UTF-8");
inTS.setAutoDetectUnicode(true);
QString lineTS;
bool isTitle = true;
result = "<table>";
while (!inTS.atEnd())
{
lineTS = inTS.readLine();
// convert (r) "�" to ®, "�" to ™
// lineTS = QString::fromUtf8(lineTS);
lineTS.replace("<", "<");
lineTS.replace(">", ">");
lineTS.replace("�", "®");
lineTS.replace("�", "™");
if (!lineTS.isEmpty())
{
if (isTitle)
{
isTitle = false;
result += "<tr><td><b>"+About::trLinksTitle(lineTS)+"</b></td></tr>";
} // if is title
else
{
result += "<tr><td><a href=\""+lineTS+"\">"+lineTS+"</a></td></tr>";
} // else is title
} // if is empty line
else
{
// empty lines switch to title (one line)
result += "<tr><td></td></tr>";
isTitle = true;
} // else is empty line
} // while ! atEnd
result += "<table>";
} // if file found
else
{
if (!fileName.isEmpty())
{
QStringList field = fileName.split("/");
if (!field.isEmpty())
{
file = field.takeLast();
}
}
result = tr("Unable to open %1 file. Please check your install directory or the Scribus website for %1 information.").arg(file);
result = "";
} // else file found
return result;
} // parseLinksFile()
示例10: contentIndexUp
// FIXME: this should actually be a member function of ContentIndex
int contentIndexUp( KMime::ContentIndex &index )
{
Q_ASSERT( index.isValid() );
QStringList ids = index.toString().split( QLatin1Char('.') );
QString lastId = ids.takeLast();
index = KMime::ContentIndex( ids.join( QLatin1String(".") ) );
return lastId.toInt();
}
示例11: notify
void UpdatesNotificationManager::notify ()
{
NotifyScheduled_ = false;
auto em = Proxy_->GetEntityManager ();
const auto upgradableCount = UpgradablePackages_.size ();
QString bodyText;
if (!upgradableCount)
{
auto cancel = Util::MakeANCancel ("org.LeechCraft.LackMan", "org.LeechCraft.LackMan");
em->HandleEntity (cancel);
return;
}
else if (upgradableCount <= 3)
{
QStringList names;
for (auto id : UpgradablePackages_)
names << Core::Instance ().GetListPackageInfo (id).Name_;
names.sort ();
if (upgradableCount == 1)
bodyText = tr ("A new version of %1 is available.")
.arg ("<em>" + names.value (0) + "</em>");
else
{
const auto& lastName = names.takeLast ();
bodyText = tr ("New versions of %1 and %2 are available.")
.arg ("<em>" + names.join ("</em>, <em>") + "</em>")
.arg ("<em>" + lastName + "</em>");
}
}
else
bodyText = tr ("New versions are available for %n package(s).",
0, upgradableCount);
auto entity = Util::MakeAN ("Lackman",
bodyText,
PInfo_,
"org.LeechCraft.LackMan",
AN::CatPackageManager,
AN::TypePackageUpdated,
"org.LeechCraft.LackMan",
{ "Lackman" },
0,
upgradableCount);
auto nah = new Util::NotificationActionHandler (entity, this);
nah->AddFunction (tr ("Open LackMan"),
[this, entity, em] () -> void
{
emit openLackmanRequested ();
em->HandleEntity (Util::MakeANCancel (entity));
});
em->HandleEntity (entity);
}
示例12: qMin
void
TrackDashboard::onArtistGotTopTags( WsReply* reply )
{
ui.tags->clear();
QStringList tags = Tag::list( reply ).values();
int x = qMin( 8, tags.count() );
while (x--)
ui.tags->addItem( tags.takeLast() );
}
示例13: createGccProfile
static Profile createGccProfile(const QString &compilerFilePath, Settings *settings,
const QStringList &toolchainTypes,
const QString &profileName = QString())
{
const QString machineName = gccMachineName(compilerFilePath);
const QStringList compilerTriplet = machineName.split(QLatin1Char('-'));
const bool isMingw = toolchainTypes.contains(QLatin1String("mingw"));
const bool isClang = toolchainTypes.contains(QLatin1String("clang"));
if (isMingw) {
if (!validMinGWMachines().contains(machineName)) {
throw ErrorInfo(Tr::tr("Detected gcc platform '%1' is not supported.")
.arg(machineName));
}
} else if (compilerTriplet.count() < 2) {
throw qbs::ErrorInfo(Tr::tr("Architecture of compiler for platform '%1' at '%2' not understood.")
.arg(machineName, compilerFilePath));
}
Profile profile(!profileName.isEmpty() ? profileName : machineName, settings);
profile.removeProfile();
if (isMingw) {
profile.setValue(QLatin1String("qbs.targetOS"), QStringList(QLatin1String("windows")));
}
const QString compilerName = QFileInfo(compilerFilePath).fileName();
QString toolchainPrefix;
if (compilerName.contains(QLatin1Char('-'))) {
QStringList nameParts = compilerName.split(QLatin1Char('-'));
profile.setValue(QLatin1String("cpp.compilerName"), nameParts.takeLast());
toolchainPrefix = nameParts.join(QLatin1Char('-')) + QLatin1Char('-');
profile.setValue(QLatin1String("cpp.toolchainPrefix"), toolchainPrefix);
}
profile.setValue(QLatin1String("cpp.linkerName"),
isClang ? QLatin1String("clang++") : QLatin1String("g++"));
setCommonProperties(profile, compilerFilePath, toolchainPrefix, toolchainTypes,
compilerTriplet.first());
// Check whether auxiliary tools reside within the toolchain's install path.
// This might not be the case when using icecc or another compiler wrapper.
const QString compilerDirPath = QFileInfo(compilerFilePath).absolutePath();
const ToolPathSetup toolPathSetup(&profile, compilerDirPath, toolchainPrefix);
toolPathSetup.apply(QLatin1String("ar"), QLatin1String("cpp.archiverPath"));
toolPathSetup.apply(QLatin1String("nm"), QLatin1String("cpp.nmPath"));
if (HostOsInfo::isOsxHost())
toolPathSetup.apply(QLatin1String("dsymutil"), QLatin1String("cpp.dsymutilPath"));
else
toolPathSetup.apply(QLatin1String("objcopy"), QLatin1String("cpp.objcopyPath"));
toolPathSetup.apply(QLatin1String("strip"), QLatin1String("cpp.stripPath"));
qStdout << Tr::tr("Profile '%1' created for '%2'.").arg(profile.name(), compilerFilePath)
<< endl;
return profile;
}
示例14: run
AbstractCommand::ReturnCodes Move::run()
{
if (! checkInRepository())
return NotInRepo;
moveToRoot();
// Move in git is really remove and add. Git will auto detect that being a move.
typedef QPair<QString, QString> RenamePair;
QList<RenamePair> renamePairs;
QStringList files = rebasedArguments();
if (files.count() < 2) { // not sure what that would mean...
Logger::error() << "Vng failed: you must specify at least two arguments for mv\n";
return InvalidOptions;
}
QString target = files.takeLast();
QFileInfo path(target);
if (files.count() > 1) { // multiple files into a dir.
if (! path.isDir()) {
Logger::error() << "Vng failed: The target directory '" << target <<
"` does not seem to be an existing directory\n";
return InvalidOptions;
}
}
else { // target is a file
if(File::fileKnownToGit(path)) {
Logger::error() << "Vng failed: The file named '"<< target <<
"` already exists in working directory.\n";
return InvalidOptions;
}
}
foreach (QString arg, files) {
if (canMoveFile(arg)) {
if (files.count() > 1)
renamePairs.append(qMakePair(arg, target + QDir::separator() + arg));
else
renamePairs.append(qMakePair(arg, target));
}
}
if (dryRun())
return Ok;
QProcess git;
QStringList arguments;
arguments << "update-index" << "--add" << "--remove";
foreach(RenamePair p, renamePairs) {
Logger::debug() << "rename " << p.first << " => " << p.second << endl;
if (QFile::rename(p.first, p.second))
arguments << p.first << p.second;
else
Logger::error() << "Vng failed: Could not rename '" << p.first << "` to '" <<
p.second << "`, check permissions\n";
}
示例15: addFileToRecentlyOpen
void Controller::addFileToRecentlyOpen(QString fileName){
QStringList recentlyOpen = Settings::getInstance().lastImportedFiles();
if(recentlyOpen.contains(fileName)){
recentlyOpen.removeAll(fileName);
}
recentlyOpen.prepend(fileName);
while(recentlyOpen.size() > RECENTLY_OPEN_MAX){
recentlyOpen.takeLast();
}
emit recentlyImportedFilesChanged(recentlyOpen);
Settings::getInstance().setLastImportedFiles(recentlyOpen);
}