From 23289ad65a1b06d3c3e9bbd4706ce75ce40c4b52 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 19 Feb 2011 13:59:19 +0100 Subject: Edit genres and actors Added dialog for editing actors and genres. --- mappingtableeditor.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 mappingtableeditor.h (limited to 'mappingtableeditor.h') diff --git a/mappingtableeditor.h b/mappingtableeditor.h new file mode 100644 index 0000000..124f76e --- /dev/null +++ b/mappingtableeditor.h @@ -0,0 +1,77 @@ +/* + 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 MAPPINGTABLEEDITOR_H +#define MAPPINGTABLEEDITOR_H + +#include +#include +#include + +class QSqlQuery; +class QContextMenuEvent; +class QPushButton; +class QLineEdit; +class QAction; +class MappingTableEditorView; +class MappingTableEditorModel; + +#include "smtreemodel.h" +#include "smtreeitem.h" + +class MappingTableEditor : public QDialog { + Q_OBJECT + public: + explicit MappingTableEditor(const QString &table, QWidget *parent = 0); + + private slots: + void selectionChanged(const QModelIndex &cur, const QModelIndex &prev); + void removeItem(); + void renameItem(); + void editItem(); + + private: + const QString mTable; + QPushButton *mClose; + QPushButton *mDelete; + QPushButton *mRename; + QLineEdit *mDataEdit; + QAction *mDeleteA; + QAction *mEditA; + MappingTableEditorView *mView; + MappingTableEditorModel *mModel; +}; + +class MappingTableEditorView : public QTreeView { + Q_OBJECT + public: + explicit MappingTableEditorView(QWidget *parent = 0); + + protected: + virtual void contextMenuEvent(QContextMenuEvent *e); +}; + +class MappingTableEditorModel : public SmTreeModel { + Q_OBJECT + public: + enum Roles { NameRole = Qt::UserRole + 1, CountRole = Qt::UserRole +2, IdRole = Qt::UserRole + 3 }; + enum Fields { Name = 0, Count = 1, Id = 2 }; + explicit MappingTableEditorModel(const QString &table, const QStringList &headers, QObject *parent = 0); + virtual ~MappingTableEditorModel(); + virtual Qt::ItemFlags flags(const QModelIndex &idx) const; + virtual QVariant data(const QModelIndex &index, int role) const; + virtual bool setData(const QModelIndex &idx, const QVariant &value, int role); + virtual bool removeData(const QModelIndex &idx); + + private: + void populate(); + const QString mTable; + QSqlDatabase mDb; + QSqlQuery *mDataQuery; +}; + +#endif // MAPPINGTABLEEDITOR_H -- cgit v1.2.3-70-g09d2