From 5ac1c127f1f91581763857a7ddc31f379819b1f8 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Mon, 8 Nov 2010 02:06:01 +0100 Subject: [PATCH] Smarter method to edit file informartion of files in the list --- src/Dialog_MainWindow.cpp | 3 +-- src/Model_FileList.cpp | 5 +++++ src/Model_FileList.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index b1e16200..93f1ea83 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -391,9 +391,8 @@ void MainWindow::editMetaButtonClicked(void) sourceFileView->selectRow(index.row()); } - AudioFileModel file = m_fileListModel->getFile(index); + AudioFileModel &file = (*m_fileListModel)[index]; iResult = metaInfoDialog->exec(file, index.row() > 0, index.row() < m_fileListModel->rowCount() - 1); - m_fileListModel->setFile(index, file); if(!iResult) break; } diff --git a/src/Model_FileList.cpp b/src/Model_FileList.cpp index 0cb510ef..37d078ed 100644 --- a/src/Model_FileList.cpp +++ b/src/Model_FileList.cpp @@ -204,6 +204,11 @@ AudioFileModel FileListModel::getFile(const QModelIndex &index) } } +AudioFileModel &FileListModel::operator[] (const QModelIndex &index) +{ + return m_fileList[index.row()]; +} + bool FileListModel::setFile(const QModelIndex &index, const AudioFileModel &audioFile) { if(index.row() >= 0 && index.row() < m_fileList.count()) diff --git a/src/Model_FileList.h b/src/Model_FileList.h index a3456b9b..a14afe33 100644 --- a/src/Model_FileList.h +++ b/src/Model_FileList.h @@ -46,6 +46,7 @@ public: bool moveFile(const QModelIndex &index, int delta); AudioFileModel getFile(const QModelIndex &index); bool setFile(const QModelIndex &index, const AudioFileModel &audioFile); + AudioFileModel &operator[] (const QModelIndex &index); public slots: void addFile(const QString &filePath);