Esempio n. 1
0
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);
      }
Esempio n. 2
0
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();
      }
Esempio n. 3
0
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);
      }
Esempio n. 4
0
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);
	}
}
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();
}
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);
}
Esempio n. 7
0
/*!
 \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");
}