From cbf3c617d366892cf6af9b5fdbc5286e47ca4b42 Mon Sep 17 00:00:00 2001 From: am Date: Thu, 6 Aug 2009 20:07:25 +0000 Subject: -prepared archiveviewwidget for size operation -need some more attributes for movieitem, like part and movienumber to sort properly git-svn-id: file:///var/svn/repos2/shemov/trunk@399 f440f766-f032-0410-8965-dc7d17de2ca0 --- archiveviewwidget.cpp | 68 ++++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 33 deletions(-) (limited to 'archiveviewwidget.cpp') diff --git a/archiveviewwidget.cpp b/archiveviewwidget.cpp index 9be3a10..37eca17 100644 --- a/archiveviewwidget.cpp +++ b/archiveviewwidget.cpp @@ -17,6 +17,8 @@ #include #include +#include + #include "archiveviewwidget.h" #include "archivefileview.h" #include "moviemodel.h" @@ -68,6 +70,8 @@ ArchiveViewWidget::ArchiveViewWidget(MovieModel *model, ListModel *genre, ListMo mFileView->setSortingEnabled(true); mFileView->setItemsExpandable(false); mFileView->setRootIsDecorated(false); + mFileView->setSelectionBehavior(QAbstractItemView::SelectRows); + mFileView->setSelectionMode(QAbstractItemView::ExtendedSelection); mFileView->setColumnHidden(MovieItem::Md5Sum, true); connect(mClearFilter, SIGNAL(clicked()), mProxy, SLOT(clearFilter())); connect(mMovieModel, SIGNAL(moviesChanged()), mProxy, SLOT(invalidate())); @@ -77,34 +81,26 @@ ArchiveViewWidget::ArchiveViewWidget(MovieModel *model, ListModel *genre, ListMo mainLayout->addLayout(filterLayout); mainLayout->addWidget(mFileView); - connect(mFileView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex)), this, SLOT(rowChanged(const QModelIndex &, const QModelIndex &))); + connect(mFileView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex)), this, SLOT(rowChanged(const QModelIndex &, const QModelIndex &))); connect(mFileView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(showMovie(const QModelIndex &))); setLayout(mainLayout); } void ArchiveViewWidget::editFile(){ - QModelIndexList selected = mFileView->selectionModel()->selectedRows(); - if(!selected.isEmpty()){ - QModelIndex idx = selected.at(0); - QModelIndex real = mProxy->mapToSource(idx); - mEditDialog->setMovie(real); - mEditDialog->show(); - mEditDialog->raise(); - mEditDialog->activateWindow(); - } + QModelIndex real = getSourceColumnZero(); + mEditDialog->setMovie(real); + mEditDialog->show(); + mEditDialog->raise(); + mEditDialog->activateWindow(); } void ArchiveViewWidget::editCovers(){ - QModelIndexList selected = mFileView->selectionModel()->selectedRows(); - if(!selected.isEmpty()){ - QModelIndex idx = selected.at(0); - QModelIndex real = mProxy->mapToSource(idx); - mCoverEditDialog->setMovie(real); - mCoverEditDialog->show(); - mCoverEditDialog->raise(); - mCoverEditDialog->activateWindow(); - } + QModelIndex real = getSourceColumnZero(); + mCoverEditDialog->setMovie(real); + mCoverEditDialog->show(); + mCoverEditDialog->raise(); + mCoverEditDialog->activateWindow(); } void ArchiveViewWidget::addMovie(){ @@ -153,12 +149,7 @@ void ArchiveViewWidget::showMovie(const QModelIndex &movie){ } void ArchiveViewWidget::properties(){ - QModelIndexList selected = fileView()->selectionModel()->selectedRows(); - if(selected.isEmpty()){ - return; - } - QModelIndex idx = selected.at(0); - QModelIndex real = mProxy->mapToSource(idx); + QModelIndex real = getSourceColumnZero(); int movid = real.data(MovieModel::IdRole).toInt(); MoviePropertiesDialog dlg(movid, this); dlg.exec(); @@ -180,13 +171,24 @@ void ArchiveViewWidget::setActorFilter(const QString &filter){ mProxy->setFilter(filter, ArchiveProxy::ActorFilter); } -void ArchiveViewWidget::rowChanged(const QModelIndex ¤t, const QModelIndex & /*prev*/){ - if(current.isValid()){ - QModelIndex idx = current; - if(current.column() != 0){ - idx = mProxy->index(current.row(), 0, current.parent()); - } - QString title = QString(tr("%1 - %2")).arg(qApp->applicationName()).arg(idx.data().toString()); - emit windowTitle(title); +void ArchiveViewWidget::rowChanged(const QModelIndex &/*current*/, const QModelIndex & /*prev*/){ + QModelIndex idx = getSourceColumnZero(); + QString title = QString(tr("%1 - %2")).arg(qApp->applicationName()).arg(idx.data().toString()); + emit windowTitle(title); +} + +const QModelIndex ArchiveViewWidget::getSourceColumnZero(){ + QModelIndex retval; + QModelIndex idx = mFileView->currentIndex(); + if(idx.column() != 0){ + idx = mProxy->index(idx.row(), 0); } + QModelIndex real = mProxy->mapToSource(idx); + if(real.column() != 0){ + retval = mMovieModel->index(real.row(), 0); + }else{ + retval = real; + } + return retval; } + -- cgit v1.2.3-70-g09d2