本文整理汇总了C++中QStringList::constBegin方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::constBegin方法的具体用法?C++ QStringList::constBegin怎么用?C++ QStringList::constBegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringList
的用法示例。
在下文中一共展示了QStringList::constBegin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateMainSourceDepend
void CProject::updateMainSourceDepend()
{
// mainSourceDependMap
QString mainSourceDependValue = settings->value("MainSourceDepend").toString();
if (mainSourceDependValue.isEmpty())
return;
// 将分组保存在dependList中
QStringList dependList = mainSourceDependValue.split(QRegExp("\\s*:\\s*"), QString::SkipEmptyParts);
QStringList::const_iterator constIterator = dependList.constBegin();
QStringList::const_iterator endIterator = dependList.constEnd();
// 分析组内的依赖关系, 保存在dependMap中
while (constIterator != endIterator) {
// 将组内文件名保存在childList中
QStringList childList = (*constIterator).split(QRegExp("\\s+"), QString::SkipEmptyParts);
// 如果组内的单词个数小于2, 则无效, 放弃它处理下一个.
if (childList.count() < 2) {
++constIterator;
continue;
}
// 主内第一个名称是main文件的依赖方式标志, "all"表示所有, "only"表示不依赖其它源文件, "part"标示依赖指定的源文件
QString mode = childList.at(0);
// 组内的第二个文件名是含main() 的源文件, 保存在mainSource中
QString mainSource = childList.at(1);
mainSource.remove(QRegExp("^./"));
// 如果mainSourceList 中没有该mainSource, 则放弃该mainSource处理下一个.
if (!mainSourceList.contains(mainSource)) {
++constIterator;
continue;
}
// 若mode = "only", 则它不依赖于任何其它源文件, dependSources为"only";
// 若mode = "part", 则它依赖于指定的源文件, dependSources, 为 "part" 和 mainSource后面的文件
// 若mode 不是上面两种情况, 则保持mainSourceDependMap中原来的值"all"
QFileInfo fileInfo(mainSource);
QString executeFile = fileInfo.path() + "/" + fileInfo.completeBaseName();
executeFile.remove(QRegExp("^./"));
if (mode == "only") {
mainSourceDependMap[mainSource] = QStringList() << "only";
executeFileDependMap[executeFile].removeAt(0);
executeFileDependMap[executeFile].insert(0, "only");
} else if (mode == "part") {
QStringList dependSources;
QStringList objects;
dependSources << "part";
objects << "part" << executeFile + ".o";
QString source = QString();
QString object = QString();
int count = childList.count();
int i = 2;
while (i < count) {
source = childList.at(i);
source.remove(QRegExp("^./"));
dependSources << source;
fileInfo.setFile(source);
object = fileInfo.path() + "/" + fileInfo.completeBaseName() + ".o";
object.remove(QRegExp("^./"));
objects << object;
++i;
}
mainSourceDependMap[mainSource] = dependSources;
executeFileDependMap[executeFile] = objects;
}
++constIterator;
}
}
示例2: if
void QgsSimpleLineSymbolLayerV2::applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QPen& pen, QPen& selPen, double& offset )
{
if ( mDataDefinedProperties.isEmpty() )
return; // shortcut
//data defined properties
double scaledWidth = 0;
QgsExpression* strokeWidthExpression = expression( "width" );
if ( strokeWidthExpression )
{
scaledWidth = strokeWidthExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble()
* QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit, mWidthMapUnitScale );
pen.setWidthF( scaledWidth );
selPen.setWidthF( scaledWidth );
}
else if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale )
{
scaledWidth = mWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit, mWidthMapUnitScale );
pen.setWidthF( scaledWidth );
selPen.setWidthF( scaledWidth );
}
//color
QgsExpression* strokeColorExpression = expression( "color" );
if ( strokeColorExpression )
{
pen.setColor( QgsSymbolLayerV2Utils::decodeColor( strokeColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );
}
//offset
QgsExpression* lineOffsetExpression = expression( "offset" );
if ( lineOffsetExpression )
{
offset = lineOffsetExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble();
}
//dash dot vector
QgsExpression* dashPatternExpression = expression( "customdash" );
if ( dashPatternExpression )
{
double scaledWidth = mWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit, mWidthMapUnitScale );
double dashWidthDiv = mPen.widthF();
if ( strokeWidthExpression )
{
dashWidthDiv = pen.widthF();
scaledWidth = pen.widthF();
}
//fix dash pattern width in Qt 4.8
QStringList versionSplit = QString( qVersion() ).split( "." );
if ( versionSplit.size() > 1
&& versionSplit.at( 1 ).toInt() >= 8
&& ( scaledWidth * context.renderContext().rasterScaleFactor() ) < 1.0 )
{
dashWidthDiv = 1.0;
}
QVector<qreal> dashVector;
QStringList dashList = dashPatternExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString().split( ";" );
QStringList::const_iterator dashIt = dashList.constBegin();
for ( ; dashIt != dashList.constEnd(); ++dashIt )
{
dashVector.push_back( dashIt->toDouble() * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mCustomDashPatternUnit, mCustomDashPatternMapUnitScale ) / dashWidthDiv );
}
pen.setDashPattern( dashVector );
}
//join style
QgsExpression* joinStyleExpression = expression( "joinstyle" );
if ( joinStyleExpression )
{
QString joinStyleString = joinStyleExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
pen.setJoinStyle( QgsSymbolLayerV2Utils::decodePenJoinStyle( joinStyleString ) );
}
//cap style
QgsExpression* capStyleExpression = expression( "capstyle" );
if ( capStyleExpression )
{
QString capStyleString = capStyleExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
pen.setCapStyle( QgsSymbolLayerV2Utils::decodePenCapStyle( capStyleString ) );
}
}
示例3: avoidIntersections
QgsAbstractGeometryV2* QgsGeometryEditUtils::avoidIntersections( const QgsAbstractGeometryV2& geom, QMap<QgsVectorLayer*, QSet<QgsFeatureId> > ignoreFeatures )
{
QScopedPointer<QgsGeometryEngine> geomEngine( QgsGeometry::createGeometryEngine( &geom ) );
if ( geomEngine.isNull() )
{
return nullptr;
}
QgsWKBTypes::Type geomTypeBeforeModification = geom.wkbType();
//check if g has polygon type
if ( QgsWKBTypes::geometryType( geomTypeBeforeModification ) != QgsWKBTypes::PolygonGeometry )
{
return nullptr;
}
//read avoid intersections list from project properties
bool listReadOk;
QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", QStringList(), &listReadOk );
if ( !listReadOk )
return nullptr; //no intersections stored in project does not mean error
QList< QgsAbstractGeometryV2* > nearGeometries;
//go through list, convert each layer to vector layer and call QgsVectorLayer::removePolygonIntersections for each
QgsVectorLayer* currentLayer = nullptr;
QStringList::const_iterator aIt = avoidIntersectionsList.constBegin();
for ( ; aIt != avoidIntersectionsList.constEnd(); ++aIt )
{
currentLayer = dynamic_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( *aIt ) );
if ( currentLayer )
{
QgsFeatureIds ignoreIds;
QMap<QgsVectorLayer*, QSet<qint64> >::const_iterator ignoreIt = ignoreFeatures.find( currentLayer );
if ( ignoreIt != ignoreFeatures.constEnd() )
ignoreIds = ignoreIt.value();
QgsFeatureIterator fi = currentLayer->getFeatures( QgsFeatureRequest( geom.boundingBox() )
.setFlags( QgsFeatureRequest::ExactIntersect )
.setSubsetOfAttributes( QgsAttributeList() ) );
QgsFeature f;
while ( fi.nextFeature( f ) )
{
if ( ignoreIds.contains( f.id() ) )
continue;
if ( !f.hasGeometry() )
continue;
nearGeometries << f.geometry().geometry()->clone();
}
}
}
if ( nearGeometries.isEmpty() )
{
return nullptr;
}
QgsAbstractGeometryV2* combinedGeometries = geomEngine.data()->combine( nearGeometries );
qDeleteAll( nearGeometries );
if ( !combinedGeometries )
{
return nullptr;
}
QgsAbstractGeometryV2* diffGeom = geomEngine.data()->difference( *combinedGeometries );
delete combinedGeometries;
return diffGeom;
}
示例4: mergeKeySets
static void mergeKeySets(NameSet *dest, const QStringList &src)
{
QStringList::const_iterator it = src.constBegin();
for (; it != src.constEnd(); ++it)
dest->insert(unescapedKey(*it), QString());
}
示例5: addItems
void FileBrowser::addItems(const QString & path )
{
if( m_dirsAsItems )
{
m_l->addTopLevelItem( new Directory( path, QString::null, m_filter ) );
return;
}
QDir cdir( path );
QStringList files = cdir.entryList( QDir::Dirs, QDir::Name );
for( QStringList::const_iterator it = files.constBegin();
it != files.constEnd(); ++it )
{
QString cur_file = *it;
if( cur_file[0] != '.' )
{
bool orphan = true;
for( int i = 0; i < m_l->topLevelItemCount(); ++i )
{
Directory * d = dynamic_cast<Directory *>(
m_l->topLevelItem( i ) );
if( d == NULL || cur_file < d->text( 0 ) )
{
Directory *dd = new Directory( cur_file, path,
m_filter );
m_l->insertTopLevelItem( i,dd );
dd->update();
orphan = false;
break;
}
else if( cur_file == d->text( 0 ) )
{
d->addDirectory( path );
d->update();
orphan = false;
break;
}
}
if( orphan )
{
Directory *d = new Directory( cur_file,
path, m_filter );
d->update();
m_l->addTopLevelItem( d );
}
}
}
files = cdir.entryList( QDir::Files, QDir::Name );
for( QStringList::const_iterator it = files.constBegin();
it != files.constEnd(); ++it )
{
QString cur_file = *it;
if( cur_file[0] != '.' )
{
// TODO: don't insert instead of removing, order changed
// remove existing file-items
QList<QTreeWidgetItem *> existing = m_l->findItems(
cur_file, Qt::MatchFixedString );
if( !existing.empty() )
{
delete existing.front();
}
(void) new FileItem( m_l, cur_file, path );
}
}
}
示例6: fi
///////////////////////////
// //
// PACKING OPERATIONS //
// //
///////////////////////////
void
ProjectPackager::runPack()
{
RG_DEBUG << "ProjectPackager::runPack()";
m_info->setText(tr("Packing project..."));
// go into spinner mode
m_progress->setMaximum(0);
QStringList audioFiles = getAudioFiles();
// the base tmp directory where we'll assemble all the files
m_packTmpDirName = QString("%1/rosegarden-project-packager-tmp").arg(QDir::homePath());
// the data directory where audio and other files will go
QFileInfo fi(m_filename);
m_packDataDirName = fi.baseName();
RG_DEBUG << "using tmp data directory: " << m_packTmpDirName << "/" <<
m_packDataDirName;
QDir tmpDir(m_packTmpDirName);
// get the original filename saved by RosegardenMainWindow and the name of
// the new one we'll be including in the bundle (name isn't changing, path
// component changes from one to the other)
// QFileInfo::baseName() given /tmp/foo/bar/rat.rgp returns rat
//
// m_filename comes in already having an .rgp extension, but the file
// was saved .rg
QString oldName = QString("%1/%2.rg").arg(fi.path()).arg(fi.baseName());
QString newName = QString("%1/%2.rg").arg(m_packTmpDirName).arg(fi.baseName());
// if the tmp directory already exists, just hose it
rmdirRecursive(m_packTmpDirName);
// make the temporary working directory
if (tmpDir.mkdir(m_packTmpDirName)) {
} else {
puke(tr("<qt><p>Could not create temporary working directory.</p>%1</qt>").arg(m_abortText));
return;
}
m_info->setText(tr("Copying audio files..."));
// leave spinner mode
m_progress->setMaximum(100);
m_progress->setValue(0);
// count total audio files
int af = 0;
QStringList::const_iterator si;
for (si = audioFiles.constBegin(); si != audioFiles.constEnd(); ++si)
af++;
int afStep = ((af == 0) ? 1 : (100 / af));
// make the data subdir
tmpDir.mkdir(m_packDataDirName);
// copy the audio files (do not remove the originals!)
af = 0;
for (si = audioFiles.constBegin(); si != audioFiles.constEnd(); ++si) {
// comes in with full path and filename
QString srcFile = (*si);
QString srcFilePk = QString("%1.pk").arg(srcFile);
// needs the filename split away from the path, so we can replace the
// path with the new one
QFileInfo fi(*si);
QString filename = QString("%1.%2").arg(fi.baseName()).arg(fi.completeSuffix());
QString dstFile = QString("%1/%2/%3").arg(m_packTmpDirName).arg(m_packDataDirName).arg(filename);
QString dstFilePk = QString("%1.pk").arg(dstFile);
RG_DEBUG << "cp " << srcFile << " " << dstFile;
RG_DEBUG << "cp " << srcFilePk << " " << dstFilePk;
if (!QFile::copy(srcFile, dstFile)) {
puke(tr("<qt>Could not copy<br>%1<br> to<br>%2<br><br>Processing aborted.</qt>").arg(srcFile).arg(dstFile));
return;
}
// Try to copy the .wav.pk file derived from transforming the name of
// the .wav file. We don't trap the fail condition for this one and
// allow it to fail silently without complaining or aborting. If the
// .wav.pk files are missing, they will be generated again as needed.
//
// Legacy .rgp files ship with improperly named .wav.pk files, from
// a bug in the original rosegarden-project-package script. You'd wind
// up with an .rgp that contained, for example:
//
//.........这里部分代码省略.........
示例7: addFeatures
bool QgsWFSProvider::addFeatures( QgsFeatureList &flist )
{
//create <Transaction> xml
QDomDocument transactionDoc;
QDomElement transactionElem = createTransactionElement( transactionDoc );
transactionDoc.appendChild( transactionElem );
//find out typename from uri and strip namespace prefix
QString tname = mShared->mURI.typeName();
if ( tname.isNull() )
{
return false;
}
removeNamespacePrefix( tname );
//Add the features
QgsFeatureList::iterator featureIt = flist.begin();
for ( ; featureIt != flist.end(); ++featureIt )
{
//Insert element
QDomElement insertElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, "Insert" );
transactionElem.appendChild( insertElem );
QDomElement featureElem = transactionDoc.createElementNS( mApplicationNamespace, tname );
QgsAttributes featureAttributes = featureIt->attributes();
int nAttrs = featureAttributes.size();
for ( int i = 0; i < nAttrs; ++i )
{
const QVariant& value = featureAttributes.at( i );
if ( value.isValid() && !value.isNull() )
{
QDomElement fieldElem = transactionDoc.createElementNS( mApplicationNamespace, mShared->mFields.at( i ).name() );
QDomText fieldText = transactionDoc.createTextNode( value.toString() );
fieldElem.appendChild( fieldText );
featureElem.appendChild( fieldElem );
}
}
//add geometry column (as gml)
const QgsGeometry* geometry = featureIt->constGeometry();
if ( geometry != nullptr )
{
QDomElement geomElem = transactionDoc.createElementNS( mApplicationNamespace, mShared->mGeometryAttribute );
QgsGeometry the_geom( *geometry );
// convert to multi if the layer geom type is multi and the geom is not
if ( QGis::isMultiType( this->geometryType( ) ) && ! the_geom.isMultipart( ) )
{
the_geom.convertToMultiType();
}
QDomElement gmlElem = QgsOgcUtils::geometryToGML( &the_geom, transactionDoc );
if ( !gmlElem.isNull() )
{
gmlElem.setAttribute( "srsName", crs().authid() );
geomElem.appendChild( gmlElem );
featureElem.appendChild( geomElem );
}
}
insertElem.appendChild( featureElem );
}
QDomDocument serverResponse;
bool success = sendTransactionDocument( transactionDoc, serverResponse );
if ( !success )
{
return false;
}
if ( transactionSuccess( serverResponse ) )
{
//transaction successful. Add the features to the cache
QStringList idList = insertedFeatureIds( serverResponse );
QStringList::const_iterator idIt = idList.constBegin();
featureIt = flist.begin();
QVector<QgsWFSFeatureGmlIdPair> serializedFeatureList;
for ( ; idIt != idList.constEnd() && featureIt != flist.end(); ++idIt, ++featureIt )
{
serializedFeatureList.push_back( QgsWFSFeatureGmlIdPair( *featureIt, *idIt ) );
}
mShared->serializeFeatures( serializedFeatureList );
// And now set the feature id from the one got from the database
QMap< QString, QgsFeatureId > map;
for ( int idx = 0; idx < serializedFeatureList.size(); idx++ )
map[ serializedFeatureList[idx].second ] = serializedFeatureList[idx].first.id();
idIt = idList.constBegin();
featureIt = flist.begin();
for ( ; idIt != idList.constEnd() && featureIt != flist.end(); ++idIt, ++featureIt )
{
if ( map.find( *idIt ) != map.end() )
featureIt->setFeatureId( map[*idIt] );
}
return true;
}
else
{
//.........这里部分代码省略.........
示例8: snapToBackgroundLayers
int QgsMapCanvasSnapper::snapToBackgroundLayers( const QgsPoint& point, QList<QgsSnappingResult>& results, const QList<QgsPoint>& excludePoints )
{
results.clear();
if ( !mSnapper )
return 5;
//topological editing on?
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
//snapping on intersection on?
int intersectionSnapping = QgsProject::instance()->readNumEntry( "Digitizing", "/IntersectionSnapping", 0 );
if ( topologicalEditing == 0 )
{
if ( intersectionSnapping == 0 )
mSnapper->setSnapMode( QgsSnapper::SnapWithOneResult );
else
mSnapper->setSnapMode( QgsSnapper::SnapWithResultsWithinTolerances );
}
else if ( intersectionSnapping == 0 )
{
mSnapper->setSnapMode( QgsSnapper::SnapWithResultsForSamePosition );
}
else
{
mSnapper->setSnapMode( QgsSnapper::SnapWithResultsWithinTolerances );
}
//read snapping settings from project
bool snappingDefinedInProject, ok;
QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", QStringList(), &snappingDefinedInProject );
QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", QStringList(), &ok );
QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", QStringList(), &ok );
QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", QStringList(), &ok );
QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", QStringList(), &ok );
if ( !( layerIdList.size() == enabledList.size() &&
layerIdList.size() == toleranceList.size() &&
layerIdList.size() == toleranceUnitList.size() &&
layerIdList.size() == snapToList.size() ) )
{
// lists must have the same size, otherwise something is wrong
return 1;
}
QList<QgsSnapper::SnapLayer> snapLayers;
QgsSnapper::SnapLayer snapLayer;
// Use snapping information from the project
if ( snappingDefinedInProject )
{
// set layers, tolerances, snap to segment/vertex to QgsSnapper
QStringList::const_iterator layerIt( layerIdList.constBegin() );
QStringList::const_iterator tolIt( toleranceList.constBegin() );
QStringList::const_iterator tolUnitIt( toleranceUnitList.constBegin() );
QStringList::const_iterator snapIt( snapToList.constBegin() );
QStringList::const_iterator enabledIt( enabledList.constBegin() );
for ( ; layerIt != layerIdList.constEnd(); ++layerIt, ++tolIt, ++tolUnitIt, ++snapIt, ++enabledIt )
{
if ( *enabledIt != "enabled" )
{
// skip layer if snapping is not enabled
continue;
}
//layer
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( QgsMapLayerRegistry::instance()->mapLayer( *layerIt ) );
if ( !vlayer || !vlayer->hasGeometryType() )
continue;
snapLayer.mLayer = vlayer;
//tolerance
snapLayer.mTolerance = tolIt->toDouble();
snapLayer.mUnitType = ( QgsTolerance::UnitType ) tolUnitIt->toInt();
// segment or vertex
if ( *snapIt == "to_vertex" )
{
snapLayer.mSnapTo = QgsSnapper::SnapToVertex;
}
else if ( *snapIt == "to_segment" )
{
snapLayer.mSnapTo = QgsSnapper::SnapToSegment;
}
else
{
// to vertex and segment
snapLayer.mSnapTo = QgsSnapper::SnapToVertexAndSegment;
}
snapLayers.append( snapLayer );
}
}
else
{
// nothing in project. Use default snapping tolerance to vertex of current layer
QgsMapLayer* currentLayer = mMapCanvas->currentLayer();
if ( !currentLayer )
//.........这里部分代码省略.........
示例9: FromStringList
bool FileSystemInfo::FromStringList(const QStringList &slist)
{
QStringList::const_iterator it = slist.constBegin();
return FromStringList(it, slist.constEnd());
}
示例10: directoryListingFinished
void TestRegressionWindow::directoryListingFinished(KJob *)
{
QTreeWidgetItem *topLevelItem = m_ui.treeWidget->topLevelItem(0);
// Gather a lot of statistics...
unsigned long availableDomFiles = 0;
unsigned long availableDumpFiles = 0;
unsigned long availableRenderFiles = 0;
unsigned long ignoredJSTests = 0;
unsigned long availableJSTests = 0;
unsigned long ignoredXMLTests = 0;
unsigned long availableXMLTests = 0;
unsigned long ignoredHTMLTests = 0;
unsigned long availableHTMLTests = 0;
unsigned long ignoredDOMTSTests = 0;
unsigned long availableDOMTSTests = 0;
// Start the actual data processing...
QMap<QString, QStringList>::const_iterator it = m_directoryMap.constBegin();
const QMap<QString, QStringList>::const_iterator end = m_directoryMap.constEnd();
for(; it != end; ++it)
{
QString directory = it.key();
QStringList filenames = it.value();
if(filenames.isEmpty()) // Do not add empty directories at all...
continue;
bool hasIgnores = (m_ignoreMap.constFind(directory) != m_directoryMap.constEnd());
bool hasFailures = (m_failureMap.constFind(directory) != m_failureMap.constEnd());
// Extract parent directory...
int position = directory.lastIndexOf('/');
QString parentDirectory = directory.mid(0, (position == -1 ? 0 : position));
QString parentDirectoryItem = directory.mid(position + 1);
bool hasParentIgnores = (m_ignoreMap.constFind(parentDirectory) != m_directoryMap.constEnd());
bool hasParentFailures = (m_failureMap.constFind(parentDirectory) != m_failureMap.constEnd());
// Sort in ascending order...
filenames.sort();
QStringList::const_iterator it2 = filenames.constBegin();
const QStringList::const_iterator end2 = filenames.constEnd();
// Create new tree widget item for the active directory...
QTreeWidgetItem *parent = topLevelItem;
if(!directory.isEmpty())
{
parent = new QTreeWidgetItem(topLevelItem, QStringList(directory));
// Directory is completely ignored, mark it 'yellow'...
if(hasParentIgnores && m_ignoreMap[parentDirectory].contains(parentDirectoryItem))
parent->setIcon(0, m_ignorePixmap);
// Directory is completely known to fail, mark it 'red'...
if(hasParentFailures && m_failureMap[parentDirectory].contains(parentDirectoryItem))
parent->setIcon(0, m_failKnownPixmap);
}
// Add all contained files as new items below 'parent'...
for(; it2 != end2; ++it2)
{
QString test = (*it2);
QString cacheName = directory + "/" + test; //krazy:exclude=duoblequote_chars DOM demands chars
QTreeWidgetItem *testItem = new QTreeWidgetItem(parent, QStringList(KUrl(test).path()));
// Remember name <-> item pair...
assert(m_itemMap.contains(cacheName));
m_itemMap.insert(cacheName, testItem);
bool ignore = (hasIgnores && m_ignoreMap[directory].contains(test));
bool ignoreParent = (hasParentIgnores && m_ignoreMap[parentDirectory].contains(parentDirectoryItem));
bool failure = (hasFailures && m_failureMap[directory].contains(test));
// Check baseline directory for this test...
QString baseLinePath = m_testsUrl.path() + "/baseline/" + cacheName;
bool dom[9], render[9];
for(unsigned int i = 0; i < 9; ++i)
{
if(i == 0)
{
dom[i] = (QFileInfo(baseLinePath + "-dom").exists());
render[i] = (QFileInfo(baseLinePath + "-render").exists());
}
else
{
dom[i] = (QFileInfo(baseLinePath + "-" + QString::number(i) + "-dom").exists()); //krazy:exclude=duoblequote_chars DOM demands chars
render[i] = (QFileInfo(baseLinePath + "-" + QString::number(i) + "-render").exists()); //krazy:exclude=duoblequote_chars DOM demands chars
}
//.........这里部分代码省略.........
示例11: KTRMRequestHandler
KTRMRequestHandler()
{
m_pimp = tp_New("KTRM", "0.1");
//tp_SetDebug(m_pimp, true);
tp_SetTRMCollisionThreshold(m_pimp, 100);
tp_SetAutoSaveThreshold(m_pimp, -1);
tp_SetMoveFiles(m_pimp, false);
tp_SetRenameFiles(m_pimp, false);
#if HAVE_MUSICBRAINZ >= 4
tp_SetFileNameEncoding(m_pimp, "UTF-8");
#else
tp_SetUseUTF8(m_pimp, true);
#endif
tp_SetNotifyCallback(m_pimp, TRMNotifyCallback, 0);
// Re-read proxy config.
KProtocolManager::reparseConfiguration();
if(KProtocolManager::useProxy()) {
// split code copied from kcm_kio.
QString noProxiesFor = KProtocolManager::noProxyFor();
QStringList noProxies = QStringList::split(QRegExp("[',''\t'' ']"), noProxiesFor);
bool useProxy = true;
// Host that libtunepimp will contact.
QString tunepimpHost = "www.musicbrainz.org";
QString tunepimpHostWithPort = "www.musicbrainz.org:80";
// Check what hosts are allowed to proceed without being proxied,
// or is using reversed proxy, what hosts must be proxied.
for(QStringList::ConstIterator it = noProxies.constBegin(); it != noProxies.constEnd(); ++it) {
QString normalizedHost = KNetwork::KResolver::normalizeDomain(*it);
if(normalizedHost == tunepimpHost ||
tunepimpHost.endsWith("." + normalizedHost))
{
useProxy = false;
break;
}
// KDE's proxy mechanism also supports exempting a specific
// host/port combo, check that also.
if(normalizedHost == tunepimpHostWithPort ||
tunepimpHostWithPort.endsWith("." + normalizedHost))
{
useProxy = false;
break;
}
}
// KDE supports a reverse proxy mechanism. Uh, yay.
if(KProtocolManager::useReverseProxy())
useProxy = !useProxy;
if(useProxy) {
KURL proxy = KProtocolManager::proxyFor("http");
QString proxyHost = proxy.host();
kdDebug(65432) << "Using proxy server " << proxyHost << " for www.musicbrainz.org.\n";
tp_SetProxy(m_pimp, proxyHost.latin1(), short(proxy.port()));
}
}
}
示例12: containsElemParams
void QgsSvgCache::containsElemParams( const QDomElement& elem, bool& hasFillParam, QColor& defaultFill, bool& hasOutlineParam, QColor& defaultOutline,
bool& hasOutlineWidthParam, double& defaultOutlineWidth ) const
{
if ( elem.isNull() )
{
return;
}
//we already have all the information, no need to go deeper
if ( hasFillParam && hasOutlineParam && hasOutlineWidthParam )
{
return;
}
//check this elements attribute
QDomNamedNodeMap attributes = elem.attributes();
int nAttributes = attributes.count();
QStringList valueSplit;
for ( int i = 0; i < nAttributes; ++i )
{
QDomAttr attribute = attributes.item( i ).toAttr();
if ( attribute.name().compare( "style", Qt::CaseInsensitive ) == 0 )
{
//entries separated by ';'
QStringList entryList = attribute.value().split( ';' );
QStringList::const_iterator entryIt = entryList.constBegin();
for ( ; entryIt != entryList.constEnd(); ++entryIt )
{
QStringList keyValueSplit = entryIt->split( ':' );
if ( keyValueSplit.size() < 2 )
{
continue;
}
QString key = keyValueSplit.at( 0 );
QString value = keyValueSplit.at( 1 );
valueSplit = value.split( " " );
if ( !hasFillParam && value.startsWith( "param(fill)" ) )
{
hasFillParam = true;
if ( valueSplit.size() > 1 )
{
defaultFill = QColor( valueSplit.at( 1 ) );
}
}
else if ( !hasOutlineParam && value.startsWith( "param(outline)" ) )
{
hasOutlineParam = true;
if ( valueSplit.size() > 1 )
{
defaultOutline = QColor( valueSplit.at( 1 ) );
}
}
else if ( !hasOutlineWidthParam && value.startsWith( "param(outline-width)" ) )
{
hasOutlineWidthParam = true;
if ( valueSplit.size() > 1 )
{
defaultOutlineWidth = valueSplit.at( 1 ).toDouble();
}
}
}
}
else
{
QString value = attribute.value();
valueSplit = value.split( " " );
if ( !hasFillParam && value.startsWith( "param(fill)" ) )
{
hasFillParam = true;
if ( valueSplit.size() > 1 )
{
defaultFill = QColor( valueSplit.at( 1 ) );
}
}
else if ( !hasOutlineParam && value.startsWith( "param(outline)" ) )
{
hasOutlineParam = true;
if ( valueSplit.size() > 1 )
{
defaultOutline = QColor( valueSplit.at( 1 ) );
}
}
else if ( !hasOutlineWidthParam && value.startsWith( "param(outline-width)" ) )
{
hasOutlineWidthParam = true;
if ( valueSplit.size() > 1 )
{
defaultOutlineWidth = valueSplit.at( 1 ).toDouble();
}
}
}
}
//pass it further to child items
QDomNodeList childList = elem.childNodes();
int nChildren = childList.count();
for ( int i = 0; i < nChildren; ++i )
{
QDomElement childElem = childList.at( i ).toElement();
//.........这里部分代码省略.........
示例13: replaceElemParams
void QgsSvgCache::replaceElemParams( QDomElement& elem, const QColor& fill, const QColor& outline, double outlineWidth )
{
if ( elem.isNull() )
{
return;
}
//go through attributes
QDomNamedNodeMap attributes = elem.attributes();
int nAttributes = attributes.count();
for ( int i = 0; i < nAttributes; ++i )
{
QDomAttr attribute = attributes.item( i ).toAttr();
//e.g. style="fill:param(fill);param(stroke)"
if ( attribute.name().compare( "style", Qt::CaseInsensitive ) == 0 )
{
//entries separated by ';'
QString newAttributeString;
QStringList entryList = attribute.value().split( ';' );
QStringList::const_iterator entryIt = entryList.constBegin();
for ( ; entryIt != entryList.constEnd(); ++entryIt )
{
QStringList keyValueSplit = entryIt->split( ':' );
if ( keyValueSplit.size() < 2 )
{
continue;
}
QString key = keyValueSplit.at( 0 );
QString value = keyValueSplit.at( 1 );
if ( value.startsWith( "param(fill" ) )
{
value = fill.name();
}
else if ( value.startsWith( "param(outline)" ) )
{
value = outline.name();
}
else if ( value.startsWith( "param(outline-width)" ) )
{
value = QString::number( outlineWidth );
}
if ( entryIt != entryList.constBegin() )
{
newAttributeString.append( ";" );
}
newAttributeString.append( key + ":" + value );
}
elem.setAttribute( attribute.name(), newAttributeString );
}
else
{
QString value = attribute.value();
if ( value.startsWith( "param(fill)" ) )
{
elem.setAttribute( attribute.name(), fill.name() );
}
else if ( value.startsWith( "param(outline)" ) )
{
elem.setAttribute( attribute.name(), outline.name() );
}
else if ( value.startsWith( "param(outline-width)" ) )
{
elem.setAttribute( attribute.name(), QString::number( outlineWidth ) );
}
}
}
QDomNodeList childList = elem.childNodes();
int nChildren = childList.count();
for ( int i = 0; i < nChildren; ++i )
{
QDomElement childElem = childList.at( i ).toElement();
replaceElemParams( childElem, fill, outline, outlineWidth );
}
}
示例14: readXml
//.........这里部分代码省略.........
sizeType = QgsUnitTypes::RenderMapUnits;
}
else
{
sizeType = QgsUnitTypes::decodeRenderUnit( elem.attribute( "sizeType" ) );
}
sizeScale = QgsSymbolLayerUtils::decodeMapUnitScale( elem.attribute( "sizeScale" ) );
//line width unit type and scale
lineSizeUnit = QgsUnitTypes::decodeRenderUnit( elem.attribute( "lineSizeType" ) );
lineSizeScale = QgsSymbolLayerUtils::decodeMapUnitScale( elem.attribute( "lineSizeScale" ) );
//label placement method
if ( elem.attribute( "labelPlacementMethod" ) == "Height" )
{
labelPlacementMethod = Height;
}
else
{
labelPlacementMethod = XHeight;
}
// orientation
if ( elem.attribute( "diagramOrientation" ) == "Left" )
{
diagramOrientation = Left;
}
else if ( elem.attribute( "diagramOrientation" ) == "Right" )
{
diagramOrientation = Right;
}
else if ( elem.attribute( "diagramOrientation" ) == "Down" )
{
diagramOrientation = Down;
}
else
{
diagramOrientation = Up;
}
// scale dependency
if ( elem.attribute( "scaleDependency" ) == "Diameter" )
{
scaleByArea = false;
}
else
{
scaleByArea = true;
}
barWidth = elem.attribute( "barWidth" ).toDouble();
angleOffset = elem.attribute( "angleOffset" ).toInt();
minimumSize = elem.attribute( "minimumSize" ).toDouble();
//colors
categoryColors.clear();
QDomNodeList attributes = elem.elementsByTagName( "attribute" );
if ( attributes.length() > 0 )
{
for ( int i = 0; i < attributes.size(); i++ )
{
QDomElement attrElem = attributes.at( i ).toElement();
QColor newColor( attrElem.attribute( "color" ) );
newColor.setAlpha( 255 - transparency );
categoryColors.append( newColor );
categoryAttributes.append( attrElem.attribute( "field" ) );
categoryLabels.append( attrElem.attribute( "label" ) );
if ( categoryLabels.back().isEmpty() )
{
categoryLabels.back() = categoryAttributes.back();
}
}
}
else
{
// Restore old format attributes and colors
QStringList colorList = elem.attribute( "colors" ).split( '/' );
QStringList::const_iterator colorIt = colorList.constBegin();
for ( ; colorIt != colorList.constEnd(); ++colorIt )
{
QColor newColor( *colorIt );
newColor.setAlpha( 255 - transparency );
categoryColors.append( QColor( newColor ) );
}
//attribute indices
categoryAttributes.clear();
QStringList catList = elem.attribute( "categories" ).split( '/' );
QStringList::const_iterator catIt = catList.constBegin();
for ( ; catIt != catList.constEnd(); ++catIt )
{
categoryAttributes.append( *catIt );
categoryLabels.append( *catIt );
}
}
}
示例15: scriptName
void
ProjectPackager::startAudioDecoder(QStringList flacFiles, QStringList wavpackFiles)
{
// we can't do a oneliner bash script straight out of a QProcess command
// line, so we'll have to create a purpose built script and run that
QString scriptName("/tmp/rosegarden-audio-decoder-backend");
m_script.setFileName(scriptName);
// remove any lingering copy from a previous run
if (m_script.exists()) m_script.remove();
if (!m_script.open(QIODevice::WriteOnly | QIODevice::Text)) {
puke(tr("<qt><p>Unable to write to temporary backend processing script %1.</p>%2</qt>").arg(scriptName).arg(m_abortText));
return;
}
QTextStream out(&m_script);
out << "# This script was generated by Rosegarden to combine multiple external processing" << endl
<< "# operations so they could be managed by a single QProcess. If you find this script" << endl
<< "# it is likely that something has gone terribly wrong. See http://rosegardenmusic.com" << endl;
int errorPoint = 1;
// The working directory must be the key to why tar is not failing, but
// failing to do anything detectable. Let's cut apart m_filename...
QFileInfo fi(m_filename);
QString dirname = fi.path();
QString basename = QString("%1.%2").arg(fi.baseName()).arg(fi.completeSuffix());
// There were mysterious stupid problems running tar xf in a separate
// QProcess step, so screw it, let's just throw it into this script!
out << "tar xzf \"" << basename << "\" || exit " << errorPoint++ << endl;
// Decode FLAC files
QStringList::const_iterator si;
for (si = flacFiles.constBegin(); si != flacFiles.constEnd(); ++si) {
QString o1 = (*si);
// the file strings are things like xxx.wav.rgp.flac
// without specifying the output file they will turn into xxx.wav.rgp.wav
// thus it is best to specify the output as xxx.wav
//
// files from new project packages have rg-23324234.flac files, files
// from old project packages have rg-2343242.wav.rgp.flac files, so we
// want a robust solution to this one... QFileInfo::baseName() should
// get it
QFileInfo fi(o1);
QString o2 = QString("%1/%2.wav").arg(fi.path()).arg(fi.baseName());
// we'll eschew anything fancy or pretty in this disposable script and
// just write a command on each line, terminating with an || exit n
// which can be used to figure out at which point processing broke, for
// cheap and easy error reporting without a lot of fancy stream wiring
//
// (let's just try escaping spaces &c. with surrounding " and see if
// that is good enough)
RG_DEBUG << "flad -d " << o1 << " -o " << o2;
out << "flac -d \"" << o1 << "\" -o \"" << o2 << "\" && rm \"" << o1 << "\" || exit " << errorPoint << endl;
errorPoint++;
}
// Decode WavPack files
for (si = wavpackFiles.constBegin(); si != wavpackFiles.constEnd(); ++si) {
QString o = (*si);
// NOTE: wvunpack -d means "delete the file if successful" not "decode"
out << "wvunpack -d \"" << o << "\" || exit " << errorPoint << endl;
errorPoint++;
}
m_script.close();
// run the assembled script
m_process = new QProcess;
// set to the working directory extracted from m_filename above, as this is
// was apparently the reason why tar always failed to do anything
m_process->setWorkingDirectory(dirname);
m_process->start("bash", QStringList() << scriptName);
connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT(finishUnpack(int, QProcess::ExitStatus)));
// wait up to 30 seconds for process to start
m_info->setText(tr("Decoding audio files..."));
if (!m_process->waitForStarted()) {
puke(tr("<qt>Could not start backend processing script %1.</qt>").arg(scriptName));
return;
}
}