From 0b807eba97e65bf9e25f83387826ef2579b79c90 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 26 Jun 2010 15:24:00 +0200 Subject: Actors and genre edit Implemented widgets for actor and genre editing of movies. Created new MappingTableWidget for both genres and actors and revamped ArchiveTreeView to show 2 widgets below the FilesTreeView separated by a splitter. While testing the new setup several bugs were fixed: -an SQL syntax error in FilesTreeModel -fixed SmModelSingleton to properly work with table names I also changed the signature of MappingTableModel::addMapping for the ease of use and added MappingTableModel::removeMapping. MappingTableModel got 2 new convenience functions: 1. bool contains(QString) to check if an item is already present 2. QModelIndex find() to get the index of a specific value from the model. --- mappingtablewidget.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 mappingtablewidget.h (limited to 'mappingtablewidget.h') diff --git a/mappingtablewidget.h b/mappingtablewidget.h new file mode 100644 index 0000000..d6df991 --- /dev/null +++ b/mappingtablewidget.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 MAPPINGTABLEWIDGET_H +#define MAPPINGTABLEWIDGET_H + +#include +#include + +class QTreeView; +class QLineEdit; +class QPushButton; +class MappingTableItemModel; +class MappingTableModel; + +class MappingTableWidget : public QWidget{ + Q_OBJECT + public: + explicit MappingTableWidget(const QString &table, QWidget *parent = 0); + + public slots: + void setStringList(const QStringList &list); + void setEditEnabled(bool enabled); + void setCurrentId(int id) { mCurrentId = id; } + + private slots: + void addItem(); + void removeItem(); + + private: + QTreeView *mView; + QPushButton *mAddItem; + QPushButton *mRemoveItem; + QLineEdit *mItemEdit; + MappingTableItemModel *mModel; + MappingTableModel *mMappingModel; + const QString mTable; + int mCurrentId; +}; + +class MappingTableItemModel : public QStringListModel { + Q_OBJECT + public: + explicit MappingTableItemModel(QObject *parent = 0); + + //data + flags + virtual QVariant data(const QModelIndex &index, int role) const; + virtual Qt::ItemFlags flags(const QModelIndex &index) const; + + //find + int lowerBound(const QString &value) const; + QModelIndex find(const QString &value) const; +}; + +#endif // MAPPINGTABLEWIDGET_H -- cgit v1.2.3-70-g09d2