Chris@378
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@378
|
2
|
Chris@378
|
3 /*
|
Chris@378
|
4 Sonic Visualiser
|
Chris@378
|
5 An audio file viewer and annotation editor.
|
Chris@378
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@378
|
7
|
Chris@378
|
8 This program is free software; you can redistribute it and/or
|
Chris@378
|
9 modify it under the terms of the GNU General Public License as
|
Chris@378
|
10 published by the Free Software Foundation; either version 2 of the
|
Chris@378
|
11 License, or (at your option) any later version. See the file
|
Chris@378
|
12 COPYING included with this distribution for more information.
|
Chris@378
|
13 */
|
Chris@378
|
14
|
Chris@378
|
15 #include "MIDIFileImportDialog.h"
|
Chris@378
|
16
|
Chris@378
|
17 #include <QMessageBox>
|
Chris@378
|
18 #include <QInputDialog>
|
Chris@378
|
19
|
Chris@378
|
20 MIDIFileImportDialog::MIDIFileImportDialog(QWidget *parent) :
|
Chris@378
|
21 m_parent(parent)
|
Chris@378
|
22 {
|
Chris@378
|
23 }
|
Chris@378
|
24
|
Chris@378
|
25 MIDIFileImportDialog::TrackPreference
|
Chris@378
|
26 MIDIFileImportDialog::getTrackImportPreference(QStringList displayNames,
|
Chris@378
|
27 bool haveSomePercussion,
|
Chris@378
|
28 QString &singleTrack) const
|
Chris@378
|
29 {
|
Chris@378
|
30 QStringList available;
|
Chris@378
|
31
|
Chris@378
|
32 QString allTracks = tr("Merge all tracks");
|
Chris@378
|
33 QString allNonPercussion = tr("Merge all non-percussion tracks");
|
Chris@378
|
34
|
Chris@378
|
35 singleTrack = "";
|
Chris@378
|
36
|
Chris@378
|
37 int nonTrackItems = 1;
|
Chris@378
|
38
|
Chris@378
|
39 available << allTracks;
|
Chris@378
|
40
|
Chris@378
|
41 if (haveSomePercussion) {
|
Chris@378
|
42 available << allNonPercussion;
|
Chris@378
|
43 ++nonTrackItems;
|
Chris@378
|
44 }
|
Chris@378
|
45
|
Chris@378
|
46 available << displayNames;
|
Chris@378
|
47
|
Chris@378
|
48 bool ok = false;
|
Chris@378
|
49 QString selected = QInputDialog::getItem
|
Chris@1408
|
50 (nullptr, tr("Select track or tracks to import"),
|
Chris@378
|
51 tr("<b>Select track to import</b><p>You can only import this file as a single annotation layer, but the file contains more than one track, or notes on more than one channel.<p>Please select the track or merged tracks you wish to import:"),
|
Chris@378
|
52 available, 0, false, &ok);
|
Chris@378
|
53
|
Chris@378
|
54 if (!ok || selected.isEmpty()) return ImportNothing;
|
Chris@378
|
55
|
Chris@378
|
56 TrackPreference pref;
|
Chris@378
|
57 if (selected == allTracks) pref = MergeAllTracks;
|
Chris@378
|
58 else if (selected == allNonPercussion) pref = MergeAllNonPercussionTracks;
|
Chris@378
|
59 else {
|
Chris@378
|
60 singleTrack = selected;
|
Chris@378
|
61 pref = ImportSingleTrack;
|
Chris@378
|
62 }
|
Chris@378
|
63
|
Chris@378
|
64 return pref;
|
Chris@378
|
65 }
|
Chris@378
|
66
|
Chris@378
|
67 void
|
Chris@378
|
68 MIDIFileImportDialog::showError(QString error)
|
Chris@378
|
69 {
|
Chris@1408
|
70 QMessageBox::critical(nullptr, tr("Error in MIDI file import"), error);
|
Chris@378
|
71 }
|
Chris@378
|
72
|