summaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-08-28 07:48:46 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-08-28 07:48:46 -0300
commitbb592028120ac1ccc41b663f2dd706cf65378776 (patch)
tree430efceb408a9b650d522896ea8a2aa64020cdde /qt-ui/diveplanner.cpp
parentcfd17116ebe24ab547a9d375c6c47a260d6d8294 (diff)
downloadsubsurface-bb592028120ac1ccc41b663f2dd706cf65378776.tar.gz
Made the TableViews share a bit of code, code cleanup.
Made the tableviews share a bit of code, and code cleanup. The tableviews for Cylinders, Weigth and Dive Planner Points now shares the CSS and I also implemented the save / load methods for the dive planner points, so the functionality is mostly done on the vieualization side. - since we are now using three tables maybe it's a better idea to create one class SubSurfaceTable that knows how to handle saving / loading of the columns... TODO for the future. ;) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index b6ddf518f..7b7f1af69 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -1,8 +1,10 @@
#include "diveplanner.h"
#include "graphicsview-common.h"
+#include "models.h"
#include "../dive.h"
#include "../divelist.h"
+
#include <cmath>
#include <QMouseEvent>
#include <QDebug>
@@ -16,7 +18,7 @@
#include <QListView>
#include <QDesktopWidget>
#include <QModelIndex>
-
+#include <QSettings>
#include "ui_diveplanner.h"
#include "mainwindow.h"
@@ -833,8 +835,46 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge
connect(ui->lowGF, SIGNAL(textChanged(QString)), this, SLOT(gflowChanged(QString)));
connect(ui->highGF, SIGNAL(textChanged(QString)), this, SLOT(gfhighChanged(QString)));
connect(ui->lastStop, SIGNAL(toggled(bool)), this, SLOT(lastStopChanged(bool)));
+
+ QFile cssFile(":table-css");
+ cssFile.open(QIODevice::ReadOnly);
+ QTextStream reader(&cssFile);
+ QString css = reader.readAll();
+
+ ui->tablePoints->setStyleSheet(css);
+ QFontMetrics metrics(defaultModelFont());
+
+ ui->tablePoints->horizontalHeader()->setResizeMode(DivePlannerPointsModel::REMOVE, QHeaderView::Fixed);
+ ui->tablePoints->verticalHeader()->setDefaultSectionSize( metrics.height() +8 );
+ initialUiSetup();
+}
+
+void DivePlannerWidget::hideEvent(QHideEvent* event)
+{
+ QSettings s;
+ s.beginGroup("DivePlanner");
+ s.beginGroup("PointTables");
+ for (int i = 0; i < CylindersModel::COLUMNS; i++) {
+ s.setValue(QString("colwidth%1").arg(i), ui->tablePoints->columnWidth(i));
+ }
+ s.endGroup();
+ s.sync();
}
+void DivePlannerWidget::initialUiSetup()
+{
+ QSettings s;
+ s.beginGroup("DivePlanner");
+ s.beginGroup("PointTables");
+ for (int i = 0; i < CylindersModel::COLUMNS; i++) {
+ QVariant width = s.value(QString("colwidth%1").arg(i));
+ if (width.isValid())
+ ui->tablePoints->setColumnWidth(i, width.toInt());
+ else
+ ui->tablePoints->resizeColumnToContents(i);
+ }
+ s.endGroup();
+}
void DivePlannerWidget::startTimeChanged(const QTime& time)
{
plannerModel->setStartTime(time);