Smarter method to edit file informartion of files in the list

This commit is contained in:
LoRd_MuldeR 2010-11-08 02:06:01 +01:00
parent 07c793d6ec
commit 5ac1c127f1
3 changed files with 7 additions and 2 deletions

View File

@ -391,9 +391,8 @@ void MainWindow::editMetaButtonClicked(void)
sourceFileView->selectRow(index.row()); 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); iResult = metaInfoDialog->exec(file, index.row() > 0, index.row() < m_fileListModel->rowCount() - 1);
m_fileListModel->setFile(index, file);
if(!iResult) break; if(!iResult) break;
} }

View File

@ -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) bool FileListModel::setFile(const QModelIndex &index, const AudioFileModel &audioFile)
{ {
if(index.row() >= 0 && index.row() < m_fileList.count()) if(index.row() >= 0 && index.row() < m_fileList.count())

View File

@ -46,6 +46,7 @@ public:
bool moveFile(const QModelIndex &index, int delta); bool moveFile(const QModelIndex &index, int delta);
AudioFileModel getFile(const QModelIndex &index); AudioFileModel getFile(const QModelIndex &index);
bool setFile(const QModelIndex &index, const AudioFileModel &audioFile); bool setFile(const QModelIndex &index, const AudioFileModel &audioFile);
AudioFileModel &operator[] (const QModelIndex &index);
public slots: public slots:
void addFile(const QString &filePath); void addFile(const QString &filePath);