Fixed a locale bug in stats view, improved edit window.
[weightgraph] / weightgraph / editwindow.cpp
index 1d54ac0..374982e 100644 (file)
@@ -9,7 +9,7 @@
 extern WeightDataModel *wdm;
 
 EditWindow::EditWindow(QWidget *parent) :
-    QMainWindow(parent)
+    QMainWindow(parent), shown(false)
 {
 #ifdef Q_WS_MAEMO_5
   setAttribute(Qt::WA_Maemo5StackedWindow);
@@ -126,6 +126,7 @@ void EditWindow::addWeight()
       return;
     }
     wdm->setWeightForDate(dw);
+    weightView.scrollTo(wdm->indexOfDate(dw.date), QAbstractItemView::PositionAtCenter);
   }
 }
 
@@ -147,3 +148,15 @@ void EditWindow::editSelected()
   if (indexes.size() == 1)
     weightView.edit(wdm->index(indexes.first().row(), 1));
 }
+
+void EditWindow::show()
+{
+  QMainWindow::show();
+  // scrollToBottom must be here: it will not scroll all the way
+  // to the bottom when called in the constructor because it'll
+  // receive the wrong window geometry while hidden.
+  if (!shown) {
+    weightView.scrollToBottom();
+    shown = true;
+  }
+}