diff options
author | am <am@f440f766-f032-0410-8965-dc7d17de2ca0> | 2009-07-19 16:12:02 +0000 |
---|---|---|
committer | am <am@f440f766-f032-0410-8965-dc7d17de2ca0> | 2009-07-19 16:12:02 +0000 |
commit | d2b854121266e32164290ee4e683c0c8388d7d41 (patch) | |
tree | 7e844a2920bc00d5d855da661a98f9b20ff13f2e /archiveviewwidget.cpp | |
parent | 80bf76dc318276f67eeec32b8f68e82cf4bb7e62 (diff) | |
download | SheMov-d2b854121266e32164290ee4e683c0c8388d7d41.tar.gz SheMov-d2b854121266e32164290ee4e683c0c8388d7d41.tar.bz2 SheMov-d2b854121266e32164290ee4e683c0c8388d7d41.zip |
-added ActorRole in MovieModel
-Fixed bug in MovieItem returning data and filling the model
-Started on archive viewing
git-svn-id: file:///var/svn/repos2/shemov/trunk@391 f440f766-f032-0410-8965-dc7d17de2ca0
Diffstat (limited to 'archiveviewwidget.cpp')
-rw-r--r-- | archiveviewwidget.cpp | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/archiveviewwidget.cpp b/archiveviewwidget.cpp new file mode 100644 index 0000000..9a0e76e --- /dev/null +++ b/archiveviewwidget.cpp @@ -0,0 +1,96 @@ +/* + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version + 2 of the License, or (at your option) any later version. +*/ + +#include <QComboBox> +#include <QLineEdit> +#include <QLineEdit> +#include <QLabel> +#include <QHBoxLayout> +#include <QVBoxLayout> +#include <QPushButton> +#include <QApplication> + +#include "archiveviewwidget.h" +#include "archivefileview.h" +#include "moviemodel.h" +#include "listmodel.h" +#include "archiveproxy.h" + +ArchiveViewWidget::ArchiveViewWidget(MovieModel *model, ListModel *genre, ListModel *actors, QWidget *parent) : QWidget(parent), mMovieModel(model), mGenreModel(genre), mActorsModel(actors){ + //filter bar + QHBoxLayout *filterLayout = new QHBoxLayout; + QLabel *l1 = new QLabel(tr("Filter by &genre")); + mGenre = new QComboBox; + l1->setBuddy(mGenre); + mGenre->setModel(mGenreModel); + connect(mGenre, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(setGenreFilter(const QString &))); + filterLayout->addWidget(l1); + filterLayout->addWidget(mGenre); + QLabel *l2 = new QLabel(tr("Filter by &actor")); + mActors = new QComboBox; + mActors->setModel(mActorsModel); + connect(mActors, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(setActorFilter(const QString &))); + l2->setBuddy(mActors); + filterLayout->addWidget(l2); + filterLayout->addWidget(mActors); + QLabel *l3 = new QLabel(tr("Filter by &title")); + mName = new QLineEdit; + l3->setBuddy(mName); + filterLayout->addWidget(l3); + filterLayout->addWidget(mName); + mFilter = new QPushButton(tr("Filter")); + connect(mFilter, SIGNAL(clicked()), this, SLOT(setFilter())); + filterLayout->addWidget(mFilter); + mClearFilter = new QPushButton(tr("Clear filter")); + filterLayout->addWidget(mClearFilter); + + //treeview + mFileView = new ArchiveFileView; + mProxy = new ArchiveProxy(this); + mProxy->setSourceModel(mMovieModel); + mFileView->setModel(mProxy); + mFileView->setSortingEnabled(true); + mFileView->setItemsExpandable(false); + mFileView->setRootIsDecorated(false); + connect(mClearFilter, SIGNAL(clicked()), mProxy, SLOT(clearFilter())); + + //main layout + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout(filterLayout); + mainLayout->addWidget(mFileView); + + connect(mFileView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex)), this, SLOT(rowChanged(const QModelIndex &, const QModelIndex &))); + + setLayout(mainLayout); +} + +void ArchiveViewWidget::setFilter(){ + QString filter = mName->text().toLower(); + if(filter.isEmpty()){ + return; + } + mProxy->setFilter(filter, ArchiveProxy::TitleFilter); +} + +void ArchiveViewWidget::setGenreFilter(const QString &filter){ + mProxy->setFilter(filter, ArchiveProxy::GenreFilter); +} + +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); + } +} |