summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2010-07-18 12:12:05 +0200
committerArno <am@disconnect.de>2010-07-18 12:12:05 +0200
commit3befd105e04fb5d724c13863b25f720e239bc14c (patch)
treed318c048aa983f681e13e23dcc2a2da95b95c4a5
parent88791c89ac1066a9c0118120e10ec3cc19c2ec72 (diff)
downloadSheMov-3befd105e04fb5d724c13863b25f720e239bc14c.tar.gz
SheMov-3befd105e04fb5d724c13863b25f720e239bc14c.tar.bz2
SheMov-3befd105e04fb5d724c13863b25f720e239bc14c.zip
Implemented setDvdNo for FilesTree
The dvd number can be set for several files at once with this function. Also fixed a little bug when showing the series name in the status bar. Only show file part number if it is > 0.
-rw-r--r--filestreemodel.h2
-rw-r--r--filestreewidget.cpp65
-rw-r--r--filestreewidget.h17
-rw-r--r--shemov.cpp6
-rw-r--r--shemov.h1
5 files changed, 89 insertions, 2 deletions
diff --git a/filestreemodel.h b/filestreemodel.h
index 73c46e0..8da3d6f 100644
--- a/filestreemodel.h
+++ b/filestreemodel.h
@@ -19,7 +19,7 @@ class QSqlQuery;
class FilesTreeModel : public SmTreeModel {
Q_OBJECT
public:
- enum CustomRoles { FileNameRole = Qt::UserRole + 1, FullPathRole = Qt::UserRole + 2, SizeRole = Qt::UserRole + 3, DvdNoRole = Qt::UserRole + 4, SizeDisplayRole = Qt::UserRole + 5, FileTypeRole = Qt::UserRole + 6, Md5SumRole = Qt::UserRole + 7, PartNoRole = Qt::UserRole + 8, SeriesPartIdRole = Qt::UserRole + 9, QualityRole = Qt::UserRole + 10, FilesIdRole = Qt::UserRole + 11, SeriesPartRole = Qt::UserRole + 12, DisplayNameRole = Qt::UserRole + 13 };
+ enum CustomRoles { FileNameRole = Qt::UserRole + 1, FullPathRole = Qt::UserRole + 2, SizeRole = Qt::UserRole + 3, DvdNoRole = Qt::UserRole + 4, SizeDisplayRole = Qt::UserRole + 5, FileTypeRole = Qt::UserRole + 6, Md5SumRole = Qt::UserRole + 7, PartNoRole = Qt::UserRole + 8, SeriesPartIdRole = Qt::UserRole + 9, QualityRole = Qt::UserRole + 10, FilesIdRole = Qt::UserRole + 11, SeriesPartRole = Qt::UserRole + 12, DisplayNameRole = Qt::UserRole + 13 };
enum FileTypes { Movie = 1, FrontCover = 2, BackCover = 3, GeneralCover = 4 };
enum Fields { FileName = 0, PartNo = 1, SizeDisplay = 2, Quality = 3, DvdNo = 4, FullPath = 5, Size = 6, FileType = 7, Md5Sum = 8, SeriesPartId = 9, FilesId = 10, SeriesPart = 11, DisplayName = 12 };
enum Mode { Normal = 0, Archived = 1, Local = 2 };
diff --git a/filestreewidget.cpp b/filestreewidget.cpp
index d3d5ad4..b25804f 100644
--- a/filestreewidget.cpp
+++ b/filestreewidget.cpp
@@ -6,12 +6,16 @@
*/
#include <QHBoxLayout>
+#include <QVBoxLayout>
#include <QSettings>
#include <QMessageBox>
#include <QFile>
#include <QDir>
#include <QContextMenuEvent>
#include <QMenu>
+#include <QLabel>
+#include <QSpinBox>
+#include <QPushButton>
#include <QDebug>
@@ -83,6 +87,29 @@ void FilesTreeWidget::moveToBurn(){
}
}
+void FilesTreeWidget::setDvdNo(){
+ DvdNoDialog dlg(this);
+ int retval = dlg.exec();
+ if(retval == QDialog::Accepted){
+ QModelIndexList selected = mView->selectionModel()->selectedRows();
+ if(selected.isEmpty()){
+ return;
+ }
+ int dvdNo = dlg.dvdNo();
+ foreach(QModelIndex i, selected){
+ int type = i.data(FilesTreeModel::FileTypeRole).toInt();
+ if(type != FilesTreeModel::Movie){
+ continue;
+ }
+ QModelIndex real = mProxy->mapToSource(i);
+ if(real.isValid()){
+ QModelIndex dvdColumn = mModel->index(real.row(), FilesTreeModel::DvdNo, real.parent());
+ mModel->setData(dvdColumn, dvdNo, Qt::EditRole);
+ }
+ }
+ }
+}
+
void FilesTreeWidget::fileSelectionChanged(const QModelIndex &current, const QModelIndex &previous){
Q_UNUSED(previous);
int seriesPartId = current.data(FilesTreeModel::SeriesPartIdRole).toInt();
@@ -93,7 +120,7 @@ void FilesTreeWidget::fileSelectionChanged(const QModelIndex &current, const QMo
QModelIndex seriesPartIdx = mSeriesModel->findValue(seriesPartId, seriesIdx, SeriesTreeModel::SeriesPartId);
QString seriesNumber = QString::number(seriesPartIdx.data(SeriesTreeModel::SeriesPartRole).toInt());
QString msg;
- if(filePart != 0){
+ if(filePart > 0){
msg = QString(tr("%1 %2 (%3)")).arg(seriesIdx.data(SeriesTreeModel::NameRole).toString()).arg(seriesNumber).arg(filePart);
}else{
msg = QString(tr("%1 %2")).arg(seriesIdx.data(SeriesTreeModel::NameRole).toString()).arg(seriesNumber);
@@ -142,3 +169,39 @@ bool FilesTreeSortModel::lessThan(const QModelIndex &left, const QModelIndex &ri
}
return QSortFilterProxyModel::lessThan(left, right);
}
+
+DvdNoDialog::DvdNoDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){
+ //spin box
+ QHBoxLayout *spinBoxLayout = new QHBoxLayout;
+ QLabel *l1 = new QLabel(tr("Select &Dvd no."));
+ mDvdNo = new QSpinBox;
+ l1->setBuddy(mDvdNo);
+ spinBoxLayout->addWidget(l1);
+ spinBoxLayout->addWidget(mDvdNo);
+ mDvdNo->setMinimum(-1);
+ SeriesTreeModel *seriesModel = static_cast<SeriesTreeModel*>(SmModelSingleton::instance()->model("SeriesModel"));
+ int nextDvdNo = seriesModel->findNextDvdNo();
+ mDvdNo->setValue(nextDvdNo);
+
+ //buttons
+ QHBoxLayout *buttonLayout = new QHBoxLayout;
+ mOk = new QPushButton(tr("Ok"));
+ connect(mOk, SIGNAL(clicked()), this, SLOT(accept()));
+ buttonLayout->addStretch();
+ buttonLayout->addWidget(mOk);
+ mCancel = new QPushButton(tr("Cancel"));
+ connect(mCancel, SIGNAL(clicked()), this, SLOT(reject()));
+ buttonLayout->addWidget(mCancel);
+
+ //main layout
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addLayout(spinBoxLayout);
+ mainLayout->addLayout(buttonLayout);
+ setLayout(mainLayout);
+
+ setWindowTitle(tr("Select Dvd no."));
+}
+
+int DvdNoDialog::dvdNo() const {
+ return mDvdNo->value();
+}
diff --git a/filestreewidget.h b/filestreewidget.h
index 06f1d3c..b6ce951 100644
--- a/filestreewidget.h
+++ b/filestreewidget.h
@@ -11,12 +11,15 @@
#include <QWidget>
#include <QTreeView>
#include <QSortFilterProxyModel>
+#include <QDialog>
class FilesTreeView;
class FilesTreeModel;
class FilesTreeSortModel;
class SeriesTreeModel;
class QContextMenuEvent;
+class QSpinBox;
+class QPushButton;
class FilesTreeWidget : public QWidget {
Q_OBJECT
@@ -27,6 +30,7 @@ class FilesTreeWidget : public QWidget {
public slots:
void moveToBurn();
+ void setDvdNo();
private slots:
void fileSelectionChanged(const QModelIndex &current, const QModelIndex &previous);
@@ -64,4 +68,17 @@ class FilesTreeSortModel : public QSortFilterProxyModel {
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
};
+class DvdNoDialog : public QDialog {
+ Q_OBJECT
+ public:
+ DvdNoDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
+ ~DvdNoDialog() {}
+ int dvdNo() const;
+
+ private:
+ QSpinBox *mDvdNo;
+ QPushButton *mOk;
+ QPushButton *mCancel;
+};
+
#endif
diff --git a/shemov.cpp b/shemov.cpp
index 46567c2..1ac1db3 100644
--- a/shemov.cpp
+++ b/shemov.cpp
@@ -418,6 +418,8 @@ void SheMov::createActions(){
//Tree FileWidget actions
mMoveToBurnA = new QAction(tr("Move to burn directory"), this);
connect(mMoveToBurnA, SIGNAL(triggered()), mATree->filesWidget(), SLOT(moveToBurn()));
+ mSetDvdNoA = new QAction(tr("Set dvd number"), this);
+ connect(mSetDvdNoA, SIGNAL(triggered()), mATree->filesWidget(), SLOT(setDvdNo()));
// misc
mOpenWithMapperFS = new QSignalMapper(this);
@@ -564,6 +566,10 @@ void SheMov::createMenus(){
//ArchiveTreeView fileWidget context menu
mATree->filesWidget()->filesTree()->addAction(mMoveToBurnA);
+ QAction *sep10 = new QAction(this);
+ sep10->setSeparator(true);
+ mATree->filesWidget()->filesTree()->addAction(sep10);
+ mATree->filesWidget()->filesTree()->addAction(mSetDvdNoA);
}
void SheMov::createOpenWithMenuFS(){
diff --git a/shemov.h b/shemov.h
index dfd6786..47f5b6e 100644
--- a/shemov.h
+++ b/shemov.h
@@ -116,6 +116,7 @@ class SheMov : public QMainWindow {
//TreeView FileWidget Actions
QAction *mMoveToBurnA;
+ QAction *mSetDvdNoA;
QActionGroup *mOpenWithGroupFS;
QActionGroup *mOpenWithGroupAV;