202
208
new KAction(i18n("&Apply Format"), 0, this,
203
209
SLOT(slotApplyFormat()), actionCollection(),
211
new KAction(i18n("&Rename Directory..."), 0, this,
212
SLOT(slotRenameDirectory()), actionCollection(),
215
new KAction(i18n("Select &All"), KShortcut("Alt+A"), this,
216
SLOT(slotSelectAll()), actionCollection(),
218
new KAction(i18n("&Next File"), KShortcut("Alt+Down"), this,
219
SLOT(slotNextFile()), actionCollection(),
221
new KAction(i18n("&Previous File"), KShortcut("Alt+Up"), this,
222
SLOT(slotPreviousFile()), actionCollection(),
224
new KAction("ID3v1: " + i18n("From Filename"), 0, view, SLOT(fromFilenameV1()),
225
actionCollection(), "v1_from_filename");
226
new KAction("ID3v1: " + i18n("From ID3v2"), 0, view, SLOT(fromID3V1()),
227
actionCollection(), "v1_from_v2");
228
new KAction("ID3v1: " + i18n("Copy"), 0, view, SLOT(copyV1()),
229
actionCollection(), "v1_copy");
230
new KAction("ID3v1: " + i18n("Paste"), 0, view, SLOT(pasteV1()),
231
actionCollection(), "v1_paste");
232
new KAction("ID3v1: " + i18n("Remove"), 0, view, SLOT(removeV1()),
233
actionCollection(), "v1_remove");
234
new KAction("ID3v2: " + i18n("From Filename"), 0, view, SLOT(fromFilenameV2()),
235
actionCollection(), "v2_from_filename");
236
new KAction("ID3v2: " + i18n("From ID3v1"), 0, view, SLOT(fromID3V2()),
237
actionCollection(), "v2_from_v1");
238
new KAction("ID3v2: " + i18n("Copy"), 0, view, SLOT(copyV2()),
239
actionCollection(), "v2_copy");
240
new KAction("ID3v2: " + i18n("Paste"), 0, view, SLOT(pasteV2()),
241
actionCollection(), "v2_paste");
242
new KAction("ID3v2: " + i18n("Remove"), 0, view, SLOT(removeV2()),
243
actionCollection(), "v2_remove");
244
new KAction(i18n("Frames:") + " " + i18n("Edit"), 0, view, SLOT(editFrame()),
245
actionCollection(), "frames_edit");
246
new KAction(i18n("Frames:") + " " + i18n("Add"), 0, view, SLOT(addFrame()),
247
actionCollection(), "frames_add");
248
new KAction(i18n("Frames:") + " " + i18n("Delete"), 0, view, SLOT(deleteFrame()),
249
actionCollection(), "frames_delete");
250
new KAction(i18n("Filename") + ": " + i18n("From ID3v1"), 0, view, SLOT(fnFromID3V1()),
251
actionCollection(), "filename_from_v1");
252
new KAction(i18n("Filename") + ": " + i18n("From ID3v2"), 0, view, SLOT(fnFromID3V2()),
253
actionCollection(), "filename_from_v2");
254
new KAction(i18n("Filename") + ": " + i18n("Focus"), 0, view->nameLineEdit, SLOT(setFocus()),
255
actionCollection(), "filename_focus");
256
new KAction("ID3v1: " + i18n("Focus"), 0, view->titleV1LineEdit, SLOT(setFocus()),
257
actionCollection(), "v1_focus");
258
new KAction("ID3v2: " + i18n("Focus"), 0, view->titleV2LineEdit, SLOT(setFocus()),
259
actionCollection(), "v2_focus");
481
557
bool Kid3App::saveDirectory(void)
560
int numFiles = 0, totalFiles = 0;
484
561
bool renamed = FALSE;
485
562
Mp3File *mp3file = view->mp3ListBox->first();
563
// Get number of files to be saved to display correct progressbar
564
while (mp3file != 0) {
565
if (mp3file->isChanged()) {
568
mp3file = view->mp3ListBox->next();
486
570
QProgressBar *progress = new QProgressBar();
487
571
statusBar()->addWidget(progress, 0, true);
488
progress->setTotalSteps(view->mp3ListBox->numRows());
572
progress->setTotalSteps(totalFiles);
489
573
progress->setProgress(numFiles);
490
574
#ifdef CONFIG_USE_KDE
491
575
kapp->processEvents();
493
577
qApp->processEvents();
579
mp3file = view->mp3ListBox->first();
495
580
while (mp3file != 0) {
496
renamed = mp3file->writeTags(FALSE) || renamed;
581
if (!mp3file->writeTags(FALSE, &renamed)) {
582
errorFiles.append(mp3file->getFilename());
583
errorFiles.append('\n');
497
585
mp3file = view->mp3ListBox->next();
499
587
progress->setProgress(numFiles);
755
849
slotStatusMsg(i18n("Ready."));
853
* Shortcuts configuration.
855
void Kid3App::slotSettingsShortcuts()
857
KKeyDialog::configure(actionCollection(), this);
863
void Kid3App::slotSelectAll()
865
view->mp3ListBox->selectAll(true);
871
void Kid3App::slotNextFile()
873
int ci = view->mp3ListBox->currentItem();
874
if (ci >= 0 && ci < (int)view->mp3ListBox->count() - 1) {
876
view->mp3ListBox->clearSelection();
877
view->mp3ListBox->setCurrentItem(ci);
878
view->mp3ListBox->setSelected(ci, true);
883
* Select previous file.
885
void Kid3App::slotPreviousFile()
887
int ci = view->mp3ListBox->currentItem();
890
view->mp3ListBox->clearSelection();
891
view->mp3ListBox->setCurrentItem(ci);
892
view->mp3ListBox->setSelected(ci, true);
758
896
#else /* CONFIG_USE_KDE */
760
898
* Display handbook.
981
* Check if the duration of the files corresponds to the duration of the
984
* @param trackDuration list with durations of imported tracks
985
* @param maxDiff the maximum difference in seconds allowed
987
* @return true if ok or user agreed with import,
988
* false if user canceled import.
990
bool Kid3App::checkDuration(QValueList<int>* trackDuration,
993
if (!trackDuration) {
999
#if QT_VERSION >= 300
1000
QValueList<int>::iterator
1002
QValueListIterator<int>
1004
it = trackDuration->begin();
1005
Mp3File *mp3file = view->mp3ListBox->first();
1006
while (mp3file != 0) {
1007
if (it != trackDuration->end()) {
1008
mp3file->readTags(false);
1009
unsigned fileLen = mp3file->getDuration();
1010
unsigned trackLen = *it;
1011
if (fileLen != 0 && trackLen != 0) {
1012
unsigned diff = fileLen > trackLen ?
1013
fileLen - trackLen : trackLen - fileLen;
1014
if (diff > maxDiff) {
1015
warningMsg.append(mp3file->getFilename());
1016
warningMsg.append(": ");
1017
warningMsg.append(Mp3File::formatTime(fileLen));
1018
warningMsg.append(" != ");
1019
warningMsg.append(Mp3File::formatTime(trackLen));
1020
warningMsg.append('\n');
1026
mp3file = view->mp3ListBox->next();
1029
if (numFiles != 0 && numTracks != 0 &&
1030
numFiles != numTracks) {
1031
warningMsg.append(i18n("Number of files is not equal to number of imported tracks"));
1032
warningMsg.append(QString(": %1 != %2\n").arg(numFiles).arg(numTracks));
1034
if (!warningMsg.isEmpty()) {
1035
return (QMessageBox::warning(0, i18n("Import Mismatch"),
1036
warningMsg + i18n("Continue import?"),
1037
QMessageBox::Ok, QMessageBox::Cancel) ==
854
1055
genCfg->importFormatHeaders,
855
1056
genCfg->importFormatTracks,
856
1057
genCfg->importFormatIdx);
1058
dialog->setTimeDifferenceCheck(genCfg->enableTimeDifferenceCheck,
1059
genCfg->maxTimeDifference);
857
1060
dialog->setFreedbConfig(freedbCfg);
858
1061
if (dialog->exec() == QDialog::Accepted) {
859
#if QT_VERSION >= 300
860
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
862
QApplication::setOverrideCursor(QCursor(WaitCursor));
864
slotStatusMsg(i18n("Import..."));
865
StandardTags st, st_hdr;
866
Mp3File *mp3file = view->mp3ListBox->first();
867
bool no_selection = view->numFilesSelected() == 0;
869
st_hdr.setInactive();
870
(void)dialog->parseHeader(st_hdr);
871
1062
genCfg->importDestV1 = dialog->getDestV1();
872
1063
QString name, header, track;
873
1064
genCfg->importFormatIdx = dialog->getImportFormat(name, header, track);
874
1065
genCfg->importFormatNames[genCfg->importFormatIdx] = name;
875
1066
genCfg->importFormatHeaders[genCfg->importFormatIdx] = header;
876
1067
genCfg->importFormatTracks[genCfg->importFormatIdx] = track;
1068
dialog->getTimeDifferenceCheck(genCfg->enableTimeDifferenceCheck,
1069
genCfg->maxTimeDifference);
877
1070
dialog->getFreedbConfig(freedbCfg);
878
while (mp3file != 0) {
879
mp3file->readTags(false);
880
if (genCfg->importDestV1) {
881
mp3file->getStandardTagsV1(&st);
883
mp3file->getStandardTagsV2(&st);
885
st_hdr.copyActiveTags(st);
886
if (!dialog->getNextTags(st, start))
889
if (genCfg->importDestV1) {
890
mp3file->setStandardTagsV1(&st);
892
mp3file->setStandardTagsV2(&st);
894
mp3file = view->mp3ListBox->next();
897
StandardTags st; // empty
898
view->setStandardTagsV1(&st);
899
view->setStandardTagsV2(&st);
900
view->nameLineEdit->setEnabled(FALSE);
904
updateModificationState();
906
slotStatusMsg(i18n("Ready."));
907
QApplication::restoreOverrideCursor();
1071
StandardTags st_hdr;
1072
st_hdr.setInactive();
1073
(void)dialog->parseHeader(st_hdr);
1074
if (!genCfg->enableTimeDifferenceCheck ||
1075
checkDuration(dialog->getTrackDurations(), genCfg->maxTimeDifference)) {
1076
#if QT_VERSION >= 300
1077
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1079
QApplication::setOverrideCursor(QCursor(WaitCursor));
1081
slotStatusMsg(i18n("Import..."));
1084
bool no_selection = view->numFilesSelected() == 0;
1085
Mp3File *mp3file = view->mp3ListBox->first();
1086
while (mp3file != 0) {
1087
mp3file->readTags(false);
1088
if (genCfg->importDestV1) {
1089
mp3file->getStandardTagsV1(&st);
1091
mp3file->getStandardTagsV2(&st);
1093
st_hdr.copyActiveTags(st);
1094
if (!dialog->getNextTags(st, start))
1097
if (genCfg->importDestV1) {
1098
mp3file->setStandardTagsV1(&st);
1100
mp3file->setStandardTagsV2(&st);
1102
mp3file = view->mp3ListBox->next();
1104
if (!no_selection) {
1105
StandardTags st; // empty
1106
view->setStandardTagsV1(&st);
1107
view->setStandardTagsV2(&st);
1108
view->nameLineEdit->setEnabled(FALSE);
1112
updateModificationState();
1114
slotStatusMsg(i18n("Ready."));
1115
QApplication::restoreOverrideCursor();
1185
void Kid3App::slotRenameDirectory(void)
1187
if (saveModified()) {
1188
QString caption(i18n("Rename Directory"));
1189
RenDirDialog *dialog =
1190
new RenDirDialog(NULL, caption, view->mp3ListBox->first(),
1191
miscCfg->dirFormatItem, miscCfg->dirFormatText);
1193
if (dialog->exec() == QDialog::Accepted) {
1194
Mp3File *mp3file = view->mp3ListBox->first();
1198
dialog->performAction(mp3file, again, &errorMsg)) {
1199
mp3file = view->mp3ListBox->next();
1201
openDirectory(dialog->getNewDirname());
1203
mp3file = view->mp3ListBox->first();
1205
dialog->performAction(mp3file, again, &errorMsg)) {
1206
mp3file = view->mp3ListBox->next();
1208
openDirectory(dialog->getNewDirname());
1210
miscCfg->dirFormatItem = dialog->getFormatItem();
1211
miscCfg->dirFormatText = dialog->getFormatText();
1212
if (!errorMsg.isEmpty()) {
1213
QMessageBox::warning(0, i18n("File Error"),
1214
i18n("Error while renaming:\n") +
1216
QMessageBox::Ok, QMessageBox::NoButton);
974
1224
* Open directory on drop.
976
1226
* @param txt URL of directory or file in directory