当前位置: 首页>>代码示例>>C++>>正文


C++ QLinkedList::clear方法代码示例

本文整理汇总了C++中QLinkedList::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QLinkedList::clear方法的具体用法?C++ QLinkedList::clear怎么用?C++ QLinkedList::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QLinkedList的用法示例。


在下文中一共展示了QLinkedList::clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: planFlashErase

/**
 * Produces an erase plan for clearing the entire device.
 *
 * Special care is taken to erase the Config Words page last, when writeConfig is
 * turned on and the device uses FLASH for Config Words.
 *
 * When writeConfig is false, care is taken to avoid erasing the Config Words page.
 *
 * This routine makes sure not to erase the Bootloader Block.
 *
 * All erases are listed in reverse address order. This forces the program to
 * erase all application code from the device before finally erasing the crucial
 * address 0 reset vector. With all application code erased, having a "GOTO BootloaderStart"
 * instruction at address 0 is no longer critical, as blank memory will provide "NOP"
 * executions all the way to the Bootloader Block. Thus, the Bootloader will be able to
 * execute when there is no application code programmed.
 */
void DeviceWritePlanner::planFlashErase(QLinkedList<Device::MemoryRange>& eraseList,
                                        unsigned int* existingData)
{
    Device::MemoryRange block;

    block.start = device->startFLASH;
    block.end = device->endFLASH;
    eraseList.clear();
    eraseList.append(block);
    if(device->family == Device::PIC32 && existingData == NULL)
    {
        return;
    }

    if(writeConfig)
    {
        eraseConfigPageLast(eraseList);
    }
    else
    {
        doNotEraseConfigPage(eraseList);
    }

    doNotEraseInterruptVectorTable(eraseList);

    doNotEraseBootBlock(eraseList);

    if(existingData != NULL)
    {
        // For differential bootloading:
        // Scan existingData to see if we can avoid erasing any pages.
        // Not explicitly required, but could occassionally reduce the
        // number of erase transactions.
    }
}
开发者ID:lamotriz,项目名称:motor-esferico,代码行数:52,代码来源:DeviceWritePlanner.cpp

示例2: planFlashVerify

/*!
 * Memory ranges used by the bootloader firmware are excluded from the verify list.
 *
 * If the Write Config option is disabled, the FLASH Erase Block containing config
 * words is excluded from the verify list. (only for devices that store config bits in
 * FLASH memory).
 */
void DeviceVerifyPlanner::planFlashVerify(QLinkedList<Device::MemoryRange>& verifyList, int start, int end)
{
    Device::MemoryRange block;

    block.start = start;
    block.end = end;
    verifyList.clear();
    verifyList.append(block);

    if(!writeConfig)
    {
        doNotVerifyConfigPage(verifyList);
    }

    doNotVerifyBootBlock(verifyList);
}
开发者ID:lamotriz,项目名称:motor-esferico,代码行数:23,代码来源:DeviceVerifyPlanner.cpp

示例3: trackdir


//.........这里部分代码省略.........
    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";
    EXPECT_TRUE(img.scaled(200,200).save(cLoc_coverJPG, "JPG"));
    prefCovers.append(QFileInfo(cLoc_coverJPG));
    QString cLoc_coverjpg = trackdir % "/" % "cover." % "jpg";
    EXPECT_TRUE(img.scaled(400,400).save(cLoc_coverjpg, "jpg"));
    prefCovers.append(QFileInfo(cLoc_coverjpg));
    extraCovers << cLoc_coverJPG << cLoc_coverjpg;

    res = CoverArtUtils::selectCoverArtForTrack(trackBaseName, trackAlbum,
                                                prefCovers);
    expected.image = QImage(cLoc_coverJPG);
    expected.info.hash = CoverArtUtils::calculateHash(expected.image);
    expected.info.coverLocation = "cover.JPG";
    EXPECT_EQ(expected, res);

    // As we are looking for %album%.jpg and %base_track.jpg%,
    // we need to check if everything works with UTF8 chars.
    trackBaseName = QString::fromUtf8("track_ðÑöæäî");
    trackAlbum = QString::fromUtf8("öæäîðÑ_album");

    prefCovers.clear();

    // 2. album_name.jpg
    cLoc_albumName = QString(trackdir % "/" % trackAlbum % "." % qFormat);
    EXPECT_TRUE(img.save(cLoc_albumName, format));
    prefCovers.append(QFileInfo(cLoc_albumName));
    res = CoverArtUtils::selectCoverArtForTrack(trackBaseName, trackAlbum,
                                                prefCovers);
    expected.image = QImage(cLoc_albumName);
    expected.info.hash = CoverArtUtils::calculateHash(expected.image);
    expected.info.coverLocation = trackAlbum % ".jpg";
    EXPECT_EQ(expected, res);

    // 1. track_filename.jpg
    cLoc_filename = QString(trackdir % "/" % trackBaseName % "." % qFormat);
    EXPECT_TRUE(img.save(cLoc_filename, format));
    prefCovers.append(QFileInfo(cLoc_filename));
    res = CoverArtUtils::selectCoverArtForTrack(trackBaseName, trackAlbum,
                                                prefCovers);
    expected.image = QImage(cLoc_filename);
    expected.info.hash = CoverArtUtils::calculateHash(expected.image);
    expected.info.coverLocation = trackBaseName % ".jpg";
    EXPECT_EQ(expected, res);

    QFile::remove(cLoc_filename);
    QFile::remove(cLoc_albumName);

    // cleaning temp dir
    foreach (QString loc, extraCovers) {
        QFile::remove(loc);
    }
开发者ID:Alppasa,项目名称:mixxx,代码行数:101,代码来源:coverartutils_test.cpp

示例4: qSort

/*!
 * @desc collects groups of concurrent items in the offset range
 */
QList< QLinkedList<QxtScheduleInternalItem *> > QxtScheduleViewPrivate::findConcurrentItems(const int from, const int to) const
{
    QList< QLinkedList<QxtScheduleInternalItem *> > allConcurrentItems;

    QList<QxtScheduleInternalItem *> allItemsSorted = m_Items;
    
    if(m_Items.size() == 0)
        return allConcurrentItems;
    
    qSort(allItemsSorted.begin(), allItemsSorted.end(), qxtScheduleItemLessThan);

    int startItem = 0;
    int endItem = allItemsSorted.size() - 1;

    //find the startitem that interferes with our range
    for (int i = 0; i < allItemsSorted.size(); i++)
    {
        if (i > 0)
        {
            if (!(allItemsSorted.at(i - 1)->visualEndTableOffset() >=  allItemsSorted.at(i)->visualStartTableOffset()
                    && allItemsSorted.at(i - 1)->visualStartTableOffset() <=  allItemsSorted.at(i)->visualEndTableOffset()))
                startItem = i;
        }

        if (allItemsSorted.at(i)->visualEndTableOffset() >= from && allItemsSorted.at(i)->visualStartTableOffset() <= to)
            break;
    }

    //find the last item that interferes with our range
    for (int i = allItemsSorted.size() - 1; i >= 0 ; i--)
    {
        if (i < allItemsSorted.size() - 1)
        {
            if (!(allItemsSorted.at(i + 1)->visualEndTableOffset() >=  allItemsSorted.at(i)->visualStartTableOffset()
                    && allItemsSorted.at(i + 1)->visualStartTableOffset() <=  allItemsSorted.at(i)->visualEndTableOffset()))
                endItem = i;
        }

        if (allItemsSorted.at(i)->visualEndTableOffset() >= from && allItemsSorted.at(i)->visualStartTableOffset() <= to)
            break;
    }

    int startOffset = allItemsSorted.at(startItem)->visualStartTableOffset();
    int endOffset = allItemsSorted.at(endItem)->visualEndTableOffset();

    /*now we have to populate a list with all items that interfere with our range */
    QLinkedList<QxtScheduleInternalItem *> concurrentItems;
    for (int iAllItemLoop = startItem; iAllItemLoop <= endItem; iAllItemLoop++)
    {
        int tempStartOffset = allItemsSorted.at(iAllItemLoop)->visualStartTableOffset();
        int tempEndOffset = allItemsSorted.at(iAllItemLoop)->visualEndTableOffset();

        if (tempEndOffset >= startOffset && tempStartOffset <= endOffset)
        {

            if (concurrentItems.size() >= 1)
            {
                bool bAppend = false;
                /*check all items in the list if the current items interfers although the items are ordered by startIndex
                *we can loose some of them if the endTime of the last Item is before the endTime of the pre last item
                */

                for (QLinkedList<QxtScheduleInternalItem *>::iterator it = concurrentItems.begin(); it != concurrentItems.end(); ++it)
                {
                    int lastStartOffset = (*it)->visualStartTableOffset();
                    int lastEndOffset   = (*it)->visualEndTableOffset();

                    if (tempEndOffset >= lastStartOffset && tempStartOffset <= lastEndOffset)
                    {
                        bAppend = true;
                        break;
                    }
                }

                if (bAppend)
                {
                    concurrentItems.append(allItemsSorted.at(iAllItemLoop));
                }
                else
                {
                    allConcurrentItems.append(concurrentItems);
                    concurrentItems.clear();
                    concurrentItems.append(allItemsSorted.at(iAllItemLoop));
                }
            }
            else
                concurrentItems.append(allItemsSorted.at(iAllItemLoop));

            if (tempStartOffset < startOffset)
                startOffset = tempStartOffset;

            if (tempEndOffset > endOffset)
                endOffset = tempEndOffset;
        }
    }
    if (concurrentItems.size() > 0)
        allConcurrentItems.append(concurrentItems);
//.........这里部分代码省略.........
开发者ID:01iv3r,项目名称:OpenPilot,代码行数:101,代码来源:qxtscheduleview_p.cpp


注:本文中的QLinkedList::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。