PlaylistView::PlaylistView(QWidget *parent)
  : QTreeView(parent),
    style_(new PlaylistProxyStyle(style())),
    playlist_(NULL),
    header_(new PlaylistHeader(Qt::Horizontal, this)),
    setting_initial_header_layout_(false),
    upgrading_from_qheaderview_(false),
    read_only_settings_(true),
    glow_enabled_(true),
    currently_glowing_(false),
    glow_intensity_step_(0),
    rating_delegate_(NULL),
    inhibit_autoscroll_timer_(new QTimer(this)),
    inhibit_autoscroll_(false),
    currently_autoscrolling_(false),
    row_height_(-1),
    currenttrack_play_(":currenttrack_play.png"),
    currenttrack_pause_(":currenttrack_pause.png"),
    cached_current_row_row_(-1),
    drop_indicator_row_(-1),
    drag_over_(false),
    dynamic_controls_(new DynamicPlaylistControls(this))
{
  setHeader(header_);
  header_->setMovable(true);
  setStyle(style_);
  setMouseTracking(true);

  connect(header_, SIGNAL(sectionResized(int,int,int)), SLOT(SaveGeometry()));
  connect(header_, SIGNAL(sectionMoved(int,int,int)), SLOT(SaveGeometry()));
  connect(header_, SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), SLOT(SaveGeometry()));
  connect(header_, SIGNAL(SectionVisibilityChanged(int,bool)), SLOT(SaveGeometry()));
  connect(header_, SIGNAL(sectionResized(int,int,int)), SLOT(InvalidateCachedCurrentPixmap()));
  connect(header_, SIGNAL(sectionMoved(int,int,int)), SLOT(InvalidateCachedCurrentPixmap()));
  connect(header_, SIGNAL(SectionVisibilityChanged(int,bool)), SLOT(InvalidateCachedCurrentPixmap()));
  connect(header_, SIGNAL(StretchEnabledChanged(bool)), SLOT(SaveSettings()));
  connect(header_, SIGNAL(ColumnAlignmentChanged()), SLOT(SaveSettings()));
  connect(header_, SIGNAL(StretchEnabledChanged(bool)), SLOT(StretchChanged(bool)));
  connect(header_, SIGNAL(MouseEntered()), SLOT(RatingHoverOut()));

  inhibit_autoscroll_timer_->setInterval(kAutoscrollGraceTimeout * 1000);
  inhibit_autoscroll_timer_->setSingleShot(true);
  connect(inhibit_autoscroll_timer_, SIGNAL(timeout()), SLOT(InhibitAutoscrollTimeout()));

  horizontalScrollBar()->installEventFilter(this);
  verticalScrollBar()->installEventFilter(this);

  setAlternatingRowColors(true);

  setAttribute(Qt::WA_MacShowFocusRect, false);

  dynamic_controls_->hide();

#ifdef Q_OS_DARWIN
  setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
#endif
}
Beispiel #2
0
PlaylistView::PlaylistView(QWidget* parent)
    : QTreeView(parent),
      app_(nullptr),
      style_(new PlaylistProxyStyle(style())),
      playlist_(nullptr),
      header_(new PlaylistHeader(Qt::Horizontal, this, this)),
      setting_initial_header_layout_(false),
      upgrading_from_qheaderview_(false),
      read_only_settings_(true),
      upgrading_from_version_(-1),
      background_image_type_(Default),
      previous_background_image_opacity_(0.0),
      fade_animation_(new QTimeLine(1000, this)),
      last_height_(-1),
      last_width_(-1),
      force_background_redraw_(false),
      glow_enabled_(true),
      currently_glowing_(false),
      glow_intensity_step_(0),
      rating_delegate_(nullptr),
      inhibit_autoscroll_timer_(new QTimer(this)),
      inhibit_autoscroll_(false),
      currently_autoscrolling_(false),
      row_height_(-1),
      currenttrack_play_(":currenttrack_play.png"),
      currenttrack_pause_(":currenttrack_pause.png"),
      cached_current_row_row_(-1),
      drop_indicator_row_(-1),
      drag_over_(false),
      dynamic_controls_(new DynamicPlaylistControls(this)) {
  setHeader(header_);
  header_->setMovable(true);
  setStyle(style_);
  setMouseTracking(true);

  connect(header_, SIGNAL(sectionResized(int, int, int)), SLOT(SaveGeometry()));
  connect(header_, SIGNAL(sectionMoved(int, int, int)), SLOT(SaveGeometry()));
  connect(header_, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)),
          SLOT(SaveGeometry()));
  connect(header_, SIGNAL(SectionVisibilityChanged(int, bool)),
          SLOT(SaveGeometry()));
  connect(header_, SIGNAL(sectionResized(int, int, int)),
          SLOT(InvalidateCachedCurrentPixmap()));
  connect(header_, SIGNAL(sectionMoved(int, int, int)),
          SLOT(InvalidateCachedCurrentPixmap()));
  connect(header_, SIGNAL(SectionVisibilityChanged(int, bool)),
          SLOT(InvalidateCachedCurrentPixmap()));
  connect(header_, SIGNAL(StretchEnabledChanged(bool)), SLOT(SaveSettings()));
  connect(header_, SIGNAL(StretchEnabledChanged(bool)),
          SLOT(StretchChanged(bool)));
  connect(header_, SIGNAL(MouseEntered()), SLOT(RatingHoverOut()));

  inhibit_autoscroll_timer_->setInterval(kAutoscrollGraceTimeout * 1000);
  inhibit_autoscroll_timer_->setSingleShot(true);
  connect(inhibit_autoscroll_timer_, SIGNAL(timeout()),
          SLOT(InhibitAutoscrollTimeout()));

  horizontalScrollBar()->installEventFilter(this);
  verticalScrollBar()->installEventFilter(this);

  setAlternatingRowColors(true);

  setAttribute(Qt::WA_MacShowFocusRect, false);

  dynamic_controls_->hide();

#ifdef Q_OS_DARWIN
  setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
#endif
  // For fading
  connect(fade_animation_, SIGNAL(valueChanged(qreal)),
          SLOT(FadePreviousBackgroundImage(qreal)));
  fade_animation_->setDirection(QTimeLine::Backward);  // 1.0 -> 0.0
}
void PlaylistHeader::enterEvent(QEvent*) {
  emit MouseEntered();
}