MIDIFileImportDialog.cpp
Go to the documentation of this file.
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 
21  m_parent(parent)
22 {
23 }
24 
25 MIDIFileImportDialog::TrackPreference
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  (nullptr, 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
69 {
70  QMessageBox::critical(nullptr, tr("Error in MIDI file import"), error);
71 }
72 
void showError(QString error) override
MIDIFileImportDialog(QWidget *parent=0)
TrackPreference getTrackImportPreference(QStringList trackNames, bool haveSomePercussion, QString &singleTrack) const override