summaryrefslogtreecommitdiffstats
path: root/propertiesdialog.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2011-08-23 16:35:44 +0200
committerArno <am@disconnect.de>2011-08-23 16:35:44 +0200
commitb0ed5d04a5934be074383541026d49afc0804adb (patch)
treef60416e4cde15fce91cc7fecad5f73fa4e0a222e /propertiesdialog.cpp
parent50783b0819531087266c626fa6066e8233bb0692 (diff)
downloadSheMov-b0ed5d04a5934be074383541026d49afc0804adb.tar.gz
SheMov-b0ed5d04a5934be074383541026d49afc0804adb.tar.bz2
SheMov-b0ed5d04a5934be074383541026d49afc0804adb.zip
Hmm, checking out treemodel again. This seems way too complex...
Diffstat (limited to 'propertiesdialog.cpp')
-rw-r--r--propertiesdialog.cpp39
1 files changed, 33 insertions, 6 deletions
diff --git a/propertiesdialog.cpp b/propertiesdialog.cpp
index 332105d..485df6b 100644
--- a/propertiesdialog.cpp
+++ b/propertiesdialog.cpp
@@ -14,6 +14,7 @@
#include <QTreeView>
#include <QTabWidget>
#include <QPushButton>
+#include <QScrollArea>
#include "propertiesdialog.h"
#include "smtreemodel.h"
@@ -41,8 +42,6 @@ void PropertiesDialog::populate(int seriesPartId){
root->appendChild(movieDummy);
SmTreeItem *pictureDummy = new SmTreeItem(QList<QVariant>() << "Covers" << -1 << DummyNode, root);
root->appendChild(pictureDummy);
- SmTreeItem *screenshotDummy = new SmTreeItem(QList<QVariant>() << "Screenshots" << -1 << DummyNode, root);
- root->appendChild(screenshotDummy);
//populate model
QSqlDatabase db = QSqlDatabase::database("treedb");
@@ -52,7 +51,7 @@ void PropertiesDialog::populate(int seriesPartId){
if(filesQuery.exec()){
while(filesQuery.next()){
QList<QVariant> data;
- data << filesQuery.value(0) << filesQuery.value(1);// << filesQuery.value(2);
+ data << filesQuery.value(0) << filesQuery.value(1);
if(filesQuery.value(2).toInt() == FilesTreeModel::Movie){
data << MovieFileNode;
SmTreeItem *dataItem = new SmTreeItem(data, movieDummy);
@@ -67,7 +66,7 @@ void PropertiesDialog::populate(int seriesPartId){
mDisplayModel->setRoot(root);
//setup caption
- QModelIndex seriesIdx = mSeriesModel->findRecursive(seriesPartId, SeriesTreeModel::SeriesPartId, mSeriesModel->index(0, SeriesTreeModel::SeriesPartId, QModelIndex()));
+ QModelIndex seriesIdx = mSeriesModel->findRecursive(seriesPartId, SeriesTreeModel::SeriesPartId, QModelIndex());
Q_ASSERT(seriesIdx.isValid());
QString captionString = QString(tr("Properties for %1")).arg(mSeriesModel->index(seriesIdx.row(), SeriesTreeModel::Name, seriesIdx.parent()).data().toString());
mCaption->setText(captionString);
@@ -79,6 +78,24 @@ void PropertiesDialog::populate(int seriesPartId){
mFileView->resizeColumnToContents(0);
}
+void PropertiesDialog::showPicture(QModelIndex current, QModelIndex previous){
+ Q_UNUSED(previous);
+ QModelIndex fileIdIdx = mDisplayModel->index(current.row(), 1, current.parent());
+ int fileId = fileIdIdx.data().toInt();
+ QModelIndex nodeTypeIdx = mDisplayModel->index(current.row(), 2, current.parent());
+ int nodeType = nodeTypeIdx.data().toInt();
+ if(nodeType == MovieFileNode){
+ QPixmap pic = SmGlobals::instance()->frameCache()->entry(current.data().toString());
+ mPictureLabel->setPixmap(pic);
+ }else if(nodeType == PictureFileNode){
+ QModelIndex fileIdx = mFilesModel->findRecursive(fileId, FilesTreeModel::FilesId, mFilesModel->index(0, 0, QModelIndex()));
+ if(fileIdx.isValid()){
+ QString fullPath = fileIdx.data(FilesTreeModel::FullPathRole).toString();
+ mPictureLabel->setPixmap(fullPath);
+ }
+ }
+}
+
void PropertiesDialog::setupGui(){
//white caption
QVBoxLayout *mainLayout = new QVBoxLayout;
@@ -94,9 +111,19 @@ void PropertiesDialog::setupGui(){
mTab = new QTabWidget;
mFileView = new QTreeView;
mFileView->setModel(mDisplayModel);
+ mFileView->setSelectionBehavior(QAbstractItemView::SelectRows);
+ mFileView->setSelectionMode(QAbstractItemView::SingleSelection);
+ connect(mFileView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(showPicture(QModelIndex,QModelIndex)));
mSplitter->addWidget(mFileView);
- QWidget *dummyTab = new QWidget;
- mTab->addTab(dummyTab, "Dummy");
+ mPicTab = new QWidget;
+ QScrollArea *picScroll = new QScrollArea;
+ mPictureLabel = new QLabel;
+ //mPictureLabel->setScaledContents(true);
+ picScroll->setWidget(mPictureLabel);
+ QHBoxLayout *pictureLayout = new QHBoxLayout;
+ pictureLayout->addWidget(mPictureLabel);
+ mPicTab->setLayout(pictureLayout);
+ mTab->addTab(mPicTab, "Picture");
mSplitter->addWidget(mTab);
mSplitter->setStretchFactor(0, 1);
mSplitter->setStretchFactor(1, 3);