summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-26 17:52:05 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-26 21:30:54 -0700
commit778d6ea103b0e7f9d60bc125a66e5fc95cc2805e (patch)
tree81c82028cf201194f0d333e752b8c7e2fbb52c7e /qt-ui
parent75650bd65f928cfc5de1453491fc03d6f7717d24 (diff)
downloadsubsurface-778d6ea103b0e7f9d60bc125a66e5fc95cc2805e.tar.gz
TableWidgets: change default column width and don't save unchanged widths
Similar change to the dive list. The idea is to not save things that are the default. This way Subsurface will do the right thing when defaults change. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/tableview.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/qt-ui/tableview.cpp b/qt-ui/tableview.cpp
index cbbea264e..a56ab47f2 100644
--- a/qt-ui/tableview.cpp
+++ b/qt-ui/tableview.cpp
@@ -29,8 +29,22 @@ TableView::~TableView()
{
QSettings s;
s.beginGroup(objectName());
- for (int i = 0; i < ui.tableView->model()->columnCount(); i++) {
- s.setValue(QString("colwidth%1").arg(i), ui.tableView->columnWidth(i));
+ // remove the old default
+ bool oldDefault = (ui.tableView->columnWidth(0) == 30);
+ for (int i = 1; oldDefault && i < ui.tableView->model()->columnCount(); i++) {
+ if (ui.tableView->columnWidth(i) != 80)
+ oldDefault = false;
+ }
+ if (oldDefault) {
+ s.remove("");
+ } else {
+ for (int i = 0; i < ui.tableView->model()->columnCount(); i++) {
+ if ((i == CylindersModel::REMOVE && ui.tableView->columnWidth(i) == 30) ||
+ ui.tableView->columnWidth(i) == 70)
+ s.remove(QString("colwidth%1").arg(i));
+ else
+ s.setValue(QString("colwidth%1").arg(i), ui.tableView->columnWidth(i));
+ }
}
s.endGroup();
}
@@ -54,7 +68,7 @@ void TableView::setModel(QAbstractItemModel *model)
s.beginGroup(objectName());
const int columnCount = ui.tableView->model()->columnCount();
for (int i = 0; i < columnCount; i++) {
- QVariant width = s.value(QString("colwidth%1").arg(i), i == CylindersModel::REMOVE ? 30 : 80);
+ QVariant width = s.value(QString("colwidth%1").arg(i), i == CylindersModel::REMOVE ? 30 : 70);
ui.tableView->setColumnWidth(i, width.toInt());
}
s.endGroup();