summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2011-08-22 16:31:05 +0200
committerArno <am@disconnect.de>2011-08-22 16:31:05 +0200
commitf427305bb038ab3af27fb8a1a17827732c3713f3 (patch)
treee1f505f9ce23aeaecedb7a3815e35c37ca06ffc8
parent6ccb1884dd9e9a57f7b25239097951d77103d331 (diff)
downloadSheMov-f427305bb038ab3af27fb8a1a17827732c3713f3.tar.gz
SheMov-f427305bb038ab3af27fb8a1a17827732c3713f3.tar.bz2
SheMov-f427305bb038ab3af27fb8a1a17827732c3713f3.zip
First draft of PropertiesDialog
Kinda mock-up of new PropertiesDialog. The caption label works, though for some reason I can't set a background image via Stylesheets. It also shows the files belonging to the SeriesPart.
-rw-r--r--propertiesdialog.cpp115
-rw-r--r--propertiesdialog.h44
-rw-r--r--seriestreewidget.cpp10
-rw-r--r--shemov.pro6
4 files changed, 171 insertions, 4 deletions
diff --git a/propertiesdialog.cpp b/propertiesdialog.cpp
new file mode 100644
index 0000000..332105d
--- /dev/null
+++ b/propertiesdialog.cpp
@@ -0,0 +1,115 @@
+/*
+ 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 "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);
+ SmTreeItem *screenshotDummy = new SmTreeItem(QList<QVariant>() << "Screenshots" << -1 << DummyNode, root);
+ root->appendChild(screenshotDummy);
+
+ //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);// << filesQuery.value(2);
+ 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->index(0, 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);
+
+ //make it usable
+ mFileView->expandAll();
+ mFileView->setColumnHidden(1, true);
+ mFileView->setColumnHidden(2, true);
+ mFileView->resizeColumnToContents(0);
+}
+
+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);
+ mSplitter->addWidget(mFileView);
+ QWidget *dummyTab = new QWidget;
+ mTab->addTab(dummyTab, "Dummy");
+ 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);
+}
diff --git a/propertiesdialog.h b/propertiesdialog.h
new file mode 100644
index 0000000..d881ec7
--- /dev/null
+++ b/propertiesdialog.h
@@ -0,0 +1,44 @@
+/*
+ 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.
+*/
+
+#ifndef PROPERTIESDIALOG_H
+#define PROPERTIESDIALOG_H
+
+#include "smdialog.h"
+
+class SmTreeModel;
+class FilesTreeModel;
+class SeriesTreeModel;
+class QLabel;
+class QSplitter;
+class QTreeView;
+class QTabWidget;
+class QPushButton;
+
+class PropertiesDialog : public SmDialog {
+ Q_OBJECT
+ public:
+ enum NodeType { PictureFileNode, MovieFileNode, ScreenshotNode, DummyNode };
+ explicit PropertiesDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
+ virtual ~PropertiesDialog();
+ void populate(int seriesPartId);
+
+ private:
+ void setupGui();
+ SmTreeModel *mDisplayModel;
+ FilesTreeModel *mFilesModel;
+ SeriesTreeModel *mSeriesModel;
+ int mCurrentId;
+ QLabel *mCaption;
+ QSplitter *mSplitter;
+ QTreeView *mFileView;
+ QTabWidget *mTab;
+ QPushButton *mOk;
+ QPushButton *mCancel;
+};
+
+#endif // PROPERTIESDIALOG_H
diff --git a/seriestreewidget.cpp b/seriestreewidget.cpp
index 17b9a90..7259157 100644
--- a/seriestreewidget.cpp
+++ b/seriestreewidget.cpp
@@ -44,6 +44,7 @@
#include "filestreemodel.h"
#include "helper.h"
#include "hoverwindow.h"
+#include "propertiesdialog.h"
SeriesTreeWidget::SeriesTreeWidget(QWidget *parent) : QWidget(parent){
//filter bar
@@ -349,9 +350,14 @@ void SeriesTreeWidget::expandItems(const QStringList &items){
void SeriesTreeWidget::editItem(){
QModelIndex current = mView->selectionModel()->currentIndex();
- QModelIndex real = mProxy->mapToSource(current);
+ if(current.data(SeriesTreeModel::TypeRole).toInt() == SeriesTreeModel::Part){
+ PropertiesDialog dlg(this);
+ dlg.populate(current.data(SeriesTreeModel::SeriesPartIdRole).toInt());
+ dlg.exec();
+ }
+ /*QModelIndex real = mProxy->mapToSource(current);
EditSeriesDialog dlg(real, this);
- dlg.exec();
+ dlg.exec();*/
}
void SeriesTreeWidget::producerFinished(QStringListModel *model){
diff --git a/shemov.pro b/shemov.pro
index bb6a6a3..7aae998 100644
--- a/shemov.pro
+++ b/shemov.pro
@@ -33,7 +33,8 @@ SOURCES = main.cpp \
consistencycheck.cpp \
seriesmetadatamodel.cpp \
mappingtableeditor.cpp \
- smdialog.cpp
+ smdialog.cpp \
+ propertiesdialog.cpp
HEADERS = listitem.h \
filesystemdirproxy.h \
filesystemwidget.h \
@@ -62,6 +63,7 @@ HEADERS = listitem.h \
consistencycheck.h \
seriesmetadatamodel.h \
mappingtableeditor.h \
- smdialog.h
+ smdialog.h \
+ propertiesdialog.h
LIBS += -lmagic -lXfixes
RESOURCES = shemov.qrc