<div dir="ltr"><div>Removed Obsolete Code <3<br></div>Music to my ears.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 9, 2015 at 4:42 PM, Lubomir I. Ivanov <span dir="ltr"><<a href="mailto:neolit123@gmail.com" target="_blank">neolit123@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: "Lubomir I. Ivanov" <<a href="mailto:neolit123@gmail.com">neolit123@gmail.com</a>><br>
<br>
The profileprintmodel.cpp/.h and the<br>
tableprintmode.cpp/.h pairs are obsolete.<br>
<br>
The print layouting is now handled via the Grantlee library<br>
and HTML.<br>
<br>
Signed-off-by: Lubomir I. Ivanov <<a href="mailto:neolit123@gmail.com">neolit123@gmail.com</a>><br>
---<br>
 qt-models/CMakeLists.txt        |   4 +-<br>
 qt-models/profileprintmodel.cpp | 157 ----------------------------------------<br>
 qt-models/profileprintmodel.h   |  26 -------<br>
 qt-models/tableprintmodel.cpp   | 127 --------------------------------<br>
 qt-models/tableprintmodel.h     |  45 ------------<br>
 5 files changed, 1 insertion(+), 358 deletions(-)<br>
 delete mode 100644 qt-models/profileprintmodel.cpp<br>
 delete mode 100644 qt-models/profileprintmodel.h<br>
 delete mode 100644 qt-models/tableprintmodel.cpp<br>
 delete mode 100644 qt-models/tableprintmodel.h<br>
<br>
diff --git a/qt-models/CMakeLists.txt b/qt-models/CMakeLists.txt<br>
index c9bcf5c..c35ca43 100644<br>
--- a/qt-models/CMakeLists.txt<br>
+++ b/qt-models/CMakeLists.txt<br>
@@ -11,12 +11,10 @@ set(SUBSURFACE_MODELS_LIB_SRCS<br>
        weightmodel.cpp<br>
        divecomputermodel.cpp<br>
        treemodel.cpp<br>
-       tableprintmodel.cpp<br>
        yearlystatisticsmodel.cpp<br>
        divetripmodel.cpp<br>
        divecomputerextradatamodel.cpp<br>
        completionmodels.cpp<br>
-       profileprintmodel.cpp<br>
        divepicturemodel.cpp<br>
        diveplotdatamodel.cpp<br>
        divelocationmodel.cpp<br>
@@ -26,4 +24,4 @@ set(SUBSURFACE_MODELS_LIB_SRCS<br>
<br>
 source_group("Subsurface Models" FILES ${SUBSURFACE_MODELS})<br>
 add_library(subsurface_models STATIC ${SUBSURFACE_MODELS_LIB_SRCS})<br>
-target_link_libraries(subsurface_models ${QT_LIBRARIES})<br>
\ No newline at end of file<br>
+target_link_libraries(subsurface_models ${QT_LIBRARIES})<br>
diff --git a/qt-models/profileprintmodel.cpp b/qt-models/profileprintmodel.cpp<br>
deleted file mode 100644<br>
index 1d01f6a..0000000<br>
--- a/qt-models/profileprintmodel.cpp<br>
+++ /dev/null<br>
@@ -1,157 +0,0 @@<br>
-#include "profileprintmodel.h"<br>
-#include "metrics.h"<br>
-#include "dive.h"<br>
-#include "divetripmodel.h"<br>
-#include "helpers.h"<br>
-<br>
-ProfilePrintModel::ProfilePrintModel(QObject *parent)<br>
-{<br>
-       fontSize = 12.0;<br>
-}<br>
-<br>
-void ProfilePrintModel::setDive(struct dive *divePtr)<br>
-{<br>
-       diveId = divePtr->id;<br>
-       // reset();<br>
-}<br>
-<br>
-void ProfilePrintModel::setFontsize(double size)<br>
-{<br>
-       fontSize = size;<br>
-}<br>
-<br>
-int ProfilePrintModel::rowCount(const QModelIndex &parent) const<br>
-{<br>
-       return 12;<br>
-}<br>
-<br>
-int ProfilePrintModel::columnCount(const QModelIndex &parent) const<br>
-{<br>
-       return 5;<br>
-}<br>
-<br>
-QVariant ProfilePrintModel::data(const QModelIndex &index, int role) const<br>
-{<br>
-       const int row = index.row();<br>
-       const int col = index.column();<br>
-<br>
-       switch (role) {<br>
-       case Qt::DisplayRole: {<br>
-               struct dive *dive = get_dive_by_uniq_id(diveId);<br>
-               struct DiveItem di;<br>
-               di.diveId = diveId;<br>
-<br>
-               const QString unknown = tr("unknown");<br>
-<br>
-               // dive# + date, depth, location, duration<br>
-               if (row == 0) {<br>
-                       if (col == 0)<br>
-                               return tr("Dive #%1 - %2").arg(dive->number).arg(di.displayDate());<br>
-                       if (col == 3) {<br>
-                               QString unit = (get_units()->length == units::METERS) ? "m" : "ft";<br>
-                               return tr("Max depth: %1 %2").arg(di.displayDepth()).arg(unit);<br>
-                       }<br>
-               }<br>
-               if (row == 1) {<br>
-                       if (col == 0)<br>
-                               return QString(get_dive_location(dive));<br>
-                       if (col == 3)<br>
-                               return QString(tr("Duration: %1 min")).arg(di.displayDuration());<br>
-               }<br>
-               // headings<br>
-               if (row == 2) {<br>
-                       if (col == 0)<br>
-                               return tr("Gas used:");<br>
-                       if (col == 2)<br>
-                               return tr("Tags:");<br>
-                       if (col == 3)<br>
-                               return tr("SAC:");<br>
-                       if (col == 4)<br>
-                               return tr("Weights:");<br>
-               }<br>
-               // notes<br>
-               if (col == 0) {<br>
-                       if (row == 6)<br>
-                               return tr("Notes:");<br>
-                       if (row == 7)<br>
-                               return QString(dive->notes);<br>
-               }<br>
-               // more headings<br>
-               if (row == 4) {<br>
-                       if (col == 0)<br>
-                               return tr("Divemaster:");<br>
-                       if (col == 1)<br>
-                               return tr("Buddy:");<br>
-                       if (col == 2)<br>
-                               return tr("Suit:");<br>
-                       if (col == 3)<br>
-                               return tr("Viz:");<br>
-                       if (col == 4)<br>
-                               return tr("Rating:");<br>
-               }<br>
-               // values for gas, sac, etc...<br>
-               if (row == 3) {<br>
-                       if (col == 0) {<br>
-                               int added = 0;<br>
-                               QString gas, gases;<br>
-                               for (int i = 0; i < MAX_CYLINDERS; i++) {<br>
-                                       if (!is_cylinder_used(dive, i))<br>
-                                               continue;<br>
-                                       gas = dive->cylinder[i].type.description;<br>
-                                       gas += QString(!gas.isEmpty() ? " " : "") + gasname(&dive->cylinder[i].gasmix);<br>
-                                       // if has a description and if such gas is not already present<br>
-                                       if (!gas.isEmpty() && gases.indexOf(gas) == -1) {<br>
-                                               if (added > 0)<br>
-                                                       gases += QString(" / ");<br>
-                                               gases += gas;<br>
-                                               added++;<br>
-                                       }<br>
-                               }<br>
-                               return gases;<br>
-                       }<br>
-                       if (col == 2) {<br>
-                               char buffer[256];<br>
-                               taglist_get_tagstring(dive->tag_list, buffer, 256);<br>
-                               return QString(buffer);<br>
-                       }<br>
-                       if (col == 3)<br>
-                               return di.displaySac();<br>
-                       if (col == 4) {<br>
-                               weight_t tw = { total_weight(dive) };<br>
-                               return get_weight_string(tw, true);<br>
-                       }<br>
-               }<br>
-               // values for DM, buddy, suit, etc...<br>
-               if (row == 5) {<br>
-                       if (col == 0)<br>
-                               return QString(dive->divemaster);<br>
-                       if (col == 1)<br>
-                               return QString(dive->buddy);<br>
-                       if (col == 2)<br>
-                               return QString(dive->suit);<br>
-                       if (col == 3)<br>
-                               return (dive->visibility) ? QString::number(dive->visibility).append(" / 5") : QString();<br>
-                       if (col == 4)<br>
-                               return (dive->rating) ? QString::number(dive->rating).append(" / 5") : QString();<br>
-               }<br>
-               return QString();<br>
-       }<br>
-       case Qt::FontRole: {<br>
-               QFont font;<br>
-               font.setPointSizeF(fontSize);<br>
-               if (row == 0 && col == 0) {<br>
-                       font.setBold(true);<br>
-               }<br>
-               return QVariant::fromValue(font);<br>
-       }<br>
-       case Qt::TextAlignmentRole: {<br>
-               // everything is aligned to the left<br>
-               unsigned int align = Qt::AlignLeft;<br>
-               // align depth and duration right<br>
-               if (row < 2 && col == 4)<br>
-                       align = Qt::AlignRight | Qt::AlignVCenter;<br>
-               return QVariant::fromValue(align);<br>
-       }<br>
-       } // switch (role)<br>
-       return QVariant();<br>
-}<br>
diff --git a/qt-models/profileprintmodel.h b/qt-models/profileprintmodel.h<br>
deleted file mode 100644<br>
index b15f2df..0000000<br>
--- a/qt-models/profileprintmodel.h<br>
+++ /dev/null<br>
@@ -1,26 +0,0 @@<br>
-#ifndef PROFILEPRINTMODEL_H<br>
-#define PROFILEPRINTMODEL_H<br>
-<br>
-#include <QAbstractTableModel><br>
-<br>
-/* ProfilePrintModel:<br>
- * this model is used when printing a data table under a profile. it requires<br>
- * some exact usage of setSpan(..) on the target QTableView widget.<br>
- */<br>
-class ProfilePrintModel : public QAbstractTableModel {<br>
-       Q_OBJECT<br>
-<br>
-private:<br>
-       int diveId;<br>
-       double fontSize;<br>
-<br>
-public:<br>
-       ProfilePrintModel(QObject *parent = 0);<br>
-       int rowCount(const QModelIndex &parent = QModelIndex()) const;<br>
-       int columnCount(const QModelIndex &parent = QModelIndex()) const;<br>
-       QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;<br>
-       void setDive(struct dive *divePtr);<br>
-       void setFontsize(double size);<br>
-};<br>
-<br>
-#endif<br>
\ No newline at end of file<br>
diff --git a/qt-models/tableprintmodel.cpp b/qt-models/tableprintmodel.cpp<br>
deleted file mode 100644<br>
index c3ed3c1..0000000<br>
--- a/qt-models/tableprintmodel.cpp<br>
+++ /dev/null<br>
@@ -1,127 +0,0 @@<br>
-#include "tableprintmodel.h"<br>
-#include "metrics.h"<br>
-#include "color.h"<br>
-<br>
-TablePrintModel::TablePrintModel()<br>
-{<br>
-       columns = 7;<br>
-       rows = 0;<br>
-}<br>
-<br>
-TablePrintModel::~TablePrintModel()<br>
-{<br>
-       for (int i = 0; i < list.size(); i++)<br>
-               delete <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(i);<br>
-}<br>
-<br>
-void TablePrintModel::insertRow(int index)<br>
-{<br>
-       struct TablePrintItem *item = new struct TablePrintItem();<br>
-       item->colorBackground = 0xffffffff;<br>
-       if (index == -1) {<br>
-               beginInsertRows(QModelIndex(), rows, rows);<br>
-               list.append(item);<br>
-       } else {<br>
-               beginInsertRows(QModelIndex(), index, index);<br>
-               list.insert(index, item);<br>
-       }<br>
-       endInsertRows();<br>
-       rows++;<br>
-}<br>
-<br>
-void TablePrintModel::callReset()<br>
-{<br>
-       beginResetModel();<br>
-       endResetModel();<br>
-}<br>
-<br>
-QVariant TablePrintModel::data(const QModelIndex &index, int role) const<br>
-{<br>
-       if (!index.isValid())<br>
-               return QVariant();<br>
-       if (role == Qt::BackgroundRole)<br>
-               return QColor(<a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->colorBackground);<br>
-       if (role == Qt::DisplayRole)<br>
-               switch (index.column()) {<br>
-               case 0:<br>
-                       return <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->number;<br>
-               case 1:<br>
-                       return <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->date;<br>
-               case 2:<br>
-                       return <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->depth;<br>
-               case 3:<br>
-                       return <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->duration;<br>
-               case 4:<br>
-                       return <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->divemaster;<br>
-               case 5:<br>
-                       return <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->buddy;<br>
-               case 6:<br>
-                       return <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->location;<br>
-               }<br>
-       if (role == Qt::FontRole) {<br>
-               QFont font;<br>
-               font.setPointSizeF(7.5);<br>
-               if (index.row() == 0 && index.column() == 0) {<br>
-                       font.setBold(true);<br>
-               }<br>
-               return QVariant::fromValue(font);<br>
-       }<br>
-       return QVariant();<br>
-}<br>
-<br>
-bool TablePrintModel::setData(const QModelIndex &index, const QVariant &value, int role)<br>
-{<br>
-       if (index.isValid()) {<br>
-               if (role == Qt::DisplayRole) {<br>
-                       switch (index.column()) {<br>
-                       case 0:<br>
-                               <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->number = value.toString();<br>
-                       case 1:<br>
-                               <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->date = value.toString();<br>
-                       case 2:<br>
-                               <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->depth = value.toString();<br>
-                       case 3:<br>
-                               <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->duration = value.toString();<br>
-                       case 4:<br>
-                               <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->divemaster = value.toString();<br>
-                       case 5:<br>
-                               <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->buddy = value.toString();<br>
-                       case 6: {<br>
-                               /* truncate if there are more than N lines of text,<br>
-                                * we don't want a row to be larger that a single page! */<br>
-                               QString s = value.toString();<br>
-                               const int maxLines = 15;<br>
-                               int count = 0;<br>
-                               for (int i = 0; i < s.length(); i++) {<br>
-                                       if (<a href="http://s.at" rel="noreferrer" target="_blank">s.at</a>(i) != QChar('\n'))<br>
-                                               continue;<br>
-                                       count++;<br>
-                                       if (count > maxLines) {<br>
-                                               s = s.left(i - 1);<br>
-                                               break;<br>
-                                       }<br>
-                               }<br>
-                               <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->location = s;<br>
-                       }<br>
-                       }<br>
-                       return true;<br>
-               }<br>
-               if (role == Qt::BackgroundRole) {<br>
-                       <a href="http://list.at" rel="noreferrer" target="_blank">list.at</a>(index.row())->colorBackground = value.value<unsigned int>();<br>
-                       return true;<br>
-               }<br>
-       }<br>
-       return false;<br>
-}<br>
-<br>
-int TablePrintModel::rowCount(const QModelIndex &parent) const<br>
-{<br>
-       Q_UNUSED(parent);<br>
-       return rows;<br>
-}<br>
-<br>
-int TablePrintModel::columnCount(const QModelIndex &parent) const<br>
-{<br>
-       Q_UNUSED(parent);<br>
-       return columns;<br>
-}<br>
diff --git a/qt-models/tableprintmodel.h b/qt-models/tableprintmodel.h<br>
deleted file mode 100644<br>
index 9263d10..0000000<br>
--- a/qt-models/tableprintmodel.h<br>
+++ /dev/null<br>
@@ -1,45 +0,0 @@<br>
-#ifndef TABLEPRINTMODEL_H<br>
-#define TABLEPRINTMODEL_H<br>
-<br>
-#include <QAbstractTableModel><br>
-<br>
-/* TablePrintModel:<br>
- * for now we use a blank table model with row items TablePrintItem.<br>
- * these are pretty much the same as DiveItem, but have color<br>
- * properties, as well. perhaps later one a more unified model has to be<br>
- * considered, but the current TablePrintModel idea has to be extended<br>
- * to support variadic column lists and column list orders that can<br>
- * be controlled by the user.<br>
- */<br>
-struct TablePrintItem {<br>
-       QString number;<br>
-       QString date;<br>
-       QString depth;<br>
-       QString duration;<br>
-       QString divemaster;<br>
-       QString buddy;<br>
-       QString location;<br>
-       unsigned int colorBackground;<br>
-};<br>
-<br>
-class TablePrintModel : public QAbstractTableModel {<br>
-       Q_OBJECT<br>
-<br>
-private:<br>
-       QList<TablePrintItem *> list;<br>
-<br>
-public:<br>
-       ~TablePrintModel();<br>
-       TablePrintModel();<br>
-<br>
-       int rows, columns;<br>
-       void insertRow(int index = -1);<br>
-       void callReset();<br>
-<br>
-       QVariant data(const QModelIndex &index, int role) const;<br>
-       bool setData(const QModelIndex &index, const QVariant &value, int role);<br>
-       int rowCount(const QModelIndex &parent) const;<br>
-       int columnCount(const QModelIndex &parent) const;<br>
-};<br>
-<br>
-#endif<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.11.msysgit.0<br>
<br>
_______________________________________________<br>
subsurface mailing list<br>
<a href="mailto:subsurface@subsurface-divelog.org">subsurface@subsurface-divelog.org</a><br>
<a href="http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface" rel="noreferrer" target="_blank">http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface</a><br>
</font></span></blockquote></div><br></div>