diff options
author | Arno <am@disconnect.de> | 2011-02-19 13:59:19 +0100 |
---|---|---|
committer | Arno <am@disconnect.de> | 2011-02-19 13:59:19 +0100 |
commit | 23289ad65a1b06d3c3e9bbd4706ce75ce40c4b52 (patch) | |
tree | 6a3599e525a29141f9d658b94e7e32a012896ca5 /mappingtableeditor.h | |
parent | a2e6438b97a8b9055bee400ccc40a062f0a0e9db (diff) | |
download | SheMov-23289ad65a1b06d3c3e9bbd4706ce75ce40c4b52.tar.gz SheMov-23289ad65a1b06d3c3e9bbd4706ce75ce40c4b52.tar.bz2 SheMov-23289ad65a1b06d3c3e9bbd4706ce75ce40c4b52.zip |
Edit genres and actors
Added dialog for editing actors and genres.
Diffstat (limited to 'mappingtableeditor.h')
-rw-r--r-- | mappingtableeditor.h | 77 |
1 files changed, 77 insertions, 0 deletions
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 <QDialog> +#include <QTreeView> +#include <QSqlDatabase> + +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 |