本文整理汇总了C++中QLinkedList::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QLinkedList::isEmpty方法的具体用法?C++ QLinkedList::isEmpty怎么用?C++ QLinkedList::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLinkedList
的用法示例。
在下文中一共展示了QLinkedList::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: joinConnectedFeatures
void Layer::joinConnectedFeatures()
{
// go through all label texts
QString labelText;
while ( !connectedTexts->isEmpty() )
{
labelText = connectedTexts->takeFirst();
//std::cerr << "JOIN: " << labelText << std::endl;
QHash< QString, QLinkedList<FeaturePart*>* >::const_iterator partsPtr = connectedHashtable->find( labelText );
if ( partsPtr == connectedHashtable->constEnd() )
continue; // shouldn't happen
QLinkedList<FeaturePart*>* parts = *partsPtr;
// go one-by-one part, try to merge
while ( !parts->isEmpty() )
{
// part we'll be checking against other in this round
FeaturePart* partCheck = parts->takeFirst();
FeaturePart* otherPart = _findConnectedPart( partCheck, parts );
if ( otherPart )
{
//std::cerr << "- connected " << partCheck << " with " << otherPart << std::endl;
// remove partCheck from r-tree
double bmin[2], bmax[2];
partCheck->getBoundingBox( bmin, bmax );
rtree->Remove( bmin, bmax, partCheck );
featureParts->removeOne( partCheck );
otherPart->getBoundingBox( bmin, bmax );
// merge points from partCheck to p->item
if ( otherPart->mergeWithFeaturePart( partCheck ) )
{
// reinsert p->item to r-tree (probably not needed)
rtree->Remove( bmin, bmax, otherPart );
otherPart->getBoundingBox( bmin, bmax );
rtree->Insert( bmin, bmax, otherPart );
}
}
}
// we're done processing feature parts with this particular label text
delete parts;
}
// we're done processing connected fetures
delete connectedHashtable;
connectedHashtable = NULL;
delete connectedTexts;
connectedTexts = NULL;
}
示例2: selectCoverArtForTrack
//static
CoverArt CoverArtUtils::selectCoverArtForTrack(
Track* pTrack,
const QLinkedList<QFileInfo>& covers) {
if (pTrack == NULL || covers.isEmpty()) {
CoverArt art;
art.info.source = CoverInfo::GUESSED;
return art;
}
const QString trackBaseName = pTrack->getFileInfo().baseName();
const QString albumName = pTrack->getAlbum();
return selectCoverArtForTrack(trackBaseName, albumName, covers);
}
示例3: geosContext
QLinkedList<const GEOSGeometry *>* pal::Util::unmulti( const GEOSGeometry *the_geom )
{
QLinkedList<const GEOSGeometry*> *queue = new QLinkedList<const GEOSGeometry*>;
QLinkedList<const GEOSGeometry*> *final_queue = new QLinkedList<const GEOSGeometry*>;
const GEOSGeometry *geom;
queue->append( the_geom );
int nGeom;
int i;
GEOSContextHandle_t geosctxt = geosContext();
while ( !queue->isEmpty() )
{
geom = queue->takeFirst();
int type = GEOSGeomTypeId_r( geosctxt, geom );
switch ( type )
{
case GEOS_MULTIPOINT:
case GEOS_MULTILINESTRING:
case GEOS_MULTIPOLYGON:
nGeom = GEOSGetNumGeometries_r( geosctxt, geom );
for ( i = 0; i < nGeom; i++ )
{
queue->append( GEOSGetGeometryN_r( geosctxt, geom, i ) );
}
break;
case GEOS_POINT:
case GEOS_LINESTRING:
case GEOS_POLYGON:
final_queue->append( geom );
break;
default:
QgsDebugMsg( QString( "unexpected geometry type:%1" ).arg( type ) );
delete final_queue;
delete queue;
return nullptr;
}
}
delete queue;
return final_queue;
}
示例4: run
void AssignLayers::run(Graph &graph)
{
emit setStatusMsg("Assigning layers...");
// copy the nodes to a linked list
QLinkedList<AbstractNode*> vertices;
for(AbstractNode* v : graph.getNodes()) {
vertices.append(v);
}
QSet<AbstractNode*> U;
QSet<AbstractNode*> Z;
QList<QList<AbstractNode*>> layers;
//add the first layer
int currentLayer = 0;
layers.append(QList<AbstractNode*>());
while(!vertices.isEmpty()) {
AbstractNode* selected = nullptr;
for(AbstractNode* v : vertices) {
if(Z.contains(v->getPredecessors().toSet())) {
selected = v;
break;
}
}
if(selected != nullptr) {
selected->setLayer(currentLayer);
layers.last().append(selected);
U.insert(selected);
vertices.removeOne(selected);
} else {
currentLayer++;
layers.append(QList<AbstractNode*>());
Z.unite(U);
}
}
graph.setLayers(layers);
graph.repaintLayers();
emit setStatusMsg("Assigning layers... Done!");
}
示例5: generatePixmap
void PluckerGenerator::generatePixmap( Okular::PixmapRequest * request )
{
const QSizeF size = mPages[ request->pageNumber() ]->size();
QPixmap *pixmap = new QPixmap( request->width(), request->height() );
pixmap->fill( Qt::white );
QPainter p;
p.begin( pixmap );
qreal width = request->width();
qreal height = request->height();
p.scale( width / (qreal)size.width(), height / (qreal)size.height() );
mPages[ request->pageNumber() ]->drawContents( &p );
p.end();
request->page()->setPixmap( request->id(), pixmap );
if ( !mLinkAdded.contains( request->pageNumber() ) ) {
QLinkedList<Okular::ObjectRect*> objects;
for ( int i = 0; i < mLinks.count(); ++i ) {
if ( mLinks[ i ].page == request->pageNumber() ) {
QTextDocument *document = mPages[ request->pageNumber() ];
QRectF rect;
calculateBoundingRect( document, mLinks[ i ].start,
mLinks[ i ].end, rect );
objects.append( new Okular::ObjectRect( rect.left(), rect.top(), rect.right(), rect.bottom(), false, Okular::ObjectRect::Action, mLinks[ i ].link ) );
}
}
if ( !objects.isEmpty() )
request->page()->setObjectRects( objects );
mLinkAdded.insert( request->pageNumber() );
}
signalPixmapRequestDone( request );
}
示例6: while
QLinkedList<const GEOSGeometry *> *unmulti( const GEOSGeometry *the_geom )
{
QLinkedList<const GEOSGeometry*> *queue = new QLinkedList<const GEOSGeometry*>;
QLinkedList<const GEOSGeometry*> *final_queue = new QLinkedList<const GEOSGeometry*>;
const GEOSGeometry *geom;
queue->append( the_geom );
int nGeom;
int i;
while ( !queue->isEmpty() )
{
geom = queue->takeFirst();
GEOSContextHandle_t geosctxt = geosContext();
switch ( GEOSGeomTypeId_r( geosctxt, geom ) )
{
case GEOS_MULTIPOINT:
case GEOS_MULTILINESTRING:
case GEOS_MULTIPOLYGON:
nGeom = GEOSGetNumGeometries_r( geosctxt, geom );
for ( i = 0; i < nGeom; i++ )
{
queue->append( GEOSGetGeometryN_r( geosctxt, geom, i ) );
}
break;
case GEOS_POINT:
case GEOS_LINESTRING:
case GEOS_POLYGON:
final_queue->append( geom );
break;
default:
delete final_queue;
delete queue;
return NULL;
}
}
delete queue;
return final_queue;
}
示例7: joinConnectedFeatures
void Layer::joinConnectedFeatures()
{
// go through all label texts
int connectedFeaturesId = 0;
Q_FOREACH ( const QString& labelText, mConnectedTexts )
{
if ( !mConnectedHashtable.contains( labelText ) )
continue; // shouldn't happen
connectedFeaturesId++;
QLinkedList<FeaturePart*>* parts = mConnectedHashtable.value( labelText );
// go one-by-one part, try to merge
while ( !parts->isEmpty() && parts->count() > 1 )
{
// part we'll be checking against other in this round
FeaturePart* partCheck = parts->takeFirst();
FeaturePart* otherPart = _findConnectedPart( partCheck, parts );
if ( otherPart )
{
// remove partCheck from r-tree
double checkpartBMin[2], checkpartBMax[2];
partCheck->getBoundingBox( checkpartBMin, checkpartBMax );
double otherPartBMin[2], otherPartBMax[2];
otherPart->getBoundingBox( otherPartBMin, otherPartBMax );
// merge points from partCheck to p->item
if ( otherPart->mergeWithFeaturePart( partCheck ) )
{
// remove the parts we are joining from the index
mFeatureIndex->Remove( checkpartBMin, checkpartBMax, partCheck );
mFeatureIndex->Remove( otherPartBMin, otherPartBMax, otherPart );
// reinsert merged line to r-tree (probably not needed)
otherPart->getBoundingBox( otherPartBMin, otherPartBMax );
mFeatureIndex->Insert( otherPartBMin, otherPartBMax, otherPart );
mConnectedFeaturesIds.insert( partCheck->featureId(), connectedFeaturesId );
mConnectedFeaturesIds.insert( otherPart->featureId(), connectedFeaturesId );
mFeatureParts.removeOne( partCheck );
delete partCheck;
}
}
}
// we're done processing feature parts with this particular label text
delete parts;
mConnectedHashtable.remove( labelText );
}
// we're done processing connected features
//should be empty, but clear to be safe
qDeleteAll( mConnectedHashtable );
mConnectedHashtable.clear();
mConnectedTexts.clear();
}
示例8: trackdir
//.........这里部分代码省略.........
QString cLoc_albumName = QString(trackdir % "/album_name." % qFormat);
EXPECT_TRUE(img.scaled(500,500).save(cLoc_albumName, format));
prefCovers << QFileInfo(cLoc_albumName);
// 3. cover.jpg
QString cLoc_cover = QString(trackdir % "/" % "cover." % qFormat);
EXPECT_TRUE(img.scaled(400,400).save(cLoc_cover, format));
prefCovers << QFileInfo(cLoc_cover);
// 4. front.jpg
QString cLoc_front = QString(trackdir % "/" % "front." % qFormat);
EXPECT_TRUE(img.scaled(300,300).save(cLoc_front, format));
prefCovers << QFileInfo(cLoc_front);
// 5. album.jpg
QString cLoc_album = QString(trackdir % "/" % "album." % qFormat);
EXPECT_TRUE(img.scaled(100,100).save(cLoc_album, format));
prefCovers << QFileInfo(cLoc_album);
// 6. folder.jpg
QString cLoc_folder = QString(trackdir % "/" % "folder." % qFormat);
EXPECT_TRUE(img.scaled(100,100).save(cLoc_folder, format));
prefCovers << QFileInfo(cLoc_folder);
// 8. other1.jpg
QString cLoc_other1 = QString(trackdir % "/" % "other1." % qFormat);
EXPECT_TRUE(img.scaled(10,10).save(cLoc_other1, format));
prefCovers << QFileInfo(cLoc_other1);
// 7. other2.jpg
QString cLoc_other2 = QString(trackdir % "/" % "other2." % qFormat);
EXPECT_TRUE(img.scaled(10,10).save(cLoc_other2, format));
prefCovers << QFileInfo(cLoc_other2);
// we must find covers in the right order
EXPECT_EQ(8, prefCovers.size());
// Remove the covers one by one from the front, checking that each one is
// selected as we remove the previously-most-preferable cover.
while (!prefCovers.isEmpty()) {
QFileInfo cover = prefCovers.first();
// We expect no cover selected for other1 since there are 2 covers,
// neither of which match our preferred cover names. other2 will be
// selected once we get to it since it is the only cover available.
if (cover.baseName() == "other1") {
expected.image = QImage();
expected.info.type = CoverInfo::NONE;
expected.info.coverLocation = QString();
expected.info.hash = 0;
} else {
expected.image = QImage(cover.filePath());
expected.info.type = CoverInfo::FILE;
expected.info.coverLocation = cover.fileName();
expected.info.hash = CoverArtUtils::calculateHash(expected.image);
}
res = CoverArtUtils::selectCoverArtForTrack(trackBaseName, trackAlbum,
prefCovers);
EXPECT_QSTRING_EQ(expected.info.coverLocation, res.info.coverLocation);
EXPECT_QSTRING_EQ(expected.info.hash, res.info.hash);
EXPECT_EQ(expected, res);
QFile::remove(cover.filePath());
prefCovers.pop_front();
}
//
// Additional tests
//
// what is chosen when cover.jpg and cover.JPG exists?
// (it must always prefer the lighter cover)
示例9: write
bool KNMusicPlaylistiTunesXMLParser::write(KNMusicPlaylistModel *playlist,
const QString &filePath)
{
//Generate the plist document.
QDomDocument plistDocument;
//Initial the plist element.
QDomElement plistRoot=plistDocument.createElement("plist");
plistRoot.setAttribute("version", "1.0");
plistDocument.appendChild(plistRoot);
//Initial the dict element.
QDomElement dictElement=plistDocument.createElement("dict");
plistRoot.appendChild(dictElement);
appendDictValue(plistDocument, dictElement, "Major Version", 1);
appendDictValue(plistDocument, dictElement, "Minor Version", 1);
appendDictValue(plistDocument, dictElement, "Date",
QDateTime::currentDateTime());
appendDictValue(plistDocument, dictElement, "Features", 5);
appendDictValue(plistDocument, dictElement, "Show Content Ratings", true);
//Generate database and song index list.
QHash<QString, int> filePathIndex;
QLinkedList<int> playlistIndexList;
//Add paths to hash keys.
for(int i=0; i<playlist->rowCount(); i++)
{
//Get current path.
QString currentPath=playlist->rowProperty(i, FilePathRole).toString();
//Check the path in the index hash.
int currentIndex=filePathIndex.value(currentPath, -1);
//If we never insert this path to the index,
if(currentIndex==-1)
{
//Get the new index.
currentIndex=i;
//Insert the path to the hash.
filePathIndex.insert(currentPath, currentIndex);
}
//Append the list.
playlistIndexList.append(currentIndex);
}
//Output the database info to dict.
//Initial the elements.
QDomElement tracksKey=plistDocument.createElement("key"),
tracksDict=plistDocument.createElement("dict");
QDomText tracksKeyValue=plistDocument.createTextNode("Tracks");
tracksKey.appendChild(tracksKeyValue);
//Add to dict elements.
dictElement.appendChild(tracksKey);
dictElement.appendChild(tracksDict);
//Write database info.
QList<int> songIndexList=filePathIndex.values();
while(!songIndexList.isEmpty())
{
int currentRow=songIndexList.takeFirst(),
trackID=currentRow+100;
//Generate current row key and dict.
QDomElement trackKey=plistDocument.createElement("key"),
trackDict=plistDocument.createElement("dict");
//Generate the track key value.
QDomText trackKeyValue=
plistDocument.createTextNode(QString::number(trackID));
trackKey.appendChild(trackKeyValue);
//Get the detail info.
const KNMusicDetailInfo detailInfo=playlist->rowDetailInfo(currentRow);
//Generate the dict.
appendDictValue(plistDocument, trackDict, "Track ID",
trackID);
appendDictValue(plistDocument, trackDict, "Name",
detailInfo.textLists[Name]);
appendDictValue(plistDocument, trackDict, "Artist",
detailInfo.textLists[Artist]);
appendDictValue(plistDocument, trackDict, "Album Artist",
detailInfo.textLists[AlbumArtist]);
appendDictValue(plistDocument, trackDict, "Genre",
detailInfo.textLists[Genre]);
appendDictValue(plistDocument, trackDict, "Kind",
detailInfo.textLists[Kind]);
appendDictValue(plistDocument, trackDict, "Size",
detailInfo.size);
appendDictValue(plistDocument, trackDict, "Total Time",
detailInfo.duration);
appendDictValue(plistDocument, trackDict, "Track Number",
detailInfo.textLists[TrackNumber].toString().toInt());
appendDictValue(plistDocument, trackDict, "Track Count",
detailInfo.textLists[TrackCount].toString().toInt());
appendDictValue(plistDocument, trackDict, "Year",
detailInfo.textLists[Year].toString().toInt());
appendDictValue(plistDocument, trackDict, "Date Modified",
detailInfo.dateModified);
appendDictValue(plistDocument, trackDict, "Date Added",
detailInfo.dateAdded);
appendDictValue(plistDocument, trackDict, "Bit Rate",
detailInfo.bitRate);
appendDictValue(plistDocument, trackDict, "Sample Rate",
detailInfo.samplingRate);
appendDictValue(plistDocument, trackDict, "Track Type", "File");
QString fileLocate=QUrl::fromLocalFile(detailInfo.filePath).toString();
#ifdef Q_OS_WIN
//.........这里部分代码省略.........
示例10: planFlashWrite
/**
* Produces FLASH erase and write plans for optimally programming application code into
* a device.
*
* This routine assumes that pages filled with blank or "NOP" instructions (0xFFFF) do
* not need to be erased nor written. For most applications, this will be sufficient,
* providing extremely fast programming.
*
* To guarantee clean memory, perform a Verify After Write CRC check on each Erase
* Block. This will find any leftover junk data from older firmware that can be erased.
*/
void DeviceWritePlanner::planFlashWrite(QLinkedList<Device::MemoryRange>& eraseList,
QLinkedList<Device::MemoryRange>& writeList,
unsigned int start, unsigned int end,
unsigned int* data, unsigned int* existingData)
{
unsigned int address = start;
Device::MemoryRange block;
while(address < end)
{
address = skipEmptyFlashPages(address, data);
block.start = address;
if(address >= end)
{
break;
}
address = findEndFlashWrite(address, data);
if(address >= end)
{
address = end;
}
block.end = address;
if(device->family == Device::PIC16 && !device->hasEraseFlashCommand())
{
// Certain PIC16 devices (such as PIC16F882) have a peculiar automatic erase
// during write feature. To make that work, writes must be expanded to align
// with Erase Block boundaries.
block.start -= (block.start % device->eraseBlockSizeFLASH);
if(block.end % device->eraseBlockSizeFLASH)
{
block.end += device->eraseBlockSizeFLASH - (block.end % device->eraseBlockSizeFLASH);
address = block.end;
}
}
writeList.append(block);
address++;
}
if(existingData == NULL && device->family == Device::PIC32)
{
// Because PIC32 has Bulk Erase available for bootloader use,
// it's faster to simply erase the entire FLASH memory space
// than erasing specific erase blocks using an erase plan.
block.start = device->startFLASH;
block.end = device->endFLASH;
eraseList.append(block);
}
else
{
if(existingData != NULL)
{
QLinkedList<Device::MemoryRange>::iterator it;
for(it = writeList.begin(); it != writeList.end(); ++it)
{
qDebug("unpruned write(%X to %X)", it->start, it->end);
}
doNotWriteExistingData(writeList, start, end, data, existingData);
for(it = writeList.begin(); it != writeList.end(); ++it)
{
qDebug("pruned write(%X to %X)", it->start, it->end);
}
}
if(!writeList.isEmpty())
{
if(device->hasEraseFlashCommand())
{
flashEraseList(eraseList, writeList, data, existingData);
}
EraseAppCheckFirst(eraseList);
WriteAppCheckLast(writeList);
if(writeConfig)
{
eraseConfigPageLast(eraseList);
writeConfigPageFirst(writeList);
doNotEraseBootBlock(eraseList); // needed in case boot block resides on config page
}
else
{
doNotEraseConfigPage(eraseList);
}
doNotEraseInterruptVectorTable(eraseList);
}
//.........这里部分代码省略.........
示例11: parseData
bool KNMusicLRCLyricsParser::parseData(const QString &lyricsTextData,
QList<qint64> &positionList,
QStringList &textList)
{
//Clear the position list and text list.
positionList.clear();
textList.clear();
//Split the lyrics text data.
QStringList lyricsRawData=lyricsTextData.split(QRegExp("\n"),
QString::SkipEmptyParts);
QList<LyricsLine> lyricsLineList;
//Remove the same line in the lyrics raw data.
lyricsRawData.removeDuplicates();
//Parse the lyrics raw data.
while(!lyricsRawData.isEmpty())
{
//Get the first line of the current list and remove all spaces.
QString currentLine=lyricsRawData.takeFirst().simplified();
//Find frames in the current line.
QRegularExpressionMatchIterator frameMatcher=
m_frameCatchRegExp.globalMatch(currentLine);
int lastPosition=0;
QLinkedList<QString> frameLists;
//Get all the frames.
while(frameMatcher.hasNext())
{
QRegularExpressionMatch matchedFrame=frameMatcher.next();
//Check is the current matched frame is at the last position.
//An example is:
// [00:00:01] Won't chu kiss me![00:00:03]Saikou no
if(matchedFrame.capturedStart()!=lastPosition)
{
//Then we should pick out the data before the current start and
//last position.
//Like 'Won't chu kiss me!' in the example.
QString text=currentLine.mid(lastPosition,
matchedFrame.capturedStart()-lastPosition);
//Parse the datas to frame lists.
while(!frameLists.isEmpty())
{
parseFrames(frameLists.takeFirst(),
text,
lyricsLineList);
}
}
//Add current frame to frame list.
frameLists.append(currentLine.mid(matchedFrame.capturedStart(),
matchedFrame.capturedLength()));
//Update the last position.
lastPosition=matchedFrame.capturedEnd();
}
//Remove the previous datas, and parse the left datas to frame lists.
currentLine.remove(0, lastPosition);
while(!frameLists.isEmpty())
{
parseFrames(frameLists.takeFirst(),
currentLine,
lyricsLineList);
}
}
//Check is the lyrics line list is empty or not, if it's empty, means we
//can't parse it.
if(lyricsLineList.isEmpty())
{
return false;
}
//Sorr the lyrics line.
//- Why stable sort?
// Because there might be some frames at the same time. Display them with
//their exist order.
qStableSort(lyricsLineList.begin(), lyricsLineList.end(), frameLessThan);
//Combine the same timestamp lyrics.
QMap<qint64, QString> lyricsCombineMap;
for(QList<LyricsLine>::iterator i=lyricsLineList.begin();
i!=lyricsLineList.end();
++i)
{
lyricsCombineMap.insert((*i).position,
lyricsCombineMap.contains((*i).position)?
lyricsCombineMap.value((*i).position)+'\n'+(*i).text:
(*i).text);
}
//Export the position and the text.
positionList=lyricsCombineMap.keys();
textList=lyricsCombineMap.values();
return true;
}
示例12: parseTag
//.........这里部分代码省略.........
char chunkHeader[8];
//Initial the chunk found flag.
bool listFound=false, id32Found=false;
//We have to prepare the list here and write the data after parse all the
//data, we want the id32 chunk has a higher priority than list chunk.
//Prepare the wav item list for list chunk.
QList<WAVItem> listData;
//Generate the raw frame linked list for id32 chunk.
QLinkedList<ID3v2Frame> frames;
//Generate the id3v2 frame function set for id32 chunk.
ID3v2FunctionSet functionSet;
//Start finding the chunk.
while(musicDataStream.device()->pos()<fileSize && !listFound && !id32Found)
{
//Read chunk head.
musicDataStream.readRawData(chunkHeader, 8);
//Calculate the chunk size.
quint32 chunkSize=KNMusicUtil::inverseCharToInt32(chunkHeader+4);
//Check if it's list chunk
if(memcmp(chunkHeader, m_listChunk, 4)==0)
{
//Set list chunk found flag to true.
listFound=true;
//Generate chunk size cache.
char *listRawData=new char[chunkSize];
//Read the raw data.
musicDataStream.readRawData(listRawData, chunkSize);
//Parse list chunk.
parseListChunk(listRawData, chunkSize, listData);
//Recover memory.
delete[] listRawData;
}
//Check if it's id32 chunk.
else if(memcmp(chunkHeader, m_id32Chunk, 4)==0)
{
//Generate ID3v2 header cache.
char rawHeader[10];
//Generate ID3v2 header structure.
ID3v2Header header;
//Read ID3v2 header data.
musicDataStream.readRawData(rawHeader, 10);
//Parse the ID3v2 header.
//and then Check is chunk size smaller than tag size.
if(!parseID3v2Header(rawHeader, header) ||
chunkSize<(header.size+10))
{
//If we cannot parse it, skip the whole chunk.
musicDataStream.skipRawData(chunkSize-10);
//Continue to next chunk.
continue;
}
//Generate the raw tag data field.
char *rawTagData=new char[header.size];
//Read the raw tag data.
musicDataStream.readRawData(rawTagData, header.size);
//Get the function set according to the minor version of the header.
getId3v2FunctionSet(header.major, functionSet);
//Parse the raw data.
parseID3v2RawData(rawTagData, header, functionSet, frames);
//Recover the memory.
delete[] rawTagData;
//Set the id32 chunk find flag to true.
id32Found=true;
}
//For all the other chunks.
else
{
//Skip the data.
musicDataStream.skipRawData(chunkSize);
}
}
//Check if the list data is not empty, first.
//The data can be overwrite by id32 chunk data.
if(!listData.isEmpty())
{
//Check all the data in the wav item list.
for(auto i : listData)
{
//Get the index of current item.
int chunkIndex=m_listKeyIndex.value(i.key, -1);
//Check the validation of chunk index.
if(chunkIndex==-1)
{
//Abandon the current index.
continue;
}
//Set the data.
analysisItem.detailInfo.textLists[chunkIndex]=
QVariant(i.value);
}
}
//Check id32 chunk data then.
if(!frames.isEmpty())
{
//Write the tag to analysis info.
writeFrameToDetails(frames, functionSet, analysisItem);
}
//Mission complete.
return true;
}
示例13: registerFeature
bool Layer::registerFeature( QgsLabelFeature* lf )
{
if ( lf->size().width() < 0 || lf->size().height() < 0 )
return false;
mMutex.lock();
if ( mHashtable.contains( lf->id() ) )
{
mMutex.unlock();
//A feature with this id already exists. Don't throw an exception as sometimes,
//the same feature is added twice (dateline split with otf-reprojection)
return false;
}
// assign label feature to this PAL layer
lf->setLayer( this );
// Split MULTI GEOM and Collection in simple geometries
bool addedFeature = false;
double geom_size = -1, biggest_size = -1;
FeaturePart* biggest_part = nullptr;
// break the (possibly multi-part) geometry into simple geometries
QLinkedList<const GEOSGeometry*>* simpleGeometries = Util::unmulti( lf->geometry() );
if ( !simpleGeometries ) // unmulti() failed?
{
mMutex.unlock();
throw InternalException::UnknownGeometry();
}
GEOSContextHandle_t geosctxt = geosContext();
bool featureGeomIsObstacleGeom = !lf->obstacleGeometry();
while ( !simpleGeometries->isEmpty() )
{
const GEOSGeometry* geom = simpleGeometries->takeFirst();
// ignore invalid geometries (e.g. polygons with self-intersecting rings)
if ( GEOSisValid_r( geosctxt, geom ) != 1 ) // 0=invalid, 1=valid, 2=exception
{
continue;
}
int type = GEOSGeomTypeId_r( geosctxt, geom );
if ( type != GEOS_POINT && type != GEOS_LINESTRING && type != GEOS_POLYGON )
{
mMutex.unlock();
throw InternalException::UnknownGeometry();
}
FeaturePart* fpart = new FeaturePart( lf, geom );
// ignore invalid geometries
if (( type == GEOS_LINESTRING && fpart->nbPoints < 2 ) ||
( type == GEOS_POLYGON && fpart->nbPoints < 3 ) )
{
delete fpart;
continue;
}
// polygons: reorder coordinates
if ( type == GEOS_POLYGON && GeomFunction::reorderPolygon( fpart->nbPoints, fpart->x, fpart->y ) != 0 )
{
delete fpart;
continue;
}
// is the feature well defined? TODO Check epsilon
bool labelWellDefined = ( lf->size().width() > 0.0000001 && lf->size().height() > 0.0000001 );
if ( lf->isObstacle() && featureGeomIsObstacleGeom )
{
//if we are not labelling the layer, only insert it into the obstacle list and avoid an
//unnecessary copy
if ( mLabelLayer && labelWellDefined )
{
addObstaclePart( new FeaturePart( *fpart ) );
}
else
{
addObstaclePart( fpart );
fpart = nullptr;
}
}
// feature has to be labeled?
if ( !mLabelLayer || !labelWellDefined )
{
//nothing more to do for this part
delete fpart;
continue;
}
if ( mMode == LabelPerFeature && ( type == GEOS_POLYGON || type == GEOS_LINESTRING ) )
{
//.........这里部分代码省略.........
示例14: mapBoundaryGeos
std::unique_ptr<Problem> Pal::extract( const QgsRectangle &extent, const QgsGeometry &mapBoundary )
{
// to store obstacles
RTree<FeaturePart *, double, 2, double> *obstacles = new RTree<FeaturePart *, double, 2, double>();
std::unique_ptr< Problem > prob = qgis::make_unique< Problem >();
int i, j;
double bbx[4];
double bby[4];
double amin[2];
double amax[2];
int max_p = 0;
LabelPosition *lp = nullptr;
bbx[0] = bbx[3] = amin[0] = prob->bbox[0] = extent.xMinimum();
bby[0] = bby[1] = amin[1] = prob->bbox[1] = extent.yMinimum();
bbx[1] = bbx[2] = amax[0] = prob->bbox[2] = extent.xMaximum();
bby[2] = bby[3] = amax[1] = prob->bbox[3] = extent.yMaximum();
prob->pal = this;
QLinkedList<Feats *> *fFeats = new QLinkedList<Feats *>;
FeatCallBackCtx context;
// prepare map boundary
geos::unique_ptr mapBoundaryGeos( QgsGeos::asGeos( mapBoundary ) );
geos::prepared_unique_ptr mapBoundaryPrepared( GEOSPrepare_r( QgsGeos::getGEOSHandler(), mapBoundaryGeos.get() ) );
context.fFeats = fFeats;
context.obstacles = obstacles;
context.candidates = prob->candidates;
context.mapBoundary = mapBoundaryPrepared.get();
ObstacleCallBackCtx obstacleContext;
obstacleContext.obstacles = obstacles;
obstacleContext.obstacleCount = 0;
// first step : extract features from layers
int previousFeatureCount = 0;
int previousObstacleCount = 0;
QStringList layersWithFeaturesInBBox;
mMutex.lock();
const auto constMLayers = mLayers;
for ( Layer *layer : constMLayers )
{
if ( !layer )
{
// invalid layer name
continue;
}
// only select those who are active
if ( !layer->active() )
continue;
// check for connected features with the same label text and join them
if ( layer->mergeConnectedLines() )
layer->joinConnectedFeatures();
layer->chopFeaturesAtRepeatDistance();
layer->mMutex.lock();
// find features within bounding box and generate candidates list
context.layer = layer;
layer->mFeatureIndex->Search( amin, amax, extractFeatCallback, static_cast< void * >( &context ) );
// find obstacles within bounding box
layer->mObstacleIndex->Search( amin, amax, extractObstaclesCallback, static_cast< void * >( &obstacleContext ) );
layer->mMutex.unlock();
if ( context.fFeats->size() - previousFeatureCount > 0 || obstacleContext.obstacleCount > previousObstacleCount )
{
layersWithFeaturesInBBox << layer->name();
}
previousFeatureCount = context.fFeats->size();
previousObstacleCount = obstacleContext.obstacleCount;
}
mMutex.unlock();
prob->nbLabelledLayers = layersWithFeaturesInBBox.size();
prob->labelledLayersName = layersWithFeaturesInBBox;
if ( fFeats->isEmpty() )
{
delete fFeats;
delete obstacles;
return nullptr;
}
prob->nbft = fFeats->size();
//.........这里部分代码省略.........
示例15: compile
void compile(QString path,QStringList& import,QFile &out){
QFile fp(path);
if(fp.open(QFile::ReadOnly)){
QDir dir(QFileInfo(fp).absoluteDir());
QString modName = QFileInfo(fp).baseName();
if(readLine(fp).trimmed()!=FILE_HEAD){
qDebug("Indicated file is not a algorithm file of Uranus2");
exit(0);
}
int pIndent,cIndent=0,functionIndent=0;
Function* function=0;
QRegExp keyWord("(\\s*)(\\w+)\\s",Qt::CaseInsensitive);
QRegExp argHook("(<.+>)?(.+)?");
QLinkedList<StackItem*> stack;
while(!fp.atEnd()){
QString line=QString::fromUtf8(fp.readLine());
keyWord.indexIn(line);
QString key=keyWord.cap(2).toLower();
line=line.mid(keyWord.cap().length()).trimmed();
pIndent = cIndent;
cIndent=keyWord.cap(1).length();
if(cIndent<functionIndent){
if(function!=0){
function->write(out);
function=0;
}
}else if(cIndent<=pIndent){
while(pIndent>=cIndent){
pIndent--;
if(!stack.isEmpty()){
stack.pop_back();
}
}
}
StackItem* parent = (stack.isEmpty())?0:stack.back(),
*self=new StackItem(key,line,cIndent);
stack.push_back(self);
if(key=="import"){
import.append(dir.absoluteFilePath(line));
}else if(key=="function"){
function=new Function(modName,line);
functionIndent=cIndent+1;
}else if(key=="hint"){
if(function!=0){
if(parent->key=="function")
self->indent++;
self->outBegin="#"+line;
function->append(self);
}
}else if(key=="arg"){
if(parent->key=="function"&&function){
function->args()<<line;
}
}else if(key=="assign"){
self->outBegin=line+"=";
function->append(self);
}else if(key=="value"){
if(parent->key=="assign"){
argHook.indexIn(line);
if(argHook.cap(1)=="<list>"){
}else if(argHook.cap(1)=="<function>"){
}else if(argHook.cap(1)=="<variable>"){
self->outBegin=argHook.cap(2).trimmed();
}else{
self->outBegin=line.trimmed();
}
parent->addChild(self);
}
}else if(key=="branch"){
self->outBegin="if True:";
function->append(self);
}else if(key=="call"){
QString fname;
if(line.left(3)=="://"){
fname=Function::conv(modName,line.mid(3));
}else{
QStringList f = line.split("/");
if(f.count()==2){
fname=Function::conv(f.at(0),f.at(1));
}
}
self->outBegin=fname+"(";
self->outSep=",";
self->outEnd=")";
if(parent->key=="do"){
function->append(self);
}else{
parent->addChild(self);
}
}else if(key=="conditional"){
self->outBegin="if True:";
function->append(self);
}else if(key=="do"){
}else if(key=="list"){
self->outBegin="[";
self->outSep=",";
self->outEnd="]";
parent->addChild(self);
}else if(key=="item"){
//.........这里部分代码省略.........