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


C++ QStringList::swap方法代码示例

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


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

示例1: soundFontUpClicked

void FluidGui::soundFontUpClicked()
      {
      int row = soundFonts->currentRow();
      if (row <= 0)
            return;
      QStringList sfonts = fluid()->soundFonts();
      sfonts.swap(row, row-1);
      fluid()->loadSoundFonts(sfonts);
      sfonts = fluid()->soundFonts();
      soundFonts->clear();
      soundFonts->addItems(sfonts);
      soundFonts->setCurrentRow(row-1);
      }
开发者ID:bojan88,项目名称:MuseScore,代码行数:13,代码来源:fluidgui.cpp

示例2: soundFontUpClicked

void ZerberusGui::soundFontUpClicked()
      {
      int row = files->currentRow();
      if (row <= 0)
            return;

      QStringList sfonts = zerberus()->soundFonts();
      sfonts.swap(row, row-1);
      zerberus()->removeSoundFonts(zerberus()->soundFonts());

      loadSoundFontsAsync(sfonts);
      files->setCurrentRow(row-1);
      emit sfChanged();
      }
开发者ID:theMusicalGamer,项目名称:MuseScore,代码行数:14,代码来源:zerberusgui.cpp

示例3: soundFontDownClicked

void FluidGui::soundFontDownClicked()
      {
      int rows = soundFonts->count();
      int row = soundFonts->currentRow();
      if (row + 1 >= rows)
            return;

      QStringList sfonts = fluid()->soundFonts();
      sfonts.swap(row, row+1);
      fluid()->loadSoundFonts(sfonts);
      sfonts = fluid()->soundFonts();
      soundFonts->clear();
      soundFonts->addItems(sfonts);
      soundFonts->setCurrentRow(row+1);
      }
开发者ID:cortices,项目名称:MuseScore,代码行数:15,代码来源:fluidgui.cpp

示例4: shuflleCards

void GameManager::shuflleCards(QStringList& cardNames)
{
	int swapIndex1, swapIndex2, listSize = cardNames.count();
	qsrand(QTime::currentTime().msec());
	
	for(int i = 0; i < NUM_SWAPS; i++)
	{
		swapIndex1 = qrand() % listSize;
		swapIndex2 = qrand() % listSize;
		
		if (swapIndex1 == swapIndex2)
			i--;
		else
			cardNames.swap(swapIndex1, swapIndex2);
	}
}
开发者ID:Horsmir,项目名称:frog,代码行数:16,代码来源:gamemanager.cpp

示例5: on_moveSongDown_clicked

void FamiTrackerModulePropertiesDialog::on_moveSongDown_clicked()
{
   CString Text;
   int Song = ui->tracks->currentIndex().row();

	if (Song == (m_pDocument->GetTrackCount() - 1))
		return;

	m_pDocument->MoveTrackDown(Song);

   QStringList songs = tracksModel->stringList();
   songs.swap(Song,Song+1);
   tracksModel->setStringList(songs);

   ui->tracks->setCurrentIndex(tracksModel->index(Song+1));
   
   updateButtons();
}
开发者ID:Tjoppen,项目名称:nesicide,代码行数:18,代码来源:famitrackermodulepropertiesdialog.cpp

示例6: setNames

void QCommandLineOptionPrivate::setNames(const QStringList &nameList)
{
    QStringList newNames;
    newNames.reserve(nameList.size());
    if (nameList.isEmpty())
        qWarning("QCommandLineOption: Options must have at least one name");
    foreach (const QString &name, nameList) {
        if (name.isEmpty()) {
            qWarning("QCommandLineOption: Option names cannot be empty");
        } else {
            const QChar c = name.at(0);
            if (c == QLatin1Char('-'))
                qWarning("QCommandLineOption: Option names cannot start with a '-'");
            else if (c == QLatin1Char('/'))
                qWarning("QCommandLineOption: Option names cannot start with a '/'");
            else if (name.contains(QLatin1Char('=')))
                qWarning("QCommandLineOption: Option names cannot contain a '='");
            else
                newNames.append(name);
        }
    }
    // commit
    names.swap(newNames);
}
开发者ID:AlexSoehn,项目名称:qt-base-deb,代码行数:24,代码来源:qcommandlineoption.cpp

示例7: HandleRename

/*!
 \brief Change name of an image/dir
 \details Renames image/dir in Photographs storage group, synchronises image database
 and thumbnail cache and notifies clients. A new thumbnail will be generated by next client
 request.
 \param id File/dir id
 \param newBase New filename
 \return QStringList Error message or "OK"
*/
QStringList ImageHandler::HandleRename(QString id, QString newBase)
{
    // Sanity check new name
    if (newBase.isEmpty() || newBase.contains("/") || newBase.contains("\\"))
        return QStringList("ERROR") << "Invalid name";

    // Find image in DB
    ImageDbWriter db;
    ImageList images, dirs;
    db.ReadDbItemsById(images, id);

    // Either single id not found or multiple comma-delimited ids received
    if (images.size() != 1)
    {
        LOG(VB_FILE, LOG_NOTICE,
            QString("Image: Image %1 not found in Db").arg(id));
        qDeleteAll(images);
        return QStringList("ERROR") << "Unknown File";
    }

    // Get filepath for solitary image
    ImageItem *im = images[0];
    QString absFilename = ImageSg::getInstance()->GetFilePath(im);

    if (absFilename.isEmpty())
    {
        delete im;
        return QStringList("ERROR") << "File not found";
    }

    // Rename file
    QFileInfo info = QFileInfo(absFilename);
    QDir dir = info.absoluteDir();
    QString newName = im->IsDirectory()
            ? newBase : QString("%1.%2").arg(newBase, info.suffix());

    if (!dir.rename(im->m_name, newName))
    {
        LOG(VB_FILE, LOG_ERR, QString("Image: Rename of %1 -> %2 failed")
            .arg(im->m_name, newName));
        delete im;
        return QStringList("ERROR") << "Rename failed";
    }

    LOG(VB_FILE, LOG_DEBUG, QString("Image: Renamed %1 -> %2")
        .arg(im->m_fileName, newName));

    ImageList dummy;

    if (im->IsDirectory())
    {
        // Cleanup thumbdir/thumbnails
        // Thumb generator now owns the image object
        QStringList mesg = ImageThumb::getInstance()->DeleteThumbs(dummy, images);

        // Notify clients of deleted ids, images, thumbs
        gCoreContext->SendEvent(MythEvent("IMAGE_DB_CHANGED", mesg));

        // Dir name change affects path of all sub-dirs & files and their thumbs
        QStringList scan;
        scan << "IMAGE_SCAN" << "START";
        return ImageScan::getInstance()->HandleScanRequest(scan);
    }

    // Retain old image for cleanup
    ImageItem *newIm = new ImageItem(*im);

    // Update db
    newIm->m_name = newName;
    newIm->m_fileName = QDir::cleanPath(QDir(newIm->m_path).filePath(newName));
    db.UpdateDbFile(newIm);
    delete newIm;

    // Clean up thumbnail
    // Thumb generator now owns the images objects
    QStringList mesg = ImageThumb::getInstance()->DeleteThumbs(images, dummy);
    // Item is modified, not deleted
    mesg.swap(0,1);

    // New thumbnail will be created by client request

    // Notify clients of changed image & thumbnail
    gCoreContext->SendEvent(MythEvent("IMAGE_DB_CHANGED", mesg));

    return QStringList("OK");
}
开发者ID:jshattoc,项目名称:mythtv,代码行数:95,代码来源:imagehandlers.cpp


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