Uberpimped the playlist into be fast and nice.
This commit is contained in:
parent
09494985d1
commit
e665b5d7ad
2 changed files with 28 additions and 12 deletions
|
@ -5,6 +5,7 @@
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
PlaylistScrollButton::PlaylistScrollButton (PlaylistScroller *parent, uint normal, uint pressed) : Button (parent, normal, pressed, true)
|
PlaylistScrollButton::PlaylistScrollButton (PlaylistScroller *parent, uint normal, uint pressed) : Button (parent, normal, pressed, true)
|
||||||
{
|
{
|
||||||
|
@ -14,6 +15,8 @@ PlaylistScrollButton::PlaylistScrollButton (PlaylistScroller *parent, uint norma
|
||||||
void
|
void
|
||||||
PlaylistScrollButton::mouseMoveEvent (QMouseEvent *event)
|
PlaylistScrollButton::mouseMoveEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
PlaylistWindow *pw = dynamic_cast<PlaylistWindow *>(window ());
|
||||||
|
|
||||||
QPoint p (event->pos ());
|
QPoint p (event->pos ());
|
||||||
|
|
||||||
int npos = pos().y()+p.y()-m_diffy;
|
int npos = pos().y()+p.y()-m_diffy;
|
||||||
|
@ -110,7 +113,12 @@ PlaylistWindow::doScroll (int pos)
|
||||||
{
|
{
|
||||||
int npos = ((float)pos) / (float)(m_scroller->getMax()) * float(m_list->height() - m_view->height());
|
int npos = ((float)pos) / (float)(m_scroller->getMax()) * float(m_list->height() - m_view->height());
|
||||||
m_list->setOffset (npos);
|
m_list->setOffset (npos);
|
||||||
|
if (npos == 0) {
|
||||||
|
m_list->update ();
|
||||||
|
} else {
|
||||||
m_list->scroll (0, npos);
|
m_list->scroll (0, npos);
|
||||||
|
}
|
||||||
|
QApplication::sendPostedEvents (m_list, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -12,9 +12,6 @@ PlaylistItem::PlaylistItem (PlaylistList *pl, uint id)
|
||||||
m_isactive = false;
|
m_isactive = false;
|
||||||
m_isselected = false;
|
m_isselected = false;
|
||||||
m_req = false;
|
m_req = false;
|
||||||
if (getSelected ()) {
|
|
||||||
qDebug ("trasigt!");
|
|
||||||
}
|
|
||||||
pl->addItem (this);
|
pl->addItem (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +41,9 @@ PlaylistList::PlaylistList (QWidget *parent) : QWidget (parent)
|
||||||
XMMSHandler *xmmsh = XMMSHandler::getInstance ();
|
XMMSHandler *xmmsh = XMMSHandler::getInstance ();
|
||||||
Skin *skin = Skin::getInstance ();
|
Skin *skin = Skin::getInstance ();
|
||||||
|
|
||||||
|
setAttribute (Qt::WA_NoBackground);
|
||||||
|
setFocusPolicy (Qt::StrongFocus);
|
||||||
|
|
||||||
connect (skin, SIGNAL (skinChanged (Skin *)),
|
connect (skin, SIGNAL (skinChanged (Skin *)),
|
||||||
this, SLOT (setPixmaps(Skin *)));
|
this, SLOT (setPixmaps(Skin *)));
|
||||||
|
|
||||||
|
@ -250,17 +250,22 @@ PlaylistList::paintEvent (QPaintEvent *event)
|
||||||
int ch = event->rect().height();
|
int ch = event->rect().height();
|
||||||
int sitem = cy / getFontH();
|
int sitem = cy / getFontH();
|
||||||
int eitem = (cy + ch) / getFontH();
|
int eitem = (cy + ch) / getFontH();
|
||||||
|
int mod = m_offset - (getFontH() * sitem);
|
||||||
|
|
||||||
if (eitem > m_items->count())
|
if (eitem > m_items->count())
|
||||||
eitem = m_items->count();
|
eitem = m_items->count();
|
||||||
|
|
||||||
for (i = sitem; i < eitem; i++) {
|
|
||||||
QRect r (3, getFontH()*(i-sitem), size().width(), getFontH());
|
|
||||||
if (event->region().contains (r)) {
|
|
||||||
PlaylistItem *item = m_items->value (i);
|
|
||||||
QString q;
|
QString q;
|
||||||
q.sprintf ("%d. ", i+1);
|
QRect r;
|
||||||
q += item->text ();
|
|
||||||
|
for (i = sitem; i < eitem; i++) {
|
||||||
|
r.setRect(0, (getFontH()*(i-sitem)) - mod,
|
||||||
|
size().width(), getFontH());
|
||||||
|
/*
|
||||||
|
if (event->rect().contains (r)) {
|
||||||
|
*/
|
||||||
|
PlaylistItem *item = m_items->value (i);
|
||||||
|
q = QString::number (i + 1) + ". " + item->text ();
|
||||||
|
|
||||||
if (item->getSelected ()) {
|
if (item->getSelected ()) {
|
||||||
paint.fillRect (r, QBrush (m_color_selected));
|
paint.fillRect (r, QBrush (m_color_selected));
|
||||||
|
@ -276,12 +281,15 @@ PlaylistList::paintEvent (QPaintEvent *event)
|
||||||
paint.drawText (r, q);
|
paint.drawText (r, q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getFontH()*(i-sitem) < size().height()) {
|
if ((getFontH()*(i-sitem) - mod) < size().height()) {
|
||||||
paint.eraseRect (QRect (0, getFontH()*(i-sitem), size().width(),
|
paint.eraseRect (QRect (0, (getFontH()*(i-sitem) - mod),
|
||||||
size().height()-getFontH()*(i-sitem)));
|
size().width(),
|
||||||
|
size().height()-(getFontH()*(i-sitem) - mod)));
|
||||||
}
|
}
|
||||||
|
|
||||||
paint.end ();
|
paint.end ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue