summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2009-12-02 08:19:01 +0000
committerdeva <deva>2009-12-02 08:19:01 +0000
commitca1da8e0d448a47704a22685248ee7b44f2c7bec (patch)
tree7c12ab5acdd6c033df7073f903d559f9c6904015
parent22db10eed86c90d05ed19446afd0fc007bec0d66 (diff)
Fixed renaming in extractor.
-rw-r--r--dgedit/audioextractor.cc17
-rw-r--r--dgedit/audioextractor.h9
-rw-r--r--dgedit/filelist.cc4
-rw-r--r--dgedit/filelist.h1
-rw-r--r--dgedit/mainwindow.cc8
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);