summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--qt-models/cleanertablemodel.cpp33
-rw-r--r--qt-models/cleanertablemodel.h27
-rw-r--r--qt-models/models.cpp32
-rw-r--r--qt-models/models.h16
5 files changed, 63 insertions, 46 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6b036164e..d6a1260e5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -247,6 +247,7 @@ endif()
# the data models that will interface
# with the views.
set(SUBSURFACE_MODELS_LIB_SRCS
+ qt-models/cleanertablemodel.cpp
qt-models/models.cpp
qt-models/filtermodels.cpp
qt-models/completionmodels.cpp
diff --git a/qt-models/cleanertablemodel.cpp b/qt-models/cleanertablemodel.cpp
new file mode 100644
index 000000000..d2405d42f
--- /dev/null
+++ b/qt-models/cleanertablemodel.cpp
@@ -0,0 +1,33 @@
+#include "cleanertablemodel.h"
+#include "metrics.h"
+
+CleanerTableModel::CleanerTableModel(QObject *parent) : QAbstractTableModel(parent)
+{
+}
+
+int CleanerTableModel::columnCount(const QModelIndex &parent) const
+{
+ return headers.count();
+}
+
+QVariant CleanerTableModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ QVariant ret;
+
+ if (orientation == Qt::Vertical)
+ return ret;
+
+ switch (role) {
+ case Qt::FontRole:
+ ret = defaultModelFont();
+ break;
+ case Qt::DisplayRole:
+ ret = headers.at(section);
+ }
+ return ret;
+}
+
+void CleanerTableModel::setHeaderDataStrings(const QStringList &newHeaders)
+{
+ headers = newHeaders;
+}
diff --git a/qt-models/cleanertablemodel.h b/qt-models/cleanertablemodel.h
new file mode 100644
index 000000000..a717d7032
--- /dev/null
+++ b/qt-models/cleanertablemodel.h
@@ -0,0 +1,27 @@
+#ifndef CLEANERTABLEMODEL_H
+#define CLEANERTABLEMODEL_H
+
+#include <QAbstractTableModel>
+#include <QStringList>
+
+/* When using a QAbstractTableModel, consider using this instead
+ * of the default implementation, as it's easyer to setup the columns
+ * and headers.
+ * Most subsurface classes uses this one to save loads of lines
+ * of code and share a consistent layout. */
+
+class CleanerTableModel : public QAbstractTableModel {
+ Q_OBJECT
+public:
+ explicit CleanerTableModel(QObject *parent = 0);
+ 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;
+};
+
+#endif
diff --git a/qt-models/models.cpp b/qt-models/models.cpp
index 69a276bfb..637a2d3b1 100644
--- a/qt-models/models.cpp
+++ b/qt-models/models.cpp
@@ -15,6 +15,7 @@
#include "gettextfromc.h"
#include "display.h"
#include "color.h"
+#include "cleanertablemodel.h"
#include <QCoreApplication>
#include <QDebug>
@@ -27,37 +28,6 @@
#include <QMessageBox>
#include <QStringListModel>
-CleanerTableModel::CleanerTableModel(QObject *parent) : QAbstractTableModel(parent)
-{
-}
-
-int CleanerTableModel::columnCount(const QModelIndex &parent) const
-{
- return headers.count();
-}
-
-QVariant CleanerTableModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- QVariant ret;
-
- if (orientation == Qt::Vertical)
- return ret;
-
- switch (role) {
- case Qt::FontRole:
- ret = defaultModelFont();
- break;
- case Qt::DisplayRole:
- ret = headers.at(section);
- }
- return ret;
-}
-
-void CleanerTableModel::setHeaderDataStrings(const QStringList &newHeaders)
-{
- headers = newHeaders;
-}
-
static QPixmap *trashIconPixmap;
// initialize the trash icon if necessary
diff --git a/qt-models/models.h b/qt-models/models.h
index 0123ce171..60b83cd95 100644
--- a/qt-models/models.h
+++ b/qt-models/models.h
@@ -18,21 +18,7 @@
#include "../dive.h"
#include "../divelist.h"
#include "../divecomputer.h"
-
-// Encapsulates Boilerplate.
-class CleanerTableModel : public QAbstractTableModel {
- Q_OBJECT
-public:
- explicit CleanerTableModel(QObject *parent = 0);
- 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;
-};
+#include "cleanertablemodel.h"
/* Encapsulates the tank_info global variable
* to show on Qt's Model View System.*/