コード例 #1
0
void SimplePatternWizardDialog::update_example() {
  PatternParser patternparser;
  QString filename = patternparser.parseSimplePattern(ui.qlineedit_pattern->text(),
	1, 12, "Meat Loaf", "Bat Out Of Hell III", "2006", "Rock", suffix, false);
  ui.qlineedit_example->setText(filename);
  ui.qlineedit_example->setCursorPosition(0);
}
コード例 #2
0
ファイル: audex.cpp プロジェクト: cotman/audex
bool Audex::construct_target_filename_for_singlefile(QString& targetFilename,
        int cdno, int nooftracks,
        const QString& artist, const QString& title,
        const QString& date, const QString& genre,
        const QString& ext, const QString& basepath,
        bool overwrite_existing_files) {

  PatternParser patternparser;
  targetFilename = ((basepath.right(1)=="/")?basepath:basepath+"/")+patternparser.parseSimplePattern(profile_model->data(profile_model->index(profile_model->currentProfileRow(), PROFILE_MODEL_COLUMN_SF_NAME_INDEX)).toString(),
        cdno, nooftracks, artist, title, date, genre, ext, FALSE);

  int lastSlash = targetFilename.lastIndexOf("/", -1);
  if (lastSlash == -1) {
    emit error(i18n("Can't find path \"%1\".", targetFilename), i18n("Please check your path (write access?)"));
    return FALSE;
  }
  QString targetPath = targetFilename.mid(0, lastSlash);
  target_dir = targetPath;
  QString targetStrippedFilename = targetFilename.mid(lastSlash+1);
  QDir *dir = new QDir(targetPath);
  if (!dir->exists()) {
    if (!dir->mkpath(targetPath)) {
      emit error(i18n("Unable to create folder \"%1\".", targetPath), i18n("Please check your path (write access?)"));
      return FALSE;
    } else {
      emit info(i18n("Folder \"%1\" successfully created.", targetPath));
    }
  } else {
    emit warning(i18n("Folder \"%1\" already exists.", targetPath));
  }
  delete dir;

  KDiskFreeSpaceInfo diskfreespace = KDiskFreeSpaceInfo::freeSpaceInfo(targetPath);
  quint64 free = diskfreespace.available() / 1024;
  if (free < 800*1024) {
    emit warning(i18n("Free space on \"%1\" is less than 800 MiB.", targetPath));
  }

  QFile *file = new QFile(targetFilename);
  if (file->exists()) {
    if (overwrite_existing_files) {
      emit warning(i18n("Warning! File \"%1\" already exists. Overwriting.", targetStrippedFilename));
    } else {
      emit warning(i18n("Warning! File \"%1\" already exists. Skipping.", targetStrippedFilename));

      cdda_model->setCustomData("filename", targetFilename);

      targetFilename.clear();
    }
  }
  delete file;

  return TRUE;

}
コード例 #3
0
ファイル: audex.cpp プロジェクト: cotman/audex
bool Audex::construct_target_filename(QString& targetFilename,
        int trackno, int cdno, int nooftracks, int gindex,
        const QString& artist, const QString& title,
        const QString& tartist, const QString& ttitle,
        const QString& year, const QString& genre,
        const QString& ext, const QString& basepath,
        bool fat_compatible, bool replacespaceswithunderscores,
        bool _2digitstracknum,
        bool overwrite_existing_files, bool is_first_track) {

  Q_UNUSED(is_first_track);

  PatternParser patternparser;
  targetFilename = ((basepath.right(1)=="/")?basepath:basepath+"/")+patternparser.parseFilenamePattern(profile_model->data(profile_model->index(profile_model->currentProfileRow(), PROFILE_MODEL_COLUMN_PATTERN_INDEX)).toString(),
        trackno, cdno, gindex, nooftracks, artist, title, tartist, ttitle, year, genre, ext, fat_compatible, replacespaceswithunderscores, _2digitstracknum);

  int lastSlash = targetFilename.lastIndexOf("/", -1);
  if (lastSlash == -1) {
    emit error(i18n("Can't find path \"%1\".", targetFilename), i18n("Please check your path (write access?)"));
    return FALSE;
  }
  QString targetPath = targetFilename.mid(0, lastSlash);
  QString targetStrippedFilename = targetFilename.mid(lastSlash+1);
  target_dir = targetPath;

  if (!p_mkdir(targetPath)) return FALSE;

  KDiskFreeSpaceInfo diskfreespace = KDiskFreeSpaceInfo::freeSpaceInfo(targetPath);
  quint64 free = diskfreespace.available() / 1024;
  if (free < 200*1024) {
    emit warning(i18n("Free space on \"%1\" is less than 200 MiB.", targetPath));
  }

  QFile *file = new QFile(targetFilename);
  if (file->exists()) {
    if (overwrite_existing_files) {
      emit warning(i18n("Warning! File \"%1\" already exists. Overwriting.", targetStrippedFilename));
    } else {
      emit warning(i18n("Warning! File \"%1\" already exists. Skipping.", targetStrippedFilename));

      cdda_model->setCustomDataPerTrack(trackno, "filename", targetFilename);
      cdda_model->setCustomDataPerTrack(trackno, "ripped", TRUE);

      targetFilename.clear();
    }
  }
  delete file;

  return TRUE;

}
コード例 #4
0
ファイル: commandwizarddialog.cpp プロジェクト: KDE/audex
void CommandWizardDialog::update_example() {
  PatternParser patternparser;
  QString filename = patternparser.parseCommandPattern(ui.qlineedit_command->text(),
        "/tmp/tmp.wav", QString("%1/music/Meat Loaf/02 - Meat Loaf - Blind As A Bat.ogg").arg(QDir::homePath()),
        2, 1, 1, 12,
        "Meat Loaf", "Bat Out Of Hell III", "Meat Loaf", "Blind As A Bat",
        "2006", "Rock", "ogg", NULL, false, QDir::tempPath(), "LAME 3.98.2", true);
  ui.qlineedit_album_example->setText(filename);
  ui.qlineedit_album_example->setCursorPosition(0);
  filename = patternparser.parseCommandPattern(ui.qlineedit_command->text(),
        "/tmp/tmp.wav", QString("%1/music/Alternative Hits/Volume 4/04 - Wolfsheim - Approaching Lightspeed.ogg").arg(QDir::homePath()),
        4, 2, 1, 18,
        "Alternative Hits", "Volume 4", "Wolfsheim", "Approaching Lightspeed",
        "2003", "Darkwave", "ogg", NULL, false, QDir::tempPath(), "LAME 3.98.2", true);
  ui.qlineedit_sampler_example->setText(filename);
  ui.qlineedit_sampler_example->setCursorPosition(0);
}