Uberpimped the playlist into be fast and nice.

This commit is contained in:
Tobias Rundstrom 2006-02-28 21:01:26 -03:00
parent 09494985d1
commit e665b5d7ad
2 changed files with 28 additions and 12 deletions

View file

@ -5,6 +5,7 @@
#include <QPaintEvent>
#include <QRect>
#include <QIcon>
#include <QApplication>
PlaylistScrollButton::PlaylistScrollButton (PlaylistScroller *parent, uint normal, uint pressed) : Button (parent, normal, pressed, true)
{
@ -14,6 +15,8 @@ PlaylistScrollButton::PlaylistScrollButton (PlaylistScroller *parent, uint norma
void
PlaylistScrollButton::mouseMoveEvent (QMouseEvent *event)
{
PlaylistWindow *pw = dynamic_cast<PlaylistWindow *>(window ());
QPoint p (event->pos ());
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());
m_list->setOffset (npos);
m_list->scroll (0, npos);
if (npos == 0) {
m_list->update ();
} else {
m_list->scroll (0, npos);
}
QApplication::sendPostedEvents (m_list, 0);
}
void

View file

@ -12,9 +12,6 @@ PlaylistItem::PlaylistItem (PlaylistList *pl, uint id)
m_isactive = false;
m_isselected = false;
m_req = false;
if (getSelected ()) {
qDebug ("trasigt!");
}
pl->addItem (this);
}
@ -44,6 +41,9 @@ PlaylistList::PlaylistList (QWidget *parent) : QWidget (parent)
XMMSHandler *xmmsh = XMMSHandler::getInstance ();
Skin *skin = Skin::getInstance ();
setAttribute (Qt::WA_NoBackground);
setFocusPolicy (Qt::StrongFocus);
connect (skin, SIGNAL (skinChanged (Skin *)),
this, SLOT (setPixmaps(Skin *)));
@ -250,17 +250,22 @@ PlaylistList::paintEvent (QPaintEvent *event)
int ch = event->rect().height();
int sitem = cy / getFontH();
int eitem = (cy + ch) / getFontH();
int mod = m_offset - (getFontH() * sitem);
if (eitem > m_items->count())
eitem = m_items->count();
QString q;
QRect r;
for (i = sitem; i < eitem; i++) {
QRect r (3, getFontH()*(i-sitem), size().width(), getFontH());
if (event->region().contains (r)) {
r.setRect(0, (getFontH()*(i-sitem)) - mod,
size().width(), getFontH());
/*
if (event->rect().contains (r)) {
*/
PlaylistItem *item = m_items->value (i);
QString q;
q.sprintf ("%d. ", i+1);
q += item->text ();
q = QString::number (i + 1) + ". " + item->text ();
if (item->getSelected ()) {
paint.fillRect (r, QBrush (m_color_selected));
@ -276,12 +281,15 @@ PlaylistList::paintEvent (QPaintEvent *event)
paint.drawText (r, q);
}
/*
}
*/
}
if (getFontH()*(i-sitem) < size().height()) {
paint.eraseRect (QRect (0, getFontH()*(i-sitem), size().width(),
size().height()-getFontH()*(i-sitem)));
if ((getFontH()*(i-sitem) - mod) < size().height()) {
paint.eraseRect (QRect (0, (getFontH()*(i-sitem) - mod),
size().width(),
size().height()-(getFontH()*(i-sitem) - mod)));
}
paint.end ();