本文整理汇总了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);
}
示例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();
}
示例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);
}
示例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);
}
}
示例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();
}
示例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);
}
示例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");
}