svgui
1.9
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 00008 This program is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU General Public License as 00010 published by the Free Software Foundation; either version 2 of the 00011 License, or (at your option) any later version. See the file 00012 COPYING included with this distribution for more information. 00013 */ 00014 00015 #include "MIDIFileImportDialog.h" 00016 00017 #include <QMessageBox> 00018 #include <QInputDialog> 00019 00020 MIDIFileImportDialog::MIDIFileImportDialog(QWidget *parent) : 00021 m_parent(parent) 00022 { 00023 } 00024 00025 MIDIFileImportDialog::TrackPreference 00026 MIDIFileImportDialog::getTrackImportPreference(QStringList displayNames, 00027 bool haveSomePercussion, 00028 QString &singleTrack) const 00029 { 00030 QStringList available; 00031 00032 QString allTracks = tr("Merge all tracks"); 00033 QString allNonPercussion = tr("Merge all non-percussion tracks"); 00034 00035 singleTrack = ""; 00036 00037 int nonTrackItems = 1; 00038 00039 available << allTracks; 00040 00041 if (haveSomePercussion) { 00042 available << allNonPercussion; 00043 ++nonTrackItems; 00044 } 00045 00046 available << displayNames; 00047 00048 bool ok = false; 00049 QString selected = QInputDialog::getItem 00050 (0, tr("Select track or tracks to import"), 00051 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:"), 00052 available, 0, false, &ok); 00053 00054 if (!ok || selected.isEmpty()) return ImportNothing; 00055 00056 TrackPreference pref; 00057 if (selected == allTracks) pref = MergeAllTracks; 00058 else if (selected == allNonPercussion) pref = MergeAllNonPercussionTracks; 00059 else { 00060 singleTrack = selected; 00061 pref = ImportSingleTrack; 00062 } 00063 00064 return pref; 00065 } 00066 00067 void 00068 MIDIFileImportDialog::showError(QString error) 00069 { 00070 QMessageBox::critical(0, tr("Error in MIDI file import"), error); 00071 } 00072