void EntriesWindow::entrySelected(const QModelIndex &index) {
Entry *e = qVariantValue<Entry *>(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<QAbstractListModel *>(list->model());
+ if(current_row + 1 < model->rowCount()) {
+ current_row++;
+ content->showEntry(qVariantValue<Entry *>(model->index(current_row).data()));
+ }
+}
+
+void EntriesWindow::showPrevEntry() {
+ QAbstractListModel *model = static_cast<QAbstractListModel *>(list->model());
+ if(current_row > 0) {
+ current_row--;
+ content->showEntry(qVariantValue<Entry *>(model->index(current_row).data()));
+ }
}
int EntryListModel::rowCount(const QModelIndex &) const {
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();
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();
}