Fixed a locale bug in stats view, improved edit window.
authorVisa Putkinen <visa.putkinen@iki.fi>
Tue, 1 Mar 2011 23:39:50 +0000 (01:39 +0200)
committerVisa Putkinen <visa.putkinen@iki.fi>
Tue, 1 Mar 2011 23:39:50 +0000 (01:39 +0200)
weightgraph/.gitignore
weightgraph/debian/changelog
weightgraph/debian/rules
weightgraph/editwindow.cpp
weightgraph/editwindow.h
weightgraph/weightdata.cpp
weightgraph/weightdata.h
weightgraph/weightstatsview.cpp

index 75c107b..37686f0 100644 (file)
@@ -1 +1,2 @@
 *.pro.user
+go.sh
index af52f7c..5a72287 100644 (file)
@@ -1,3 +1,10 @@
+weightgraph (1.0.1) unstable; urgency=low
+
+  * Few bugfixes.
+  * Improved edit window a bit.
+
+ -- Visa Putkinen <visa.putkinen@iki.fi>  Wed, 02 Mar 2011 01:30:53 +0200
+
 weightgraph (1.0.0) unstable; urgency=low
 
   * Initial Release.
index d466bcd..f7a38f9 100755 (executable)
@@ -17,7 +17,7 @@ build: build-stamp
 build-stamp: builddir/Makefile
        dh_testdir
        # compile commands go here
-       cd builddir && $(MAKE) -j4
+       cd builddir && $(MAKE) -j6
        touch $@
 
 clean:
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;
+  }
+}
index 6a162c2..68b16b1 100644 (file)
@@ -22,9 +22,11 @@ public slots:
   void addWeight();
   void removeSelected();
   void editSelected();
+  void show();
 private:
   WeightView weightView;
   QPushButton addButton, removeButton, editButton;
+  bool shown;
 };
 
 class AddWeightDialog : public QDialog
index 36b286c..23c18e3 100644 (file)
@@ -158,6 +158,10 @@ int WeightDataModel::rowOfDate(const QDate &date) const
       return i;
   return -1;
 }
+QModelIndex WeightDataModel::indexOfDate(const QDate &date) const
+{
+  return index(rowOfDate(date), 0);
+}
 
 bool WeightDataModel::dateExists(const QDate &date) const
 {
index 41ded86..170ec75 100644 (file)
@@ -37,6 +37,7 @@ public:
   bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
   bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
   int rowOfDate(const QDate &date) const;
+  QModelIndex indexOfDate(const QDate &date) const;
   bool dateExists(const QDate &date) const;
   int rowForNewDate(const QDate &date) const;
   void clear();
index 65e4f0f..0ab0362 100644 (file)
@@ -28,6 +28,8 @@ WeightStatsView::WeightStatsView(WeightDataModel *wdm, QWidget *parent) :
   updateStats();
 }
 
+static const char* wdays[] = {"Monday", "Tuesday", "Wednesday", "Thursday",
+                              "Friday", "Saturday", "Sunday"};
 QString dateString(QDate date)
 {
   int days = date.daysTo(QDate::currentDate());
@@ -38,7 +40,9 @@ QString dateString(QDate date)
   else if (days == 1)
     return "Yesterday";
   else if (days < 7)
-    return date.toString("dddd");
+    // return date.toString("dddd"); (Use this with l10n!)
+    // The following is used because the system locale might not be English
+    return wdays[date.dayOfWeek()-1];
   else
     return date.toString(Qt::ISODate);
 }