本文整理汇总了C++中QStringList::join方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::join方法的具体用法?C++ QStringList::join怎么用?C++ QStringList::join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringList
的用法示例。
在下文中一共展示了QStringList::join方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeSmartFilterRegex
QString computeSmartFilterRegex(const QStringList &filters)
{
return QString("(?:_|\\b)(?:%1)(?:_|\\b)").arg(filters.join(QString(")|(?:")));
}
示例2: import
//.........这里部分代码省略.........
QDirIterator loopAirportsFiles( mainObject->X->airports_path(), QDirIterator::Subdirectories );
QString xFileName;
msg = "FGx airportsdata reload: Scanning XML files in "+mainObject->X->airports_path();
outLog(msg);
progress.setWindowTitle(msg);
progress.setRange(0, 50000);
// Check the fgfs additional argument list,
// and/or any additional scenery path inputs
// *** take care NOT to duplicate ***
QStringList fgfs_args = mainObject->X->get_fgfs_args();
int i, ind;
QDir d;
QString path;
#ifdef Q_OS_WIN
QChar psep(';');
#else
QChar psep(':');
#endif
// AIIIIII, found the doubler !, said yves very very loud - well done said pete ;-)
for (i = 0; i < fgfs_args.size(); i++) {
msg = fgfs_args.at(i);
ind = msg.indexOf(QChar('"'));
if (ind == 0)
msg = msg.mid(1,msg.length()-2);
if (msg.indexOf("--fg-scenery=") == 0) {
// got a scenery folder to scan
msg = msg.mid(13);
ind = msg.indexOf(QChar('"'));
if (ind == 0)
msg = msg.mid(1,msg.length()-2);
QStringList path_list = msg.split(psep);
int pathnumber = 0;
for( QStringList::ConstIterator entry = path_list.begin(); entry != path_list.end(); entry++) {
path = *entry;
pathnumber = pathnumber + 1;
if (d.exists(path)) {
// we have a PATH to check, but we are ONLY checking 'Airports'
if ( !(path.indexOf(QChar('/')) == (path.size()-1)) &&
!(path.indexOf(QChar('\\')) == (path.size()-1)) )
path.append("/");
path.append("Airports"); // XML is only in here
if (!d.exists(path))
continue;
QDirIterator loopFiles( path, QDirIterator::Subdirectories );
while (loopFiles.hasNext()) {
//= Get file handle if there is one
xFileName = loopFiles.next();
//= Check if file entry is a *.threshold.xml - cos this is what we want
if(xFileName.endsWith(".threshold.xml") ){
//= Split out "CODE.threshold.xml" with a "."
QFileInfo fileInfoThreshold(xFileName);
QString airport_code = fileInfoThreshold.fileName().split(".").at(0);
//* Update progress
if(c % 100 == 0){
progress.setValue(c);
progress.setLabelText(xFileName);
progress.repaint();
}
QString airport_name("");
if(airports.contains(airport_code)){
airport_name = airports.value(airport_code);
}
QStringList cols; // missing in middle is description ??
cols << airport_code << airport_name << fileInfoThreshold.absoluteDir().absolutePath() << QString::number(pathnumber);
out << cols.join("\t").append("\n");
air_added++;
found++;
}
if(progress.wasCanceled()){
progress.hide();
return true;
}
c++;
}
}
}
}
}
cacheFile.close();
msg.sprintf("*** FGx airportsdata reload: Walked %d files, found %d threshold.xml, appended %d to cache",
c, found, air_added);
outLog(msg+", in "+getElapTimeStg(tm.elapsed()));
progress.hide();
return false;
}
示例3: qstringlist_process
QString qstringlist_process (const QString &s, const QString ¶ms, int mode)
{
QStringList sl;
QStringList l;
QString result;
if (mode != QSTRL_PROC_FLT_WITH_SORTCASECARE_SEP && mode != QSTRL_PROC_LIST_FLIP_SEP)
sl = s.split (QChar::ParagraphSeparator);
switch (mode)
{
case QSTRL_PROC_FLT_WITH_SORTCASECARE_SEP:
{
if (s.indexOf (params) == -1)
return s;
QStringList sl = s.split (params);
sl.sort();
result = sl.join (params);
return result;
};
case QSTRL_PROC_LIST_FLIP_SEP: {
if (s.indexOf (params) == -1)
return s;
QStringList sl = s.split (params);
sl.sort();
foreach (QString t, sl)
l.prepend (t);
result = l.join (params);
return result;
};
case QSTRL_PROC_FLT_WITH_SORTNOCASECARE:
{
QMap <QString, QString> map;
foreach (QString value, sl)
map.insert (value.toLower(), value);
foreach (QString value, map)
l.append (value);
break;
}
case QSTRL_PROC_FLT_REMOVE_EMPTY:
{
foreach (QString s, sl)
if (! s.isEmpty())
l.append (s);
break;
};
case QSTRL_PROC_FLT_REMOVE_DUPS:
{
foreach (QString s, sl)
if (! l.contains (s))
l.append (s);
break;
};
case QSTRL_PROC_REMOVE_FORMATTING:
{
foreach (QString t, sl)
l.append (t.simplified());
break;
};
case QSTRL_PROC_FLT_WITH_REGEXP:
{
l = sl.filter (QRegExp (params));
break;
}
case QSTRL_PROC_FLT_WITH_SORTCASECARE:
{
l = sl;
l.sort();
break;
}
case QSTRL_PROC_LIST_FLIP:
{
foreach (QString t, sl)
l.prepend (t);
break;
}
case QSTRL_PROC_FLT_LESS:
{
int t = params.toInt();
foreach (QString s, sl)
//.........这里部分代码省略.........
示例4: sFillCustom
void dspTimePhasedOpenAPItems::sFillCustom()
{
if (!_periods->isPeriodSelected())
{
if (isVisible())
QMessageBox::warning( this, tr("Select Calendar Periods"),
tr("Please select one or more Calendar Periods") );
return;
}
_columnDates.clear();
_apopen->setColumnCount(2);
QString sql("SELECT vend_id, vend_number, vend_name");
QStringList linetotal;
int columns = 1;
QList<XTreeWidgetItem*> selected = _periods->selectedItems();
for (int i = 0; i < selected.size(); i++)
{
PeriodListViewItem *cursor = (PeriodListViewItem*)selected[i];
QString bucketname = QString("bucket%1").arg(columns++);
sql += QString(", openAPItemsValue(vend_id, %2) AS %1,"
" 'curr' AS %3_xtnumericrole, 0 AS %4_xttotalrole")
.arg(bucketname)
.arg(cursor->id())
.arg(bucketname)
.arg(bucketname);
_apopen->addColumn(formatDate(cursor->startDate()), _bigMoneyColumn, Qt::AlignRight, true, bucketname);
_columnDates.append(DatePair(cursor->startDate(), cursor->endDate()));
linetotal << QString("openAPItemsValue(vend_id, %1)").arg(cursor->id());
}
_apopen->addColumn(tr("Total"), _bigMoneyColumn, Qt::AlignRight, true, "linetotal");
sql += ", " + linetotal.join("+") + " AS linetotal,"
" 'curr' AS linetotal_xtnumericrole,"
" 0 AS linetotal_xttotalrole,"
" (" + linetotal.join("+") + ") = 0.0 AS xthiddenrole "
"FROM vend "
"<? if exists(\"vend_id\") ?>"
"WHERE (vend_id=<? value (\"vend_id\") ?>)"
"<? elseif exists(\"vendtype_id\") ?>"
"WHERE (vend_vendtype_id=<? value (\"vendtype_id\") ?>)"
"<? elseif exists(\"vendtype_code\") ?>"
"WHERE (vend_vendtype_id IN (SELECT vendtype_id FROM vendtype WHERE (vendtype_code ~ <? value (\"vendtype_pattern\") ?>))) "
"<? endif ?>"
"ORDER BY vend_number;";
MetaSQLQuery mql(sql);
ParameterList params;
if (! setParams(params))
return;
q = mql.toQuery(params);
_apopen->populate(q);
if (q.lastError().type() != QSqlError::NoError)
{
systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
return;
}
}
示例5: 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 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._to_stdout = False\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'");
}
pyCode += "mono_sample.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 + "'");
if( m_sets.ckSumSpecs->isChecked() || runFiles.size() == 1)
{
QString pySaveName;
if( saveName.isEmpty() )
{
pySaveName = "None";
}
else
{
pySaveName = "r'" + saveName + "'";
}
pyCode += QString("mono_sample.convert_to_energy(%1, %2, %3, %4, %5, %6, %7, motor=%8, offset=%9)");
pyCode = pyCode.arg(pyRunFiles, eiGuess,pyWhiteBeam,pyAbsRunFiles,absEiGuess, pyAbsWhiteBeam, pySaveName, pyMotorName, pySeOffset);
}
else
{
QString pySaveName;
if( saveName.isEmpty() )
{
pySaveName = "None";
}
else
{
pySaveName = "r'" + QFileInfo(saveName).absolutePath() + "'";
}
pyCode += "rfiles = " + pyRunFiles + "\n";
if( absRunFiles.isEmpty() )
{
pyCode +=
"for run in rfiles:\n"
" mono_sample.convert_to_energy(run, %1, %2, save_path=%3, motor=%4, offset=%5)\n";
pyCode = pyCode.arg(eiGuess, pyWhiteBeam, pySaveName, pyMotorName, pySeOffset);
}
else
{
pyCode += "abs_rfiles = " + pyAbsRunFiles + "\n";
pyCode +=
"for run, abs in zip(rfiles, abs_rfiles):\n"
" mono_sample.convert_to_energy(run, %1, %2, abs, %3, %4, save_path=%5, motor=%6, offset=%7)\n";
pyCode = pyCode.arg(eiGuess, pyWhiteBeam, absEiGuess, pyAbsWhiteBeam, pySaveName, pyMotorName, pySeOffset);
}
}
m_pyScript = pyCode;
}
示例6: main
int main( int argc, char * argv[] )
{
// first look for data directory
if( !QDir("data").exists() )
{
qWarning( "! %s", qPrintable(QObject::tr("Data directory not found in current working directory! Searching...")) );
QString newWorkingDirectory;
QStringList dataSearchPaths;
dataSearchPaths << "./";
dataSearchPaths << "../";
QStringList::const_iterator i;
for( i = dataSearchPaths.constBegin(); i != dataSearchPaths.constEnd(); ++i )
{
QDir dir((*i)+"data");
if( dir.exists() )
{
newWorkingDirectory = (*i);
// qDebug( "* %s", qPrintable(QObject::tr("Data directory found at \"%1\"").arg(newWorkingDirectory)) );
break;
}
}
if( newWorkingDirectory.isNull() )
{
qFatal( "E %s", qPrintable(QObject::tr("Data directory not found! Tried: \"%1\"!").arg(dataSearchPaths.join("\" \""))) );
}
if( !QDir::setCurrent( newWorkingDirectory ) )
{
qFatal( "E %s", qPrintable(QObject::tr("Could not change working directory to \"%1\"!").arg(newWorkingDirectory)) );
}
qDebug( "* %s", qPrintable(QObject::tr("Changed working directory to \"%1\"").arg(newWorkingDirectory)) );
}
// needed for QSettings
QCoreApplication::setOrganizationName( "Splatterlinge" );
QCoreApplication::setApplicationName( "Splatterlinge" );
QTextCodec::setCodecForLocale( QTextCodec::codecForName( "UTF-8" ) );
QApplication::setDesktopSettingsAware( false );
QApplication::setStyle( QStyleFactory::create( "Plastique" ) );
QApplication app( argc, argv );
MainWindow window;
window.show();
return app.exec();
}
示例7: on_list_variables_itemClicked
void radeon_profile::on_list_variables_itemClicked(QListWidgetItem *item)
{
ui->list_vaules->clear();
if (item->text().contains("----")) // the separator
return;
if (envVars.isEmpty())
return;
// read variable possible values from file
QStringList values = envVars.filter(ui->list_variables->currentItem()->text())[0].remove(ui->list_variables->currentItem()->text()+"|").split("#",QString::SkipEmptyParts);
// if value for this variable is 'user_input' display a window for input
if (values[0] == "user_input") {
bool ok;
QString input = QInputDialog::getText(this, tr("Enter value"), tr("Enter valid value for ") + ui->list_variables->currentItem()->text(), QLineEdit::Normal,"",&ok);
// look for this variable in list
int varIndex = selectedVariableVaules.indexOf(QRegExp(ui->list_variables->currentItem()->text()+".+",Qt::CaseInsensitive),0);
if (!input.isEmpty() && ok) {
// if value was ok
if (varIndex == -1)
// add it to list
selectedVariableVaules.append(ui->list_variables->currentItem()->text()+"="+input);
else
// replace if already exists
selectedVariableVaules[varIndex] = ui->list_variables->currentItem()->text()+"=\""+input+"\"";
} else {
// hehe, looks weird but check ok status is for, when input was empty, and whether user click ok or cancel, dispaly quesion
if ((varIndex != -1) || ok) {
if (QMessageBox::question(this, tr("Question"), tr("Remove this item?"), QMessageBox::Yes | QMessageBox::No,QMessageBox::Yes) == QMessageBox::Yes)
selectedVariableVaules.removeAt(varIndex);
}
}
ui->txt_summary->setText(selectedVariableVaules.join(" "));
return;
}
// go through list from file and check if it is selected (exists in summary)
for (int i= 0 ; i< values.count(); i++ ) {
// look for selected variable in list with variables and its values
int varIndex = selectedVariableVaules.indexOf(QRegExp(ui->list_variables->currentItem()->text()+".+",Qt::CaseInsensitive),0);
QListWidgetItem *valItem = new QListWidgetItem();
valItem->setText(values[i]);
// if not, add to list where from user can choose, add unchecked
if (varIndex == -1) {
valItem->setFlags(item->flags() | Qt::ItemIsUserCheckable);
valItem->setCheckState(Qt::Unchecked);
} else {
// if it is on list, add checked
if (selectedVariableVaules[varIndex].contains(valItem->text()))
valItem->setCheckState(Qt::Checked);
else {
// other, unchecked
valItem->setFlags(item->flags() | Qt::ItemIsUserCheckable);
valItem->setCheckState(Qt::Unchecked);
}
}
ui->list_vaules->addItem(valItem);
}
}
示例8: save
/*
* this method saves the attribute together with the host string that
* defines the type of object that this attribute is associated to (like
* position or document) and the hosts database id.
*/
void AttributeMap::save( dbID id )
{
checkHost();
QSqlQuery attribQuery;
attribQuery.prepare( "SELECT id, valueIsList FROM attributes WHERE hostObject=:host AND hostId=:hostId AND name=:name" );
attribQuery.bindValue( ":host", mHost );
attribQuery.bindValue( ":hostId", id.toString() );
Iterator it;
for ( it = begin(); it != end(); ++it ) {
Attribute att = it.value();
kDebug() << ">> oo- saving attribute with name " << it.key() << " for " << id.toString() << " att-name: " << att.name();
attribQuery.bindValue( ":name", att.name() );
attribQuery.exec();
QString attribId;
if ( attribQuery.next() ) {
// the attrib exists. Check the values
attribId = attribQuery.value(0).toString(); // the id
if ( att.value().isNull() || att.mDelete ) {
// the value is empty. the existing entry needs to be dropped
dbDeleteAttribute( attribId );
return;
}
} else {
// the attrib does not yet exist. Create if att value is not null.
if ( att.value().isNull() ) {
kDebug() << "oo- skip writing of attribute, value is empty";
} else {
kDebug() << "oo- writing of attribute name " << att.name();
QSqlQuery insQuery;
insQuery.prepare( "INSERT INTO attributes (hostObject, hostId, name, valueIsList, relationTable, "
"relationIDColumn, relationStringColumn) "
"VALUES (:host, :hostId, :name, :valueIsList, :relTable, :relIDCol, :relStringCol )" );
insQuery.bindValue( ":host", mHost );
insQuery.bindValue( ":hostId", id.toString() );
insQuery.bindValue( ":name", att.name() );
insQuery.bindValue( ":valueIsList", att.listValue() );
// Write the relation table info. These remain empty for non related attributes.
insQuery.bindValue( ":relTable", att.mTable );
insQuery.bindValue( ":relIDCol", att.mIdCol );
insQuery.bindValue( ":relStringCol", att.mStringCol );
insQuery.exec();
dbID attId = KraftDB::self()->getLastInsertID();
attribId = attId.toString();
}
}
// store the id to be able to drop not longer existent values
kDebug() << "adding attribute id " << attribId << " for attribute " << att.name();
// now there is a valid entry in the attribute table. Check the values.
QSqlQuery valueQuery( "SELECT id, value FROM attributeValues WHERE attributeId=" + attribId );
typedef QMap<QString, QString> ValueMap;
ValueMap valueMap;
while ( valueQuery.next() ) {
QString idStr = valueQuery.value( 0 ).toString(); // id
QString valStr = valueQuery.value( 1 ).toString(); // value
valueMap[valStr] = idStr;
}
// create a stringlist with the current values of the attribute
if ( att.listValue() ) {
QStringList newValues;
newValues = att.mValue.toStringList();
kDebug() << "new values are: " << newValues.join( ", " );
if ( newValues.empty() ) {
// delete the entire attribute.
dbDeleteValue( attribId ); // deletes all values
dbDeleteAttribute( attribId );
valueMap.clear();
} else {
// we really have new values
QSqlQuery insValue;
insValue.prepare( "INSERT INTO attributeValues (attributeId, value) VALUES (:attribId, :val)" );
insValue.bindValue( ":attribId", attribId );
// loop over all existing new values of the attribute.
for ( QStringList::Iterator valIt = newValues.begin(); valIt != newValues.end(); ++valIt ) {
QString curValue = *valIt;
if ( valueMap.contains( curValue ) ) {
// the valueMap is already saved. remove it from the valueMap string
//.........这里部分代码省略.........
示例9: data
QVariant ServerItem::data(int column, int role) const {
if (bParent) {
if (column == 0) {
switch (role) {
case Qt::DisplayRole:
return qsName;
case Qt::DecorationRole:
if (itType == FavoriteType)
return loadIcon(QLatin1String("skin:emblems/emblem-favorite.svg"));
else if (itType == LANType)
return loadIcon(QLatin1String("skin:places/network-workgroup.svg"));
else if (! qsCountryCode.isEmpty())
return loadIcon(QString::fromLatin1(":/flags/%1.png").arg(qsCountryCode));
else
return loadIcon(QLatin1String("skin:categories/applications-internet.svg"));
}
}
} else {
if (role == Qt::DisplayRole) {
switch (column) {
case 0:
return qsName;
case 1:
return (dPing > 0.0) ? QString::number(uiPing) : QVariant();
case 2:
return uiUsers ? QString::fromLatin1("%1/%2").arg(uiUsers).arg(uiMaxUsers) : QVariant();
}
} else if (role == Qt::ToolTipRole) {
QStringList qsl;
foreach(const QHostAddress &qha, qlAddresses)
qsl << qha.toString();
double ploss = 100.0;
if (uiSent > 0)
ploss = (uiSent - qMin(uiRecv, uiSent)) * 100. / uiSent;
QString qs;
qs +=
QLatin1String("<table>") +
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Servername"), qsName) +
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Hostname"), qsHostname);
if (! qsBonjourHost.isEmpty())
qs += QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Bonjour name"), qsBonjourHost);
qs +=
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Port")).arg(usPort) +
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Addresses"), qsl.join(QLatin1String(", ")));
if (! qsUrl.isEmpty())
qs += QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Website"), qsUrl);
if (uiSent > 0) {
qs += QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Packet loss"), QString::fromLatin1("%1% (%2/%3)").arg(ploss, 0, 'f', 1).arg(uiRecv).arg(uiSent));
if (uiRecv > 0) {
qs +=
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Ping (80%)"), ConnectDialog::tr("%1 ms").
arg(boost::accumulators::extended_p_square(* asQuantile)[1] / 1000., 0, 'f', 2)) +
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Ping (95%)"), ConnectDialog::tr("%1 ms").
arg(boost::accumulators::extended_p_square(* asQuantile)[2] / 1000., 0, 'f', 2)) +
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Bandwidth"), ConnectDialog::tr("%1 kbit/s").arg(uiBandwidth / 1000)) +
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Users"), QString::fromLatin1("%1/%2").arg(uiUsers).arg(uiMaxUsers)) +
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Version")).arg(MumbleVersion::toString(uiVersion));
}
}
qs += QLatin1String("</table>");
return qs;
} else if (role == Qt::BackgroundRole) {
示例10: load_model_data
bool Loader_obj::load_model_data(Model& mdl, QString path){
qDebug("Parsing obj file...");
QStringList pathlist = path.split("/",QString::KeepEmptyParts); //KeepEmptyParts
QString model_name = pathlist.last();
qDebug("Model name: " + model_name.toUtf8());
//LOAD MESH DATA
QFile file(path);
if (!file.open (QIODevice::ReadOnly))
{
qDebug("Model import: Error 1: Model file could not be loaded...");
return false;
}
QTextStream stream ( &file );
QString line;
QString mtllib;
QString current_mesh;
QMap<QString,QVector<int> >mesh_faces;
QMap<QString,QString> mesh_mtl;
QMap<QString,Material* > mtln_mtl;
QVector<Vector3> model_vertices;
QVector<Vector3> model_vertex_normals;
QVector<Vector3> model_vertex_texture_coordinates;
while( !stream.atEnd() ) {
line = stream.readLine();
QStringList list = line.split(QRegExp("\\s+"),QString::SkipEmptyParts); //SkipEmptyParts
if(!list.empty()){
if(list.first() == "mtllib"){
mtllib = list.last();
}
else if(list.first() == "v"){
model_vertices.append(Vector3( list.value(1).toFloat(),
list.value(2).toFloat(),
list.value(3).toFloat()));
}
else if(list.first() == "vn"){
model_vertex_normals.append(Vector3( list.value(1).toFloat(),
list.value(2).toFloat(),
list.value(3).toFloat()));
}
else if(list.first() == "vt"){
model_vertex_texture_coordinates.append(Vector3( list.value(1).toFloat(),
list.value(2).toFloat(),
list.value(3).toFloat()));
}
else if(list.first() == "g"){
current_mesh = list.value(1);
}
else if(list.first() == "usemtl"){
mesh_mtl[current_mesh] = list.value(1);
}
else if(list.first() == "f"){
QStringList face_part_1_list = list.value(1).split("/",QString::SkipEmptyParts); //SkipEmptyParts
QStringList face_part_2_list = list.value(2).split("/",QString::SkipEmptyParts); //SkipEmptyParts
QStringList face_part_3_list = list.value(3).split("/",QString::SkipEmptyParts); //SkipEmptyParts
mesh_faces[current_mesh].append(face_part_1_list.value(0).toInt());
mesh_faces[current_mesh].append(face_part_1_list.value(1).toInt());
mesh_faces[current_mesh].append(face_part_1_list.value(2).toInt());
mesh_faces[current_mesh].append(face_part_2_list.value(0).toInt());
mesh_faces[current_mesh].append(face_part_2_list.value(1).toInt());
mesh_faces[current_mesh].append(face_part_2_list.value(2).toInt());
mesh_faces[current_mesh].append(face_part_3_list.value(0).toInt());
mesh_faces[current_mesh].append(face_part_3_list.value(1).toInt());
mesh_faces[current_mesh].append(face_part_3_list.value(2).toInt());
}
}
}
file.close();
//LOAD MTL DATA
pathlist.removeAt(pathlist.length()-1);
QString mtl_path = pathlist.join("/") + "/" + mtllib;
QString tex_path = pathlist.join("/") + "/";
QFile mtlfile(mtl_path);
if (!mtlfile.open (QIODevice::ReadOnly))
{
qDebug("Model import: Error 2: Model material file could not be loaded...");
return false;
}
QTextStream mtlstream ( &mtlfile );
QString mtlline;
//.........这里部分代码省略.........
示例11: pc
// solaris 2.6
char *qt_parsePrintersConf(QList<QPrinterDescription> *printers, bool *found)
{
QFile pc(QLatin1String("/etc/printers.conf"));
if (!pc.open(QIODevice::ReadOnly)) {
if (found)
*found = false;
return 0;
}
if (found)
*found = true;
char *line = new char[1025];
line[1024] = '\0';
QString printerDesc;
int lineLength = 0;
char *defaultPrinter = 0;
while (!pc.atEnd() &&
(lineLength=pc.readLine(line, 1024)) > 0) {
if (*line == '#') {
*line = '\0';
lineLength = 0;
}
if (lineLength >= 2 && line[lineLength-2] == '\\') {
line[lineLength-2] = '\0';
printerDesc += QString::fromLocal8Bit(line);
} else {
printerDesc += QString::fromLocal8Bit(line);
printerDesc = printerDesc.simplified();
int i = printerDesc.indexOf(QLatin1Char(':'));
QString printerName, printerHost, printerComment;
QStringList aliases;
if (i >= 0) {
// have : want |
int j = printerDesc.indexOf(QLatin1Char('|'));
if (j >= i)
j = -1;
printerName = printerDesc.mid(0, j < 0 ? i : j);
if (printerName == QLatin1String("_default")) {
i = printerDesc.indexOf(
QRegExp(QLatin1String(": *use *=")));
while (printerDesc[i] != QLatin1Char('='))
i++;
while (printerDesc[i] == QLatin1Char('=') || printerDesc[i].isSpace())
i++;
j = i;
while (j < (int)printerDesc.length() &&
printerDesc[j] != QLatin1Char(':') && printerDesc[j] != QLatin1Char(','))
j++;
// that's our default printer
defaultPrinter =
qstrdup(printerDesc.mid(i, j-i).toAscii().data());
printerName = QString();
printerDesc = QString();
} else if (printerName == QLatin1String("_all")) {
// skip it.. any other cases we want to skip?
printerName = QString();
printerDesc = QString();
}
if (j > 0) {
// try extracting a comment from the aliases
aliases = printerDesc.mid(j + 1, i - j - 1).split(QLatin1Char('|'));
#ifndef QT_NO_PRINTDIALOG
printerComment = QPrintDialog::tr("Aliases: %1")
.arg(aliases.join(QLatin1String(", ")));
#endif
}
// look for signs of this being a remote printer
i = printerDesc.indexOf(
QRegExp(QLatin1String(": *bsdaddr *=")));
if (i >= 0) {
// point k at the end of remote host name
while (printerDesc[i] != QLatin1Char('='))
i++;
while (printerDesc[i] == QLatin1Char('=') || printerDesc[i].isSpace())
i++;
j = i;
while (j < (int)printerDesc.length() &&
printerDesc[j] != QLatin1Char(':') && printerDesc[j] != QLatin1Char(','))
j++;
// and stuff that into the string
printerHost = printerDesc.mid(i, j-i);
// maybe stick the remote printer name into the comment
if (printerDesc[j] == QLatin1Char(',')) {
i = ++j;
while (printerDesc[i].isSpace())
i++;
j = i;
while (j < (int)printerDesc.length() &&
printerDesc[j] != QLatin1Char(':') && printerDesc[j] != QLatin1Char(','))
j++;
if (printerName != printerDesc.mid(i, j-i)) {
printerComment =
QLatin1String("Remote name: ");
printerComment += printerDesc.mid(i, j-i);
}
//.........这里部分代码省略.........
示例12: createMergers
bool ScriptMergerCreator::createMergers(const MatchSet& matches,
vector<Merger*>& mergers) const
{
bool result = false;
assert(matches.size() > 0);
set< pair<ElementId, ElementId> > eids;
shared_ptr<PluginContext> script;
Persistent<Object> plugin;
QStringList matchType;
// go through all the matches
for (MatchSet::const_iterator it = matches.begin(); it != matches.end(); ++it)
{
const ScriptMatch* sm = dynamic_cast<const ScriptMatch*>(*it);
// check to make sure all the input matches are building matches.
if (sm == 0)
{
// return an empty result
return false;
}
// add all the element to element pairs to a set
else
{
script = sm->getScript();
HandleScope handleScope;
Context::Scope context_scope(script->getContext());
plugin = sm->getPlugin();
set< pair<ElementId, ElementId> > s = sm->getMatchPairs();
eids.insert(s.begin(), s.end());
if (matchType.contains(sm->getMatchName()) == false)
{
matchType.append(sm->getMatchName());
}
}
}
ScriptMerger* sm = new ScriptMerger(script, plugin, eids);
// only add the POI merge if there are elements to merge.
if (sm->hasFunction("mergeSets"))
{
if (eids.size() >= 1)
{
mergers.push_back(sm);
result = true;
}
else
{
delete sm;
}
}
else
{
if (eids.size() == 1)
{
mergers.push_back(sm);
result = true;
}
else if (eids.size() > 1)
{
delete sm;
mergers.push_back(new MarkForReviewMerger(eids, "Overlapping matches", matchType.join(";"),
1.0));
result = true;
}
else
{
delete sm;
}
}
return result;
}
示例13: data
QVariant TransferListModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid()) return QVariant();
BitTorrent::TorrentHandle *const torrent = m_torrents.value(index.row());
if (!torrent) return QVariant();
if ((role == Qt::DecorationRole) && (index.column() == TR_NAME))
return getIconByState(torrent->state());
if (role == Qt::ForegroundRole)
return getColorByState(torrent->state());
if ((role != Qt::DisplayRole) && (role != Qt::UserRole))
return QVariant();
switch (index.column()) {
case TR_NAME:
return torrent->name();
case TR_PRIORITY:
return torrent->queuePosition();
case TR_SIZE:
return torrent->wantedSize();
case TR_PROGRESS:
return torrent->progress();
case TR_STATUS:
return QVariant::fromValue(torrent->state());
case TR_SEEDS:
return (role == Qt::DisplayRole) ? torrent->seedsCount() : torrent->totalSeedsCount();
case TR_PEERS:
return (role == Qt::DisplayRole) ? torrent->leechsCount() : torrent->totalLeechersCount();
case TR_DLSPEED:
return torrent->downloadPayloadRate();
case TR_UPSPEED:
return torrent->uploadPayloadRate();
case TR_ETA:
return torrent->eta();
case TR_RATIO:
return torrent->realRatio();
case TR_CATEGORY:
return torrent->category();
case TR_TAGS: {
QStringList tagsList = torrent->tags().toList();
tagsList.sort();
return tagsList.join(", ");
}
case TR_ADD_DATE:
return torrent->addedTime();
case TR_SEED_DATE:
return torrent->completedTime();
case TR_TRACKER:
return torrent->currentTracker();
case TR_DLLIMIT:
return torrent->downloadLimit();
case TR_UPLIMIT:
return torrent->uploadLimit();
case TR_AMOUNT_DOWNLOADED:
return torrent->totalDownload();
case TR_AMOUNT_UPLOADED:
return torrent->totalUpload();
case TR_AMOUNT_DOWNLOADED_SESSION:
return torrent->totalPayloadDownload();
case TR_AMOUNT_UPLOADED_SESSION:
return torrent->totalPayloadUpload();
case TR_AMOUNT_LEFT:
return torrent->incompletedSize();
case TR_TIME_ELAPSED:
return (role == Qt::DisplayRole) ? torrent->activeTime() : torrent->seedingTime();
case TR_SAVE_PATH:
return Utils::Fs::toNativePath(torrent->savePath());
case TR_COMPLETED:
return torrent->completedSize();
case TR_RATIO_LIMIT:
return torrent->maxRatio();
case TR_SEEN_COMPLETE_DATE:
return torrent->lastSeenComplete();
case TR_LAST_ACTIVITY:
if (torrent->isPaused() || torrent->isChecking())
return -1;
return torrent->timeSinceActivity();
case TR_TOTAL_SIZE:
return torrent->totalSize();
}
return QVariant();
}
示例14: on_sendButton_clicked
//.........这里部分代码省略.........
// process prepareStatus and on error generate message shown to user
processSendCoinsReturn(prepareStatus,
BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()));
if(prepareStatus.status != WalletModel::OK) {
fNewRecipientAllowed = true;
return;
}
CAmount txFee = currentTransaction.getTransactionFee();
// Format confirmation message
QStringList formatted;
Q_FOREACH(const SendCoinsRecipient &rcp, currentTransaction.getRecipients())
{
// generate bold amount string
QString amount = "<b>" + BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount);
amount.append("</b>");
// generate monospace address string
QString address = "<span style='font-family: monospace;'>" + rcp.address;
address.append("</span>");
QString recipientElement;
if (!rcp.paymentRequest.IsInitialized()) // normal payment
{
if(rcp.label.length() > 0) // label with address
{
recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.label));
recipientElement.append(QString(" (%1)").arg(address));
}
else // just address
{
recipientElement = tr("%1 to %2").arg(amount, address);
}
}
else if(!rcp.authenticatedMerchant.isEmpty()) // authenticated payment request
{
recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant));
}
else // unauthenticated payment request
{
recipientElement = tr("%1 to %2").arg(amount, address);
}
formatted.append(recipientElement);
}
QString questionString = tr("Are you sure you want to send?");
questionString.append("<br /><br />%1");
if(txFee > 0)
{
// append fee string if a fee is required
questionString.append("<hr /><span style='color:#aa0000;'>");
questionString.append(BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), txFee));
questionString.append("</span> ");
questionString.append(tr("added as transaction fee"));
// append transaction size
questionString.append(" (" + QString::number((double)currentTransaction.getTransactionSize() / 1000) + " kB)");
}
// add total amount in all subdivision units
questionString.append("<hr />");
CAmount totalAmount = currentTransaction.getTotalTransactionAmount() + txFee;
QStringList alternativeUnits;
Q_FOREACH(BitcoinUnits::Unit u, BitcoinUnits::availableUnits())
{
if(u != model->getOptionsModel()->getDisplayUnit())
alternativeUnits.append(BitcoinUnits::formatHtmlWithUnit(u, totalAmount));
}
questionString.append(tr("Total Amount %1 (= %2)")
.arg(BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), totalAmount))
.arg(alternativeUnits.join(" " + tr("or") + " ")));
QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"),
questionString.arg(formatted.join("<br />")),
QMessageBox::Yes | QMessageBox::Cancel,
QMessageBox::Cancel);
if(retval != QMessageBox::Yes)
{
fNewRecipientAllowed = true;
return;
}
// now send the prepared transaction
WalletModel::SendCoinsReturn sendStatus = model->sendCoins(currentTransaction);
// process sendStatus and on error generate message shown to user
processSendCoinsReturn(sendStatus);
if (sendStatus.status == WalletModel::OK)
{
accept();
CoinControlDialog::coinControl->UnSelectAll();
coinControlUpdateLabels();
}
fNewRecipientAllowed = true;
}
示例15: foreach
}
_tray->setToolTip(tr("Disconnected from %1").arg(
accountNames.join(QLatin1String(", "))));
#else
QStringList messages;
messages.append(tr("Disconnected from accounts:"));
foreach (AccountStatePtr a, problemAccounts) {
QString message = tr("Account %1: %2").arg(
a->account()->displayName(), a->stateString(a->state()));
if (! a->connectionErrors().empty()) {
message += QLatin1String("\n");
message += a->connectionErrors().join(QLatin1String("\n"));
}
messages.append(message);
}
_tray->setToolTip(messages.join(QLatin1String("\n\n")));
#endif
return;
}
if (allSignedOut) {
_tray->setIcon(Theme::instance()->folderOfflineIcon(true));
_tray->setToolTip(tr("Please sign in"));
return;
}
// display the info of the least successful sync (eg. do not just display the result of the latest sync)
QString trayMessage;
FolderMan *folderMan = FolderMan::instance();
Folder::Map map = folderMan->map();
SyncResult overallResult = FolderMan::accountStatus(map.values());