summaryrefslogtreecommitdiffstats
path: root/propertiesdialog.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2012-10-10 18:28:45 +0200
committerArno <am@disconnect.de>2012-10-10 18:28:45 +0200
commitdab3f05dcb2975c07247e3bebd8e9a7e8b9e83ce (patch)
tree70ee72f169620d5a6b07b7c116a0455183f6ef26 /propertiesdialog.cpp
parentd562d4a3527044aaeb36534bc2d4b65b587c9bb3 (diff)
downloadSheMov-dab3f05dcb2975c07247e3bebd8e9a7e8b9e83ce.tar.gz
SheMov-dab3f05dcb2975c07247e3bebd8e9a7e8b9e83ce.tar.bz2
SheMov-dab3f05dcb2975c07247e3bebd8e9a7e8b9e83ce.zip
SeriesTreeModel fix
* make it possible to delete whole series again. No code fix, just the database layout: add on delete cascade to metadata * get rid of propertiesdialog.{cpp,h}. It was useless and called from the "Edit.." context menu. Code bloat, I guess... * Do something useful when calling "Edit...". Rename Series or ask for a new SeriesPart
Diffstat (limited to 'propertiesdialog.cpp')
-rw-r--r--propertiesdialog.cpp142
1 files changed, 0 insertions, 142 deletions
diff --git a/propertiesdialog.cpp b/propertiesdialog.cpp
deleted file mode 100644
index 2068cdf..0000000
--- a/propertiesdialog.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- 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 <QSqlDatabase>
-#include <QSqlQuery>
-#include <QLabel>
-#include <QHBoxLayout>
-#include <QVBoxLayout>
-#include <QSplitter>
-#include <QTreeView>
-#include <QTabWidget>
-#include <QPushButton>
-#include <QScrollArea>
-
-#include "propertiesdialog.h"
-#include "smtreemodel.h"
-#include "smtreeitem.h"
-#include "filestreemodel.h"
-#include "seriestreemodel.h"
-#include "smglobals.h"
-
-PropertiesDialog::PropertiesDialog(QWidget *parent, Qt::WindowFlags f) : SmDialog(parent, f), mCurrentId(-1) {
- //init model
- const QStringList headers = QStringList() << "Name" << "Id" << "NodeType";
- mDisplayModel = new SmTreeModel(headers, this);
- mFilesModel = static_cast<FilesTreeModel*>(SmGlobals::instance()->model("FilesModel"));
- mSeriesModel = static_cast<SeriesTreeModel*>(SmGlobals::instance()->model("SeriesModel"));
- setupGui();
-}
-
-PropertiesDialog::~PropertiesDialog() {}
-
-void PropertiesDialog::populate(int seriesPartId){
- //prepare items
- mCurrentId = seriesPartId;
- SmTreeItem *root = new SmTreeItem(3);
- SmTreeItem *movieDummy = new SmTreeItem(QList<QVariant>() << "Movies" << -1 << DummyNode, root);
- root->appendChild(movieDummy);
- SmTreeItem *pictureDummy = new SmTreeItem(QList<QVariant>() << "Covers" << -1 << DummyNode, root);
- root->appendChild(pictureDummy);
-
- //populate model
- QSqlDatabase db = QSqlDatabase::database("treedb");
- QSqlQuery filesQuery(db);
- filesQuery.prepare("SELECT tfilename, ifiles_id, sifiletype FROM files WHERE iseriespart_id = :id");
- filesQuery.bindValue(":id", mCurrentId);
- if(filesQuery.exec()){
- while(filesQuery.next()){
- QList<QVariant> data;
- data << filesQuery.value(0) << filesQuery.value(1);
- if(filesQuery.value(2).toInt() == FilesTreeModel::Movie){
- data << MovieFileNode;
- SmTreeItem *dataItem = new SmTreeItem(data, movieDummy);
- movieDummy->appendChild(dataItem);
- }else{
- data << PictureFileNode;
- SmTreeItem *dataItem = new SmTreeItem(data, pictureDummy);
- pictureDummy->appendChild(dataItem);
- }
- }
- }
- mDisplayModel->setRoot(root);
-
- //setup caption
- QModelIndex seriesIdx = mSeriesModel->findRecursive(seriesPartId, SeriesTreeModel::SeriesPartId, mSeriesModel->rootIndex());
- 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);
-
- //make it usable
- mFileView->expandAll();
- mFileView->setColumnHidden(1, true);
- mFileView->setColumnHidden(2, true);
- 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->rootIndex());
- if(fileIdx.isValid()){
- QString fullPath = fileIdx.data(FilesTreeModel::FullPathRole).toString();
- mPictureLabel->setPixmap(fullPath);
- }
- }
-}
-
-void PropertiesDialog::setupGui(){
- //white caption
- QVBoxLayout *mainLayout = new QVBoxLayout;
- QString topStyleSheet = QString("QFrame#caption { background-color: white; border: 1px solid black; font-weight: bold; padding-left: 10px; padding-top: 4px; padding-bottom: 4px;}");
- mCaption = new QLabel;
- mCaption->setFrameShape(QFrame::StyledPanel);
- mCaption->setObjectName("caption");
- mCaption->setStyleSheet(topStyleSheet);
- mainLayout->addWidget(mCaption);
-
- //data
- QSplitter *mSplitter = new QSplitter;
- 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);
- 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);
- mainLayout->addWidget(mSplitter);
-
- //button bar
- QHBoxLayout *buttonLayout = new QHBoxLayout;
- mOk = new QPushButton(tr("Ok"));
- mCancel = new QPushButton(tr("Cancel"));
- buttonLayout->addStretch();
- buttonLayout->addWidget(mOk);
- buttonLayout->addWidget(mCancel);
- connect(mCancel, SIGNAL(clicked()), this, SLOT(reject()));
- mainLayout->addLayout(buttonLayout);
- setLayout(mainLayout);
-}