1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-18 04:19:55 +01:00

Add icons to the move up/move down/clear buttons, and implement the clear button

This commit is contained in:
David Sansome 2010-07-11 16:58:22 +00:00
parent f750ac1351
commit 1f9e72f971
39 changed files with 390 additions and 27 deletions

View File

@ -246,5 +246,8 @@
<file>icons/48x48/drive-removable-media-usb-pendrive.png</file>
<file>schema-15.sql</file>
<file>device-schema.sql</file>
<file>icons/22x22/go-down.png</file>
<file>icons/32x32/go-down.png</file>
<file>icons/48x48/go-down.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -74,6 +74,10 @@ Playlist::Playlist(PlaylistBackend* backend, TaskManager* task_manager,
proxy_->setSourceModel(this);
queue_->setSourceModel(this);
connect(queue_, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
SLOT(TracksAboutToBeDequeued(QModelIndex,int,int)));
connect(queue_, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(TracksDequeued()));
}
Playlist::~Playlist() {
@ -1065,3 +1069,18 @@ quint64 Playlist::GetTotalLength() const {
PlaylistItemList Playlist::library_items_by_id(int id) const {
return library_items_by_id_.values(id);
}
void Playlist::TracksAboutToBeDequeued(const QModelIndex&, int begin, int end) {
qDebug() << begin << end;
for (int i=begin ; i<=end ; ++i) {
temp_queue_change_indexes_ << queue_->mapToSource(queue_->index(i, Column_Title));
}
}
void Playlist::TracksDequeued() {
foreach (const QModelIndex& index, temp_queue_change_indexes_) {
qDebug() << "Changed" << index.row() << index.data(Role_QueuePosition);
emit dataChanged(index, index);
}
temp_queue_change_indexes_.clear();
}

View File

@ -197,10 +197,16 @@ class Playlist : public QAbstractListModel {
void MoveItemsWithoutUndo(const QList<int>& source_rows, int pos);
void MoveItemsWithoutUndo(int start, const QList<int>& dest_rows);
private slots:
void TracksAboutToBeDequeued(const QModelIndex&, int begin, int end);
void TracksDequeued();
private:
PlaylistFilter* proxy_;
Queue* queue_;
QList<QModelIndex> temp_queue_change_indexes_;
PlaylistBackend* backend_;
TaskManager* task_manager_;
int id_;

View File

@ -101,13 +101,13 @@ int Queue::columnCount(const QModelIndex &parent) const {
}
QVariant Queue::data(const QModelIndex& proxy_index, int role) const {
QModelIndex source_index = source_indexes_[proxy_index.row()];
switch (role) {
case Playlist::Role_QueuePosition:
return proxy_index.row();
case Qt::DisplayRole: {
QModelIndex source_index = source_indexes_[proxy_index.row()];
case Qt::DisplayRole:
if (proxy_index.column() == Column_CombinedArtistTitle) {
const QString artist = source_index.sibling(source_index.row(), Playlist::Column_Artist).data().toString();
const QString title = source_index.sibling(source_index.row(), Playlist::Column_Title).data().toString();
@ -116,12 +116,10 @@ QVariant Queue::data(const QModelIndex& proxy_index, int role) const {
return title;
return artist + " - " + title;
}
}
// fallthrough
default: {
QModelIndex source_index = source_indexes_[proxy_index.row()];
default:
return source_index.data(role);
}
}
}
@ -147,3 +145,16 @@ void Queue::ToggleTracks(const QModelIndexList &source_indexes) {
int Queue::PositionOf(const QModelIndex& source_index) const {
return mapFromSource(source_index).row();
}
bool Queue::is_empty() const {
return source_indexes_.isEmpty();
}
void Queue::Clear() {
if (source_indexes_.isEmpty())
return;
beginRemoveRows(QModelIndex(), 0, source_indexes_.count()-1);
source_indexes_.clear();
endRemoveRows();
}

View File

@ -33,11 +33,14 @@ public:
ColumnCount
};
// Query the queue
bool is_empty() const;
int PositionOf(const QModelIndex& source_index) const;
// Modify the queue
QModelIndex TakeNext();
void ToggleTracks(const QModelIndexList& source_indexes);
void Clear();
// QAbstractProxyModel
void setSourceModel(QAbstractItemModel* source_model);
@ -47,8 +50,8 @@ public:
// QAbstractItemModel
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &child) const;
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex& proxy_index, int role) const;
private slots:

View File

@ -20,6 +20,7 @@
#include "queue.h"
#include "queuemanager.h"
#include "ui_queuemanager.h"
#include "ui/iconloader.h"
QueueManager::QueueManager(QWidget *parent)
: QDialog(parent),
@ -28,8 +29,17 @@ QueueManager::QueueManager(QWidget *parent)
current_playlist_(NULL)
{
ui_->setupUi(this);
ui_->list->setItemDelegate(new QueuedItemDelegate(this));
// Set icons on buttons
ui_->move_down->setIcon(IconLoader::Load("go-down"));
ui_->move_up->setIcon(IconLoader::Load("go-up"));
ui_->clear->setIcon(IconLoader::Load("edit-clear-list"));
// Button connections
connect(ui_->move_down, SIGNAL(clicked()), SLOT(MoveDown()));
connect(ui_->move_up, SIGNAL(clicked()), SLOT(MoveUp()));
connect(ui_->clear, SIGNAL(clicked()), SLOT(Clear()));
}
QueueManager::~QueueManager() {
@ -43,7 +53,49 @@ void QueueManager::SetPlaylistManager(PlaylistManager* manager) {
}
void QueueManager::CurrentPlaylistChanged(Playlist* playlist) {
if (current_playlist_) {
disconnect(current_playlist_->queue(), SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(UpdateButtonState()));
disconnect(current_playlist_->queue(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
this, SLOT(UpdateButtonState()));
}
current_playlist_ = playlist;
connect(current_playlist_->queue(), SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(UpdateButtonState()));
connect(current_playlist_->queue(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
this, SLOT(UpdateButtonState()));
ui_->list->setModel(current_playlist_->queue());
ui_->list->setModelColumn(Queue::Column_CombinedArtistTitle);
connect(ui_->list->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
SLOT(UpdateButtonState()));
}
void QueueManager::MoveUp() {
}
void QueueManager::MoveDown() {
}
void QueueManager::Clear() {
current_playlist_->queue()->Clear();
}
void QueueManager::UpdateButtonState() {
const QModelIndex current = ui_->list->selectionModel()->currentIndex();
if (current.isValid()) {
ui_->move_up->setEnabled(current.row() != 0);
ui_->move_down->setEnabled(current.row() != current_playlist_->queue()->rowCount()-1);
} else {
ui_->move_up->setEnabled(false);
ui_->move_down->setEnabled(false);
}
ui_->clear->setEnabled(!current_playlist_->queue()->is_empty());
}

View File

@ -23,6 +23,8 @@ class Playlist;
class PlaylistManager;
class Ui_QueueManager;
class QModelIndex;
class QueueManager : public QDialog {
Q_OBJECT
@ -34,6 +36,11 @@ public:
private slots:
void CurrentPlaylistChanged(Playlist* playlist);
void UpdateButtonState();
void MoveUp();
void MoveDown();
void Clear();
private:
Ui_QueueManager* ui_;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>455</width>
<height>366</height>
<width>582</width>
<height>363</height>
</rect>
</property>
<property name="windowTitle">
@ -35,35 +35,50 @@
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="move_up">
<widget class="QPushButton" name="move_up">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move up</string>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="move_down">
<widget class="QPushButton" name="move_down">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move down</string>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="clear">
<widget class="QPushButton" name="clear">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Clear</string>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
@ -91,7 +106,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>

View File

@ -303,6 +303,9 @@ msgstr ""
msgid "Classical"
msgstr ""
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr ""
@ -960,9 +963,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr ""
msgid "Move up"
msgstr ""
msgid "Music"
msgstr ""

View File

@ -304,6 +304,9 @@ msgstr "Vybrat obal ručně"
msgid "Classical"
msgstr "Klasická"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Vprázdnit seznam skladeb"
@ -964,9 +967,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Přesunout do knihovny..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Hudba"

View File

@ -304,6 +304,9 @@ msgstr "Vælg omslag manuelt"
msgid "Classical"
msgstr "Klassisk"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Ryd spilleliste"
@ -965,9 +968,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Flyt til bibliotek..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Musik"

View File

@ -303,6 +303,9 @@ msgstr "Cover selbst auswählen"
msgid "Classical"
msgstr "Klassisch"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Wiedergabeliste leeren"
@ -967,9 +970,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "In die Musiksammlung verschieben..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Musik"

View File

@ -310,6 +310,9 @@ msgstr "Επιλογή εξώφυλλου χειροκίνητα"
msgid "Classical"
msgstr "Κλασσική"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Καθαρισμός λίστας"
@ -973,9 +976,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Μετακίνηση στην βιβλιοθήκη..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Μουσική"

View File

@ -303,6 +303,9 @@ msgstr "Choose manual cover"
msgid "Classical"
msgstr "Classical"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Clear playlist"
@ -964,9 +967,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Move to library..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Music"

View File

@ -303,6 +303,9 @@ msgstr "Choose manual cover"
msgid "Classical"
msgstr "Classical"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Clear playlist"
@ -962,9 +965,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Move to library..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Music"

View File

@ -305,6 +305,9 @@ msgstr "Establecer carátula personalizada"
msgid "Classical"
msgstr "Clásico"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Limpiar lista de reproducción"
@ -971,9 +974,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Mover a la colección..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Música"

View File

@ -303,6 +303,9 @@ msgstr ""
msgid "Classical"
msgstr ""
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Tyhjennä soittolista"
@ -961,9 +964,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Siirrä kirjastoon..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Musiikki"

View File

@ -304,6 +304,9 @@ msgstr "Choisir une jaquette manuellement"
msgid "Classical"
msgstr "Classique"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Vider la liste de lecture"
@ -968,9 +971,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Déplacer vers la bibliothèque..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Musique"

View File

@ -303,6 +303,9 @@ msgstr "Escoller unha capa manualmente"
msgid "Classical"
msgstr "Clásica"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr ""
@ -962,9 +965,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Mover para a biblioteca..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr ""

View File

@ -304,6 +304,9 @@ msgstr "Scelta manuale della copertina"
msgid "Classical"
msgstr "Classica"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Svuota la scaletta"
@ -969,9 +972,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Sposta nella raccolta..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Musica"

View File

@ -303,6 +303,9 @@ msgstr ""
msgid "Classical"
msgstr "Классикалық"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr ""
@ -962,9 +965,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr ""
msgid "Move up"
msgstr ""
msgid "Music"
msgstr ""

View File

@ -303,6 +303,9 @@ msgstr "Velg cover manuelt"
msgid "Classical"
msgstr "Klassisk"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Tøm spillelisten"
@ -963,9 +966,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Flytt til bibliotek..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Musikk"

View File

@ -303,6 +303,9 @@ msgstr ""
msgid "Classical"
msgstr "Classic"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Voidar la lista de lectura"
@ -960,9 +963,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr ""
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Musica"

View File

@ -304,6 +304,9 @@ msgstr "Wybierz okładkę ręcznie"
msgid "Classical"
msgstr ""
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Wyczyść playlistę"
@ -962,9 +965,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Przenieś do biblioteki..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Muzyka"

View File

@ -308,6 +308,9 @@ msgstr "Escolher uma capa manualmente"
msgid "Classical"
msgstr "Clássica"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Limpar a lista de reprodução"
@ -970,9 +973,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Mover para a biblioteca..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Música"

View File

@ -306,6 +306,9 @@ msgstr "Escolher capa manualmente"
msgid "Classical"
msgstr "Clássica"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Limpar lista de reprodução"
@ -970,9 +973,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Mover para biblioteca..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Música"

View File

@ -303,6 +303,9 @@ msgstr ""
msgid "Classical"
msgstr "Clasică"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Golește lista"
@ -961,9 +964,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Mută în bibliotecă..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Muzică"

View File

@ -302,6 +302,9 @@ msgstr "Укажите обложку вручную"
msgid "Classical"
msgstr "Classical"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Очистить список воспроизведения"
@ -964,9 +967,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Переместить в коллекцию..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Музыка"

View File

@ -308,6 +308,9 @@ msgstr "Vybrať obal ručne"
msgid "Classical"
msgstr "Classical"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Vyprázdniť playlist"
@ -970,9 +973,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Presunúť do zbierky..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Hudba"

View File

@ -303,6 +303,9 @@ msgstr "Ange omslag manuellt"
msgid "Classical"
msgstr "Klassiskt"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Töm spellista"
@ -965,9 +968,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Flytta till bibliotek"
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Musik"

View File

@ -303,6 +303,9 @@ msgstr ""
msgid "Classical"
msgstr "Klasik"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Çalma listesini temizle"
@ -960,9 +963,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr ""
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Müzik"

View File

@ -294,6 +294,9 @@ msgstr ""
msgid "Classical"
msgstr ""
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr ""
@ -951,9 +954,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr ""
msgid "Move up"
msgstr ""
msgid "Music"
msgstr ""

View File

@ -307,6 +307,9 @@ msgstr "Виберіть обкладинку вручну"
msgid "Classical"
msgstr "Класична"
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "Очистити список відтворення"
@ -969,9 +972,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr "Перемістити до фонотеки..."
msgid "Move up"
msgstr ""
msgid "Music"
msgstr "Музика"

View File

@ -303,6 +303,9 @@ msgstr ""
msgid "Classical"
msgstr ""
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr ""
@ -960,9 +963,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr ""
msgid "Move up"
msgstr ""
msgid "Music"
msgstr ""

View File

@ -303,6 +303,9 @@ msgstr ""
msgid "Classical"
msgstr ""
msgid "Clear"
msgstr ""
msgid "Clear playlist"
msgstr "清除播放清單"
@ -960,9 +963,15 @@ msgstr ""
msgid "Mount points"
msgstr ""
msgid "Move down"
msgstr ""
msgid "Move to library..."
msgstr ""
msgid "Move up"
msgstr ""
msgid "Music"
msgstr ""

View File

@ -1302,7 +1302,11 @@ void MainWindow::PlaylistDelete() {
}
void MainWindow::PlaylistQueue() {
QModelIndexList indexes = playlists_->current()->proxy()->mapSelectionToSource(
ui_->playlist->view()->selectionModel()->selection()).indexes();
QModelIndexList indexes;
foreach (const QModelIndex& proxy_index,
ui_->playlist->view()->selectionModel()->selectedRows()) {
indexes << playlists_->current()->proxy()->mapToSource(proxy_index);
}
playlists_->current()->queue()->ToggleTracks(indexes);
}