本文整理汇总了C++中QStringList::append方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::append方法的具体用法?C++ QStringList::append怎么用?C++ QStringList::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringList
的用法示例。
在下文中一共展示了QStringList::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse
static void parse( MetaTranslator *tor, const char *initialContext,
const char *defaultContext )
{
QMap<QCString, QCString> qualifiedContexts;
QStringList namespaces;
QCString context;
QCString text;
QCString com;
QCString functionContext = initialContext;
QCString prefix;
bool utf8 = FALSE;
bool missing_Q_OBJECT = FALSE;
yyTok = getToken();
while ( yyTok != Tok_Eof ) {
switch ( yyTok ) {
case Tok_class:
/*
Partial support for inlined functions.
*/
yyTok = getToken();
if ( yyBraceDepth == (int) namespaces.count() &&
yyParenDepth == 0 ) {
do {
/*
This code should execute only once, but we play
safe with impure definitions such as
'class Q_EXPORT QMessageBox', in which case
'QMessageBox' is the class name, not 'Q_EXPORT'.
*/
functionContext = yyIdent;
yyTok = getToken();
} while ( yyTok == Tok_Ident );
while ( yyTok == Tok_Gulbrandsen ) {
yyTok = getToken();
functionContext += "::";
functionContext += yyIdent;
yyTok = getToken();
}
if ( yyTok == Tok_Colon ) {
missing_Q_OBJECT = TRUE;
} else {
functionContext = defaultContext;
}
}
break;
case Tok_namespace:
yyTok = getToken();
if ( yyTok == Tok_Ident ) {
QCString ns = yyIdent;
yyTok = getToken();
if ( yyTok == Tok_LeftBrace &&
yyBraceDepth == (int) namespaces.count() + 1 )
namespaces.append( QString(ns) );
}
break;
case Tok_tr:
case Tok_trUtf8:
utf8 = ( yyTok == Tok_trUtf8 );
yyTok = getToken();
if ( match(Tok_LeftParen) && matchString(&text) ) {
com = "";
if ( match(Tok_RightParen) || (match(Tok_Comma) &&
matchString(&com) && match(Tok_RightParen)) ) {
if ( prefix.isNull() ) {
context = functionContext;
if ( !namespaces.isEmpty() )
context.prepend( (namespaces.join(QString("::")) +
QString("::")).latin1() );
} else {
context = prefix;
}
prefix = (const char *) 0;
if ( qualifiedContexts.contains(context) )
context = qualifiedContexts[context];
tor->insert( MetaTranslatorMessage(context, text, com,
QString::null, utf8) );
if ( lacks_Q_OBJECT.contains(context) ) {
qWarning( "%s:%d: Class '%s' lacks Q_OBJECT macro",
(const char *) yyFileName, yyLineNo,
(const char *) context );
lacks_Q_OBJECT.remove( context );
} else {
needs_Q_OBJECT.insert( context, 0 );
}
}
}
break;
case Tok_translate:
utf8 = FALSE;
yyTok = getToken();
if ( match(Tok_LeftParen) &&
matchString(&context) &&
match(Tok_Comma) &&
matchString(&text) ) {
com = "";
//.........这里部分代码省略.........
示例2: qml
QQmlEngine* MScore::qml()
{
if (_qml == 0) {
//-----------some qt bindings
_qml = new QQmlEngine;
#ifdef Q_OS_WIN
QStringList importPaths;
QDir dir(QCoreApplication::applicationDirPath() + QString("/../qml"));
importPaths.append(dir.absolutePath());
_qml->setImportPathList(importPaths);
#endif
#ifdef Q_OS_MAC
QStringList importPaths;
QDir dir(mscoreGlobalShare + QString("/qml"));
importPaths.append(dir.absolutePath());
_qml->setImportPathList(importPaths);
#endif
qmlRegisterType<MsProcess> ("MuseScore", 1, 0, "QProcess");
qmlRegisterType<FileIO, 1> ("FileIO", 1, 0, "FileIO");
//-----------mscore bindings
qmlRegisterUncreatableType<Direction>("MuseScore", 1, 0, "Direction", tr("You can't create an enumeration"));
qmlRegisterType<MScore> ("MuseScore", 1, 0, "MScore");
qmlRegisterType<MsScoreView>("MuseScore", 1, 0, "ScoreView");
// qmlRegisterType<QmlPlugin> ("MuseScore", 1, 0, "MuseScore");
qmlRegisterType<Score> ("MuseScore", 1, 0, "Score");
qmlRegisterType<Segment> ("MuseScore", 1, 0, "Segment");
qmlRegisterType<Chord> ("MuseScore", 1, 0, "Chord");
qmlRegisterType<Note> ("MuseScore", 1, 0, "Note");
qmlRegisterType<NoteHead> ("MuseScore", 1, 0, "NoteHead");
qmlRegisterType<Accidental> ("MuseScore", 1, 0, "Accidental");
qmlRegisterType<Rest> ("MuseScore", 1, 0, "Rest");
qmlRegisterType<Measure> ("MuseScore", 1, 0, "Measure");
qmlRegisterType<Cursor> ("MuseScore", 1, 0, "Cursor");
qmlRegisterType<StaffText> ("MuseScore", 1, 0, "StaffText");
qmlRegisterType<Part> ("MuseScore", 1, 0, "Part");
qmlRegisterType<Staff> ("MuseScore", 1, 0, "Staff");
qmlRegisterType<Harmony> ("MuseScore", 1, 0, "Harmony");
qmlRegisterType<PageFormat> ("MuseScore", 1, 0, "PageFormat");
qmlRegisterType<TimeSig> ("MuseScore", 1, 0, "TimeSig");
qmlRegisterType<KeySig> ("MuseScore", 1, 0, "KeySig");
qmlRegisterType<Slur> ("MuseScore", 1, 0, "Slur");
qmlRegisterType<Tie> ("MuseScore", 1, 0, "Tie");
qmlRegisterType<NoteDot> ("MuseScore", 1, 0, "NoteDot");
qmlRegisterType<FiguredBass>("MuseScore", 1, 0, "FiguredBass");
qmlRegisterType<Text> ("MuseScore", 1, 0, "MText");
qmlRegisterType<Lyrics> ("MuseScore", 1, 0, "Lyrics");
qmlRegisterType<FiguredBassItem>("MuseScore", 1, 0, "FiguredBassItem");
qmlRegisterType<LayoutBreak>("MuseScore", 1, 0, "LayoutBreak");
qmlRegisterType<Hook> ("MuseScore", 1, 0, "Hook");
qmlRegisterType<Stem> ("MuseScore", 1, 0, "Stem");
qmlRegisterType<StemSlash> ("MuseScore", 1, 0, "StemSlash");
qmlRegisterType<Beam> ("MuseScore", 1, 0, "Beam");
qmlRegisterType<Excerpt> ("MuseScore", 1, 0, "Excerpt");
qmlRegisterType<BarLine> ("MuseScore", 1, 0, "BarLine");
qmlRegisterType<FractionWrapper> ("MuseScore", 1, 1, "Fraction");
qRegisterMetaType<FractionWrapper*>("FractionWrapper*");
qmlRegisterUncreatableType<Element>("MuseScore", 1, 0,
"Element", tr("you cannot create an element"));
//classed enumerations
qmlRegisterUncreatableType<MSQE_TextStyleType>("MuseScore", 1, 0, "TextStyleType", tr("You can't create an enum"));
qmlRegisterUncreatableType<MSQE_BarLineType>("MuseScore", 1, 0, "BarLineType", tr("You can't create an enum"));
//-----------virtual classes
qmlRegisterType<ChordRest>();
qmlRegisterType<SlurTie>();
qmlRegisterType<Spanner>();
}
return _qml;
}
示例3: idsToNames
static QStringList idsToNames(QVector<ID> ids) {
QStringList decs;
foreach (ID id, ids) {
decs.append(Factory::name(id).c_str());
}
示例4: copySelectionToExcel
void QEnhancedTableView::copySelectionToExcel() {
if (!model()) return;
if (!selectionModel()) return;
QModelIndexList sel=selectionModel()->selectedIndexes();
QSet<int> rows, cols;
int colmin=0;
int rowmin=0;
for (int i=0; i<sel.size(); i++) {
int r=sel[i].row();
int c=sel[i].column();
rows.insert(r);
cols.insert(c);
if (i==0) {
colmin=c;
rowmin=r;
} else {
if (c<colmin) colmin=c;
if (r<rowmin) rowmin=r;
}
}
QList<int> rowlist=QList<int>::fromSet(rows);
qSort(rowlist.begin(), rowlist.end());
QList<int> collist=QList<int>::fromSet(cols);
qSort(collist.begin(), collist.end());
int rowcnt=rowlist.size();
int colcnt=collist.size();
QList<QStringList> data;
// header row:
//
// <EMPTY> | <HOR_HEDER1> | <HOR_HEADER2> | ...
QStringList hrow;
hrow.append(""); // empty header for first column (vertical headers!)
for (int c=0; c<colcnt; c++) {
hrow.append(QString("\"%1\"").arg(model()->headerData(collist[c], Qt::Horizontal).toString()));
}
data.append(hrow);
// now add dta rows:
//
// <~~~~~~~~~ colcnt times ~~~~~~~~~~>
// <VER_HEADER> | <EMPTY> | <EMPTY> | ... | <EMPTY>
for (int r=0; r<rowcnt; r++) {
QStringList row;
row.append(QString("\"%1\"").arg(model()->headerData(rowlist[r], Qt::Vertical).toString())); // vertical header
for (int c=0; c<colcnt; c++) {
row.append(""); // empty columns for data
}
data.append(row);
}
for (int i=0; i<sel.size(); i++) {
int r=rowlist.indexOf(sel[i].row());
int c=collist.indexOf(sel[i].column());
QVariant vdata=sel[i].data(Qt::EditRole);
QString txt="";
switch (vdata.type()) {
case QVariant::Int:
case QVariant::LongLong:
case QVariant::UInt:
case QVariant::ULongLong:
case QVariant::Bool:
txt=vdata.toString();
break;
case QVariant::Double:
txt=QLocale().toString(vdata.toDouble());
break;
case QVariant::PointF:
txt=QLocale().toString(vdata.toPointF().x());
break;
default:
txt=QString("\"%1\"").arg(vdata.toString());
break;
}
if ((r>=0) && (c>=0) && (r<=data.size()) && (c<=colcnt))data[r+1][c+1]=txt;
}
QString result="";
for (int r=0; r<data.size(); r++) {
result+=data[r].join("\t")+"\n";
}
QApplication::clipboard()->setText(result);
}
示例5: UAVDataObject
/**
* Constructor
*/
SystemSettings::SystemSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
{
// Create fields
QList<UAVObjectField *> fields;
QStringList GUIConfigDataElemNames;
GUIConfigDataElemNames.append("0");
GUIConfigDataElemNames.append("1");
GUIConfigDataElemNames.append("2");
GUIConfigDataElemNames.append("3");
fields.append( new UAVObjectField(QString("GUIConfigData"), QString("bits"), UAVObjectField::UINT32, GUIConfigDataElemNames, QStringList(), QString("")));
QStringList AirSpeedMaxElemNames;
AirSpeedMaxElemNames.append("0");
fields.append( new UAVObjectField(QString("AirSpeedMax"), QString("m/s"), UAVObjectField::FLOAT32, AirSpeedMaxElemNames, QStringList(), QString("")));
QStringList AirSpeedMinElemNames;
AirSpeedMinElemNames.append("0");
fields.append( new UAVObjectField(QString("AirSpeedMin"), QString("m/s"), UAVObjectField::FLOAT32, AirSpeedMinElemNames, QStringList(), QString("")));
QStringList AirframeTypeElemNames;
AirframeTypeElemNames.append("0");
QStringList AirframeTypeEnumOptions;
AirframeTypeEnumOptions.append("FixedWing");
AirframeTypeEnumOptions.append("FixedWingElevon");
AirframeTypeEnumOptions.append("FixedWingVtail");
AirframeTypeEnumOptions.append("VTOL");
AirframeTypeEnumOptions.append("HeliCP");
AirframeTypeEnumOptions.append("QuadX");
AirframeTypeEnumOptions.append("QuadP");
AirframeTypeEnumOptions.append("Hexa");
AirframeTypeEnumOptions.append("Octo");
AirframeTypeEnumOptions.append("Custom");
AirframeTypeEnumOptions.append("HexaX");
AirframeTypeEnumOptions.append("OctoV");
AirframeTypeEnumOptions.append("OctoCoaxP");
AirframeTypeEnumOptions.append("OctoCoaxX");
AirframeTypeEnumOptions.append("HexaCoax");
AirframeTypeEnumOptions.append("Tri");
AirframeTypeEnumOptions.append("GroundVehicleCar");
AirframeTypeEnumOptions.append("GroundVehicleDifferential");
AirframeTypeEnumOptions.append("GroundVehicleMotorcycle");
fields.append( new UAVObjectField(QString("AirframeType"), QString(""), UAVObjectField::ENUM, AirframeTypeElemNames, AirframeTypeEnumOptions, QString("")));
QStringList ThrustControlElemNames;
ThrustControlElemNames.append("0");
QStringList ThrustControlEnumOptions;
ThrustControlEnumOptions.append("Throttle");
ThrustControlEnumOptions.append("Collective");
ThrustControlEnumOptions.append("None");
fields.append( new UAVObjectField(QString("ThrustControl"), QString(""), UAVObjectField::ENUM, ThrustControlElemNames, ThrustControlEnumOptions, QString("")));
// Initialize object
initializeFields(fields, (quint8 *)&data, NUMBYTES);
// Set the default field values
setDefaultFieldValues();
// Set the object description
setDescription(DESCRIPTION);
// Set the Category of this object type
setCategory(CATEGORY);
connect(this, SIGNAL(objectUpdated(UAVObject *)), SLOT(emitNotifications()));
}
示例6: indexAttachment
// Index any files that are attached.
void IndexRunner::indexAttachment(qint32 lid, Resource &r) {
if (!officeFound)
return;
QLOG_DEBUG() << "indexing attachment to note " << lid;
if (!keepRunning || pauseIndexing) {
indexTimer->start();
return;
}
ResourceTable rtable(db);
qint32 reslid = rtable.getLid(r.guid);
if (lid <= 0) {
indexTimer->start();
return;
}
QLOG_DEBUG() << "Resource " << reslid;
QString extension = "";
ResourceAttributes attributes;
if (r.attributes.isSet())
attributes = r.attributes;
if (attributes.fileName.isSet()) {
extension = attributes.fileName;
int i = extension.indexOf(".");
if (i != -1)
extension = extension.mid(i);
}
if (extension != ".doc" && extension != ".xls" && extension != ".ppt" &&
extension != ".docx" && extension != ".xlsx" && extension != ".pptx" &&
extension != ".pps" && extension != ".pdf" && extension != ".odt" &&
extension != ".odf" && extension != ".ott" && extension != ".odm" &&
extension != ".html" && extension != ".txt" && extension != ".oth" &&
extension != ".ods" && extension != ".ots" && extension != ".odg" &&
extension != ".otg" && extension != ".odp" && extension != ".otp" &&
extension != ".odb" && extension != ".oxt" && extension != ".htm" &&
extension != ".docm")
return;
QString file = global.fileManager.getDbaDirPath() + QString::number(reslid) +extension;
QFile dataFile(file);
if (!dataFile.exists()) {
QDir dir(global.fileManager.getDbaDirPath());
QStringList filterList;
filterList.append(QString::number(lid)+".*");
QStringList list= dir.entryList(filterList, QDir::Files);
if (list.size() > 0) {
file = global.fileManager.getDbaDirPath()+list[0];
}
}
QString outDir = global.fileManager.getTmpDirPath();
QProcess sofficeProcess;
QString cmd = "soffice --headless --convert-to txt:\"Text\" --outdir "
+outDir + " "
+file;
sofficeProcess.start(cmd,
QIODevice::ReadWrite|QIODevice::Unbuffered);
QLOG_DEBUG() << "Starting soffice ";
sofficeProcess.waitForStarted();
QLOG_DEBUG() << "Waiting for completion";
sofficeProcess.waitForFinished();
int rc = sofficeProcess.exitCode();
QLOG_DEBUG() << "soffice Errors:" << sofficeProcess.readAllStandardError();
QLOG_DEBUG() << "soffice Output:" << sofficeProcess.readAllStandardOutput();
QLOG_DEBUG() << "return code:" << rc;
if (rc == 255) {
QLOG_ERROR() << "soffice not found. Disabling attachment indexing.";
this->officeFound = false;
return;
}
QFile txtFile(outDir+QString::number(reslid) +".txt");
if (txtFile.open(QIODevice::ReadOnly)) {
QString text;
text = txtFile.readAll();
NSqlQuery sql(db);
db->lockForWrite();
sql.prepare("Insert into SearchIndex (lid, weight, source, content) values (:lid, :weight, 'recognition', :content)");
sql.bindValue(":lid", lid);
sql.bindValue(":weight", 100);
sql.bindValue(":content", text);
QLOG_DEBUG() << "Adding note resource to index DB";
sql.exec();
db->unlock();
txtFile.close();
}
QDir dir;
dir.remove(outDir+QString::number(reslid) +".txt");
}
示例7: createLog
//.........这里部分代码省略.........
* open a new paragraph
*/
if(szTmpNick != szNick)
{
/*
* People is not the same, close the paragraph opened
* before and open a new one
*/
if(!bFirstLine)
szOutputBuffer += "</p>\n";
szTmp.prepend("<p>");
szNick = szTmpNick;
} else {
// Break the line
szTmp.prepend("<br />\n");
}
szOutputBuffer += szTmp;
bFirstLine = false;
}
// Close the last paragraph
szOutputBuffer += "</p>\n";
// regexp to search all embedded icons
rx.setPattern("<img src=\"smallicons:([^\"]+)");
int iIndex = szOutputBuffer.indexOf(rx);
QStringList szImagesList;
// search for icons
while (iIndex >= 0)
{
int iLength = rx.matchedLength();
QString szCap = rx.cap(1);
// if the icon isn't in the images list then add
if(szImagesList.indexOf(szCap) == -1)
szImagesList.append(szCap);
iIndex = szOutputBuffer.indexOf(rx, iIndex + iLength);
}
// get current theme path
QString szCurrentThemePath;
g_pApp->getLocalKvircDirectory(szCurrentThemePath,KviApplication::Themes,KVI_OPTION_STRING(KviOption_stringIconThemeSubdir));
szCurrentThemePath += KVI_PATH_SEPARATOR_CHAR;
// current coresmall path
szCurrentThemePath += "coresmall";
szCurrentThemePath += KVI_PATH_SEPARATOR_CHAR;
// check if coresmall exists in current theme
if(!KviFileUtils::directoryExists(szCurrentThemePath))
{
// get global coresmall path
g_pApp->getGlobalKvircDirectory(szCurrentThemePath,KviApplication::Pics,"coresmall");
KviQString::ensureLastCharIs(szCurrentThemePath,QChar(KVI_PATH_SEPARATOR_CHAR));
}
// copy all icons to the log destination folder
for(int i=0; i < szImagesList.count(); i++)
{
QString szSourceFile = szCurrentThemePath + szImagesList.at(i);
QString szDestFile = szLogDir + szImagesList.at(i);
KviFileUtils::copyFile(szSourceFile,szDestFile);
}
// remove internal tags
rx.setPattern("<qt>|</qt>|smallicons:");
szOutputBuffer.replace(rx,"");
szOutputBuffer.replace(">!nc",">");
szOutputBuffer.replace("@!nc","@");
szOutputBuffer.replace("%!nc","%");
// Close the document
szOutputBuffer += "</body>\n</html>\n";
break;
}
}
// File overwriting already dealt with when file path was obtained
QFile log(szLog);
if(!log.open(QIODevice::WriteOnly | QIODevice::Text))
return;
if(pszFile)
{
*pszFile = "";
*pszFile = info.filePath();
}
// Ensure we're writing in UTF-8
QTextStream output(&log);
output.setCodec("UTF-8");
output << szOutputBuffer;
// Close file descriptors
log.close();
}
示例8: it
// parsing
QHash<QString, QVariant> Parser::parse(QStringList argv)
{
QHash<QString, QVariant> map;
QStringListIterator it(argv);
QString programName = it.next();
QString optionPrefix;
QString flagPrefix;
QListIterator<PositionalDef *> positionals(m_positionals);
QStringList expecting;
getPrefix(optionPrefix, flagPrefix);
while (it.hasNext())
{
QString arg = it.next();
if (!expecting.isEmpty())
// we were expecting an argument
{
QString name = expecting.first();
/*
if (map.contains(name))
throw ParsingError(
QString("Option %2%1 was given multiple times").arg(name,
optionPrefix));
*/
map[name] = QVariant(arg);
expecting.removeFirst();
continue;
}
if (arg.startsWith(optionPrefix))
// we have an option
{
// qDebug("Found option %s", qPrintable(arg));
QString name = arg.mid(optionPrefix.length());
QString equals;
if ((m_argStyle == ArgumentStyle::Equals ||
m_argStyle == ArgumentStyle::SpaceAndEquals) &&
name.contains("="))
{
int i = name.indexOf("=");
equals = name.mid(i + 1);
name = name.left(i);
}
if (m_options.contains(name))
{
/*
if (map.contains(name))
throw ParsingError(QString("Option %2%1 was given multiple times")
.arg(name, optionPrefix));
*/
OptionDef *option = m_options[name];
if (option->type == otSwitch)
map[name] = true;
else // if (option->type == otOption)
{
if (m_argStyle == ArgumentStyle::Space)
expecting.append(name);
else if (!equals.isNull())
map[name] = equals;
else if (m_argStyle == ArgumentStyle::SpaceAndEquals)
expecting.append(name);
else
throw ParsingError(QString("Option %2%1 reqires an argument.")
.arg(name, optionPrefix));
}
continue;
}
throw ParsingError(QString("Unknown Option %2%1").arg(name, optionPrefix));
}
if (arg.startsWith(flagPrefix))
// we have (a) flag(s)
{
// qDebug("Found flags %s", qPrintable(arg));
QString flags = arg.mid(flagPrefix.length());
QString equals;
if ((m_argStyle == ArgumentStyle::Equals ||
m_argStyle == ArgumentStyle::SpaceAndEquals) &&
flags.contains("="))
{
int i = flags.indexOf("=");
equals = flags.mid(i + 1);
flags = flags.left(i);
}
for (int i = 0; i < flags.length(); i++)
{
//.........这里部分代码省略.........
示例9: createTime
QTime timeBox::createTime ( bool *ok )
{
// QString entry;
int h = 0, m = 0, is = 0;
double s = 0.0;
QTime qt;
bool valueFound = false, badEntry = false , checkValue = false;
//Initialize bool for result
if ( ok != NULL ) *ok = false;
// QString errMsg = i18n( "Unable to parse %1 entry. Specify a %1 value as a simple integer, a floating-point number, or a triplet of values using colons or spaces as separators." );
QString entry = text().stripWhiteSpace();
//Try simplest cases: integer or double representation
h = entry.toInt( &checkValue );
if ( checkValue ) {
qt = QTime( h, 0, 0 );
valueFound = true;
if ( ok != NULL ) *ok = true;
return qt;
} else {
double x = entry.toDouble( &checkValue );
if ( checkValue ) {
int seconds = int(x * 3600);
QTime qt(0,0,0);
qt.addSecs(seconds);
valueFound = true;
if ( ok != NULL ) *ok = true;
return qt;
}
}
//no success yet...try assuming multiple fields
if ( !valueFound ) {
QStringList fields;
//check for colon-delimiters or space-delimiters
if ( entry.contains(':') )
fields = QStringList::split( ':', entry );
else fields = QStringList::split( " ", entry );
// If two fields we will add a third one, and then parse with
// the 3-field code block. If field[1] is a double, convert
// it to integer mins, and convert the remainder to secs
if ( fields.count() == 2 ) {
double mx = fields[1].toDouble( &checkValue );
if ( checkValue ) {
fields[1] = QString("%1").arg( int(mx) );
fields.append( QString("%1").arg( int( 60.0*(mx - int(mx)) ) ) );
} else {
fields.append( QString( "0" ) );
}
}
// Three fields space-delimited ( h/d m s );
// ignore all after 3rd field
if ( fields.count() >= 3 ) {
fields[0].replace( QRegExp("h"), "" );
fields[1].replace( QRegExp("m"), "" );
fields[2].replace( QRegExp("s"), "" );
}
//See if first two fields parse as integers.
//
h = fields[0].toInt( &checkValue );
if ( !checkValue ) badEntry = true;
m = fields[1].toInt( &checkValue );
if ( !checkValue ) badEntry = true;
s = fields[2].toDouble( &checkValue );
if ( !checkValue ) badEntry = true;
if ( !badEntry ) {
valueFound = true;
is = (int)s;
if ( ok != NULL ) *ok = true;
QTime qt(h,m,is);
return qt;
} else {
if ( ok != NULL ) *ok = false;
}
}
// if ( !valueFound )
// KMessageBox::sorry( 0, errMsg.arg( "Angle" ), i18n( "Could Not Set Value" ) );
return qt;
}
示例10: createProcessingScript
/** Adds user values from the GUI into the Python script
* @param runFiles :: a comma separated list of data file names
* @param whiteBeam :: The filename of the white beam run
* @param absRunFiles :: run files for absolute normalization
* @param absWhiteBeam :: run file for absolute white beam normalization
* @param saveName :: filename for output saving
*/
void deltaECalc::createProcessingScript(const QStringList &runFiles,
const QString &whiteBeam,
const QStringList &absRunFiles,
const QString &absWhiteBeam,
const QString &saveName) {
QString pyCode = "import Direct.DirectEnergyConversion as direct\n";
pyCode += QString("mono_sample = direct.DirectEnergyConversion('%1')\n")
.arg(m_sets.cbInst->currentText());
// Turn off printing to stdout
pyCode += QString("mono_sample.prop_man.log_to_mantid = True\n");
addAnalysisOptions(pyCode);
addMaskingCommands(pyCode);
// Check save formats
QStringList fileExts;
if (m_sets.save_ckSPE->isChecked()) {
fileExts.append("'spe'");
}
if (m_sets.save_ckNexus->isChecked()) {
fileExts.append("'nxs'");
}
if (m_sets.save_ckNxSPE->isChecked()) {
fileExts.append("'nxspe'");
}
if (fileExts.size() == 0)
pyCode += "mono_sample.prop_man.save_format = None\n";
else
pyCode +=
"mono_sample.prop_man.save_format = " + fileExts.join(",") + "\n\n";
// Create the python variables. The strings are wrapped with r'' for slash
// safety
QString pyRunFiles = createPyListAsString(runFiles);
QString eiGuess = m_sets.leEGuess->text();
QString pyWhiteBeam =
(whiteBeam.isEmpty()) ? "None" : QString("r'" + whiteBeam + "'");
// Absolute values
QString pyAbsRunFiles = createPyListAsString(absRunFiles);
QString absEiGuess = m_sets.leVanEi->text();
QString pyAbsWhiteBeam =
(absWhiteBeam.isEmpty()) ? "None" : QString("r'" + absWhiteBeam + "'");
// SE Offset value
QString seOffset = m_sets.seOffsetEdit->text();
QString pySeOffset = (seOffset.isEmpty()) ? "None" : seOffset;
// SE Motor Name
QString motorName = m_sets.motorNameEdit->text();
QString pyMotorName =
(motorName.isEmpty()) ? "None" : QString("r'" + motorName + "'");
QString None = "None";
auto rebin = None;
auto map_file = None;
pyCode += "mono_sample.prop_man.motor_name = " + pyMotorName + "\n";
pyCode += "mono_sample.prop_man.motor_offset = " + pySeOffset + "\n";
if (m_sets.ckSumSpecs->isChecked() || runFiles.size() == 1) {
if (m_sets.ckSumSpecs->isChecked())
pyCode += "mono_sample.prop_man.sum_runs = True\n";
QString pySaveName;
if (saveName.isEmpty()) {
pyCode += "mono_sample.prop_man.save_file_name = None\n";
} else {
pyCode += "mono_sample.prop_man.save_file_name = r'" + saveName + "'\n";
}
pyCode +=
QString("mono_sample.convert_to_energy(%1, %2, %3, %4, %5, %6, %7)");
pyCode = pyCode.arg(pyWhiteBeam, pyRunFiles, eiGuess, rebin, map_file,
pyAbsRunFiles, pyAbsWhiteBeam);
} else {
QString pySaveName;
if (saveName.isEmpty()) {
pySaveName = "r'" + QFileInfo(saveName).absolutePath() + "'";
pyCode += "mono_sample.prop_man.save_file = " + pySaveName + "\n";
}
pyCode += "rfiles = " + pyRunFiles + "\n";
if (absRunFiles.isEmpty()) {
pyCode += "for run in rfiles:\n"
" mono_sample.convert_to_energy(run, %1, %2)\n";
pyCode = pyCode.arg(eiGuess, pyWhiteBeam);
} else {
pyCode += "abs_rfiles = " + pyAbsRunFiles + "\n";
pyCode += "for run, abs in zip(rfiles, abs_rfiles):\n"
" mono_sample.convert_to_energy(%1, run, %2, %3,abs, %6)\n";
pyCode = pyCode.arg(pyWhiteBeam, eiGuess, rebin, map_file, pyAbsRunFiles,
pyAbsWhiteBeam);
// pyWhiteBeam,pyRunFiles,
// eiGuess,rebin,map_file,pyAbsRunFiles,
// pyAbsWhiteBeam
}
}
//.........这里部分代码省略.........
示例11: setAttribute
void vtkDataMeshInteractor::setAttribute(const QString & attributeName)
{
vtkPointSet * pointSet = vtkPointSet::SafeDownCast(d->metaDataSet->GetDataSet());
if ( ! pointSet )
return;
vtkDataSetAttributes * attributes = NULL;
vtkMapper * mapper2d = d->actor2d->GetMapper();
vtkMapper * mapper3d = d->actor3d->GetMapper();
if (pointSet->GetPointData()->HasArray(qPrintable(attributeName)))
{
attributes = pointSet->GetPointData();
mapper2d->SetScalarModeToUsePointFieldData();
mapper3d->SetScalarModeToUsePointFieldData();
}
else if (pointSet->GetCellData()->HasArray(qPrintable(attributeName)))
{
attributes = pointSet->GetCellData();
mapper2d->SetScalarModeToUseCellFieldData();
mapper3d->SetScalarModeToUseCellFieldData();
}
if (attributes)
{
if(d->colorParam)
d->colorParam->hide();
if(d->LUTParam)
{
QStringList luts;
const std::vector<std::string> & vec = vtkLookupTableManager::GetAvailableLookupTables();
for(std::vector<std::string>::const_iterator it = vec.begin(); it < vec.end(); ++it)
luts.append(QString::fromStdString(*it));
d->LUTParam->clear();
foreach(QString lut, luts)
d->LUTParam->addItem(lut);
d->attribute = attributes->GetArray(qPrintable(attributeName));
attributes->SetActiveScalars(qPrintable(attributeName));
d->LUTParam->show();
}
mapper2d->SelectColorArray(qPrintable(attributeName));
mapper3d->SelectColorArray(qPrintable(attributeName));
this->setLut(d->lut.first);
mapper2d->SetScalarVisibility(1);
mapper3d->SetScalarVisibility(1);
}
else
{
if(d->LUTParam)
d->LUTParam->hide();
if(d->colorParam)
d->colorParam->show();
d->attribute = NULL;
mapper2d->SetScalarVisibility(0);
mapper3d->SetScalarVisibility(0);
}
d->render->Render();
}
示例12: checkIncludes
Indicator * CUS::calculate ()
{
Config config;
QStringList varList;
QDict<PlotLine> lines;
lines.setAutoDelete(TRUE);
checkIncludes();
Indicator *output = new Indicator;
output->setDateFlag(dateFlag);
output->setLogScale(logScale);
int loop;
for (loop = 0; loop < (int) formulaList.count(); loop++)
{
// check if whole line is a comment
QString s = formulaList[loop].left(2);
if ( ! s.compare("//"))
continue;
if (formulaList[loop].contains(":="))
{
QStringList l = QStringList::split(":=", formulaList[loop], FALSE);
if (l.count() != 2)
{
qDebug("CUS::calculate: line %i parm missing", loop);
return output;
}
QString var = l[0].stripWhiteSpace();
if (varList.findIndex(var) != -1)
{
qDebug("CUS::calculate: line %i duplicate variable: %s", loop, var.latin1());
return output;
}
varList.append(var);
QStringList l2 = QStringList::split("(", l[1], FALSE);
if (l2.count() != 2)
{
qDebug("CUS::calculate: line %i bad indicator format", loop);
return output;
}
QString plugin = l2[0].stripWhiteSpace();
QString parms = l2[1];
parms.truncate(parms.find(")", 0, TRUE));
parms = parms.stripWhiteSpace();
while(parms.contains(" "))
parms = parms.remove(parms.find(" ", 0, TRUE), 1);
IndicatorPlugin *plug = config.getIndicatorPlugin(plugin);
if (! plug)
{
qDebug("CUS::calculate: %s plugin not loaded", plugin.latin1());
config.closePlugin(plugin);
return output;
}
plug->setIndicatorInput(data);
l = QStringList::split(",", parms, FALSE);
int loop2;
QPtrList<PlotLine> inList;
inList.setAutoDelete(FALSE);
for (loop2 = 0; loop2 < (int) l.count(); loop2++)
{
if (varList.findIndex(l[loop2]) != -1)
inList.append(lines.find(l[loop2]));
else
{
int itype = inputTypeList.findIndex(l[loop2]);
if (itype != -1)
{
PlotLine *in = data->getInput((BarData::InputType) itype);
if (! in)
{
qDebug("CUS::calculate:line%i parm%i: input not found", loop, loop2);
return output;
}
lines.replace(l[loop2], in);
inList.append(in);
}
}
}
PlotLine *out = plug->calculateCustom(parms, inList);
if (! out)
{
qDebug("CUS::calculate: line %i: no PlotLine returned: %s", loop, parms.latin1());
config.closePlugin(plugin);
return output;
}
lines.replace(var, out);
}
createPlot(formulaList[loop], lines, output);
}
//.........这里部分代码省略.........
示例13: modal_widg
//.........这里部分代码省略.........
QList<qt_mac_filter_name*> filts = makeFiltersList(filter);
qt_mac_nav_filter_type t;
t.index = 0;
t.filts = &filts;
if(filts.count() > 1) {
int i = 0;
CFStringRef *arr = (CFStringRef *)malloc(sizeof(CFStringRef) * filts.count());
for (QList<qt_mac_filter_name*>::Iterator it = filts.begin(); it != filts.end(); ++it) {
QString rg = (*it)->description;
arr[i++] = CFStringCreateWithCharacters(NULL, (UniChar *)rg.unicode(), rg.length());
}
options.popupExtension = CFArrayCreate(NULL, (const void **)arr, filts.count(), NULL);
}
NavDialogRef dlg;
if(directory) {
if(NavCreateChooseFolderDialog(&options, make_navProcUPP(), NULL, NULL, &dlg)) {
qDebug("Shouldn't happen %s:%d", __FILE__, __LINE__);
return retstrl;
}
} else {
if(NavCreateGetFileDialog(&options, NULL, make_navProcUPP(), NULL,
make_navFilterUPP(), (void *) (filts.isEmpty() ? NULL : &t),
&dlg)) {
qDebug("Shouldn't happen %s:%d", __FILE__, __LINE__);
return retstrl;
}
}
if(pwd && !pwd->isEmpty()) {
FSRef fsref;
if(qt_mac_create_fsref(*pwd, &fsref) == noErr) {
AEDesc desc;
if(AECreateDesc(typeFSRef, &fsref, sizeof(FSRef), &desc) == noErr)
NavCustomControl(dlg, kNavCtlSetLocation, (void*)&desc);
}
}
NavDialogRun(dlg);
if (selectedFilter) {
NavMenuItemSpec navSpec;
bzero(&navSpec, sizeof(NavMenuItemSpec));
qt_mac_filter_name *sel_filt_name = makeFiltersList(*selectedFilter).at(0);
for (int i = 0; i < filts.count(); ++i) {
const qt_mac_filter_name *filter = filts.at(i);
if (sel_filt_name->description == filter->description
&& sel_filt_name->regxp == filter->regxp
&& sel_filt_name->filter == filter->filter) {
navSpec.menuType = i;
break;
}
}
NavCustomControl(dlg, kNavCtlSelectCustomType, &navSpec);
}
if(options.modality == kWindowModalityWindowModal) { //simulate modality
QWidget modal_widg(parent, __FILE__ "__modal_dlg",
Qt::WType_TopLevel | Qt::WStyle_Customize | Qt::WStyle_DialogBorder);
modal_widg.createWinId();
QApplicationPrivate::enterModal(&modal_widg);
while(g_nav_blocking)
qApp->processEvents(QEventLoop::WaitForMoreEvents);
QApplicationPrivate::leaveModal(&modal_widg);
}
if(!(NavDialogGetUserAction(dlg) &
(kNavUserActionOpen | kNavUserActionChoose | kNavUserActionNewFolder))) {
NavDialogDispose(dlg);
return retstrl;
}
NavReplyRecord ret;
NavDialogGetReply(dlg, &ret);
NavDialogDispose(dlg);
long count;
err = AECountItems(&(ret.selection), &count);
if(!ret.validRecord || err != noErr || !count) {
NavDisposeReply(&ret);
return retstrl;
}
for(long index = 1; index <= count; index++) {
FSRef ref;
err = AEGetNthPtr(&(ret.selection), index, typeFSRef, 0, 0, &ref, sizeof(ref), 0);
if(err != noErr)
break;
if(!str_buffer) {
qAddPostRoutine(cleanup_str_buffer);
str_buffer = (UInt8 *)malloc(1024);
}
FSRefMakePath(&ref, str_buffer, 1024);
retstrl.append(QString::fromUtf8((const char *)str_buffer));
}
NavDisposeReply(&ret);
if(selectedFilter)
*selectedFilter = filts.at(t.index)->filter;
while (!filts.isEmpty())
delete filts.takeFirst();
return retstrl;
}
示例14: getDeviceRegistryProperty
static QVariant getDeviceRegistryProperty(::HDEVINFO DeviceInfoSet,
::PSP_DEVINFO_DATA DeviceInfoData,
::DWORD property)
{
::DWORD dataType = 0;
::DWORD dataSize = 0;
QVariant v;
::SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
DeviceInfoData,
property,
&dataType,
0,
0,
&dataSize);
QByteArray data(dataSize, 0);
if (::SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
DeviceInfoData,
property,
0,
reinterpret_cast<unsigned char*>(data.data()),
dataSize,
0)) {
switch (dataType) {
case REG_EXPAND_SZ:
case REG_SZ: {
QString s;
if (dataSize) {
s = QString::fromWCharArray(((const wchar_t *)data.constData()));
}
v = QVariant(s);
break;
}
case REG_MULTI_SZ: {
QStringList l;
if (dataSize) {
int i = 0;
for (;;) {
QString s = QString::fromWCharArray((const wchar_t *)data.constData() + i);
i += s.length() + 1;
if (s.isEmpty())
break;
l.append(s);
}
}
v = QVariant(l);
break;
}
case REG_NONE:
case REG_BINARY: {
QString s;
if (dataSize) {
s = QString::fromWCharArray((const wchar_t *)data.constData(), data.size() / 2);
}
v = QVariant(s);
break;
}
case REG_DWORD_BIG_ENDIAN:
case REG_DWORD: {
Q_ASSERT(data.size() == sizeof(int));
int i = 0;
::memcpy((void *)(&i), data.constData(), sizeof(int));
v = i;
break;
}
default:
v = QVariant();
}
}
return v;
}
示例15: QMainWindow
/* 主窗口
* 初始化
* modelIndex -> Index2 -> 指标表
* model -> data > 数据表
*/
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
// Qt::WindowFlags flags=Qt::Dialog;
// flags = Qt::WindowMinimizeButtonHint&~Qt::WindowMaximizeButtonHint;
// setWindowFlags(flags);
setupUi(this);
//modelIndex --index2
kjAnalytics =new DynamicArray();
kjAnalyticsAll =new DynamicArray();
modelIndex = new QSqlRelationalTableModel(this);
QString tableNameI="Index2";
modelIndex->setTable (tableNameI);
modelIndex->setEditStrategy (QSqlTableModel::OnManualSubmit);
modelIndex->select ();
//model -- data
model= new QSqlRelationalTableModel(this);
tableName="data_all";
model->setTable (tableName);
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
this->setHeader ();
//生成年份下拉筐的备选项
model->select ();
//model -- data2
model2=new QSqlRelationalTableModel(this);
QString tableName2="data2";
model2->setTable (tableName2);
model2->setEditStrategy(QSqlTableModel::OnManualSubmit);
model2->select();
//model -- data3
model3=new QSqlRelationalTableModel(this);
QString tableName3="data3";
model3->setTable (tableName3);
model3->setEditStrategy(QSqlTableModel::OnManualSubmit);
model3->select();
//model -- data4
model4=new QSqlRelationalTableModel(this);
QString tableName4="data4";
model4->setTable (tableName4);
model4->setEditStrategy(QSqlTableModel::OnManualSubmit);
model4->select();
AllIndexTable();
typeModel = new QStringListModel;
typeModel1 = new QStringListModel;
tableName="data_all";
model->setTable (tableName);
//生成年份下拉筐的备选项
model->select ();
int rowC = model->rowCount ();
QStringList qsl;
qsl.append ("全部");
for (int i = 0; i < rowC ; ++i) {
if(!qsl.contains (model->record (i).value ("year").toString ()))
qsl.append (model->record (i).value ("year").toString ());
}
typeModel->setStringList (qsl);
year_comboBox->setModel (typeModel);
year_comboBox->show ();
//设置表格控件显示内容 model
model->setTable (tableName);
setHeader ();
setFilter ();
model->setSort(0,Qt::AscendingOrder);
model->select();
all_tableView->setModel (model);
all_tableView->hideColumn (0);
// QTableView *view = new QTableView;
// view->setModel(model2);
// //view->hideColumn(0); // don't show the ID
// view->show();
// QTableView *view1 = new QTableView;
// view1->setModel(model3);
//.........这里部分代码省略.........