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); }
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; }