diff options
-rw-r--r-- | dgedit/audioextractor.cc | 17 | ||||
-rw-r--r-- | dgedit/audioextractor.h | 9 | ||||
-rw-r--r-- | dgedit/filelist.cc | 4 | ||||
-rw-r--r-- | dgedit/filelist.h | 1 | ||||
-rw-r--r-- | dgedit/mainwindow.cc | 8 |
5 files changed, 31 insertions, 8 deletions
diff --git a/dgedit/audioextractor.cc b/dgedit/audioextractor.cc index 92ed4d6..92bd105 100644 --- a/dgedit/audioextractor.cc +++ b/dgedit/audioextractor.cc @@ -99,7 +99,7 @@ void AudioExtractor::exportSelection(QString name, void AudioExtractor::exportSelections(Selections selections) { - QVector< QPair<QString, QString> >::iterator j = audiofiles.begin(); + AudioFileList::iterator j = audiofiles.begin(); while(j != audiofiles.end()) { QString file = j->first; @@ -131,9 +131,9 @@ void AudioExtractor::addFile(QString file, QString name) void AudioExtractor::removeFile(QString file, QString name) { - QVector< QPair<QString, QString> >::iterator j = audiofiles.begin(); + AudioFileList::iterator j = audiofiles.begin(); while(j != audiofiles.end()) { - if(file == j->first && name == j->second) { + if(file == j->first/* && name == j->second*/) { audiofiles.erase(j); return; } @@ -151,3 +151,14 @@ void AudioExtractor::setExportPath(const QString &path) exportpath = path; } +void AudioExtractor::changeName(QString file, QString name) +{ + AudioFileList::iterator j = audiofiles.begin(); + while(j != audiofiles.end()) { + if(file == j->first) { + j->second = name; + return; + } + j++; + } +} diff --git a/dgedit/audioextractor.h b/dgedit/audioextractor.h index 75d3553..39f0353 100644 --- a/dgedit/audioextractor.h +++ b/dgedit/audioextractor.h @@ -28,12 +28,14 @@ #define __DRUMGIZMO_AUDIOEXTRACTOR_H__ #include <QObject> -#include <QVector> -#include <QPair> +#include <QSet> +#include <QLinkedList> #include <QString> #include "selection.h" +typedef QLinkedList< QPair<QString, QString> > AudioFileList; + class AudioExtractor : public QObject { Q_OBJECT public: @@ -41,6 +43,7 @@ public: public slots: void addFile(QString file, QString name); + void changeName(QString file, QString name); void removeFile(QString file, QString name); void exportSelections(Selections selections); void setExportPath(const QString &path); @@ -49,7 +52,7 @@ public slots: private: float *load(QString file, size_t *size); void exportSelection(QString name, int index, float *data, size_t size, Selection sel); - QVector< QPair<QString, QString> > audiofiles; + AudioFileList audiofiles; QString exportpath; QString prefix; }; diff --git a/dgedit/filelist.cc b/dgedit/filelist.cc index 29a12c2..00d7d87 100644 --- a/dgedit/filelist.cc +++ b/dgedit/filelist.cc @@ -155,8 +155,12 @@ QString FileList::itemName(QListWidgetItem *i) void FileList::setItemName(QListWidgetItem *i, QString name) { + QString oldname = itemName(i); + i->setData(Qt::UserRole, name); i->setData(Qt::DisplayRole, name + "\t" + itemFile(i)); + + if(oldname != "" && oldname != name) emit nameChanged(itemFile(i), name); } void FileList::setItemMaster(QListWidgetItem *i, bool master) diff --git a/dgedit/filelist.h b/dgedit/filelist.h index 22b702d..637ed6c 100644 --- a/dgedit/filelist.h +++ b/dgedit/filelist.h @@ -41,6 +41,7 @@ signals: void masterFileChanged(QString filename); void fileAdded(QString file, QString name); void fileRemoved(QString file, QString name); + void nameChanged(QString file, QString name); public slots: void addFiles(); diff --git a/dgedit/mainwindow.cc b/dgedit/mainwindow.cc index 9b78968..cabe0d6 100644 --- a/dgedit/mainwindow.cc +++ b/dgedit/mainwindow.cc @@ -135,8 +135,12 @@ MainWindow::MainWindow() filelist = new FileList(); connect(filelist, SIGNAL(masterFileChanged(QString)), this, SLOT(loadFile(QString))); connect(loadbtn, SIGNAL(clicked()), filelist, SLOT(addFiles())); - connect(filelist, SIGNAL(fileAdded(QString, QString)), extractor, SLOT(addFile(QString, QString))); - connect(filelist, SIGNAL(fileRemoved(QString, QString)), extractor, SLOT(removeFile(QString, QString))); + connect(filelist, SIGNAL(fileAdded(QString, QString)), + extractor, SLOT(addFile(QString, QString))); + connect(filelist, SIGNAL(fileRemoved(QString, QString)), + extractor, SLOT(removeFile(QString, QString))); + connect(filelist, SIGNAL(nameChanged(QString, QString)), + extractor, SLOT(changeName(QString, QString))); configs->addWidget(filelist); QDockWidget *dockWidget = new QDockWidget(tr("Dock Widget"), this); |