本文整理汇总了C++中QLinkedList::first方法的典型用法代码示例。如果您正苦于以下问题:C++ QLinkedList::first方法的具体用法?C++ QLinkedList::first怎么用?C++ QLinkedList::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLinkedList
的用法示例。
在下文中一共展示了QLinkedList::first方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main ()
{
QLinkedList<int> myQLinkedList;
myQLinkedList.push_back(77);
myQLinkedList.push_back(22);
assert(myQLinkedList.first() != 77);
// now front equals 77, and back 22
myQLinkedList.first() -= myQLinkedList.back();
assert(myQLinkedList.first() == 55);
cout << "myQLinkedList.front() is now " << myQLinkedList.first() << endl;
return 0;
}
示例2: exceptionLinkedList
void tst_ExceptionSafety::exceptionLinkedList() {
{
QLinkedList<FlexibleThrowerSmall> list;
QLinkedList<FlexibleThrowerSmall> list2;
QLinkedList<FlexibleThrowerSmall> list3;
for( int i = 0; i<10; i++ )
list.append( FlexibleThrowerSmall(i) );
try {
throwType = ThrowAtCopy;
list.append( FlexibleThrowerSmall(10));
} catch (...) {
}
QCOMPARE( list.size(), 10 );
try {
throwType = ThrowAtCopy;
list.prepend( FlexibleThrowerSmall(10));
} catch (...) {
}
QCOMPARE( list.first().value(), 0 );
QCOMPARE( list.size(), 10 );
try {
throwType = ThrowAtCopy;
list3 = list;
list3.append( FlexibleThrowerSmall(11) );
} catch (...) {
}
QCOMPARE( list.first().value(), 0 );
QCOMPARE( list.size(), 10 );
QCOMPARE( list3.size(), 10 );
}
QCOMPARE(objCounter, 0 ); // check that every object has been freed
}
示例3: run
void SendDataThread::run()
{
while(true)
{
QMutexLocker locker(&m_DataMutex);
m_DataCondition.wait(&m_DataMutex);
int count = m_DataList.count();
for(int i = 0; i < count; ++i)
{
const QByteArray& data = m_DataList.first();
if(!::sendData(m_Socket, data.data(), data.size()))
{
qDebug()<<"Send data to server error";
return;
}
m_DataList.pop_front();
}
}
}
示例4: trackdir
//.........这里部分代码省略.........
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)
QString cLoc_coverJPG = trackdir % "/" % "cover." % "JPG";
示例5: selectCoverArtForTrack
//static
CoverArt CoverArtUtils::selectCoverArtForTrack(
const QString& trackBaseName,
const QString& albumName,
const QLinkedList<QFileInfo>& covers) {
CoverArt art;
art.info.source = CoverInfo::GUESSED;
if (covers.isEmpty()) {
return art;
}
PreferredCoverType bestType = NONE;
const QFileInfo* bestInfo = NULL;
// If there is a single image then we use it unconditionally. Otherwise
// we use the priority order described in PreferredCoverType. Notably,
// if there are multiple image files in the folder we require they match
// one of the name patterns -- otherwise we run the risk of picking an
// arbitrary image that happens to be in the same folder as some of the
// user's music files.
if (covers.size() == 1) {
bestInfo = &covers.first();
} else {
// TODO(XXX) Sort instead so that we can fall-back if one fails to
// open?
foreach (const QFileInfo& file, covers) {
const QString coverBaseName = file.baseName();
if (bestType > TRACK_BASENAME &&
coverBaseName.compare(trackBaseName,
Qt::CaseInsensitive) == 0) {
bestType = TRACK_BASENAME;
bestInfo = &file;
// This is the best type so we know we're done.
break;
} else if (bestType > ALBUM_NAME &&
coverBaseName.compare(albumName,
Qt::CaseInsensitive) == 0) {
bestType = ALBUM_NAME;
bestInfo = &file;
} else if (bestType > COVER &&
coverBaseName.compare(QLatin1String("cover"),
Qt::CaseInsensitive) == 0) {
bestType = COVER;
bestInfo = &file;
} else if (bestType > FRONT &&
coverBaseName.compare(QLatin1String("front"),
Qt::CaseInsensitive) == 0) {
bestType = FRONT;
bestInfo = &file;
} else if (bestType > ALBUM &&
coverBaseName.compare(QLatin1String("album"),
Qt::CaseInsensitive) == 0) {
bestType = ALBUM;
bestInfo = &file;
} else if (bestType > FOLDER &&
coverBaseName.compare(QLatin1String("folder"),
Qt::CaseInsensitive) == 0) {
bestType = FOLDER;
bestInfo = &file;
}
}
}
if (bestInfo != NULL) {
art.image = QImage(bestInfo->filePath());
if (!art.image.isNull()) {
art.info.source = CoverInfo::GUESSED;
art.info.type = CoverInfo::FILE;
// TODO() here we may introduce a duplicate hash code
art.info.hash = CoverArtUtils::calculateHash(art.image);
art.info.coverLocation = bestInfo->fileName();
return art;
}
}
return art;
}