simplified controls column widget (just a html label)
authortmarki <tmarki@gmail.com>
Fri, 13 Aug 2010 11:04:03 +0000 (13:04 +0200)
committertmarki <tmarki@gmail.com>
Fri, 13 Aug 2010 11:04:03 +0000 (13:04 +0200)
tomamp/mainwindow.cpp
tomamp/mainwindow.h

index 8bcd24f..349cce5 100644 (file)
@@ -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("<b><a href='up'>▲</a></b>"));
-        up->setStyleSheet("padding-right:3px;");
-        up->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
-        bar->addWidget(up);
-        QLabel* down = new QLabel;
-        down->setText(QString::fromUtf8("<b><a href='down'>▼</a></b>"));
-        down->setStyleSheet("padding-right:3px;");
-        bar->addWidget(down);
-        QLabel* del = new QLabel;
-        del->setText(QString::fromUtf8("<b><a href='del'>╳</a></b>"));
-        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("<b><a style='text-decoration:none' href='up'>▲</a> <a style='text-decoration:none' href='down'>▼</a> <a style='text-decoration:none' href='del'>╳</a> <a style='text-decoration:none' href='info'>i</a></b>"));
+        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())
     {
index a18122f..59e247e 100644 (file)
@@ -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;