diff options
-rw-r--r-- | archiveiteminfoedit.cpp | 188 | ||||
-rw-r--r-- | archiveiteminfoedit.h | 59 | ||||
-rw-r--r-- | shemov.pro | 6 |
3 files changed, 251 insertions, 2 deletions
diff --git a/archiveiteminfoedit.cpp b/archiveiteminfoedit.cpp new file mode 100644 index 0000000..9d25fb6 --- /dev/null +++ b/archiveiteminfoedit.cpp @@ -0,0 +1,188 @@ +/* + 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 <QVBoxLayout> +#include <QHBoxLayout> +#include <QLabel> +#include <QTreeView> +#include <QComboBox> +#include <QSpinBox> +#include <QLineEdit> +#include <QSplitter> +#include <QModelIndex> + +#include "archiveiteminfoedit.h" +#include "fileinfomodel.h" +#include "actorwidget.h" +#include "listmodelsingleton.h" +#include "moviemodelsingleton.h" +#include "listeditor.h" + + +ArchiveItemInfoEdit::ArchiveItemInfoEdit(QWidget *parent) : QWidget(parent){ + //Models + mGenreModel = ListModelSingleton::instance()->model("genre"); + mActorModel = ListModelSingleton::instance()->model("actor"); + mMovieModel = MovieModelSingleton::instance(); + + //InfoWidget + QWidget *infoWidget = new QWidget; + QVBoxLayout *infoWidgetLayout = new QVBoxLayout; + + //Movie Information + QLabel *infoCaption = new QLabel(tr("Movie Information")); + infoWidgetLayout->addWidget(infoCaption); + mInfoView = new QTreeView; + mInfoModel = new FileInfoModel; + mInfoView->setModel(mInfoModel); + infoWidgetLayout->addWidget(mInfoView); + + //Actor Information + mActorView = new ActorWidget; + infoWidgetLayout->addWidget(mActorView); + + //Genre Information + QLabel *genreLabel = new QLabel(tr("Select genre")); + mGenre = new QComboBox; + mGenre->setModel(mGenreModel); + QHBoxLayout *genreLayout = new QHBoxLayout; + genreLayout->addWidget(genreLabel); + genreLayout->addWidget(mGenre); + infoWidgetLayout->addLayout(genreLayout); + + //Quality, Series, Part + DVD Infomation + QHBoxLayout *miscInfoLayout = new QHBoxLayout; + + //Quality + QLabel *qualityLabel = new QLabel(tr("Quality")); + mQuality = new QSpinBox; + mQuality->setMinimum(0); + mQuality->setMaximum(10); + miscInfoLayout->addWidget(qualityLabel); + miscInfoLayout->addWidget(mQuality); + + //DVD + QLabel *dvdLabel = new QLabel(tr("DVD no.")); + mDvd = new QSpinBox; + mDvd->setMinimum(-1); + mDvd->setMaximum(10); + miscInfoLayout->addWidget(dvdLabel); + miscInfoLayout->addWidget(mDvd); + miscInfoLayout->addStretch(); + + //Series + QLabel *seriesLabel = new QLabel(tr("Series no.")); + mSeries = new QSpinBox; + mSeries->setMinimum(-1); + mSeries->setMaximum(1000); + miscInfoLayout->addWidget(seriesLabel); + miscInfoLayout->addWidget(mSeries); + + //Part + QLabel *partLabel = new QLabel(tr("Part no.")); + mPart = new QSpinBox; + mPart->setMinimum(-1); + mPart->setMaximum(100); + miscInfoLayout->addWidget(partLabel); + miscInfoLayout->addWidget(mPart); + + //Add to infoWidget + infoWidgetLayout->addLayout(miscInfoLayout); + + //Title + QHBoxLayout *titleLayout = new QHBoxLayout; + QLabel *titleLabel = new QLabel(tr("Movie title")); + mTitle = new QLineEdit; + titleLayout->addWidget(titleLabel); + titleLayout->addWidget(mTitle); + infoWidgetLayout->addLayout(titleLayout); + + //Create widget + infoWidget->setLayout(infoWidgetLayout); + + //ListEditorWidget + QWidget *editorWidget = new QWidget; + QVBoxLayout *editorWidgetLayout = new QVBoxLayout; + + //GenreEditor + ListEditor *genreEditor = new ListEditor(mGenreModel); + editorWidgetLayout->addWidget(genreEditor); + + //ActorEditor + ListEditor *actorEditor = new ListEditor(mActorModel); + editorWidgetLayout->addWidget(actorEditor); + connect(actorEditor, SIGNAL(itemAdded(QString)), this, SLOT(addActor(QString))); + editorWidgetLayout->addStretch(); + + //Create widget + editorWidget->setLayout(editorWidgetLayout); + + //Splitter + QSplitter *splitter = new QSplitter; + splitter->addWidget(infoWidget); + splitter->addWidget(editorWidget); + + //Create this widget + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(splitter); + setLayout(mainLayout); +} + +const QString ArchiveItemInfoEdit::genre() const { + return mGenre->currentText(); +} + +const QString ArchiveItemInfoEdit::title() const { + return mTitle->text(); +} + +int ArchiveItemInfoEdit::quality() const { + return mQuality->value(); +} + +int ArchiveItemInfoEdit::dvd() const { + return mDvd->value(); +} + +int ArchiveItemInfoEdit::series() const { + return mSeries->value(); +} + +int ArchiveItemInfoEdit::part() const { + return mPart->value(); +} + +void ArchiveItemInfoEdit::setGenre(const QString &genre){ + QModelIndex idx = mGenreModel->index(genre); + if(idx.isValid()){ + mGenre->setCurrentIndex(idx.row()); + } +} + +void ArchiveItemInfoEdit::setTitle(const QString &title){ + mTitle->setText(title); +} + +void ArchiveItemInfoEdit::setQuality(int quality){ + mQuality->setValue(quality); +} + +void ArchiveItemInfoEdit::setDvd(int dvd){ + mDvd->setValue(dvd); +} + +void ArchiveItemInfoEdit::setSeries(int series){ + mSeries->setValue(series); +} + +void ArchiveItemInfoEdit::setPart(int part){ + mPart->setValue(part); +} + +void ArchiveItemInfoEdit::addActor(const QString &actor){ + mActorView->addActor(actor); +} diff --git a/archiveiteminfoedit.h b/archiveiteminfoedit.h new file mode 100644 index 0000000..d06fa0a --- /dev/null +++ b/archiveiteminfoedit.h @@ -0,0 +1,59 @@ +/* + 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 ARCHIVEITEMINFOEDIT_H +#define ARCHIVEITEMINFOEDIT_H + +#include <QWidget> + +class QTreeView; +class QComboBox; +class QSpinBox; +class QLineEdit; +class FileInfoModel; +class ActorWidget; +class ListModel; +class MovieModel; + +class ArchiveItemInfoEdit : public QWidget { + Q_OBJECT + public: + explicit ArchiveItemInfoEdit(QWidget *parent = 0); + const QString genre() const; + const QString title() const; + int quality() const; + int dvd() const; + int series() const; + int part() const; + + public slots: + void setGenre(const QString &genre); + void setTitle(const QString &title); + void setQuality(int quality); + void setDvd(int dvd); + void setSeries(int series); + void setPart(int part); + + private slots: + void addActor(const QString &actor); + + private: + QTreeView *mInfoView; + QComboBox *mGenre; + QSpinBox *mQuality; + QSpinBox *mDvd; + QSpinBox *mSeries; + QSpinBox *mPart; + QLineEdit *mTitle; + ActorWidget *mActorView; + FileInfoModel *mInfoModel; + ListModel *mGenreModel; + ListModel *mActorModel; + MovieModel *mMovieModel; +}; + +#endif @@ -44,7 +44,8 @@ SOURCES = main.cpp \ listmodelsingleton.cpp \ moviemodelsingleton.cpp \ pictureviewer.cpp \ - pictureviewerinfoitem.cpp + pictureviewerinfoitem.cpp \ + archiveiteminfoedit.cpp HEADERS = listitem.h \ listmodel.h \ movieitem.h \ @@ -84,6 +85,7 @@ HEADERS = listitem.h \ listmodelsingleton.h \ moviemodelsingleton.h \ pictureviewer.h \ - pictureviewerinfoitem.h + pictureviewerinfoitem.h \ + archiveiteminfoedit.h LIBS += -lmagic RESOURCES = shemov.qrc |