]> git.sur5r.net Git - minitube/blob - src/channellistview.cpp
f791f71c7e0ffb217c65155615f6bd7dbf0441c3
[minitube] / src / channellistview.cpp
1 /* $BEGIN_LICENSE
2
3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
5
6 Minitube is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 Minitube is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Minitube.  If not, see <http://www.gnu.org/licenses/>.
18
19 $END_LICENSE */
20
21 #include "channellistview.h"
22 #include "painterutils.h"
23
24 ChannelListView::ChannelListView() {
25
26     setSelectionMode(QAbstractItemView::NoSelection);
27
28     // layout
29     setSpacing(10);
30     setFlow(QListView::LeftToRight);
31     setWrapping(true);
32     setResizeMode(QListView::Adjust);
33     setMovement(QListView::Static);
34     setUniformItemSizes(true);
35
36     // cosmetics
37     setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
38     setFrameShape(QFrame::NoFrame);
39     setAttribute(Qt::WA_MacShowFocusRect, false);
40
41     QPalette p = palette();
42     /*
43     p.setColor(QPalette::Base, p.window().color());
44     p.setColor(QPalette::Text, p.windowText().color());
45     */
46     p.setColor(QPalette::Disabled, QPalette::Base, p.base().color());
47     p.setColor(QPalette::Disabled, QPalette::Text, p.text().color());
48     setPalette(p);
49
50     verticalScrollBar()->setPageStep(3);
51     verticalScrollBar()->setSingleStep(1);
52
53     setMouseTracking(true);
54
55 }
56
57 void ChannelListView::mousePressEvent(QMouseEvent *event) {
58     if (event->button() == Qt::RightButton)
59         emit contextMenu(event->pos());
60     else
61         QListView::mousePressEvent(event);
62 }
63
64 void ChannelListView::mouseMoveEvent(QMouseEvent *event) {
65     QWidget::mouseMoveEvent(event);
66     const QModelIndex index = indexAt(event->pos());
67     if (index.isValid()) setCursor(Qt::PointingHandCursor);
68     else unsetCursor();
69 }
70
71 void ChannelListView::paintEvent(QPaintEvent *event) {
72     if (!errorMessage.isEmpty())
73         PainterUtils::centeredMessage(errorMessage, viewport());
74     else
75         QListView::paintEvent(event);
76 }