2010-07-03 23:05:55 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-07-03 23:05:55 +02:00
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DEVICEVIEW_H
|
|
|
|
#define DEVICEVIEW_H
|
|
|
|
|
2014-02-06 14:48:00 +01:00
|
|
|
#include <memory>
|
|
|
|
|
2010-07-18 00:53:27 +02:00
|
|
|
#include "core/song.h"
|
2010-07-04 13:34:25 +02:00
|
|
|
#include "library/libraryview.h"
|
2010-07-04 02:37:41 +02:00
|
|
|
#include "widgets/autoexpandingtreeview.h"
|
2010-07-03 23:05:55 +02:00
|
|
|
|
|
|
|
class QAction;
|
|
|
|
class QMenu;
|
2010-07-04 01:00:07 +02:00
|
|
|
class QSortFilterProxyModel;
|
|
|
|
|
2012-02-12 14:41:50 +01:00
|
|
|
class Application;
|
2010-07-04 01:00:07 +02:00
|
|
|
class DeviceManager;
|
2010-07-04 17:01:24 +02:00
|
|
|
class DeviceProperties;
|
2010-07-18 19:13:43 +02:00
|
|
|
class LibraryModel;
|
2010-07-04 01:00:07 +02:00
|
|
|
class MergedProxyModel;
|
2010-07-03 23:05:55 +02:00
|
|
|
|
2010-07-04 13:34:25 +02:00
|
|
|
class DeviceItemDelegate : public LibraryItemDelegate {
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2010-07-04 13:34:25 +02:00
|
|
|
DeviceItemDelegate(QObject* parent);
|
|
|
|
|
|
|
|
static const int kIconPadding;
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void paint(QPainter* painter, const QStyleOptionViewItem& option,
|
|
|
|
const QModelIndex& index) const;
|
2010-07-04 13:34:25 +02:00
|
|
|
};
|
|
|
|
|
2010-07-04 02:37:41 +02:00
|
|
|
class DeviceView : public AutoExpandingTreeView {
|
2010-07-03 23:05:55 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2014-02-10 16:03:54 +01:00
|
|
|
DeviceView(QWidget* parent = nullptr);
|
2010-07-04 17:01:24 +02:00
|
|
|
~DeviceView();
|
2010-07-03 23:05:55 +02:00
|
|
|
|
2012-02-12 14:41:50 +01:00
|
|
|
void SetApplication(Application* app);
|
2010-07-04 01:00:07 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
protected:
|
|
|
|
void contextMenuEvent(QContextMenuEvent*);
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent* event);
|
2010-07-04 01:00:07 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
2010-07-18 00:53:27 +02:00
|
|
|
// Device menu actions
|
2010-07-04 01:00:07 +02:00
|
|
|
void Connect();
|
2010-07-25 03:07:51 +02:00
|
|
|
void Unmount();
|
2010-07-04 14:56:49 +02:00
|
|
|
void Forget();
|
2010-07-04 17:01:24 +02:00
|
|
|
void Properties();
|
2010-07-04 02:33:34 +02:00
|
|
|
|
2010-07-18 00:53:27 +02:00
|
|
|
// Library menu actions
|
|
|
|
void Load();
|
|
|
|
void AddToPlaylist();
|
2011-02-09 18:51:59 +01:00
|
|
|
void OpenInNewPlaylist();
|
2010-07-18 19:13:43 +02:00
|
|
|
void Organise();
|
2010-07-18 00:53:27 +02:00
|
|
|
void Delete();
|
|
|
|
|
2010-07-25 11:27:41 +02:00
|
|
|
void DeviceConnected(int row);
|
2010-07-04 02:33:34 +02:00
|
|
|
void DeviceDisconnected(int row);
|
2010-07-04 01:00:07 +02:00
|
|
|
|
2010-08-14 13:51:50 +02:00
|
|
|
void DeleteFinished(const SongList& songs_with_errors);
|
|
|
|
|
2010-09-18 16:29:43 +02:00
|
|
|
// AutoExpandingTreeView
|
|
|
|
bool CanRecursivelyExpand(const QModelIndex& index) const;
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2010-07-04 02:58:01 +02:00
|
|
|
QModelIndex MapToDevice(const QModelIndex& merged_model_index) const;
|
2010-07-18 00:53:27 +02:00
|
|
|
QModelIndex MapToLibrary(const QModelIndex& merged_model_index) const;
|
2010-07-31 18:12:16 +02:00
|
|
|
QModelIndex FindParentDevice(const QModelIndex& merged_model_index) const;
|
2010-07-18 00:53:27 +02:00
|
|
|
SongList GetSelectedSongs() const;
|
2010-07-04 01:00:07 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2012-02-12 14:41:50 +01:00
|
|
|
Application* app_;
|
2010-07-04 01:00:07 +02:00
|
|
|
MergedProxyModel* merged_model_;
|
|
|
|
QSortFilterProxyModel* sort_model_;
|
|
|
|
|
2014-02-06 14:48:00 +01:00
|
|
|
std::unique_ptr<DeviceProperties> properties_dialog_;
|
|
|
|
std::unique_ptr<OrganiseDialog> organise_dialog_;
|
2010-07-04 17:01:24 +02:00
|
|
|
|
2010-07-18 00:53:27 +02:00
|
|
|
QMenu* device_menu_;
|
2010-07-25 03:07:51 +02:00
|
|
|
QAction* eject_action_;
|
2010-07-04 14:56:49 +02:00
|
|
|
QAction* forget_action_;
|
2010-07-04 17:01:24 +02:00
|
|
|
QAction* properties_action_;
|
2010-07-18 00:53:27 +02:00
|
|
|
|
|
|
|
QMenu* library_menu_;
|
|
|
|
QAction* load_action_;
|
|
|
|
QAction* add_to_playlist_action_;
|
2011-02-09 18:51:59 +01:00
|
|
|
QAction* open_in_new_playlist_;
|
2010-07-18 19:13:43 +02:00
|
|
|
QAction* organise_action_;
|
2010-07-18 00:53:27 +02:00
|
|
|
QAction* delete_action_;
|
|
|
|
|
2010-07-04 01:00:07 +02:00
|
|
|
QModelIndex menu_index_;
|
2010-07-03 23:05:55 +02:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // DEVICEVIEW_H
|