From 9cd3c49d7b86b443726b724013f08efce13b8022 Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 30 Nov 2009 14:33:32 +0000 Subject: Adding files from gui now works. --- dgedit/mainwindow.cc | 40 ++++++++++++++++++++++++---------------- dgedit/mainwindow.h | 3 +-- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/dgedit/mainwindow.cc b/dgedit/mainwindow.cc index 7af947a..b46904a 100644 --- a/dgedit/mainwindow.cc +++ b/dgedit/mainwindow.cc @@ -37,7 +37,7 @@ #include #include #include - +#include #define MAXVAL 10000000L #define SINGLESTEP MAXVAL/100000 @@ -109,7 +109,7 @@ MainWindow::MainWindow() QPushButton *loadbtn = new QPushButton(); loadbtn->setText("Load"); - connect(loadbtn, SIGNAL(clicked()), this, SLOT(loadFile())); + connect(loadbtn, SIGNAL(clicked()), this, SLOT(addFile())); btns->addWidget(autosel); btns->addWidget(clearsel); @@ -136,10 +136,7 @@ MainWindow::MainWindow() configs->addWidget(new QLabel("Files:")); filelist = new QListWidget(); - addFile("/home/deva/aasimonster/tmp/china/Amb L-20.wav", "amb-l"); - addFile("/home/deva/aasimonster/tmp/china/Amb R-20.wav", "amb-r"); - addFile("/home/deva/aasimonster/tmp/china/OH L-20.wav", "oh-l"); - addFile("/home/deva/aasimonster/tmp/china/OH R-20.wav", "oh-r"); + connect(filelist, SIGNAL(itemSelectionChanged()), this, SLOT(loadFile())); configs->addWidget(filelist); QDockWidget *dockWidget = new QDockWidget(tr("Dock Widget"), this); @@ -221,23 +218,34 @@ void MainWindow::doExport() void MainWindow::loadFile() { - QString filename = - QFileDialog::getOpenFileName(this, tr("Open file"), - "", tr("Audio Files (*.wav)")); + QString filename = filelist->currentItem()->text(); + + setCursor(Qt::WaitCursor); statusBar()->showMessage("Loading..."); qApp->processEvents(); sorter->setWavData(NULL, 0); canvas->load(filename); sorter->setWavData(canvas->data, canvas->size); statusBar()->showMessage("Ready"); + setCursor(Qt::ArrowCursor); } -void MainWindow::addFile(QString file, QString name) +void MainWindow::addFile() { - QListWidgetItem *item = new QListWidgetItem(); - item->setText(file); - item->setData(Qt::UserRole, name); - filelist->addItem(item); - - extractor->addFile(file, name); + QStringList files = QFileDialog::getOpenFileNames(this, tr("Open file"), + "", tr("Audio Files (*.wav)")); + QStringList::Iterator i = files.begin(); + while(i != files.end()) { + QString file = *i; + QFileInfo fi(file); + QString name = fi.baseName(); + + QListWidgetItem *item = new QListWidgetItem(); + item->setText(file); + item->setData(Qt::UserRole, name); + filelist->addItem(item); + + extractor->addFile(file, name); + i++; + } } diff --git a/dgedit/mainwindow.h b/dgedit/mainwindow.h index 42a9f18..df40e3a 100644 --- a/dgedit/mainwindow.h +++ b/dgedit/mainwindow.h @@ -40,8 +40,6 @@ Q_OBJECT public: MainWindow(); - void addFile(QString file, QString name); - public slots: void setXScale(int); void setYScale(int); @@ -49,6 +47,7 @@ public slots: void setYOffset(int); void doExport(); void loadFile(); + void addFile(); protected: void closeEvent(QCloseEvent*); -- cgit v1.2.3