From ecef1633ec9a985286d3be941b50526dc90052b8 Mon Sep 17 00:00:00 2001 From: tmarki Date: Wed, 11 Aug 2010 12:54:37 +0200 Subject: [PATCH] added install code to .pro experimental playlist control (up), not really good yet --- mainwindow.cpp | 27 +++++++++++++++++++++++---- mainwindow.h | 1 + playlistmanager.cpp | 11 +++++++++++ playlistmanager.h | 1 + tomamp.pro | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 4 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index c70baa2..78d23b0 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -619,9 +619,9 @@ void MainWindow::setupUi() timeLcd = new QLCDNumber; QStringList headers; - headers << tr("Artist") << tr("Title") << tr("Album"); + headers << tr("Artist") << tr("Title") << tr("Album") << "Controls"; - musicTable = new QTableWidget(0, 3); + musicTable = new QTableWidget(0, 4); musicTable->setHorizontalHeaderLabels(headers); musicTable->setSelectionMode(QAbstractItemView::SingleSelection); musicTable->setSelectionBehavior(QAbstractItemView::SelectRows); @@ -740,10 +740,10 @@ void MainWindow::playlistChanged(int from) musicTable->insertRow(currentRow); setRowFromItem (currentRow, plman.getItem(i)); } - if (plman.indexOf(mediaObject->currentSource()) < 0) +/* if (plman.indexOf(mediaObject->currentSource()) < 0) { setItem (firstGood, false); - } + }*/ setupShuffleList(); } @@ -769,6 +769,25 @@ void MainWindow::setRowFromItem (int row, const PlaylistItem& item) item3->setFlags(item3->flags() ^ Qt::ItemIsEditable); musicTable->setItem(row, 2, item3); } + qDebug () << "Widget: " << musicTable->cellWidget(row, 3); + + if (!musicTable->cellWidget(row, 3)) + { + QToolBar* bar = new QToolBar; + QPushButton* up = new QPushButton; + up->setText("up"); + up->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + bar->setProperty("row", row); + bar->addWidget(up); + musicTable->setCellWidget(row, 3, bar); + connect (up, SIGNAL (clicked ()), this, SLOT (buttonUp ())); + } +} + +void MainWindow::buttonUp() +{ + qDebug () << "Presses up on " << sender()->parent()->property("row"); + plman.moveItemUp(sender()->parent()->property("row").toInt()); } void MainWindow::itemUpdated(int index) diff --git a/mainwindow.h b/mainwindow.h index 023f673..5376287 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -98,6 +98,7 @@ private slots: void removeAllButSelectedItem (); void highlightRow (int i); void unhighlightRow (int i); + void buttonUp (); protected: void contextMenuEvent (QContextMenuEvent*e); diff --git a/playlistmanager.cpp b/playlistmanager.cpp index 4488583..0b43077 100644 --- a/playlistmanager.cpp +++ b/playlistmanager.cpp @@ -320,3 +320,14 @@ bool PlaylistManager::fileSupported (const QString& fname) const return false; } + +void PlaylistManager::moveItemUp (int i) +{ + if (i) + { + PlaylistItem tmp = items[i - 1]; + items[i - 1] = items[i]; + items[i] = tmp; + emit playlistChanged(i - 1); + } +} diff --git a/playlistmanager.h b/playlistmanager.h index eb91c09..407e38b 100644 --- a/playlistmanager.h +++ b/playlistmanager.h @@ -39,6 +39,7 @@ public slots: void loadPlaylist(const QString& filename); void clearPlaylist(); void addPlaylist (const QString& filename); + void moveItemUp (int i); signals: void playlistChanged (int from); void itemUpdated (int index); diff --git a/tomamp.pro b/tomamp.pro index 9cc2006..87474f9 100644 --- a/tomamp.pro +++ b/tomamp.pro @@ -35,3 +35,37 @@ RESOURCES += \ OTHER_FILES += \ bugs.txt \ README + +unix { + # VARIABLES + isEmpty(PREFIX):PREFIX = /usr #/local ? + BINDIR = $$PREFIX/bin + DATADIR = $$PREFIX/share + DEFINES += DATADIR=\"$$DATADIR\" \ + PKGDATADIR=\"$$PKGDATADIR\" + + contains(QT_CONFIG, hildon):{ + DEFINES += CHIMGDIR=\'\"$$DATADIR/$${TARGET}\"\' + } + # MAKE INSTALL + INSTALLS += target \ + imagery \ + desktop \ + iconxpm \ + icon26 \ + icon40 \ + icon64 + target.path = $$BINDIR + imagery.path = $$DATADIR/$${TARGET}/images + imagery.files += ../src/images/*png + desktop.path = $$DATADIR/applications/hildon + desktop.files += $${TARGET}.desktop + iconxpm.path = $$DATADIR/pixmap + iconxpm.files += ../data/maemo/$${TARGET}.xpm + icon26.path = $$DATADIR/icons/hicolor/26x26/apps + icon26.files += ../data/26x26/Tomamp.png + icon40.path = $$DATADIR/icons/hicolor/40x40/apps + icon40.files += ../data/40x40/Tomamp.png + icon64.path = $$DATADIR/icons/hicolor/64x64/apps + icon64.files += ../data/64x64/Tomamp.png +} -- 1.7.9.5