From e13ccfc0b642e8d04d77e32354b0083f8ad26897 Mon Sep 17 00:00:00 2001 From: Visa Putkinen Date: Wed, 2 Mar 2011 01:39:50 +0200 Subject: [PATCH] Fixed a locale bug in stats view, improved edit window. --- weightgraph/.gitignore | 1 + weightgraph/debian/changelog | 7 +++++++ weightgraph/debian/rules | 2 +- weightgraph/editwindow.cpp | 15 ++++++++++++++- weightgraph/editwindow.h | 2 ++ weightgraph/weightdata.cpp | 4 ++++ weightgraph/weightdata.h | 1 + weightgraph/weightstatsview.cpp | 6 +++++- 8 files changed, 35 insertions(+), 3 deletions(-) diff --git a/weightgraph/.gitignore b/weightgraph/.gitignore index 75c107b..37686f0 100644 --- a/weightgraph/.gitignore +++ b/weightgraph/.gitignore @@ -1 +1,2 @@ *.pro.user +go.sh diff --git a/weightgraph/debian/changelog b/weightgraph/debian/changelog index af52f7c..5a72287 100644 --- a/weightgraph/debian/changelog +++ b/weightgraph/debian/changelog @@ -1,3 +1,10 @@ +weightgraph (1.0.1) unstable; urgency=low + + * Few bugfixes. + * Improved edit window a bit. + + -- Visa Putkinen Wed, 02 Mar 2011 01:30:53 +0200 + weightgraph (1.0.0) unstable; urgency=low * Initial Release. diff --git a/weightgraph/debian/rules b/weightgraph/debian/rules index d466bcd..f7a38f9 100755 --- a/weightgraph/debian/rules +++ b/weightgraph/debian/rules @@ -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: diff --git a/weightgraph/editwindow.cpp b/weightgraph/editwindow.cpp index 1d54ac0..374982e 100644 --- a/weightgraph/editwindow.cpp +++ b/weightgraph/editwindow.cpp @@ -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; + } +} diff --git a/weightgraph/editwindow.h b/weightgraph/editwindow.h index 6a162c2..68b16b1 100644 --- a/weightgraph/editwindow.h +++ b/weightgraph/editwindow.h @@ -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 diff --git a/weightgraph/weightdata.cpp b/weightgraph/weightdata.cpp index 36b286c..23c18e3 100644 --- a/weightgraph/weightdata.cpp +++ b/weightgraph/weightdata.cpp @@ -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 { diff --git a/weightgraph/weightdata.h b/weightgraph/weightdata.h index 41ded86..170ec75 100644 --- a/weightgraph/weightdata.h +++ b/weightgraph/weightdata.h @@ -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(); diff --git a/weightgraph/weightstatsview.cpp b/weightgraph/weightstatsview.cpp index 65e4f0f..0ab0362 100644 --- a/weightgraph/weightstatsview.cpp +++ b/weightgraph/weightstatsview.cpp @@ -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); } -- 1.7.9.5