本文整理汇总了C++中QStringList::first方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::first方法的具体用法?C++ QStringList::first怎么用?C++ QStringList::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringList
的用法示例。
在下文中一共展示了QStringList::first方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addNewTheme
// Copy theme package into themes directory
void SplashInstaller::addNewTheme(const KUrl &srcURL)
{
const QString dir = KGlobal::dirs()->saveLocation("ksplashthemes");
KUrl url;
QStringList themeNames;
QString filename = srcURL.fileName();
int i = filename.lastIndexOf('.');
// Convert extension to lower case.
if (i >= 0)
filename = filename.left(i)+filename.mid(i).toLower();
url.setPath(KStandardDirs::locateLocal("tmp",filename));
// Remove file from temporary directory if it aleady exists - usually the result of a failed install.
if ( KIO::NetAccess::exists( url, KIO::NetAccess::SourceSide, 0 ) )
KIO::NetAccess::del( url, 0 );
if (srcURL.fileName().toLower() == "theme.rc" ) // uncompressed theme selected
{
QString themeName;
// Get the name of the Theme from the theme.rc file
KConfig _cnf(srcURL.path());
KConfigGroup cnf(&_cnf, QString("KSplash Theme: %1").arg(themeName) );
// copy directory of theme.rc to ThemesDir
KIO::NetAccess::dircopy(KUrl(srcURL.directory()), KUrl(dir + themeName));
themeNames << themeName;
}
else
{
bool rc = KIO::NetAccess::file_copy(srcURL, url, 0);
if (!rc)
{
kWarning() << "Failed to copy theme " << srcURL.fileName()
<< " into temporary directory " << url.path() << endl;
return;
}
// Extract into theme directory: we may have multiple themes in one tarball!
KTar tarFile(url.path());
if (!tarFile.open(QIODevice::ReadOnly))
{
kWarning() << "Unable to open archive: " << url.path();
KIO::NetAccess::del( url, 0 );
return;
}
KArchiveDirectory const *ad = tarFile.directory();
// Find first directory entry.
const QStringList entries = ad->entries();
foreach(const QString& s, entries)
{
if( ad->entry(s)->isDirectory() )
{
// each directory may contain one theme
themeNames << s;
}
}
if (themeNames.count() < 1)
{
kWarning() << "No directory in archive: " << url.path();
tarFile.close();
KIO::NetAccess::del( url, 0 );
return;
}
// copy the theme into the "ksplashthemes" directory
ad->copyTo(dir);
tarFile.close();
KIO::NetAccess::del( url, 0 );
}
readThemesList();
mThemesList->setCurrentRow(findTheme(themeNames.first()));
if (mThemesList->currentItem())
{
mThemesList->currentItem()->setSelected(true);
}
}
示例2: initializePage
void CMakeRunPage::initializePage()
{
if (m_mode == Initial) {
m_complete = m_cmakeWizard->existsUpToDateXmlFile();
m_buildDirectory = m_cmakeWizard->buildDirectory();
if (m_cmakeWizard->existsUpToDateXmlFile()) {
m_descriptionLabel->setText(
tr("The directory %1 already contains a cbp file, which is recent enough. "
"You can pass special arguments or change the used toolchain here and rerun cmake. "
"Or simply finish the wizard directly").arg(m_buildDirectory));
} else {
m_descriptionLabel->setText(
tr("The directory %1 does not contain a cbp file. Qt Creator needs to create this file by running cmake. "
"Some projects require command line arguments to the initial cmake call.").arg(m_buildDirectory));
}
} else if (m_mode == CMakeRunPage::Update) {
m_descriptionLabel->setText(tr("The directory %1 contains an outdated .cbp file. Qt "
"Creator needs to update this file by running cmake. "
"If you want to add additional command line arguments, "
"add them below. Note that cmake remembers command "
"line arguments from the previous runs.").arg(m_buildDirectory));
} else if(m_mode == CMakeRunPage::Recreate) {
m_descriptionLabel->setText(tr("The directory %1 specified in a build-configuration, "
"does not contain a cbp file. Qt Creator needs to "
"recreate this file, by running cmake. "
"Some projects require command line arguments to "
"the initial cmake call. Note that cmake remembers command "
"line arguments from the previous runs.").arg(m_buildDirectory));
} else if(m_mode == CMakeRunPage::Change) {
m_buildDirectory = m_cmakeWizard->buildDirectory();
m_descriptionLabel->setText(tr("Qt Creator needs to run cmake in the new build directory. "
"Some projects require command line arguments to the "
"initial cmake call."));
}
if (m_cmakeWizard->cmakeManager()->hasCodeBlocksMsvcGenerator()) {
m_generatorComboBox->setVisible(true);
QString cachedGenerator;
// Try to find out generator from CMakeCachhe file, if it exists
QFile fi(m_buildDirectory + "/CMakeCache.txt");
if (fi.exists()) {
// Cache exists, then read it...
if (fi.open(QIODevice::ReadOnly | QIODevice::Text)) {
while (!fi.atEnd()) {
QString line = fi.readLine();
if (line.startsWith("CMAKE_GENERATOR:INTERNAL=")) {
int splitpos = line.indexOf('=');
if (splitpos != -1) {
cachedGenerator = line.mid(splitpos + 1).trimmed();
}
break;
}
}
}
}
m_generatorComboBox->clear();
// Find out whether we have multiple msvc versions
QStringList msvcVersions = ProjectExplorer::ToolChain::availableMSVCVersions();
if (msvcVersions.isEmpty()) {
} else if (msvcVersions.count() == 1) {
m_generatorComboBox->addItem(tr("NMake Generator"), msvcVersions.first());
} else {
foreach (const QString &msvcVersion, msvcVersions)
m_generatorComboBox->addItem(tr("NMake Generator (%1)").arg(msvcVersion), msvcVersion);
}
if (cachedGenerator == "NMake Makefiles" && !msvcVersions.isEmpty())
m_generatorComboBox->setCurrentIndex(0);
m_generatorComboBox->addItem(tr("MinGW Generator"), "mingw");
if (cachedGenerator == "MinGW Makefiles")
m_generatorComboBox->setCurrentIndex(m_generatorComboBox->count() - 1);
} else {
示例3: applyGamerAction
/**
* @brief GameView::applyGamerAction Réception des action des joueurs
* @param s Chaine d'action
*
* Cette methode est utilisée par la GameView coté serveur afin d'executer
* les actions des clients
*/
void GameView::applyGamerAction(QString s)
{
QStringList msgStr = s.split(".");
if(msgStr.size() != 5) return;
ACTIONS cmd = (ACTIONS)msgStr.first().toInt();
msgStr.pop_front();
int gamerId = msgStr.first().toInt(); //Identifiant du joueur
msgStr.pop_front();
Node *nodeFrom = scene->getNode(msgStr.first().toInt()); //noeud source
msgStr.pop_front();
Node *nodeTo = scene->getNode(msgStr.first().toInt()); //noeud cible
msgStr.pop_front();
int param = msgStr.first().toInt(); //Parametre de l'action (nb ressource / pouvoir id)
switch (cmd)
{
case GA_SEND:
{
qDebug()<<"GameView : in 'applyGamerAction' recive GA_SEND";
receive_GA_SEND(gamerId, nodeFrom, nodeTo, param);
break;
}
case GA_USEPOWER_DESTROY:
{
qDebug()<<"GameView : in 'applyGamerAction' recive GA_USEPOWER_DESTROY";
receive_GA_USEPOWER_DESTROY(gamerId, nodeFrom, nodeTo, param);
break;
}
case GA_USEPOWER_INVINCIBILITY:
{
qDebug()<<"GameView : in 'applyGamerAction' recive GA_USEPOWER_INVINCIBILITY";
receive_GA_USEPOWER_INVINCIBILITY(gamerId, nodeFrom, nodeTo, param);
break;
}
case GA_USEPOWER_ARMORE:
{
qDebug()<<"GameView : in 'applyGamerAction' recive GA_USEPOWER_ARMORE";
receive_GA_USEPOWER_ARMORE(gamerId, nodeFrom, nodeTo, param);
break;
}
case GA_USEPOWER_TELEPORTATION:
{
qDebug()<<"GameView : in 'applyGamerAction' recive GA_USEPOWER_TELEPORTATION";
receive_GA_USEPOWER_TELEPORTATION(gamerId, nodeFrom, nodeTo, param);
break;
}
case GA_GAME_FINISHED:
{
qDebug()<<"GameView : in 'applyGamerAction' recive GA_GAME_FINISHED";
receive_GA_GAME_FINISHED(gamerId, nodeFrom, nodeTo, param);
break;
}
case GA_MANA_BURN:
{
qDebug()<<"GameView : in 'applyGamerAction' recive GA_MANA_BURN";
receive_GA_MANA_BURN(gamerId, nodeFrom, nodeTo, param);
break;
}
default:
qCritical()<<"GameView : unexpected case in 'applyGamerAction'";
break;
}
}
示例4: EjecutarInstruccion
void EjecutarInstruccion(char *instruccion) {
QString slInstruccion = QString("%1").arg(instruccion);
QString slInstruccionAEjecutar;
// Pasar cualquier instruccion a mayuscula
slInstruccion = slInstruccion.toLower();
// Retirar blancos de instruccion (espacios,tabuladores, etc.)
slInstruccion = slInstruccion.simplified();
if(slInstruccion.contains(QRegExp(";"))) {
// Ignorar instruccion
return;
}
else if(slInstruccion.contains(QRegExp("mov"))) {
emInstruccion = MOV;
printf("MOV\n");
slInstruccionAEjecutar = slInstruccion.replace("mov", "");
printf("slInstruccionAEjecutar\n");
QStringList sllOperadorOperandos = slInstruccionAEjecutar.split(",");
QString slDestino, slOrigen;
if(!sllOperadorOperandos.isEmpty()) {
if(sllOperadorOperandos.length() != 2) {
printf("Error diferente de dos operandos.\n");
return;
}
else {
slDestino = sllOperadorOperandos.first();
slOrigen = sllOperadorOperandos.last();
Verificar2Operandos(slDestino, slOrigen);
}
}
else {
printf("Error instruccion vacia.");
}
}
else if(slInstruccion.contains(QRegExp("add"))) {
emInstruccion = ADD;
printf("ADD\n");
slInstruccionAEjecutar = slInstruccion.replace("add", "");
printf("slInstruccionAEjecutar\n");
QStringList sllOperadorOperandos = slInstruccionAEjecutar.split(",");
QString slDestino, slOrigen;
if(!sllOperadorOperandos.isEmpty()) {
if(sllOperadorOperandos.length() != 2) {
printf("Error diferente de dos operandos.\n");
return;
}
else {
slDestino = sllOperadorOperandos.first();
slOrigen = sllOperadorOperandos.last();
Verificar2Operandos(slDestino, slOrigen);
}
}
}
else if(slInstruccion.contains(QRegExp("sub"))) {
emInstruccion = SUB;
printf("SUB\n");
slInstruccionAEjecutar = slInstruccion.replace("sub", "");
printf("slInstruccionAEjecutar\n");
QStringList sllOperadorOperandos = slInstruccionAEjecutar.split(",");
QString slDestino, slOrigen;
if(!sllOperadorOperandos.isEmpty()) {
if(sllOperadorOperandos.length() != 2) {
printf("Error diferente de dos operandos.\n");
return;
}
else {
slDestino = sllOperadorOperandos.first();
slOrigen = sllOperadorOperandos.last();
Verificar2Operandos(slDestino, slOrigen);
}
}
}
else if(slInstruccion.contains(QRegExp("div"))) {
emInstruccion = DIV;
printf("DIV\n");
slInstruccionAEjecutar = slInstruccion.replace("div", "");
printf("slInstruccionAEjecutar\n");
QStringList sllOperadorOperandos = slInstruccionAEjecutar.split(",");
QString slDestino, slOrigen;
if(!sllOperadorOperandos.isEmpty()) {
if(sllOperadorOperandos.length() != 2) {
printf("Error diferente de dos operandos.\n");
return;
}
else {
slDestino = sllOperadorOperandos.first();
slOrigen = sllOperadorOperandos.last();
Verificar2Operandos(slDestino, slOrigen);
}
}
}
else if(slInstruccion.contains(QRegExp("mul"))) {
emInstruccion = MUL;
printf("MUL\n");
slInstruccionAEjecutar = slInstruccion.replace("mul", "");
printf("slInstruccionAEjecutar\n");
QStringList sllOperadorOperandos = slInstruccionAEjecutar.split(",");
QString slDestino, slOrigen;
if(!sllOperadorOperandos.isEmpty()) {
if(sllOperadorOperandos.length() != 2) {
printf("Error diferente de dos operandos.\n");
//.........这里部分代码省略.........
示例5: poEscapedString
static QString poEscapedString(const QString &prefix, const QString &keyword,
bool noWrap, const QString &ba)
{
QStringList lines;
int off = 0;
QString res;
while (off < ba.length()) {
ushort c = ba[off++].unicode();
switch (c) {
case '\n':
res += QLatin1String("\\n");
lines.append(res);
res.clear();
break;
case '\r':
res += QLatin1String("\\r");
break;
case '\t':
res += QLatin1String("\\t");
break;
case '\v':
res += QLatin1String("\\v");
break;
case '\a':
res += QLatin1String("\\a");
break;
case '\b':
res += QLatin1String("\\b");
break;
case '\f':
res += QLatin1String("\\f");
break;
case '"':
res += QLatin1String("\\\"");
break;
case '\\':
res += QLatin1String("\\\\");
break;
default:
if (c < 32) {
res += QLatin1String("\\x");
res += QString::number(c, 16);
if (off < ba.length() && isxdigit(ba[off].unicode()))
res += QLatin1String("\"\"");
} else {
res += QChar(c);
}
break;
}
}
if (!res.isEmpty())
lines.append(res);
if (!lines.isEmpty()) {
if (!noWrap) {
if (lines.count() != 1 ||
lines.first().length() > MAX_LEN - keyword.length() - prefix.length() - 3)
{
QStringList olines = lines;
lines = QStringList(QString());
const int maxlen = MAX_LEN - prefix.length() - 2;
foreach (const QString &line, olines) {
int off = 0;
while (off + maxlen < line.length()) {
int idx = line.lastIndexOf(QLatin1Char(' '), off + maxlen - 1) + 1;
if (idx == off) {
#ifdef HARD_WRAP_LONG_WORDS
// This doesn't seem too nice, but who knows ...
idx = off + maxlen;
#else
idx = line.indexOf(QLatin1Char(' '), off + maxlen) + 1;
if (!idx)
break;
#endif
}
lines.append(line.mid(off, idx - off));
off = idx;
}
lines.append(line.mid(off));
}
}
} else if (lines.count() > 1) {
示例6: if
/**
return the property that matches the given key sequence, if any
@param scope scope of key
@param key keyname
@param rootProperty is likely to be the top level QgsPropertyKey in QgsProject:e:Imp.
@return null if not found, otherwise located Property
*/
static
QgsProperty * findKey_( QString const & scope,
QString const & key,
QgsPropertyKey & rootProperty )
{
QgsPropertyKey * currentProperty = &rootProperty;
QgsProperty * nextProperty; // link to next property down hiearchy
QStringList keySequence = makeKeyTokens_( scope, key );
while ( ! keySequence.isEmpty() )
{
// if the current head of the sequence list matches the property name,
// then traverse down the property hierarchy
if ( keySequence.first() == currentProperty->name() )
{
// remove front key since we're traversing down a level
keySequence.pop_front();
// if we have only one key name left, then return the key found
if ( 1 == keySequence.count() )
{
return currentProperty->find( keySequence.front() );
}
// if we're out of keys then the current property is the one we
// want; i.e., we're in the rate case of being at the top-most
// property node
else if ( keySequence.isEmpty() )
{
return currentProperty;
}
else if (( nextProperty = currentProperty->find( keySequence.first() ) ) )
{
if ( nextProperty->isKey() )
{
currentProperty = dynamic_cast<QgsPropertyKey*>( nextProperty );
}
// it may be that this may be one of several property value
// nodes keyed by QDict string; if this is the last remaining
// key token and the next property is a value node, then
// that's the situation, so return the currentProperty
else if ( nextProperty->isValue() && ( 1 == keySequence.count() ) )
{
return currentProperty;
}
else // QgsPropertyValue not Key, so return null
{
return 0x0;
}
}
else // if the next key down isn't found
{ // then the overall key sequence doesn't exist
return 0x0;
}
}
else
{
return 0x0;
}
}
return 0x0;
} // findKey_
示例7: QDialog
//.........这里部分代码省略.........
QHBoxLayout *smallHLayout = new QHBoxLayout;
leftSideLayout->addLayout(smallHLayout);
m_numResultsLabel = new QLabel;
smallHLayout->addWidget(m_numResultsLabel);
smallHLayout->addStretch();
m_buildChecker = new QCheckBox(tr("Buil&d"));
smallHLayout->addWidget(m_buildChecker);
m_sowpodsChecker = new QCheckBox(tr("Remove &British"));
connect(m_sowpodsChecker, SIGNAL(toggled(bool)), this, SLOT(setRemoveSowpods(bool)));
if (!(m_flags & IgnoreBritishness))
smallHLayout->addWidget(m_sowpodsChecker);
m_listBox = new QListWidget;
leftSideLayout->addWidget(m_listBox);
m_numResultsLabel->setBuddy(m_listBox);
// right side
QLabel *filtersLabel = new QLabel(tr("&Filters:"));
rightSideLayout->addWidget(filtersLabel);
m_filtersBox = new QListWidget;
rightSideLayout->addWidget(m_filtersBox);
connect(m_filtersBox, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(showFilter(QListWidgetItem *)));
filtersLabel->setBuddy(m_filtersBox);
QStringList filters;
if (m_flags & ProbabilityInsteadOfPlayability)
filters << "Probability";
else
filters << "Playability";
filters << "Regex";
filters << "Num. Anagrams";
if (!(m_flags & IgnoreBritishness))
filters << "Keep British";
m_filtersBox->addItems(filters);
m_filtersLayout = new QVBoxLayout;
rightSideLayout->addLayout(m_filtersLayout);
m_currentFilter = 0;
m_applyButton = new QPushButton(tr("&Apply"));
rightSideLayout->addWidget(m_applyButton);
// bottom
QHBoxLayout *filenameLayout = new QHBoxLayout;
vbox->addLayout(filenameLayout);
QPushButton *filenameButton = new QPushButton(tr("Pic&k filename..."));
filenameLayout->addWidget(filenameButton);
connect(filenameButton, SIGNAL(clicked()), this, SLOT(chooseFilename()));
m_filenameEdit = new QLineEdit;
filenameLayout->addWidget(m_filenameEdit);
QHBoxLayout *buttonBox = new QHBoxLayout;
vbox->addLayout(buttonBox);
QHBoxLayout *buttonBox2 = new QHBoxLayout;
vbox->addLayout(buttonBox2);
m_writeButton = new QPushButton(tr("&Write alphagram file"));
m_writeNormalButton = new QPushButton(tr("&Write normal file"));
m_studyThisButton = new QPushButton(tr("Write and &Study"));
QPushButton *openButton = new QPushButton(tr("&Open File..."));
QPushButton *clearButton = new QPushButton(tr("C&lear"));
m_closeButton = new QPushButton(tr("&Close"));
buttonBox->addWidget(m_writeButton);
buttonBox->addWidget(m_writeNormalButton);
if (!(m_flags & NothingToReturn))
buttonBox->addWidget(m_studyThisButton);
buttonBox->addWidget(openButton);
buttonBox2->addWidget(clearButton);
buttonBox2->addStretch();
buttonBox2->addWidget(m_closeButton);
filenameChanged(QString::null); // disable write button initially
connect(m_filenameEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filenameChanged(const QString &)));
connect(m_writeButton, SIGNAL(clicked()), this, SLOT(writeButtonClicked()));
connect(m_writeNormalButton, SIGNAL(clicked()), this, SLOT(writeNormalButtonClicked()));
connect(m_studyThisButton, SIGNAL(clicked()), this, SLOT(studyButtonClicked()));
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(done()));
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
connect(openButton, SIGNAL(clicked()), this, SLOT(openFile()));
showFilter(filters.first());
//m_filtersBox->setCurrentItem(0);
clear();
}
示例8: start
//.........这里部分代码省略.........
} else if (arg.endsWith(QLatin1String(".pro"), Qt::CaseInsensitive)) {
proFiles << arg;
} else {
QFileInfo fi(arg);
if (fi.isDir()) {
if ( verbose )
Console::out(tr("Scanning directory '%1'...\n").arg(arg));
QDir dir = QDir(fi.filePath());
if (extensionsNameFilters.isEmpty()) {
extensions = extensions.trimmed();
// Remove the potential dot in front of each extension
if (extensions.startsWith(QLatin1Char('.')))
extensions.remove(0,1);
extensions.replace(QLatin1String(",."), QLatin1String(","));
extensions.insert(0, QLatin1String("*."));
extensions.replace(QLatin1Char(','), QLatin1String(",*."));
extensionsNameFilters = extensions.split(QLatin1Char(','));
}
QDir::Filters filters = QDir::Files | QDir::NoSymLinks;
QFileInfoList fileinfolist;
recursiveFileInfoList(dir, extensionsNameFilters, filters, true, &fileinfolist);
QFileInfoList::iterator ii;
QString fn;
for (ii = fileinfolist.begin(); ii != fileinfolist.end(); ++ii) {
// Make sure the path separator is stored with '/' in the ts file
fn = ii->canonicalFilePath().replace(QLatin1Char('\\'),QLatin1Char('/'));
#ifdef LINGUIST_DEBUG
qDebug() << fn;
#endif
sourceFiles << fn;
}
}else{
sourceFiles << fi.canonicalFilePath().replace(QLatin1Char('\\'),QLatin1Char('/'));
}
}
} //for
if ( proFiles.count() > 0 ) {
proFiles = getListOfProfiles(proFiles, verbose);
}
bool firstPass = true;
for (int pi = 0; firstPass || pi < proFiles.count(); ++pi) {
QStringList tsFiles = tsFileNames;
if (proFiles.count() > 0) {
QString pf = proFiles.at(pi);
QMap<QByteArray, QStringList> variables;
if(!evaluateProFile(pf, verbose, &variables))
return 2;
sourceFiles = variables.value("SOURCES");
QStringList tmp = variables.value("CODECFORTR");
if (!tmp.isEmpty()) {
codecForTr = tmp.first().toAscii();
fetchedTor.setCodecForTr(codecForTr.constData());
}
tmp = variables.value("CODECFORSRC");
if (!tmp.isEmpty()) {
codecForSource = tmp.first().toAscii();
}
tsFiles += variables.value("TRANSLATIONS");
}
for (QStringList::iterator it = sourceFiles.begin(); it != sourceFiles.end(); ++it) {
#ifdef LINGUIST_DEBUG
qDebug() << " " << (*it);
#endif
if ( (*it).endsWith(QLatin1String(".java"), Qt::CaseInsensitive) ) {
fetchtr_java( *it, &fetchedTor, defaultContext, true, codecForSource );
}
else if ( (*it).endsWith(QLatin1String(".ui"), Qt::CaseInsensitive) ) {
#ifdef LINGUIST_DEBUG
qDebug() << " " << (*it) + ".h";
#endif
fetchtr_ui( *it, &fetchedTor, defaultContext, true );
fetchtr_cpp( *it + QLatin1String(".h"), &fetchedTor,
defaultContext, false, codecForSource );
} else {
fetchtr_cpp( *it, &fetchedTor, defaultContext, true, codecForSource );
}
}
removeDuplicates(&tsFiles, false);
if ( tsFiles.count() > 0) {
updateTsFiles( fetchedTor, tsFiles, QString::fromLatin1(codecForTr.constData()), noObsolete, onlyPlural, verbose );
}
firstPass = false;
}
if ( numFiles == 0 ) {
printUsage();
return 1;
}
return 0;
}
示例9: main
//.........这里部分代码省略.........
parser.addOption(bindir);
QCommandLineOption plugindir(QStringList() << QStringLiteral("plugin-dir") << QStringLiteral("plugin-directory"),
QCoreApplication::translate("qtpaths", "Location of Qt plugins."));
parser.addOption(plugindir);
parser.process(app);
QStandardPaths::enableTestMode(parser.isSet(testmode));
QStringList results;
if (parser.isSet(qtversion)) {
QString qtversionstring = QString::fromLatin1(qVersion());
results << qtversionstring;
}
if (parser.isSet(installprefix)) {
QString path = QLibraryInfo::location(QLibraryInfo::PrefixPath);
results << path;
}
if (parser.isSet(bindir)) {
QString path = QLibraryInfo::location(QLibraryInfo::BinariesPath);
results << path;
}
if (parser.isSet(plugindir)) {
QString path = QLibraryInfo::location(QLibraryInfo::PluginsPath);
results << path;
}
if (parser.isSet(types)) {
QStringList typesList = ::types();
results << typesList.join('\n');
}
if (parser.isSet(display)) {
QStandardPaths::StandardLocation location = parseLocationOrError(parser.value(display));
QString text = QStandardPaths::displayName(location);
results << text;
}
if (parser.isSet(paths)) {
QStandardPaths::StandardLocation location = parseLocationOrError(parser.value(paths));
QStringList paths = QStandardPaths::standardLocations(location);
results << paths.join(pathsep);
}
if (parser.isSet(writablePath)) {
QStandardPaths::StandardLocation location = parseLocationOrError(parser.value(writablePath));
QString path = QStandardPaths::writableLocation(location);
results << path;
}
if (parser.isSet(findExe)) {
QString searchitem = searchStringOrError(&parser);
QString path = QStandardPaths::findExecutable(searchitem);
results << path;
}
if (parser.isSet(locateDir)) {
QStandardPaths::StandardLocation location = parseLocationOrError(parser.value(locateDir));
QString searchitem = searchStringOrError(&parser);
QString path = QStandardPaths::locate(location, searchitem, QStandardPaths::LocateDirectory);
results << path;
}
if (parser.isSet(locateFile)) {
QStandardPaths::StandardLocation location = parseLocationOrError(parser.value(locateFile));
QString searchitem = searchStringOrError(&parser);
QString path = QStandardPaths::locate(location, searchitem, QStandardPaths::LocateFile);
results << path;
}
if (parser.isSet(locateDirs)) {
QStandardPaths::StandardLocation location = parseLocationOrError(parser.value(locateDirs));
QString searchitem = searchStringOrError(&parser);
QStringList paths = QStandardPaths::locateAll(location, searchitem, QStandardPaths::LocateDirectory);
results << paths.join(pathsep);
}
if (parser.isSet(locateFiles)) {
QStandardPaths::StandardLocation location = parseLocationOrError(parser.value(locateFiles));
QString searchitem = searchStringOrError(&parser);
QStringList paths = QStandardPaths::locateAll(location, searchitem, QStandardPaths::LocateFile);
results << paths.join(pathsep);
}
if (results.isEmpty()) {
parser.showHelp();
} else if (results.size() == 1) {
const QString &item = results.first();
message(item);
if (item.isEmpty())
return EXIT_FAILURE;
} else {
QString errorMessage = QCoreApplication::translate("qtpaths", "Several options given, only one is supported at a time.");
error(errorMessage);
}
return EXIT_SUCCESS;
}
示例10: showContextMenu
void WebWidget::showContextMenu(const QPoint &position)
{
m_contextMenuReason = QContextMenuEvent::Other;
const bool hasSelection = (this->hasSelection() && !getSelectedText().trimmed().isEmpty());
if (m_ignoreContextMenu || (position.isNull() && (!hasSelection || m_clickPosition.isNull())))
{
return;
}
const QPoint hitPosition = (position.isNull() ? m_clickPosition : position);
if (isScrollBar(hitPosition) || (SettingsManager::getValue(QLatin1String("Browser/JavaScriptCanDisableContextMenu")).toBool() && !canShowContextMenu(hitPosition)))
{
return;
}
updateHitTestResult(hitPosition);
updateEditActions();
QStringList flags;
if (m_hitResult.flags.testFlag(IsFormTest))
{
flags.append(QLatin1String("form"));
}
if (!m_hitResult.imageUrl.isValid() && m_hitResult.flags.testFlag(IsSelectedTest) && hasSelection)
{
flags.append(QLatin1String("selection"));
}
if (m_hitResult.linkUrl.isValid())
{
if (m_hitResult.linkUrl.scheme() == QLatin1String("mailto"))
{
flags.append(QLatin1String("mail"));
}
else
{
flags.append(QLatin1String("link"));
}
}
if (!m_hitResult.imageUrl.isEmpty())
{
flags.append(QLatin1String("image"));
}
if (m_hitResult.mediaUrl.isValid())
{
flags.append(QLatin1String("media"));
}
if (m_hitResult.flags.testFlag(IsContentEditableTest))
{
flags.append(QLatin1String("edit"));
}
if (flags.isEmpty() || (flags.size() == 1 && flags.first() == QLatin1String("form")))
{
flags.append(QLatin1String("standard"));
if (m_hitResult.frameUrl.isValid())
{
flags.append(QLatin1String("frame"));
}
}
if (flags.isEmpty())
{
return;
}
Menu menu(Menu::NoMenuRole, this);
menu.load(QLatin1String("menu/webWidget.json"), flags);
menu.exec(mapToGlobal(hitPosition));
}
示例11: mutateAfterCopy
void PackageStructureTest::mutateAfterCopy()
{
const bool mainscriptRequired = ps.isRequired("mainscript");
const QStringList imageMimeTypes = ps.mimeTypes("images");
const QStringList defaultMimeTypes = ps.mimeTypes("translations");
const QString packageRoot = ps.defaultPackageRoot();
const bool externalPaths = ps.allowExternalPaths();
const QStringList contentsPrefixPaths = ps.contentsPrefixPaths();
const QList<QByteArray> files = ps.files();
const QList<QByteArray> dirs = ps.directories();
KPackage::Package copy(ps);
copy.setRequired("mainscript", !mainscriptRequired);
QCOMPARE(ps.isRequired("mainscript"), mainscriptRequired);
QCOMPARE(copy.isRequired("mainscript"), !mainscriptRequired);
copy = ps;
const QString copyPackageRoot = packageRoot + "more/";
copy.setDefaultPackageRoot(copyPackageRoot);
QCOMPARE(ps.defaultPackageRoot(), packageRoot);
QCOMPARE(copy.defaultPackageRoot(), copyPackageRoot);
copy = ps;
copy.setAllowExternalPaths(!externalPaths);
QCOMPARE(ps.allowExternalPaths(), externalPaths);
QCOMPARE(copy.allowExternalPaths(), !externalPaths);
copy = ps;
QStringList copyContentsPrefixPaths = contentsPrefixPaths;
copyContentsPrefixPaths << QStringLiteral("more/");
copy.setContentsPrefixPaths(copyContentsPrefixPaths);
QCOMPARE(ps.contentsPrefixPaths(), contentsPrefixPaths);
QCOMPARE(copy.contentsPrefixPaths(), copyContentsPrefixPaths);
copy = ps;
copy.addFileDefinition("nonsense", QStringLiteral("foobar"), QString());
QCOMPARE(ps.files(), files);
QVERIFY(ps.files() != copy.files());
copy = ps;
copy.addDirectoryDefinition("nonsense", QStringLiteral("foobar"), QString());
QCOMPARE(ps.directories(), dirs);
QVERIFY(ps.directories() != copy.directories());
copy = ps;
copy.removeDefinition("mainscript");
QCOMPARE(ps.files(), files);
QVERIFY(ps.files() != copy.files());
copy = ps;
QVERIFY(!imageMimeTypes.isEmpty());
QStringList copyMimeTypes;
copyMimeTypes << imageMimeTypes.first();
copy.setMimeTypes("images", copyMimeTypes);
QCOMPARE(ps.mimeTypes("images"), imageMimeTypes);
QCOMPARE(copy.mimeTypes("images"), copyMimeTypes);
copy = ps;
QStringList copyDefaultMimeTypes = defaultMimeTypes;
copyDefaultMimeTypes << QStringLiteral("rubbish");
copy.setDefaultMimeTypes(copyDefaultMimeTypes);
QCOMPARE(ps.mimeTypes("translations"), defaultMimeTypes);
QCOMPARE(copy.mimeTypes("translations"), copyDefaultMimeTypes);
}
示例12: parseEntityString
void FakeJobResponse::parseEntityString( QList<FakeJobResponse *> &collectionResponseList, QHash<Collection::Id, FakeJobResponse *> &itemResponseMap, Collection::List &recentCollections, FakeServerData *fakeServerData, const QString& _entityString, int depth )
{
QString entityString = _entityString;
if ( entityString.startsWith( 'C' ) )
{
Collection collection;
entityString.remove( 0, 2 );
Q_ASSERT( entityString.startsWith( '(' ) );
entityString.remove( 0, 1 );
QStringList parts = entityString.split( ')' );
if ( !parts.first().isEmpty() )
{
QString typesString = parts.takeFirst();
QStringList types = typesString.split(',');
types.replaceInStrings(" ", "");
collection.setContentMimeTypes( types );
} else {
parts.removeFirst();
}
collection.setId( fakeServerData->nextCollectionId() );
collection.setName( QString("Collection %1").arg( collection.id() ) );
collection.setRemoteId( QString( "remoteId %1" ).arg( collection.id() ) );
if ( depth == 0 )
collection.setParentCollection( Collection::root() );
else
collection.setParentCollection( recentCollections.at( depth ) );
if ( recentCollections.size() == ( depth + 1) )
recentCollections.append( collection );
else
recentCollections[ depth + 1 ] = collection;
int order = 0;
if ( !parts.first().isEmpty() )
{
QString displayName;
QString optionalSection = parts.first().trimmed();
if ( optionalSection.startsWith( QLatin1Char( '\'' ) ) )
{
optionalSection.remove( 0, 1 );
QStringList optionalParts = optionalSection.split( QLatin1Char( '\'' ) );
displayName = optionalParts.takeFirst();
EntityDisplayAttribute *eda = new EntityDisplayAttribute();
eda->setDisplayName( displayName );
collection.addAttribute( eda );
optionalSection = optionalParts.first();
}
QString orderString = optionalSection.trimmed();
if ( !orderString.isEmpty() )
{
bool ok;
order = orderString.toInt(&ok);
Q_ASSERT(ok);
}
} else
{
order = 1;
}
while ( collectionResponseList.size() < order )
{
collectionResponseList.append( new FakeJobResponse( recentCollections[ depth ], FakeJobResponse::RespondToCollectionFetch, fakeServerData ) );
}
collectionResponseList[ order - 1 ]->appendCollection( collection );
}
if ( entityString.startsWith( 'I' ) )
{
Item item;
entityString.remove( 0, 2 );
entityString = entityString.trimmed();
QString type;
int order = 0;
int iFirstSpace = entityString.indexOf( QLatin1Char( ' ' ) );
type = entityString.left( iFirstSpace );
entityString = entityString.remove( 0, iFirstSpace + 1 ).trimmed();
if ( iFirstSpace > 0 && !entityString.isEmpty() )
{
QString displayName;
QString optionalSection = entityString;
if ( optionalSection.startsWith( QLatin1Char( '\'' ) ) )
{
optionalSection.remove( 0, 1 );
QStringList optionalParts = optionalSection.split( QLatin1Char( '\'' ) );
displayName = optionalParts.takeFirst();
EntityDisplayAttribute *eda = new EntityDisplayAttribute();
eda->setDisplayName( displayName );
item.addAttribute( eda );
optionalSection = optionalParts.first();
}
QString orderString = optionalSection.trimmed();
if ( !orderString.isEmpty() )
{
bool ok;
order = orderString.toInt( &ok );
Q_ASSERT( ok );
}
//.........这里部分代码省略.........
示例13: endElement
void QgsGml::endElement( const XML_Char* el )
{
QString elementName( QString::fromUtf8( el ) );
ParseMode theParseMode( mParseModeStack.isEmpty() ? none : mParseModeStack.top() );
QStringList splitName = elementName.split( NS_SEPARATOR );
QString localName = splitName.last();
QString ns = splitName.size() > 1 ? splitName.first() : "";
if ( theParseMode == coordinate && elementName == GML_NAMESPACE + NS_SEPARATOR + "coordinates" )
{
mParseModeStack.pop();
}
else if ( theParseMode == attribute && localName == mAttributeName ) //add a thematic attribute to the feature
{
mParseModeStack.pop();
//find index with attribute name
QMap<QString, QPair<int, QgsField> >::const_iterator att_it = mThematicAttributes.find( mAttributeName );
if ( att_it != mThematicAttributes.constEnd() )
{
QVariant var;
switch ( att_it.value().second.type() )
{
case QVariant::Double:
var = QVariant( mStringCash.toDouble() );
break;
case QVariant::Int:
var = QVariant( mStringCash.toInt() );
break;
case QVariant::LongLong:
var = QVariant( mStringCash.toLongLong() );
break;
default: //string type is default
var = QVariant( mStringCash );
break;
}
Q_ASSERT( mCurrentFeature );
mCurrentFeature->setAttribute( att_it.value().first, QVariant( mStringCash ) );
}
}
else if ( theParseMode == geometry && localName == mGeometryAttribute )
{
mParseModeStack.pop();
}
else if ( theParseMode == boundingBox && elementName == GML_NAMESPACE + NS_SEPARATOR + "boundedBy" )
{
//create bounding box from mStringCash
if ( createBBoxFromCoordinateString( mCurrentExtent, mStringCash ) != 0 )
{
QgsDebugMsg( "creation of bounding box failed" );
}
mParseModeStack.pop();
}
else if ( theParseMode == feature && localName == mTypeName )
{
Q_ASSERT( mCurrentFeature );
if ( mCurrentWKBSize > 0 )
{
mCurrentFeature->setGeometryAndOwnership( mCurrentWKB, mCurrentWKBSize );
}
else if ( !mCurrentExtent.isEmpty() )
{
mCurrentFeature->setGeometry( QgsGeometry::fromRect( mCurrentExtent ) );
}
else
{
mCurrentFeature->setGeometry( 0 );
}
mCurrentFeature->setValid( true );
mFeatures.insert( mCurrentFeature->id(), mCurrentFeature );
if ( !mCurrentFeatureId.isEmpty() )
{
mIdMap.insert( mCurrentFeature->id(), mCurrentFeatureId );
}
mCurrentFeature = 0;
++mFeatureCount;
mParseModeStack.pop();
}
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "Point" )
{
QList<QgsPoint> pointList;
if ( pointsFromCoordinateString( pointList, mStringCash ) != 0 )
{
//error
}
if ( theParseMode == QgsGml::geometry )
{
//directly add WKB point to the feature
if ( getPointWKB( &mCurrentWKB, &mCurrentWKBSize, *( pointList.begin() ) ) != 0 )
{
//error
}
if ( *mWkbType != QGis::WKBMultiPoint ) //keep multitype in case of geometry type mix
{
*mWkbType = QGis::WKBPoint;
}
//.........这里部分代码省略.........
示例14: startElement
void QgsGml::startElement( const XML_Char* el, const XML_Char** attr )
{
QString elementName( QString::fromUtf8( el ) );
ParseMode theParseMode( mParseModeStack.isEmpty() ? none : mParseModeStack.top() );
QStringList splitName = elementName.split( NS_SEPARATOR );
QString localName = splitName.last();
QString ns = splitName.size() > 1 ? splitName.first() : "";
if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "coordinates" )
{
mParseModeStack.push( QgsGml::coordinate );
mStringCash.clear();
mCoordinateSeparator = readAttribute( "cs", attr );
if ( mCoordinateSeparator.isEmpty() )
{
mCoordinateSeparator = ",";
}
mTupleSeparator = readAttribute( "ts", attr );
if ( mTupleSeparator.isEmpty() )
{
mTupleSeparator = " ";
}
}
else if ( localName == mGeometryAttribute )
{
mParseModeStack.push( QgsGml::geometry );
}
//else if ( mParseModeStack.size() == 0 && elementName == GML_NAMESPACE + NS_SEPARATOR + "boundedBy" )
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "boundedBy" )
{
mParseModeStack.push( QgsGml::boundingBox );
}
else if ( theParseMode == none && localName == mTypeName )
{
Q_ASSERT( !mCurrentFeature );
mCurrentFeature = new QgsFeature( mFeatureCount );
QgsAttributes attributes( mThematicAttributes.size() ); //add empty attributes
mCurrentFeature->setAttributes( attributes );
mParseModeStack.push( QgsGml::feature );
mCurrentFeatureId = readAttribute( "fid", attr );
}
else if ( theParseMode == boundingBox && elementName == GML_NAMESPACE + NS_SEPARATOR + "Box" )
{
//read attribute srsName="EPSG:26910"
int epsgNr;
if ( readEpsgFromAttribute( epsgNr, attr ) != 0 )
{
QgsDebugMsg( "error, could not get epsg id" );
}
}
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "Polygon" )
{
mCurrentWKBFragments.push_back( QList<unsigned char*>() );
mCurrentWKBFragmentSizes.push_back( QList<int>() );
}
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiPoint" )
{
mParseModeStack.push( QgsGml::multiPoint );
//we need one nested list for intermediate WKB
mCurrentWKBFragments.push_back( QList<unsigned char*>() );
mCurrentWKBFragmentSizes.push_back( QList<int>() );
}
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiLineString" )
{
mParseModeStack.push( QgsGml::multiLine );
//we need one nested list for intermediate WKB
mCurrentWKBFragments.push_back( QList<unsigned char*>() );
mCurrentWKBFragmentSizes.push_back( QList<int>() );
}
else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "MultiPolygon" )
{
mParseModeStack.push( QgsGml::multiPolygon );
}
else if ( theParseMode == feature && mThematicAttributes.contains( localName ) )
{
mParseModeStack.push( QgsGml::attribute );
mAttributeName = localName;
mStringCash.clear();
}
}
示例15: SmallIconSet
void
Amarok::coverContextMenu( QWidget *parent, QPoint point, const QString &artist, const QString &album, bool showCoverManager )
{
KPopupMenu menu;
enum { SHOW, FETCH, CUSTOM, DELETE, MANAGER };
menu.insertTitle( i18n( "Cover Image" ) );
menu.insertItem( SmallIconSet( Amarok::icon( "zoom" ) ), i18n( "&Show Fullsize" ), SHOW );
menu.insertItem( SmallIconSet( Amarok::icon( "download" ) ), i18n( "&Fetch From amazon.%1" ).arg( CoverManager::amazonTld() ), FETCH );
menu.insertItem( SmallIconSet( Amarok::icon( "files" ) ), i18n( "Set &Custom Cover" ), CUSTOM );
bool disable = !album.isEmpty(); // disable setting covers for unknown albums
menu.setItemEnabled( FETCH, disable );
menu.setItemEnabled( CUSTOM, disable );
menu.insertSeparator();
menu.insertItem( SmallIconSet( Amarok::icon( "remove" ) ), i18n( "&Unset Cover" ), DELETE );
if ( showCoverManager ) {
menu.insertSeparator();
menu.insertItem( SmallIconSet( Amarok::icon( "covermanager" ) ), i18n( "Cover &Manager" ), MANAGER );
}
#ifndef AMAZON_SUPPORT
menu.setItemEnabled( FETCH, false );
#endif
disable = !CollectionDB::instance()->albumImage( artist, album, 0 ).contains( "nocover" );
menu.setItemEnabled( SHOW, disable );
menu.setItemEnabled( DELETE, disable );
switch( menu.exec( point ) )
{
case SHOW:
CoverManager::viewCover( artist, album, parent );
break;
case DELETE:
{
const int button = KMessageBox::warningContinueCancel( parent,
i18n( "Are you sure you want to remove this cover from the Collection?" ),
QString::null,
KStdGuiItem::del() );
if ( button == KMessageBox::Continue )
CollectionDB::instance()->removeAlbumImage( artist, album );
break;
}
case FETCH:
#ifdef AMAZON_SUPPORT
CollectionDB::instance()->fetchCover( parent, artist, album, false );
break;
#endif
case CUSTOM:
{
QString artist_id; artist_id.setNum( CollectionDB::instance()->artistID( artist ) );
QString album_id; album_id.setNum( CollectionDB::instance()->albumID( album ) );
QStringList values = CollectionDB::instance()->albumTracks( artist_id, album_id );
QString startPath = ":homedir";
if ( !values.isEmpty() ) {
KURL url;
url.setPath( values.first() );
startPath = url.directory();
}
KURL file = KFileDialog::getImageOpenURL( startPath, parent, i18n("Select Cover Image File") );
if ( !file.isEmpty() )
CollectionDB::instance()->setAlbumImage( artist, album, file );
break;
}
case MANAGER:
CoverManager::showOnce( album );
break;
}
}