+void BufferView::changeHighlight(BufferView::Direction direction)
+{
+ // If for some weird reason we get a new delegate
+ BufferViewDelegate *delegate = qobject_cast<BufferViewDelegate*>(itemDelegate(_currentHighlight));
+ if (delegate) {
+ delegate->currentHighlight = QModelIndex();
+ }
+
+ QModelIndex newIndex = _currentHighlight;
+ if (!newIndex.isValid()) {
+ newIndex = model()->index(0, 0);
+ }
+
+ if (direction == Backward) {
+ newIndex = indexBelow(newIndex);
+ } else {
+ newIndex = indexAbove(newIndex);
+ }
+
+ if (!newIndex.isValid()) {
+ return;
+ }
+
+ _currentHighlight = newIndex;
+
+ delegate = qobject_cast<BufferViewDelegate*>(itemDelegate(_currentHighlight));
+ if (delegate) {
+ delegate->currentHighlight = _currentHighlight;
+ }
+ viewport()->update();
+}
+
+void BufferView::selectHighlighted()
+{
+ if (_currentHighlight.isValid()) {
+ selectionModel()->setCurrentIndex(_currentHighlight, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+ selectionModel()->select(_currentHighlight, QItemSelectionModel::ClearAndSelect);
+ } else {
+ selectFirstBuffer();
+ }
+
+ clearHighlight();
+}
+
+void BufferView::clearHighlight()
+{
+ // If for some weird reason we get a new delegate
+ BufferViewDelegate *delegate = qobject_cast<BufferViewDelegate*>(itemDelegate(_currentHighlight));
+ if (delegate) {
+ delegate->currentHighlight = QModelIndex();
+ }
+ _currentHighlight = QModelIndex();
+ viewport()->update();
+}
+