From 55a1e2fa6172d8ca69c06a9b99e449717cb2d9c1 Mon Sep 17 00:00:00 2001 From: tmarki Date: Fri, 13 Aug 2010 13:04:03 +0200 Subject: [PATCH] simplified controls column widget (just a html label) --- tomamp/mainwindow.cpp | 53 +++++++++++++++++++++++++------------------------ tomamp/mainwindow.h | 8 +++++--- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/tomamp/mainwindow.cpp b/tomamp/mainwindow.cpp index 8bcd24f..349cce5 100644 --- a/tomamp/mainwindow.cpp +++ b/tomamp/mainwindow.cpp @@ -782,32 +782,35 @@ void MainWindow::setRowFromItem (int row, const PlaylistItem& item) if (!musicTable->cellWidget(row, 3)) { - QToolBar* bar = new QToolBar; - QLabel* up = new QLabel; - up->setText(QString::fromUtf8("▲")); - up->setStyleSheet("padding-right:3px;"); - up->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - bar->addWidget(up); - QLabel* down = new QLabel; - down->setText(QString::fromUtf8("▼")); - down->setStyleSheet("padding-right:3px;"); - bar->addWidget(down); - QLabel* del = new QLabel; - del->setText(QString::fromUtf8("╳")); - del->setStyleSheet("padding-right:3px;"); - bar->addWidget(del); - down->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - bar->setProperty("row", row); - musicTable->setCellWidget(row, 3, bar); - connect (up, SIGNAL (linkActivated (const QString&)), this, SLOT (buttonUp ())); - connect (down, SIGNAL (linkActivated (const QString&)), this, SLOT (buttonDown ())); - connect (del, SIGNAL (linkActivated (const QString&)), this, SLOT (buttonDel ())); + QLabel* label = new QLabel; + label->setText(QString::fromUtf8("▲ ▼ ╳ i")); + label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + label->setProperty("row", row); + musicTable->setCellWidget(row, 3, label); + connect (label, SIGNAL (linkActivated (const QString&)), this, SLOT (playlistControl (const QString&))); +/* connect (down, SIGNAL (linkActivated (const QString&)), this, SLOT (buttonDown ())); + connect (del, SIGNAL (linkActivated (const QString&)), this, SLOT (buttonDel ()));*/ } } -void MainWindow::buttonUp() +void MainWindow::playlistControl (const QString& con) { - int i = sender()->parent()->property("row").toInt(); + int i = sender ()->property("row").toInt(); + qDebug () << "Playlist control: " << con << " on " << i; + if (con == "up") + buttonUp(i); + else if (con == "down") + buttonDown(i); + else if (con == "del") + buttonDel (i); + else + QMessageBox::information(this, tr ("Coming up..."), tr ("This feature is not implemented yet.")); +} + + +void MainWindow::buttonUp(int i) +{ + //int i = sender()->parent()->property("row").toInt(); qDebug () << "Presses up on " << i; if (i) { @@ -820,9 +823,8 @@ void MainWindow::buttonUp() } } -void MainWindow::buttonDown() +void MainWindow::buttonDown(int i) { - int i = sender()->parent()->property("row").toInt(); qDebug () << "Presses down on " << i; if (i < plman.size() - 1) { @@ -835,9 +837,8 @@ void MainWindow::buttonDown() } } -void MainWindow::buttonDel() +void MainWindow::buttonDel(int i) { - int i = sender()->parent()->property("row").toInt(); qDebug () << "Presses del on " << i; if (i < plman.size()) { diff --git a/tomamp/mainwindow.h b/tomamp/mainwindow.h index a18122f..59e247e 100644 --- a/tomamp/mainwindow.h +++ b/tomamp/mainwindow.h @@ -98,11 +98,10 @@ private slots: void removeAllButSelectedItem (); void highlightRow (int i); void unhighlightRow (int i); - void buttonUp (); - void buttonDown (); - void buttonDel (); + void itemRemoved (int i); void showOptions (); + void playlistControl (const QString&); protected: void contextMenuEvent (QContextMenuEvent*e); @@ -112,6 +111,9 @@ private: void setupUi(); void setupShuffleList(); void setRowFromItem (int row, const PlaylistItem& item); + void buttonUp (int i); + void buttonDown (int i); + void buttonDel (int i); Phonon::SeekSlider *seekSlider; Phonon::MediaObject *mediaObject; -- 1.7.9.5