summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoram <am@f440f766-f032-0410-8965-dc7d17de2ca0>2009-08-06 20:07:25 +0000
committeram <am@f440f766-f032-0410-8965-dc7d17de2ca0>2009-08-06 20:07:25 +0000
commitcbf3c617d366892cf6af9b5fdbc5286e47ca4b42 (patch)
tree8f8d904dc13e7a688b06b262a6bf2266aab06f82
parent44a73ebcfc2ad65fe7301d49f7020f9f8dcd7762 (diff)
downloadSheMov-cbf3c617d366892cf6af9b5fdbc5286e47ca4b42.tar.gz
SheMov-cbf3c617d366892cf6af9b5fdbc5286e47ca4b42.tar.bz2
SheMov-cbf3c617d366892cf6af9b5fdbc5286e47ca4b42.zip
-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
-rw-r--r--archiveviewwidget.cpp68
-rw-r--r--archiveviewwidget.h1
2 files changed, 36 insertions, 33 deletions
diff --git a/archiveviewwidget.cpp b/archiveviewwidget.cpp
index 9be3a10..37eca17 100644
--- a/archiveviewwidget.cpp
+++ b/archiveviewwidget.cpp
@@ -17,6 +17,8 @@
#include <QSettings>
#include <QProcess>
+#include <QDebug>
+
#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 &current, 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;
}
+
diff --git a/archiveviewwidget.h b/archiveviewwidget.h
index 1e7e06a..fd2cf55 100644
--- a/archiveviewwidget.h
+++ b/archiveviewwidget.h
@@ -50,6 +50,7 @@ class ArchiveViewWidget : public QWidget {
void rowChanged(const QModelIndex &current, const QModelIndex &prev);
private:
+ const QModelIndex getSourceColumnZero();
QComboBox *mGenre;
QComboBox *mActors;
QLineEdit *mName;