Updated changelog
[grr] / src / entrieswindow.cpp
index 7106aab..40e10cf 100644 (file)
@@ -63,8 +63,30 @@ void EntriesWindow::entriesUpdated() {
 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 {
@@ -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();
@@ -154,6 +176,12 @@ void EntryListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt
                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();
 }