X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fentrieswindow.cpp;h=40e10cfcb497cb3e993f6a0659af84d4b9a43a5d;hb=HEAD;hp=18f575a3d5932b53a82969f0a3e1f4f14c8398f3;hpb=7f1f955b572af3ed84cf079fdd9cee4626db010a;p=grr diff --git a/src/entrieswindow.cpp b/src/entrieswindow.cpp index 18f575a..40e10cf 100644 --- a/src/entrieswindow.cpp +++ b/src/entrieswindow.cpp @@ -63,8 +63,30 @@ void EntriesWindow::entriesUpdated() { void EntriesWindow::entrySelected(const QModelIndex &index) { Entry *e = qVariantValue(index.data()); - ContentWindow *w = new ContentWindow(this, e); - w->show(); + current_row = index.row(); + + content = new ContentWindow(this, e); + + connect(content, SIGNAL(showNextEntry()), SLOT(showNextEntry())); + connect(content, SIGNAL(showPrevEntry()), SLOT(showPrevEntry())); + + content->show(); +} + +void EntriesWindow::showNextEntry() { + QAbstractListModel *model = static_cast(list->model()); + if(current_row + 1 < model->rowCount()) { + current_row++; + content->showEntry(qVariantValue(model->index(current_row).data())); + } +} + +void EntriesWindow::showPrevEntry() { + QAbstractListModel *model = static_cast(list->model()); + if(current_row > 0) { + current_row--; + content->showEntry(qVariantValue(model->index(current_row).data())); + } } int EntryListModel::rowCount(const QModelIndex &) const { @@ -123,7 +145,7 @@ void EntryListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt QRect rect = option.rect; rect.adjust(20, 8, -20, -8); QPoint topleft = rect.topLeft(); - topleft.ry() += 2; + QPoint bottomleft = rect.bottomLeft(); rect.adjust(36, 0, 0, 0); painter->save(); @@ -141,13 +163,25 @@ void EntryListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt painter->drawText(rect, Qt::AlignBottom | Qt::AlignLeft, e->author); - painter->drawText(rect, Qt::AlignBottom | Qt::AlignRight, e->published.toString()); + QString date; + if(e->published.date() == QDateTime::currentDateTime().date()) + date = e->published.time().toString(Qt::DefaultLocaleShortDate); + else + date = e->published.date().toString(); + + painter->drawText(rect, Qt::AlignBottom | Qt::AlignRight, date); if(e->flags & ENTRY_FLAG_STARRED) { QImage img = QImage(QLatin1String(":/images/star-1")); painter->drawImage(topleft, img); } + if(e->flags & ENTRY_FLAG_SHARED) { + QImage img = QImage(QLatin1String(":/images/shared-1")); + bottomleft.ry() -= img.height(); + painter->drawImage(bottomleft, img); + } + painter->restore(); }