mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 19:45:31 +01:00
incorporating David's suggestions
This commit is contained in:
parent
07739d6c68
commit
e24e786a5d
@ -73,11 +73,12 @@ void LibraryQuery::AddWhere(const QString& column, const QVariant& value, const
|
||||
else {
|
||||
if(!op.compare("IN", Qt::CaseInsensitive)) {
|
||||
QStringList final;
|
||||
foreach(const QString& old, value.toStringList()) {
|
||||
final << "'" + QString(old).replace("'", "''") + "'";
|
||||
foreach(const QString& single_value, value.toStringList()) {
|
||||
final.append("?");
|
||||
bound_values_ << single_value;
|
||||
}
|
||||
|
||||
where_clauses_ << QString("%1 IN (%3)").arg(column, final.join(","));
|
||||
where_clauses_ << QString("%1 IN (" + final.join(",") + ")").arg(column);
|
||||
} else {
|
||||
where_clauses_ << QString("%1 %2 ?").arg(column, op);
|
||||
bound_values_ << value;
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "core/musicstorage.h"
|
||||
#include "devices/devicemanager.h"
|
||||
#include "devices/devicestatefiltermodel.h"
|
||||
#include "scripting/scriptmanager.h"
|
||||
#include "scripting/uiinterface.h"
|
||||
#include "smartplaylists/wizard.h"
|
||||
#include "ui/iconloader.h"
|
||||
#include "ui/organisedialog.h"
|
||||
@ -96,46 +98,6 @@ LibraryView::LibraryView(QWidget* parent)
|
||||
|
||||
ReloadSettings();
|
||||
setStyleSheet("QTreeView::item{padding-top:1px;}");
|
||||
|
||||
context_menu_ = new QMenu(this);
|
||||
load_ = context_menu_->addAction(IconLoader::Load("media-playback-start"),
|
||||
tr("Load"), this, SLOT(Load()));
|
||||
add_to_playlist_ = context_menu_->addAction(IconLoader::Load("media-playback-start"),
|
||||
tr("Add to playlist"), this, SLOT(AddToPlaylist()));
|
||||
add_to_playlist_enqueue_ = context_menu_->addAction(IconLoader::Load("media-playback-start"),
|
||||
tr("Enqueue to playlist"), this, SLOT(AddToPlaylistEnqueue()));
|
||||
|
||||
context_menu_->addSeparator();
|
||||
new_smart_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"),
|
||||
tr("New smart playlist..."), this, SLOT(NewSmartPlaylist()));
|
||||
edit_smart_playlist_ = context_menu_->addAction(IconLoader::Load("edit-rename"),
|
||||
tr("Edit smart playlist..."), this, SLOT(EditSmartPlaylist()));
|
||||
delete_smart_playlist_ = context_menu_->addAction(IconLoader::Load("edit-delete"),
|
||||
tr("Delete smart playlist"), this, SLOT(DeleteSmartPlaylist()));
|
||||
|
||||
context_menu_->addSeparator();
|
||||
organise_ = context_menu_->addAction(IconLoader::Load("edit-copy"),
|
||||
tr("Organise files..."), this, SLOT(Organise()));
|
||||
copy_to_device_ = context_menu_->addAction(IconLoader::Load("multimedia-player-ipod-mini-blue"),
|
||||
tr("Copy to device..."), this, SLOT(CopyToDevice()));
|
||||
// this will get finalized later
|
||||
copy_to_device_->setDisabled(true);
|
||||
delete_ = context_menu_->addAction(IconLoader::Load("edit-delete"),
|
||||
tr("Delete from disk..."), this, SLOT(Delete()));
|
||||
|
||||
context_menu_->addSeparator();
|
||||
edit_track_ = context_menu_->addAction(IconLoader::Load("edit-rename"),
|
||||
tr("Edit track information..."), this, SLOT(EditTracks()));
|
||||
edit_tracks_ = context_menu_->addAction(IconLoader::Load("edit-rename"),
|
||||
tr("Edit tracks information..."), this, SLOT(EditTracks()));
|
||||
|
||||
context_menu_->addSeparator();
|
||||
show_in_various_ = context_menu_->addAction(
|
||||
tr("Show in various artists"), this, SLOT(ShowInVarious()));
|
||||
no_show_in_various_ = context_menu_->addAction(
|
||||
tr("Don't show in various artists"), this, SLOT(NoShowInVarious()));
|
||||
|
||||
context_menu_->addSeparator();
|
||||
}
|
||||
|
||||
LibraryView::~LibraryView() {
|
||||
@ -163,11 +125,10 @@ void LibraryView::SetLibrary(LibraryModel *library) {
|
||||
|
||||
void LibraryView::SetDeviceManager(DeviceManager* device_manager) {
|
||||
devices_ = device_manager;
|
||||
}
|
||||
|
||||
// lazy finalization
|
||||
copy_to_device_->setDisabled(devices_->connected_devices_model()->rowCount() == 0);
|
||||
connect(devices_->connected_devices_model(), SIGNAL(IsEmptyChanged(bool)),
|
||||
copy_to_device_, SLOT(setDisabled(bool)));
|
||||
void LibraryView::SetScriptManager(ScriptManager* scripts) {
|
||||
scripts_ = scripts;
|
||||
}
|
||||
|
||||
void LibraryView::TotalSongCountUpdated(int count) {
|
||||
@ -221,6 +182,54 @@ void LibraryView::mouseReleaseEvent(QMouseEvent* e) {
|
||||
}
|
||||
|
||||
void LibraryView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
if(!context_menu_) {
|
||||
context_menu_ = new QMenu(this);
|
||||
load_ = context_menu_->addAction(IconLoader::Load("media-playback-start"),
|
||||
tr("Load"), this, SLOT(Load()));
|
||||
add_to_playlist_ = context_menu_->addAction(IconLoader::Load("media-playback-start"),
|
||||
tr("Add to playlist"), this, SLOT(AddToPlaylist()));
|
||||
add_to_playlist_enqueue_ = context_menu_->addAction(IconLoader::Load("media-playback-start"),
|
||||
tr("Enqueue to playlist"), this, SLOT(AddToPlaylistEnqueue()));
|
||||
|
||||
context_menu_->addSeparator();
|
||||
new_smart_playlist_ = context_menu_->addAction(IconLoader::Load("document-new"),
|
||||
tr("New smart playlist..."), this, SLOT(NewSmartPlaylist()));
|
||||
edit_smart_playlist_ = context_menu_->addAction(IconLoader::Load("edit-rename"),
|
||||
tr("Edit smart playlist..."), this, SLOT(EditSmartPlaylist()));
|
||||
delete_smart_playlist_ = context_menu_->addAction(IconLoader::Load("edit-delete"),
|
||||
tr("Delete smart playlist"), this, SLOT(DeleteSmartPlaylist()));
|
||||
|
||||
context_menu_->addSeparator();
|
||||
organise_ = context_menu_->addAction(IconLoader::Load("edit-copy"),
|
||||
tr("Organise files..."), this, SLOT(Organise()));
|
||||
copy_to_device_ = context_menu_->addAction(IconLoader::Load("multimedia-player-ipod-mini-blue"),
|
||||
tr("Copy to device..."), this, SLOT(CopyToDevice()));
|
||||
delete_ = context_menu_->addAction(IconLoader::Load("edit-delete"),
|
||||
tr("Delete from disk..."), this, SLOT(Delete()));
|
||||
|
||||
context_menu_->addSeparator();
|
||||
edit_track_ = context_menu_->addAction(IconLoader::Load("edit-rename"),
|
||||
tr("Edit track information..."), this, SLOT(EditTracks()));
|
||||
edit_tracks_ = context_menu_->addAction(IconLoader::Load("edit-rename"),
|
||||
tr("Edit tracks information..."), this, SLOT(EditTracks()));
|
||||
|
||||
context_menu_->addSeparator();
|
||||
show_in_various_ = context_menu_->addAction(
|
||||
tr("Show in various artists"), this, SLOT(ShowInVarious()));
|
||||
no_show_in_various_ = context_menu_->addAction(
|
||||
tr("Don't show in various artists"), this, SLOT(NoShowInVarious()));
|
||||
|
||||
context_menu_->addSeparator();
|
||||
|
||||
copy_to_device_->setDisabled(devices_->connected_devices_model()->rowCount() == 0);
|
||||
connect(devices_->connected_devices_model(), SIGNAL(IsEmptyChanged(bool)),
|
||||
copy_to_device_, SLOT(setDisabled(bool)));
|
||||
|
||||
if(scripts_) {
|
||||
scripts_->ui()->RegisterActionLocation("library_context_menu", context_menu_, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
context_menu_index_ = indexAt(e->pos());
|
||||
if (!context_menu_index_.isValid())
|
||||
return;
|
||||
|
@ -29,6 +29,7 @@
|
||||
class DeviceManager;
|
||||
class LibraryModel;
|
||||
class OrganiseDialog;
|
||||
class ScriptManager;
|
||||
class TaskManager;
|
||||
|
||||
class QMimeData;
|
||||
@ -55,6 +56,7 @@ class LibraryView : public AutoExpandingTreeView {
|
||||
// this will return all of it's songs.
|
||||
SongList GetSelectedSongs() const;
|
||||
|
||||
void SetScriptManager(ScriptManager* scripts);
|
||||
void SetTaskManager(TaskManager* task_manager);
|
||||
void SetLibrary(LibraryModel* library);
|
||||
void SetDeviceManager(DeviceManager* device_manager);
|
||||
@ -63,8 +65,6 @@ class LibraryView : public AutoExpandingTreeView {
|
||||
void keyboardSearch(const QString &search);
|
||||
void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
|
||||
|
||||
QMenu* context_menu() const { return context_menu_; }
|
||||
|
||||
public slots:
|
||||
void TotalSongCountUpdated(int count);
|
||||
void ReloadSettings();
|
||||
@ -108,6 +108,8 @@ class LibraryView : public AutoExpandingTreeView {
|
||||
void ShowInVarious(bool on);
|
||||
|
||||
private:
|
||||
ScriptManager* scripts_;
|
||||
|
||||
LibraryModel* library_;
|
||||
DeviceManager* devices_;
|
||||
TaskManager* task_manager_;
|
||||
|
@ -587,7 +587,6 @@ MainWindow::MainWindow(
|
||||
scripts_->ui()->RegisterActionLocation("tools_menu", ui_->menu_tools, ui_->action_update_library);
|
||||
scripts_->ui()->RegisterActionLocation("extras_menu", ui_->menu_extras, NULL);
|
||||
scripts_->ui()->RegisterActionLocation("help_menu", ui_->menu_help, NULL);
|
||||
scripts_->ui()->RegisterActionLocation("library_context_menu", library_view_->view()->context_menu(), NULL);
|
||||
|
||||
// Load theme
|
||||
StyleSheetLoader* css_loader = new StyleSheetLoader(this);
|
||||
@ -649,6 +648,8 @@ MainWindow::MainWindow(
|
||||
library_, library_view_->view(), player_, playlists_,
|
||||
task_manager_, settings_dialog_.get(), radio_model_));
|
||||
connect(ui_->action_script_manager, SIGNAL(triggered()), SLOT(ShowScriptDialog()));
|
||||
|
||||
library_view_->view()->SetScriptManager(scripts_);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user