int bookmarkPos = (int)((qreal)height * (qreal)b.pos);
painter.drawPixmap(2, bookmarkPos - scrollPos.y(), bookmarkPixmap);
}
- QPen pen(Qt::gray);
- pen.setStyle(Qt::DotLine);
- pen.setWidth(3);
- painter.setPen(pen);
- if (contentIndex > 0) {
- painter.drawLine(0, -scrollPos.y(), width(), -scrollPos.y());
- }
- if (contentIndex < (mBook->parts.size() - 1)) {
- int h = contentsHeight - scrollPos.y() - 1;
- painter.drawLine(0, h, width(), h);
+ if (mBook) {
+ QPen pen(Qt::gray);
+ pen.setStyle(Qt::DotLine);
+ pen.setWidth(3);
+ painter.setPen(pen);
+ if (contentIndex > 0) {
+ painter.drawLine(0, -scrollPos.y(), width(), -scrollPos.y());
+ }
+ if (contentIndex < (mBook->parts.size() - 1)) {
+ int h = contentsHeight - scrollPos.y() - 1;
+ painter.drawLine(0, h, width(), h);
+ }
}
}
connect(list, SIGNAL(activated(const QModelIndex &)),
this, SLOT(onItemActivated(const QModelIndex &)));
+ connect(list, SIGNAL(itemSelectionChanged()),
+ this, SLOT(onItemSelectionChanged()));
+ connect(list, SIGNAL(itemSelectionChanged()),
+ this, SIGNAL(itemSelectionChanged()));
}
void ListWindow::populateList()
}
int row = index.row() - buttons.count();
- qDebug() << "Activated" << index.row() << ", emit activated(" << row << ")";
+ qDebug() << "Activated" << index.row() << ", emit activated(" << row
+ << ")";
emit activated(mModel->index(row, 0));
}
}
#endif // Q_WS_MAEMO_5
+
+void ListWindow::onItemSelectionChanged()
+{
+ TRACE;
+ bool enabled = currentItem().isValid();
+ foreach (QAction *action, itemActions) {
+ action->setEnabled(enabled);
+ }
+}
/** Emitted when a list item is activated. */
void activated(const QModelIndex &index);
+ /** Emitted when selection has changed. */
+ void itemSelectionChanged();
+
public slots:
/** Set the current (selected) item. */
void setCurrentItem(const QModelIndex &item);
protected slots:
void onItemActivated(const QModelIndex &);
void populateList();
+ void onItemSelectionChanged();
protected:
struct Button {