summaryrefslogtreecommitdiffstats
path: root/qt-ui/models.h
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-10-11 10:50:40 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-10-11 10:50:40 -0300
commit26c87fafc2cd2c0329b780699ba90f21a5592031 (patch)
treeb356464f9f278cc1b3460d81ba3c02ca07ca37fd /qt-ui/models.h
parent1b9a4f2bf8e9de9144133a435f3470fd77975945 (diff)
downloadsubsurface-26c87fafc2cd2c0329b780699ba90f21a5592031.tar.gz
Begin to Cleanup the Models, trying to reduce boilerplate.
The Model View system in Qt is *very* verbose, this is the beginning of a series of patches that will concentrate the boilerplate somewhere and reduce the amount of lines and will also try to make the code cleaner and easyer to understand, Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/models.h')
-rw-r--r--qt-ui/models.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/qt-ui/models.h b/qt-ui/models.h
index 75c3e08ac..24f829add 100644
--- a/qt-ui/models.h
+++ b/qt-ui/models.h
@@ -17,6 +17,19 @@
QFont defaultModelFont();
+// Encapsulates Boilerplate.
+class CleanerTableModel : public QAbstractTableModel{
+ Q_OBJECT
+public:
+ CleanerTableModel();
+ virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
+ virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+protected:
+ void setHeaderDataStrings(const QStringList& headers);
+private:
+ QStringList headers;
+};
+
/* Encapsulates the tank_info global variable
* to show on Qt's Model View System.*/
class TankInfoModel : public QAbstractTableModel {
@@ -67,14 +80,12 @@ private:
/* Encapsulation of the Cylinder Model, that presents the
* Current cylinders that are used on a dive. */
-class CylindersModel : public QAbstractTableModel {
+class CylindersModel : public CleanerTableModel {
Q_OBJECT
public:
- enum Column {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, COLUMNS};
+ enum Column {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE};
explicit CylindersModel(QObject* parent = 0);
- /*reimp*/ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
- /*reimp*/ int columnCount(const QModelIndex& parent = QModelIndex()) const;
/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const;
/*reimp*/ Qt::ItemFlags flags(const QModelIndex& index) const;