本文整理汇总了C++中QStringList::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::contains方法的具体用法?C++ QStringList::contains怎么用?C++ QStringList::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringList
的用法示例。
在下文中一共展示了QStringList::contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: foreach
Morphos::Morphos (QString mo)
{
// éclater en sous-chaînes
if (!mo.isEmpty ()) mo = mo.simplified ();
if (mo.isEmpty ())
{
graphie = "";
return;
}
elements = mo.split (QRegExp ("\\W+"));
QStringList eclats = elements;
QStringList gr;
QString el;
foreach (el, eclats)
if (k.contains (el))
{
gr << el;
eclats.replace(eclats.indexOf (el), "");
}
foreach (el, eclats)
if (g.contains (el))
{
gr << el;
eclats.replace(eclats.indexOf (el), "");
}
foreach (el, eclats)
if (n.contains (el))
{
gr << el;
eclats.replace(eclats.indexOf (el), "");
}
foreach (el, eclats)
if (d.contains (el))
{
gr << el;
eclats.replace(eclats.indexOf (el), "");
}
foreach (el, eclats)
if (p.contains (el))
{
gr << el;
eclats.replace(eclats.indexOf (el), "");
}
foreach (el, eclats)
if (t.contains (el))
{
gr << el;
eclats.replace(eclats.indexOf (el), "");
}
foreach (el, eclats)
if (m.contains (el))
{
gr << el;
eclats.replace(eclats.indexOf (el), "");
}
foreach (el, eclats)
if (v.contains (el))
{
gr << el;
eclats.replace(eclats.indexOf (el), "");
}
graphie = gr.join (" ").simplified ();
}
示例2: findRunningProcess
/** Check if a process with a given name is running
* @param names list of names to check
* @return list of detected processes.
*/
QStringList Utils::findRunningProcess(QStringList names)
{
QStringList processlist;
QStringList found;
#if defined(Q_OS_WIN32)
HANDLE hdl;
PROCESSENTRY32 entry;
bool result;
hdl = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(hdl == INVALID_HANDLE_VALUE) {
qDebug() << "[Utils] CreateToolhelp32Snapshot failed.";
return found;
}
entry.dwSize = sizeof(PROCESSENTRY32);
entry.szExeFile[0] = '\0';
if(!Process32First(hdl, &entry)) {
qDebug() << "[Utils] Process32First failed.";
return found;
}
processlist.append(QString::fromWCharArray(entry.szExeFile));
do {
entry.dwSize = sizeof(PROCESSENTRY32);
entry.szExeFile[0] = '\0';
result = Process32Next(hdl, &entry);
if(result) {
processlist.append(QString::fromWCharArray(entry.szExeFile));
}
} while(result);
CloseHandle(hdl);
#endif
#if defined(Q_OS_MACX)
ProcessSerialNumber psn = { 0, kNoProcess };
OSErr err;
do {
pid_t pid;
err = GetNextProcess(&psn);
err = GetProcessPID(&psn, &pid);
if(err == noErr) {
char buf[32] = {0};
ProcessInfoRec info;
memset(&info, 0, sizeof(ProcessInfoRec));
info.processName = (unsigned char*)buf;
info.processInfoLength = sizeof(ProcessInfoRec);
err = GetProcessInformation(&psn, &info);
if(err == noErr) {
// some processes start with nonprintable characters. Skip those.
int i;
for(i = 0; i < 32; i++) {
if(isprint(buf[i])) break;
}
// avoid adding duplicates.
QString process = QString::fromUtf8(&buf[i]);
if(!processlist.contains(process)) {
processlist.append(process);
}
}
}
} while(err == noErr);
#endif
// check for given names in list of processes
for(int i = 0; i < names.size(); ++i) {
#if defined(Q_OS_WIN32)
// the process name might be truncated. Allow the extension to be partial.
int index = processlist.indexOf(QRegExp(names.at(i) + "(\\.(e(x(e?)?)?)?)?"));
#else
int index = processlist.indexOf(names.at(i));
#endif
if(index != -1) {
found.append(processlist.at(index));
}
}
qDebug() << "[Utils] Found listed processes running:" << found;
return found;
}
示例3: QStringList
QStringList QgsStyleV2::findSymbols( QString qword )
{
if ( !mCurrentDB )
{
QgsDebugMsg( "Sorry! Cannot open database to search" );
return QStringList();
}
char *query = sqlite3_mprintf( "SELECT name FROM symbol WHERE xml LIKE '%%%q%%'", qword.toUtf8().constData() );
sqlite3_stmt *ppStmt;
int nErr = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, NULL );
QStringList symbols;
while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
symbols << QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, 0 ) );
}
sqlite3_finalize( ppStmt );
query = sqlite3_mprintf( "SELECT id FROM tag WHERE name LIKE '%%%q%%'", qword.toUtf8().constData() );
nErr = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, NULL );
QStringList tagids;
while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
tagids << QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, 0 ) );
}
sqlite3_finalize( ppStmt );
QString dummy = tagids.join( ", " );
query = sqlite3_mprintf( "SELECT symbol_id FROM tagmap WHERE tag_id IN (%q)", dummy.toUtf8().constData() );
nErr = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, NULL );
QStringList symbolids;
while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
symbolids << QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, 0 ) );
}
sqlite3_finalize( ppStmt );
dummy = symbolids.join( ", " );
query = sqlite3_mprintf( "SELECT name FROM symbol WHERE id IN (%q)", dummy.toUtf8().constData() );
nErr = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, NULL );
while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
QString symbolName = QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, 0 ) );
if ( !symbols.contains( symbolName ) )
symbols << symbolName;
}
sqlite3_finalize( ppStmt );
return symbols;
}
示例4: importSimplePlugin
void tst_QScriptExtensionPlugin::importSimplePlugin()
{
QScriptEngine eng;
QCoreApplication::addLibraryPath("plugins");
QVERIFY(eng.importedExtensions().isEmpty());
QStringList available = eng.availableExtensions();
QVERIFY(available.contains("simple"));
QVERIFY(available.contains("simple.foo"));
QVERIFY(available.contains("simple.foo.bar"));
QScriptValue extensionObject;
{
QVERIFY(eng.importExtension("simple").isUndefined());
QCOMPARE(eng.importedExtensions().size(), 1);
QCOMPARE(eng.importedExtensions().at(0), QString::fromLatin1("simple"));
QVERIFY(eng.availableExtensions().contains("simple"));
QVERIFY(eng.globalObject().property("pluginKey").equals("simple"));
QVERIFY(eng.globalObject().property("package").isObject());
extensionObject = eng.globalObject().property("simple");
QVERIFY(extensionObject.isObject());
QVERIFY(extensionObject.equals(eng.globalObject().property("package")));
}
{
QVERIFY(eng.importExtension("simple.foo").isUndefined());
QCOMPARE(eng.importedExtensions().size(), 2);
QCOMPARE(eng.importedExtensions().at(1), QString::fromLatin1("simple.foo"));
QVERIFY(eng.availableExtensions().contains("simple.foo"));
QVERIFY(eng.globalObject().property("pluginKey").equals("simple.foo"));
QVERIFY(eng.globalObject().property("package").isObject());
QVERIFY(!extensionObject.equals(eng.globalObject().property("package")));
QVERIFY(extensionObject.equals(eng.globalObject().property("simple")));
QVERIFY(extensionObject.property("foo").isObject());
QVERIFY(extensionObject.property("foo").equals(eng.globalObject().property("package")));
}
{
QVERIFY(eng.importExtension("simple.foo.bar").isUndefined());
QCOMPARE(eng.importedExtensions().size(), 3);
QCOMPARE(eng.importedExtensions().at(2), QString::fromLatin1("simple.foo.bar"));
QVERIFY(eng.availableExtensions().contains("simple.foo.bar"));
QVERIFY(eng.globalObject().property("pluginKey").equals("simple.foo.bar"));
QVERIFY(eng.globalObject().property("package").isObject());
QVERIFY(!extensionObject.equals(eng.globalObject().property("package")));
QVERIFY(extensionObject.equals(eng.globalObject().property("simple")));
QVERIFY(extensionObject.property("foo").property("bar").isObject());
QVERIFY(extensionObject.property("foo").property("bar").equals(eng.globalObject().property("package")));
}
// Extensions can't be imported multiple times.
eng.globalObject().setProperty("pluginKey", QScriptValue());
QVERIFY(eng.importExtension("simple").isUndefined());
QCOMPARE(eng.importedExtensions().size(), 3);
QVERIFY(!eng.globalObject().property("pluginKey").isValid());
QVERIFY(eng.importExtension("simple.foo").isUndefined());
QCOMPARE(eng.importedExtensions().size(), 3);
QVERIFY(!eng.globalObject().property("pluginKey").isValid());
QVERIFY(eng.importExtension("simple.foo.bar").isUndefined());
QCOMPARE(eng.importedExtensions().size(), 3);
QVERIFY(!eng.globalObject().property("pluginKey").isValid());
}
示例5: writeDataForMultipleFits
/**
* Write log and parameter values to the table for the case of multiple fits.
* @param table :: [input, output] Table to write to
* @param paramsByLabel :: [input] Map of <label name, <workspace name,
* <parameter, value>>>
* @param paramsToDisplay :: [input] List of parameters to display in table
*/
void MuonAnalysisResultTableCreator::writeDataForMultipleFits(
ITableWorkspace_sptr &table,
const QMap<QString, WSParameterList> ¶msByLabel,
const QStringList ¶msToDisplay) const {
assert(m_multiple);
assert(m_logValues);
// Add data to table
for (const auto &labelName : m_items) {
Mantid::API::TableRow row = table->appendRow();
size_t columnIndex(0); // Which column we are writing to
row << labelName.toStdString();
columnIndex++;
// Get log values for this row and write in table
for (const auto &log : m_logs) {
QStringList valuesPerWorkspace;
for (const auto &wsName : paramsByLabel[labelName].keys()) {
const auto &logValues = m_logValues->value(wsName);
const auto &val = logValues[log];
auto dashIndex = val.toString().indexOf("-");
// Special case: if log is time in sec, subtract the first start time
if (log.endsWith(" (s)")) {
auto seconds =
val.toDouble() - static_cast<double>(m_firstStart_ns) * 1.e-9;
valuesPerWorkspace.append(QString::number(seconds));
} else if (dashIndex != 0 && dashIndex != -1) {
valuesPerWorkspace.append(logValues[log].toString());
} else if (MuonAnalysisHelper::isNumber(val.toString()) &&
!log.endsWith(" (text)")) {
valuesPerWorkspace.append(QString::number(val.toDouble()));
} else {
valuesPerWorkspace.append(logValues[log].toString());
}
}
// Range of values - use string comparison as works for numbers too
// Why not use std::minmax_element? To avoid MSVC warning: QT bug 41092
// (https://bugreports.qt.io/browse/QTBUG-41092)
valuesPerWorkspace.sort();
auto dashIndex =
valuesPerWorkspace.front().toStdString().find_first_of("-");
if (dashIndex != std::string::npos && dashIndex != 0) {
std::ostringstream oss;
auto dad = valuesPerWorkspace.front().toStdString();
oss << valuesPerWorkspace.front().toStdString();
row << oss.str();
} else {
if (MuonAnalysisHelper::isNumber(valuesPerWorkspace.front())) {
const auto &min = valuesPerWorkspace.front().toDouble();
const auto &max = valuesPerWorkspace.back().toDouble();
if (min == max) {
row << min;
} else {
std::ostringstream oss;
oss << valuesPerWorkspace.front().toStdString() << "-"
<< valuesPerWorkspace.back().toStdString();
row << oss.str();
}
} else {
const auto &front = valuesPerWorkspace.front().toStdString();
const auto &back = valuesPerWorkspace.back().toStdString();
if (front == back) {
row << front;
} else {
std::ostringstream oss;
oss << valuesPerWorkspace[0].toStdString();
for (int k = 1; k < valuesPerWorkspace.size(); k++) {
oss << ", " << valuesPerWorkspace[k].toStdString();
row << oss.str();
}
}
}
}
columnIndex++;
}
// Parse column name - could be param name or f[n].param
const auto parseColumnName =
[¶msToDisplay](
const std::string &columnName) -> std::pair<int, std::string> {
if (paramsToDisplay.contains(QString::fromStdString(columnName))) {
return {0, columnName};
} else {
// column name is f[n].param
size_t pos = columnName.find_first_of('.');
//.........这里部分代码省略.........
示例6: confrimInvite
InviteWidget::InviteWidget(QStringList items,
QString gd, QWidget *parent)
: THWidgetBase(parent)
{
setAttribute(Qt::WA_DeleteOnClose);
setFixedSize(250, 180);
setTitleBarWidth(250);
setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);
setWindowModality(Qt::ApplicationModal);
bar->setBarButtons(HappyTitleBar::MinButtonHint);
bar->setBarButtons(HappyTitleBar::MaxButtonHint);
bar->setExtraButtonVisible(false);
bar->setBarIcon(":res/happy.png");
bar->setBarContent(cn("邀请成员列表"));
connect(bar, &HappyTitleBar::signalClose, this, [=] () {
this->close();
});
members = items;
gdm = gd;
QLabel *lab = new QLabel(cn("选择邀请对象(未筛选)"));
lab->setFixedWidth(120);
lab->setStyleSheet(QStringLiteral("font-family:微软雅黑;font:12px;color:white;"));
QPushButton *pb = new QPushButton(cn("筛选"), this);
pb->setFixedWidth(50);
pb->setCheckable(true);
QHBoxLayout *h1 = new QHBoxLayout();
h1->setContentsMargins(0, 0, 0, 0);
h1->addStretch(1);
h1->addWidget(lab, 0, Qt::AlignCenter);
h1->addWidget(pb, 0, Qt::AlignCenter);
h1->addStretch(1);
CheckList *list = new CheckList(this);
QPushButton *confrim = new QPushButton(cn("确认"), this);
confrim->setFixedWidth(50);
QVBoxLayout *v = new QVBoxLayout(this);
v->setContentsMargins(10, 35, 10, 15);
v->addLayout(h1, 1);
v->addWidget(list, 5);
v->addWidget(confrim, 1, Qt::AlignCenter);
QFile file;
file.setFileName(":res/css/button2.css");
if (file.open(QIODevice::ReadOnly))
{
QByteArray ba = file.readAll();
pb->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba));
confrim->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba));
}
file.close();
file.setFileName(":res/css/list2.css");
if (file.open(QIODevice::ReadOnly))
{
QByteArray ba = file.readAll();
list->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba));
}
file.close();
// load data
ConfigureData *conf = ConfigureData::getInstance();
updateColor(conf->getColorIni("color1"), conf->getColorIni("color2"));
list->setmyuid(conf->getUuid());
connect(pb, &QPushButton::toggled,
this, [=] (bool b) {
QString str = cn("选择邀请对象(%1)");
if (b)
{
QStringList selectList;
QStringList items = gdm.split(";");
for (QString str : members)
{
QStringList temp = str.split(":");
if (temp.size() == 2)
{
if (!items.contains(temp.last()))
{
selectList << str;
}
}
}
list->addCheckItems(selectList);
str = str.arg(cn("筛选"));
}
else
{
list->addCheckItems(members);
str = str.arg(cn("未筛选"));
}
lab->setText(str);
});
connect(confrim, &QPushButton::clicked,
this, [=] () {
QString uids = list->checkedids();
QStringList lst = uids.split(";");
if (lst.size() <= 1)
{
MsgBox::ShowMsgBox(cn("提示"),
cn("没有选择"),
cn("确定"));
return;
//.........这里部分代码省略.........
示例7: createTransactionDocument
QDomDocument createTransactionDocument( QgsServerInterface* serverIface, const QString& version,
const QgsServerRequest& request )
{
Q_UNUSED( version );
QDomDocument doc;
QgsWfsProjectParser* configParser = getConfigParser( serverIface );
#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsAccessControl* accessControl = serverIface->accessControls();
#endif
const QString requestBody = request.getParameter( QStringLiteral( "REQUEST_BODY" ) );
QString errorMsg;
if ( !doc.setContent( requestBody, true, &errorMsg ) )
{
throw QgsRequestNotWellFormedException( errorMsg );
}
QDomElement docElem = doc.documentElement();
QDomNodeList docChildNodes = docElem.childNodes();
// Re-organize the transaction document
QDomDocument mDoc;
QDomElement mDocElem = mDoc.createElement( QStringLiteral( "myTransactionDocument" ) );
mDocElem.setAttribute( QStringLiteral( "xmlns" ), QGS_NAMESPACE );
mDocElem.setAttribute( QStringLiteral( "xmlns:wfs" ), WFS_NAMESPACE );
mDocElem.setAttribute( QStringLiteral( "xmlns:gml" ), GML_NAMESPACE );
mDocElem.setAttribute( QStringLiteral( "xmlns:ogc" ), OGC_NAMESPACE );
mDocElem.setAttribute( QStringLiteral( "xmlns:qgs" ), QGS_NAMESPACE );
mDocElem.setAttribute( QStringLiteral( "xmlns:xsi" ), QStringLiteral( "http://www.w3.org/2001/XMLSchema-instance" ) );
mDoc.appendChild( mDocElem );
QDomElement actionElem;
QString actionName;
QDomElement typeNameElem;
QString typeName;
for ( int i = docChildNodes.count(); 0 < i; --i )
{
actionElem = docChildNodes.at( i - 1 ).toElement();
actionName = actionElem.localName();
if ( actionName == QLatin1String( "Insert" ) )
{
QDomElement featureElem = actionElem.firstChild().toElement();
typeName = featureElem.localName();
}
else if ( actionName == QLatin1String( "Update" ) )
{
typeName = actionElem.attribute( QStringLiteral( "typeName" ) );
}
else if ( actionName == QLatin1String( "Delete" ) )
{
typeName = actionElem.attribute( QStringLiteral( "typeName" ) );
}
if ( typeName.contains( QLatin1String( ":" ) ) )
typeName = typeName.section( QStringLiteral( ":" ), 1, 1 );
QDomNodeList typeNameList = mDocElem.elementsByTagName( typeName );
if ( typeNameList.count() == 0 )
{
typeNameElem = mDoc.createElement( typeName );
mDocElem.appendChild( typeNameElem );
}
else
typeNameElem = typeNameList.at( 0 ).toElement();
typeNameElem.appendChild( actionElem );
}
// It's time to make the transaction
// Create the response document
QDomDocument resp;
//wfs:WFS_TransactionRespone element
QDomElement respElem = resp.createElement( QStringLiteral( "WFS_TransactionResponse" )/*wfs:WFS_TransactionResponse*/ );
respElem.setAttribute( QStringLiteral( "xmlns" ), WFS_NAMESPACE );
respElem.setAttribute( QStringLiteral( "xmlns:xsi" ), QStringLiteral( "http://www.w3.org/2001/XMLSchema-instance" ) );
respElem.setAttribute( QStringLiteral( "xsi:schemaLocation" ), WFS_NAMESPACE + " http://schemas.opengis.net/wfs/1.0.0/wfs.xsd" );
respElem.setAttribute( QStringLiteral( "xmlns:ogc" ), OGC_NAMESPACE );
respElem.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.0.0" ) );
resp.appendChild( respElem );
// Store the created feature id for WFS
QStringList insertResults;
// Get the WFS layers id
QStringList wfsLayersId = configParser->wfsLayers();;
QList<QgsMapLayer*> layerList;
QgsMapLayer* currentLayer = nullptr;
// Loop through the layer transaction elements
docChildNodes = mDocElem.childNodes();
for ( int i = 0; i < docChildNodes.count(); ++i )
{
// Get the vector layer
typeNameElem = docChildNodes.at( i ).toElement();
typeName = typeNameElem.tagName();
//.........这里部分代码省略.........
示例8: if
QQuickTransition *QQuickStateGroupPrivate::findTransition(const QString &from, const QString &to)
{
QQuickTransition *highest = 0;
int score = 0;
bool reversed = false;
bool done = false;
for (int ii = 0; !done && ii < transitions.count(); ++ii) {
QQuickTransition *t = transitions.at(ii);
if (!t->enabled())
continue;
for (int ii = 0; ii < 2; ++ii)
{
if (ii && (!t->reversible() ||
(t->fromState() == QLatin1String("*") &&
t->toState() == QLatin1String("*"))))
break;
QStringList fromState;
QStringList toState;
fromState = t->fromState().split(QLatin1Char(','));
for (int jj = 0; jj < fromState.count(); ++jj)
fromState[jj] = fromState.at(jj).trimmed();
toState = t->toState().split(QLatin1Char(','));
for (int jj = 0; jj < toState.count(); ++jj)
toState[jj] = toState.at(jj).trimmed();
if (ii == 1)
qSwap(fromState, toState);
int tScore = 0;
if (fromState.contains(from))
tScore += 2;
else if (fromState.contains(QLatin1String("*")))
tScore += 1;
else
continue;
if (toState.contains(to))
tScore += 2;
else if (toState.contains(QLatin1String("*")))
tScore += 1;
else
continue;
if (ii == 1)
reversed = true;
else
reversed = false;
if (tScore == 4) {
highest = t;
done = true;
break;
} else if (tScore > score) {
score = tScore;
highest = t;
}
}
}
if (highest)
highest->setReversed(reversed);
return highest;
}
示例9: keys
/*!
Returns the list of valid keys, i.e. the keys this factory can
create styles for.
\sa create()
*/
QStringList QStyleFactory::keys()
{
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
QStringList list = loader()->keys();
#else
QStringList list;
#endif
#ifndef QT_NO_STYLE_WINDOWS
if (!list.contains(QLatin1String("Windows")))
list << QLatin1String("Windows");
#endif
#ifndef QT_NO_STYLE_WINDOWSCE
if (!list.contains(QLatin1String("WindowsCE")))
list << QLatin1String("WindowsCE");
#endif
#ifndef QT_NO_STYLE_WINDOWSMOBILE
if (!list.contains(QLatin1String("WindowsMobile")))
list << QLatin1String("WindowsMobile");
#endif
#ifndef QT_NO_STYLE_WINDOWSXP
if (!list.contains(QLatin1String("WindowsXP")) &&
(QSysInfo::WindowsVersion >= QSysInfo::WV_XP && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
list << QLatin1String("WindowsXP");
#endif
#ifndef QT_NO_STYLE_WINDOWSVISTA
if (!list.contains(QLatin1String("WindowsVista")) &&
(QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
list << QLatin1String("WindowsVista");
#endif
#ifndef QT_NO_STYLE_MOTIF
if (!list.contains(QLatin1String("Motif")))
list << QLatin1String("Motif");
#endif
#ifndef QT_NO_STYLE_CDE
if (!list.contains(QLatin1String("CDE")))
list << QLatin1String("CDE");
#endif
#ifndef QT_NO_STYLE_S60
if (!list.contains(QLatin1String("S60")))
list << QLatin1String("S60");
#endif
#ifndef QT_NO_STYLE_PLASTIQUE
if (!list.contains(QLatin1String("Plastique")))
list << QLatin1String("Plastique");
#endif
#ifndef QT_NO_STYLE_GTK
if (!list.contains(QLatin1String("GTK+")))
list << QLatin1String("GTK+");
#endif
#ifndef QT_NO_STYLE_CLEANLOOKS
if (!list.contains(QLatin1String("Cleanlooks")))
list << QLatin1String("Cleanlooks");
#endif
#ifndef QT_NO_STYLE_MAC
QString mstyle = QLatin1String("Macintosh");
# ifdef Q_WS_MAC
mstyle += QLatin1String(" (aqua)");
# endif
if (!list.contains(mstyle))
list << mstyle;
#endif
return list;
}
示例10: connect
bool QLinuxFbScreen::connect(const QString &displaySpec)
{
d_ptr->displaySpec = displaySpec;
const QStringList args = displaySpec.split(QLatin1Char(':'));
if (args.contains(QLatin1String("nographicsmodeswitch")))
d_ptr->doGraphicsMode = false;
#ifdef QT_QWS_DEPTH_GENERIC
if (args.contains(QLatin1String("genericcolors")))
d_ptr->doGenericColors = true;
#endif
QRegExp ttyRegExp(QLatin1String("tty=(.*)"));
if (args.indexOf(ttyRegExp) != -1)
d_ptr->ttyDevice = ttyRegExp.cap(1);
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
#ifndef QT_QWS_FRAMEBUFFER_LITTLE_ENDIAN
if (args.contains(QLatin1String("littleendian")))
#endif
QScreen::setFrameBufferLittleEndian(true);
#endif
// Check for explicitly specified device
const int len = 8; // "/dev/fbx"
int m = displaySpec.indexOf(QLatin1String("/dev/fb"));
QString dev;
if (m > 0)
dev = displaySpec.mid(m, len);
else
dev = QLatin1String("/dev/fb0");
if (access(dev.toLatin1().constData(), R_OK|W_OK) == 0)
d_ptr->fd = open(dev.toLatin1().constData(), O_RDWR);
if (d_ptr->fd == -1) {
if (QApplication::type() == QApplication::GuiServer) {
perror("QScreenLinuxFb::connect");
qCritical("Error opening framebuffer device %s", qPrintable(dev));
return false;
}
if (access(dev.toLatin1().constData(), R_OK) == 0)
d_ptr->fd = open(dev.toLatin1().constData(), O_RDONLY);
}
fb_fix_screeninfo finfo;
fb_var_screeninfo vinfo;
//#######################
// Shut up Valgrind
memset(&vinfo, 0, sizeof(vinfo));
memset(&finfo, 0, sizeof(finfo));
//#######################
/* Get fixed screen information */
if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) {
perror("QLinuxFbScreen::connect");
qWarning("Error reading fixed information");
return false;
}
if (finfo.type == FB_TYPE_VGA_PLANES) {
qWarning("VGA16 video mode not supported");
return false;
}
/* Get variable screen information */
if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) {
perror("QLinuxFbScreen::connect");
qWarning("Error reading variable information");
return false;
}
grayscale = vinfo.grayscale;
d = vinfo.bits_per_pixel;
if (d == 24) {
d = vinfo.red.length + vinfo.green.length + vinfo.blue.length;
if (d <= 0)
d = 24; // reset if color component lengths are not reported
} else if (d == 16) {
d = vinfo.red.length + vinfo.green.length + vinfo.blue.length;
if (d <= 0)
d = 16;
}
lstep = finfo.line_length;
int xoff = vinfo.xoffset;
int yoff = vinfo.yoffset;
const char* qwssize;
if((qwssize=::getenv("QWS_SIZE")) && sscanf(qwssize,"%dx%d",&w,&h)==2) {
if (d_ptr->fd != -1) {
if ((uint)w > vinfo.xres) w = vinfo.xres;
if ((uint)h > vinfo.yres) h = vinfo.yres;
}
dw=w;
dh=h;
int xxoff, yyoff;
if (sscanf(qwssize, "%*dx%*d+%d+%d", &xxoff, &yyoff) == 2) {
if (xxoff < 0 || xxoff + w > vinfo.xres)
//.........这里部分代码省略.........
示例11: make_tuple
const std::tuple<MapFVTables, MapOCRanges> dXorg::parseOcTable() {
MapFVTables tables;
MapOCRanges ocRanges;
QStringList sl = getValueFromSysFsFile(driverFiles.sysFs.pp_od_clk_voltage).remove(' ')
.replace(QRegularExpression(":|MHz|mV", QRegularExpression::CaseInsensitiveOption), "|").split('\n');
// OD_VDDC_CURVE only in Vega20+
bool vega20Mode = sl.contains(QString(OD_VDDC_CURVE).append('|'));
for (auto i = 0; i < sl.length(); ++i) {
if (vega20Mode) {
if (sl.at(i).contains(OD_SCLK)) {
QStringList stateMin = sl[++i].split("|", QString::SkipEmptyParts);
QStringList stateMax = sl[++i].split("|", QString::SkipEmptyParts);
ocRanges.insert(OD_SCLK, OCRange(stateMin[1].toUInt(), stateMax[1].toUInt()));
continue;
}
if (sl.at(i).contains(OD_MCLK)) {
QStringList stateMax = sl[++i].split("|", QString::SkipEmptyParts);
ocRanges.insert(OD_MCLK, OCRange(0, stateMax[1].toUInt()));
continue;
}
}
QString tableKey;
for (; i < sl.length(); ++i) {
auto tableItems = sl[i].split("|", QString::SkipEmptyParts);
if (tableItems.length() == 1) {
if (tableItems[0] == OD_RANGE) {
for (++i; i < sl.length(); ++i) {
auto state = sl[i].split("|", QString::SkipEmptyParts);
if (state.length() == 1)
break;
ocRanges.insert(state[0], OCRange(state[1].toUInt(), state[2].toUInt()));
}
} else
tableKey = tableItems[0]; // next table key
} else {
FVTable fvt;
for (; i < sl.length(); ++i) {
auto state = sl[i].split("|", QString::SkipEmptyParts);
if (state.length() == 1) {
--i; // go back to next table start
break;
}
fvt.insert(state[0].toUInt(), FreqVoltPair(state[1].toUInt(), state[2].toUInt()));
}
tables.insert(tableKey, fvt);
}
}
}
return std::make_tuple(tables, ocRanges);
}
示例12: listValuesFromNode
QStringList Attribute::listValuesFromNode(const QDomElement &m_node)
{
QStringList result;
if (m_references.size() == 0) {
// Parse the content of the attribute
QDomElement content = m_node.firstChildElement();
if ((content.tagName() == "choice") && (m_name != "style:text-emphasize")) {
QDomElement valueChild = content.firstChildElement();
do {
if (valueChild.tagName() == "value") {
result << valueChild.text();
} else if (valueChild.tagName() == "ref") {
m_references << valueChild.attribute("name");
} else if (valueChild.tagName() == "list") {
// Parse that sublist
if (valueChild.childNodes().length() != 1) {
kFatal() << "Unrecognized list element in " << m_name;
}
QDomElement subElement = valueChild.firstChildElement();
if (subElement.nodeName() == "oneOrMore") {
// Build a list of each sub item
QStringList allowedValues;
QDomElement subChoices = subElement.firstChildElement();
if (subChoices.nodeName() != "choice") {
kFatal() << "Unrecognized oneOrMore element in " << m_name;
}
QDomElement subValueChild = subChoices.firstChildElement();
do {
if (subValueChild.nodeName() == "value") {
allowedValues << subValueChild.text();
} else {
kFatal() << "Unrecognized oneOrMore element in " << m_name;
}
subValueChild = subValueChild.nextSiblingElement();
} while (!subValueChild.isNull());
QStringList mergedAllowedValues;
while (mergedAllowedValues.length() != (pow((double) allowedValues.length(), allowedValues.length()))) {
foreach (QString baseValue, allowedValues) {
if (!mergedAllowedValues.contains(baseValue))
mergedAllowedValues << baseValue;
foreach (QString knownValue, mergedAllowedValues) {
if ((knownValue == baseValue) || (knownValue.contains(baseValue + ' ')) || (knownValue.contains(' ' + baseValue))) {
continue;
}
QString builtValue = knownValue + ' ' + baseValue;
if (!mergedAllowedValues.contains(builtValue))
mergedAllowedValues << builtValue;
}
}
}
foreach (QString allowedValue, mergedAllowedValues) {
QStringList equivalenceList;
equivalenceList << allowedValue;
QStringList currentList = allowedValue.split(' ');
currentList.sort();
foreach (QString otherAllowedValue, mergedAllowedValues) {
if (otherAllowedValue == allowedValue)
continue;
QStringList otherList = otherAllowedValue.split(' ');
otherList.sort();
if (otherList == currentList)
equivalenceList << otherAllowedValue;
}
equivalenceList.sort();
if (!m_equivalences.contains(equivalenceList))
m_equivalences << equivalenceList;
}
result << mergedAllowedValues;
}
} else {
示例13: resourceDirs
QStringList KStandardDirs::resourceDirs(const char *type) const
{
QStringList *candidates = dircache.find(type);
if(!candidates)
{ // filling cache
if(strcmp(type, "socket") == 0)
const_cast< KStandardDirs * >(this)->createSpecialResource(type);
else if(strcmp(type, "tmp") == 0)
const_cast< KStandardDirs * >(this)->createSpecialResource(type);
else if(strcmp(type, "cache") == 0)
const_cast< KStandardDirs * >(this)->createSpecialResource(type);
QDir testdir;
candidates = new QStringList();
QStringList *dirs;
bool restrictionActive = false;
if(d && d->restrictionsActive)
{
if(d->dataRestrictionActive)
restrictionActive = true;
else if(d->restrictions["all"])
restrictionActive = true;
else if(d->restrictions[type])
restrictionActive = true;
d->dataRestrictionActive = false; // Reset
}
dirs = relatives.find(type);
if(dirs)
{
bool local = true;
const QStringList *prefixList = 0;
if(strncmp(type, "xdgdata-", 8) == 0)
prefixList = &(d->xdgdata_prefixes);
else if(strncmp(type, "xdgconf-", 8) == 0)
prefixList = &(d->xdgconf_prefixes);
else
prefixList = &prefixes;
for(QStringList::ConstIterator pit = prefixList->begin(); pit != prefixList->end(); ++pit)
{
for(QStringList::ConstIterator it = dirs->begin(); it != dirs->end(); ++it)
{
QString path = realPath(*pit + *it);
testdir.setPath(path);
if(local && restrictionActive)
continue;
if((local || testdir.exists()) && !candidates->contains(path))
candidates->append(path);
}
local = false;
}
}
dirs = absolutes.find(type);
if(dirs)
for(QStringList::ConstIterator it = dirs->begin(); it != dirs->end(); ++it)
{
testdir.setPath(*it);
if(testdir.exists())
{
QString filename = realPath(*it);
if(!candidates->contains(filename))
candidates->append(filename);
}
}
dircache.insert(type, candidates);
}
#if 0
kdDebug() << "found dirs for resource " << type << ":" << endl;
for (QStringList::ConstIterator pit = candidates->begin();
pit != candidates->end();
pit++)
{
fprintf(stderr, "%s\n", (*pit).latin1());
}
#endif
return *candidates;
}
示例14: lookupDirectory
static void lookupDirectory(const QString &path, const QString &relPart, const QRegExp ®exp, QStringList &list, QStringList &relList,
bool recursive, bool unique)
{
QString pattern = regexp.pattern();
if(recursive || pattern.contains('?') || pattern.contains('*'))
{
if(path.isEmpty()) // for sanity
return;
// We look for a set of files.
DIR *dp = opendir(QFile::encodeName(path));
if(!dp)
return;
assert(path.at(path.length() - 1) == '/');
struct dirent *ep;
KDE_struct_stat buff;
QString _dot(".");
QString _dotdot("..");
while((ep = readdir(dp)) != 0L)
{
QString fn(QFile::decodeName(ep->d_name));
if(fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~')
continue;
if(!recursive && !regexp.exactMatch(fn))
continue; // No match
QString pathfn = path + fn;
if(KDE_stat(QFile::encodeName(pathfn), &buff) != 0)
{
kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl;
continue; // Couldn't stat (e.g. no read permissions)
}
if(recursive)
{
if(S_ISDIR(buff.st_mode))
{
lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, unique);
}
if(!regexp.exactMatch(fn))
continue; // No match
}
if(S_ISREG(buff.st_mode))
{
if(!unique || !relList.contains(relPart + fn))
{
list.append(pathfn);
relList.append(relPart + fn);
}
}
}
closedir(dp);
}
else
{
// We look for a single file.
QString fn = pattern;
QString pathfn = path + fn;
KDE_struct_stat buff;
if(KDE_stat(QFile::encodeName(pathfn), &buff) != 0)
return; // File not found
if(S_ISREG(buff.st_mode))
{
if(!unique || !relList.contains(relPart + fn))
{
list.append(pathfn);
relList.append(relPart + fn);
}
}
}
}
示例15: slotUpdateFileList
void PICComponent::slotUpdateFileList()
{
QStringList preFileList = KTechlab::self()->recentFiles();
QStringList fileList;
if ( ProjectInfo * info = ProjectManager::self()->currentProject() )
{
const KUrl::List urls = info->childOutputURLs( ProjectItem::AllTypes, ProjectItem::ProgramOutput );
KUrl::List::const_iterator urlsEnd = urls.end();
for ( KUrl::List::const_iterator it = urls.begin(); it != urlsEnd; ++it )
fileList << (*it).path();
}
const QStringList::iterator end = preFileList.end();
for ( QStringList::iterator it = preFileList.begin(); it != end; ++it )
{
QString file = KUrl(*it).path();
if ( (file.endsWith(".flowcode") || file.endsWith(".asm") || file.endsWith(".cod") || file.endsWith(".basic") || file.endsWith(".microbe") ) && !fileList.contains(file) ) {
fileList.append(file);
}
}
QString fileName = dataString("program");
property("program")->setAllowed(fileList);
property("program")->setValue( fileName.isEmpty() ? _def_PICComponent_fileName : fileName );
}