summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2016-11-10 18:10:30 +0100
committerArno <arno@disconnect.de>2016-11-10 18:10:30 +0100
commitaa0cdc4493c0f0435a64cfa8cee010c7659dc8fa (patch)
tree0b10d02fd9e9b81f06e846aa515245cd5a54b8b6
parent54eaa7a4a883978a308d799e1f108bdce5e9c030 (diff)
downloadSheMov-aa0cdc4493c0f0435a64cfa8cee010c7659dc8fa.tar.gz
SheMov-aa0cdc4493c0f0435a64cfa8cee010c7659dc8fa.tar.bz2
SheMov-aa0cdc4493c0f0435a64cfa8cee010c7659dc8fa.zip
Add Random file browser
Idea: Select random movies based on a selection of genres and actors in a new tab, so you don't have the agony of choice. This is just the basic layout. The selectors are filled and the buttons are connected, but it doesn't select anything yet.
-rw-r--r--randomtab.cpp161
-rw-r--r--randomtab.h53
-rw-r--r--shemov.cpp7
-rw-r--r--shemov.h2
-rw-r--r--shemov.pro6
5 files changed, 227 insertions, 2 deletions
diff --git a/randomtab.cpp b/randomtab.cpp
new file mode 100644
index 0000000..c94deec
--- /dev/null
+++ b/randomtab.cpp
@@ -0,0 +1,161 @@
+/*
+ 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 <QGroupBox>
+#include <QIntValidator>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QGridLayout>
+#include <QSplitter>
+#include <QStandardItemModel>
+#include <QStandardItem>
+#include <QTreeView>
+#include <QSortFilterProxyModel>
+#include <QSqlQuery>
+
+#include "randomtab.h"
+
+RandomTab::RandomTab(QWidget *parent) : QWidget(parent) {
+ mDb = QSqlDatabase::database("treedb");
+ mGenreModel = new QStandardItemModel(this);
+ mActorModel = new QStandardItemModel(this);
+ setupModels();
+ setupGui();
+ clearAll();
+}
+
+void RandomTab::setupGui(){
+ QGroupBox *numBox = new QGroupBox(tr("Select no."));
+ mNumber = new QLineEdit;
+ QIntValidator *numValidator = new QIntValidator(1, 100, this);
+ mNumber->setValidator(numValidator);
+ mNumber->setText("10");
+ QHBoxLayout *numL = new QHBoxLayout;
+ numL->addWidget(mNumber);
+ numBox->setLayout(numL);
+
+ QGroupBox *genreBox = new QGroupBox(tr("Genres"));
+ mGenre1 = new QComboBox;
+ mGenre1->setModel(mGenreModel);
+ mGenre2 = new QComboBox;
+ mGenre2->setModel(mGenreModel);
+ mGenre3 = new QComboBox;
+ mGenre3->setModel(mGenreModel);
+ QVBoxLayout *genreL = new QVBoxLayout;
+ genreL->addWidget(mGenre1);
+ genreL->addWidget(mGenre2);
+ genreL->addWidget(mGenre3);
+ genreBox->setLayout(genreL);
+
+ QGroupBox *actorBox = new QGroupBox(tr("Actors"));
+ mActor1 = new QComboBox;
+ mActor1->setModel(mActorModel);
+ mActor2 = new QComboBox;
+ mActor2->setModel(mActorModel);
+ mActor3 = new QComboBox;
+ mActor3->setModel(mActorModel);
+ QVBoxLayout *actorL = new QVBoxLayout;
+ actorL->addWidget(mActor1);
+ actorL->addWidget(mActor2);
+ actorL->addWidget(mActor3);
+ actorBox->setLayout(actorL);
+
+ QGroupBox *actionBox = new QGroupBox(tr("Energize!"));
+ mRefresh = new QPushButton(QIcon(":/refresh.png"), tr("Refresh"));
+ connect(mRefresh, SIGNAL(clicked()), this, SLOT(refreshComboboxes()));
+ mClear = new QPushButton(QIcon(":/delete.png"), tr("Clear"));
+ connect(mClear, SIGNAL(clicked()), this, SLOT(clearAll()));
+ mSelect = new QPushButton(QIcon(":/huge_bra.png"), tr("Go!"));
+ connect(mSelect, SIGNAL(clicked()), this, SLOT(select()));
+ QGridLayout *actionL = new QGridLayout;
+ actionL->addWidget(mClear, 0, 0);
+ actionL->addWidget(mRefresh, 0, 1);
+ actionL->addWidget(mSelect, 1, 0, 2, 0);
+ actionBox->setLayout(actionL);
+
+ QWidget *leftWidget = new QWidget;
+ QVBoxLayout *lwL = new QVBoxLayout;
+ lwL->addWidget(numBox);
+ lwL->addWidget(genreBox);
+ lwL->addWidget(actorBox);
+ lwL->addWidget(actionBox);
+ lwL->addStretch();
+ leftWidget->setLayout(lwL);
+
+ mFileView = new QTreeView;
+ mFileModel = new QStandardItemModel;
+ mFileProxy = new QSortFilterProxyModel;
+ mFileProxy->setSourceModel(mFileModel);
+ mFileView->setModel(mFileProxy);
+
+ QWidget *rightWidget = new QWidget;
+ QVBoxLayout *rwL = new QVBoxLayout;
+ rwL->addWidget(mFileView);
+ rightWidget->setLayout(rwL);
+
+ QSplitter *leftRightSplitter = new QSplitter(Qt::Horizontal);
+ leftRightSplitter->addWidget(leftWidget);
+ leftRightSplitter->addWidget(rightWidget);
+ leftRightSplitter->setStretchFactor(1, 4);
+
+ QHBoxLayout *mainLayout = new QHBoxLayout;
+ mainLayout->addWidget(leftRightSplitter);
+ setLayout(mainLayout);
+}
+
+void RandomTab::setupModels(){
+ // Genres
+ mGenreModel->clear();
+ QStandardItem *genreRoot = mGenreModel->invisibleRootItem();
+ QStandardItem *noneG = new QStandardItem;
+ noneG->setText(tr("<none>"));
+ noneG->setData(-1, IdRole);
+ genreRoot->appendRow(noneG);
+ QSqlQuery genQ("SELECT tgenrename, igenres_id FROM genres ORDER BY tgenrename ASC", mDb);
+ while(genQ.next()){
+ QStandardItem *i = new QStandardItem;
+ i->setText(genQ.value(0).toString());
+ i->setData(genQ.value(1), IdRole);
+ genreRoot->appendRow(i);
+ }
+
+ // Actors
+ mActorModel->clear();
+ QStandardItem *actorRoot = mActorModel->invisibleRootItem();
+ QStandardItem *noneA = new QStandardItem;
+ noneA->setText(tr("<none>"));
+ noneA->setData(-1, IdRole);
+ actorRoot->appendRow(noneA);
+ QSqlQuery actQ("SELECT tactorname, iactors_id FROM actors ORDER BY tactorname ASC", mDb);
+ while(actQ.next()){
+ QStandardItem *i = new QStandardItem;
+ i->setText(actQ.value(0).toString());
+ i->setData(actQ.value(1), IdRole);
+ actorRoot->appendRow(i);
+ }
+}
+
+void RandomTab::clearAll(){
+ mGenre1->setCurrentIndex(0);
+ mGenre2->setCurrentIndex(0);
+ mGenre3->setCurrentIndex(0);
+ mActor1->setCurrentIndex(0);
+ mActor2->setCurrentIndex(0);
+ mActor3->setCurrentIndex(0);
+}
+
+void RandomTab::refreshComboboxes(){
+ setupModels();
+ clearAll();
+}
+
+void RandomTab::select(){
+
+}
diff --git a/randomtab.h b/randomtab.h
new file mode 100644
index 0000000..f8d2218
--- /dev/null
+++ b/randomtab.h
@@ -0,0 +1,53 @@
+/*
+ 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 RANDOMTAB_H
+#define RANDOMTAB_H
+
+#include <QWidget>
+#include <QSqlDatabase>
+
+class QComboBox;
+class QPushButton;
+class QTreeView;
+class QSortFilterProxyModel;
+class QStandardItemModel;
+class QLineEdit;
+
+class RandomTab : public QWidget {
+ Q_OBJECT
+ public:
+ enum CustomRoles { IdRole = Qt::UserRole + 1 };
+ explicit RandomTab(QWidget *parent = 0);
+
+ public slots:
+ void setupModels();
+ void clearAll();
+ void refreshComboboxes();
+ void select();
+
+ private:
+ void setupGui();
+ QComboBox *mGenre1;
+ QComboBox *mGenre2;
+ QComboBox *mGenre3;
+ QComboBox *mActor1;
+ QComboBox *mActor2;
+ QComboBox *mActor3;
+ QLineEdit *mNumber;
+ QPushButton *mSelect;
+ QPushButton *mClear;
+ QPushButton *mRefresh;
+ QTreeView *mFileView;
+ QStandardItemModel *mFileModel;
+ QStandardItemModel *mGenreModel;
+ QStandardItemModel *mActorModel;
+ QSortFilterProxyModel *mFileProxy;
+ QSqlDatabase mDb;
+};
+
+#endif // RANDOMTAB_H
diff --git a/shemov.cpp b/shemov.cpp
index 38bbf7a..27c3345 100644
--- a/shemov.cpp
+++ b/shemov.cpp
@@ -38,6 +38,7 @@
#include "archivecontroller.h"
#include "archivebrowser.h"
#include "searchdialog.h"
+#include "randomtab.h"
SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags), mOpenWithGroupFS(0), mOpenWithGroupAV(0) {
//application icon
@@ -89,6 +90,12 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla
connect(mArchiveBrowser, SIGNAL(itemCountChanged(int)), this, SLOT(updateSelectedCount(int)));
connect(mArchiveBrowser, SIGNAL(needFSFreeUpdate()), this, SLOT(setFsFree()));
+ //randomtab
+ splash.showMessage(tr("Creating Random Browser..."), Qt::AlignHCenter, Qt::yellow);
+ qApp->processEvents();
+ mRandomTab = new RandomTab;
+ mTab->addTab(mRandomTab, tr("Random"));
+
//newmoviewizard + dbanalyzer + newpicsdialog + searchdialog
splash.showMessage(tr("Creating misc. Dialogs..."), Qt::AlignHCenter, Qt::yellow);
qApp->processEvents();
diff --git a/shemov.h b/shemov.h
index 3406446..fed0ce9 100644
--- a/shemov.h
+++ b/shemov.h
@@ -23,6 +23,7 @@ class NewPicsDialog;
class ArchiveView;
class ArchiveBrowser;
class SearchDialog;
+class RandomTab;
class SheMov : public QMainWindow {
Q_OBJECT
@@ -214,5 +215,6 @@ class SheMov : public QMainWindow {
PicturesWidget *mPicWidget;
ArchiveView *mArchive;
ArchiveBrowser *mArchiveBrowser;
+ RandomTab *mRandomTab;
};
#endif
diff --git a/shemov.pro b/shemov.pro
index b03aff6..435df21 100644
--- a/shemov.pro
+++ b/shemov.pro
@@ -46,7 +46,8 @@ SOURCES = main.cpp \
archivebrowsermodel.cpp \
unpacker.cpp \
searchdialog.cpp \
- copyworker.cpp
+ copyworker.cpp \
+ randomtab.cpp
HEADERS = \
filesystemdirproxy.h \
filesystemwidget.h \
@@ -87,7 +88,8 @@ HEADERS = \
archivebrowsermodel.h \
unpacker.h \
searchdialog.h \
- copyworker.h
+ copyworker.h \
+ randomtab.h
LIBS += -lmagic -lXfixes -lX11 -lMagick++-6.Q16HDRI
INCLUDEPATH += /usr/include/ImageMagick-6/
RESOURCES = shemov.qrc