Mercurial > hg > svgui
comparison widgets/MIDIFileImportDialog.cpp @ 378:22b72f0f6a4e
* More work to abstract out interactive components used in the data library,
so that it does not need to depend on QtGui.
author | Chris Cannam |
---|---|
date | Fri, 14 Mar 2008 17:14:21 +0000 |
parents | |
children | c8a6fd3f9dff |
comparison
equal
deleted
inserted
replaced
377:0bcb449d15f4 | 378:22b72f0f6a4e |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 | |
8 This program is free software; you can redistribute it and/or | |
9 modify it under the terms of the GNU General Public License as | |
10 published by the Free Software Foundation; either version 2 of the | |
11 License, or (at your option) any later version. See the file | |
12 COPYING included with this distribution for more information. | |
13 */ | |
14 | |
15 #include "MIDIFileImportDialog.h" | |
16 | |
17 #include <QMessageBox> | |
18 #include <QInputDialog> | |
19 | |
20 MIDIFileImportDialog::MIDIFileImportDialog(QWidget *parent) : | |
21 m_parent(parent) | |
22 { | |
23 } | |
24 | |
25 MIDIFileImportDialog::TrackPreference | |
26 MIDIFileImportDialog::getTrackImportPreference(QStringList displayNames, | |
27 bool haveSomePercussion, | |
28 QString &singleTrack) const | |
29 { | |
30 QStringList available; | |
31 | |
32 QString allTracks = tr("Merge all tracks"); | |
33 QString allNonPercussion = tr("Merge all non-percussion tracks"); | |
34 | |
35 singleTrack = ""; | |
36 | |
37 int nonTrackItems = 1; | |
38 | |
39 available << allTracks; | |
40 | |
41 if (haveSomePercussion) { | |
42 available << allNonPercussion; | |
43 ++nonTrackItems; | |
44 } | |
45 | |
46 available << displayNames; | |
47 | |
48 bool ok = false; | |
49 QString selected = QInputDialog::getItem | |
50 (0, tr("Select track or tracks to import"), | |
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:"), | |
52 available, 0, false, &ok); | |
53 | |
54 if (!ok || selected.isEmpty()) return ImportNothing; | |
55 | |
56 TrackPreference pref; | |
57 if (selected == allTracks) pref = MergeAllTracks; | |
58 else if (selected == allNonPercussion) pref = MergeAllNonPercussionTracks; | |
59 else { | |
60 singleTrack = selected; | |
61 pref = ImportSingleTrack; | |
62 } | |
63 | |
64 return pref; | |
65 } | |
66 | |
67 void | |
68 MIDIFileImportDialog::showError(QString error) | |
69 { | |
70 QMessageBox::critical(0, tr("Error in MIDI file import"), error); | |
71 } | |
72 |