void PlaylistView::setModel(QAbstractItemModel *m) {
  if (model()) {
    disconnect(model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
               this, SLOT(InvalidateCachedCurrentPixmap()));
    disconnect(model(), SIGNAL(layoutAboutToBeChanged()),
               this, SLOT(RatingHoverOut()));
  }

  QTreeView::setModel(m);

  connect(model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
          this, SLOT(InvalidateCachedCurrentPixmap()));
  connect(model(), SIGNAL(layoutAboutToBeChanged()),
          this, SLOT(RatingHoverOut()));
}
Example #2
0
void PlaylistView::setModel(QAbstractItemModel* m) {
  if (model()) {
    disconnect(model(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
               SLOT(InvalidateCachedCurrentPixmap()));
    disconnect(model(), SIGNAL(layoutAboutToBeChanged()), this,
               SLOT(RatingHoverOut()));
    // When changing the model, always invalidate the current pixmap.
    // If a remote client uses "stop after", without invaliding the stop
    // mark would not appear.
    InvalidateCachedCurrentPixmap();
  }

  QTreeView::setModel(m);

  connect(model(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
          SLOT(InvalidateCachedCurrentPixmap()));
  connect(model(), SIGNAL(layoutAboutToBeChanged()), this,
          SLOT(RatingHoverOut()));
}
Example #3
0
void PlaylistView::scrollContentsBy(int dx, int dy) {
  if (dx) {
    InvalidateCachedCurrentPixmap();
  }
  cached_tree_ = QPixmap();

  QTreeView::scrollContentsBy(dx, dy);

  if (!currently_autoscrolling_) {
    // We only want to do this if the scroll was initiated by the user
    inhibit_autoscroll_ = true;
    inhibit_autoscroll_timer_->start();
  }
}
Example #4
0
void PlaylistView::RatingHoverOut() {
  if (!(editTriggers() & QAbstractItemView::SelectedClicked)) {
    return;
  }

  const QModelIndex old_index = rating_delegate_->mouse_over_index();
  rating_delegate_->set_mouse_out();
  setCursor(QCursor());

  update(old_index);
  for (const QModelIndex& index : selectedIndexes()) {
    if (index.column() == Playlist::Column_Rating) {
      update(index);
    }
  }

  if (old_index.data(Playlist::Role_IsCurrent).toBool()) {
    InvalidateCachedCurrentPixmap();
  }
}
Example #5
0
void PlaylistView::RatingHoverIn(const QModelIndex& index, const QPoint& pos) {
  if (editTriggers() & QAbstractItemView::NoEditTriggers) {
    return;
  }

  const QModelIndex old_index = rating_delegate_->mouse_over_index();
  rating_delegate_->set_mouse_over(index, selectedIndexes(), pos);
  setCursor(Qt::PointingHandCursor);

  update(index);
  update(old_index);
  for (const QModelIndex& index : selectedIndexes()) {
    if (index.column() == Playlist::Column_Rating) {
      update(index);
    }
  }

  if (index.data(Playlist::Role_IsCurrent).toBool() ||
      old_index.data(Playlist::Role_IsCurrent).toBool()) {
    InvalidateCachedCurrentPixmap();
  }
}