Clementine-audio-player-Mac.../src/devices/deviceview.h

112 lines
2.8 KiB
C
Raw Normal View History

/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
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
#include <memory>
#include "core/song.h"
2010-07-04 13:34:25 +02:00
#include "library/libraryview.h"
#include "widgets/autoexpandingtreeview.h"
class QAction;
class QMenu;
2010-07-04 01:00:07 +02:00
class QSortFilterProxyModel;
class Application;
2010-07-04 01:00:07 +02:00
class DeviceManager;
2010-07-04 17:01:24 +02:00
class DeviceProperties;
class LibraryModel;
2010-07-04 01:00:07 +02:00
class MergedProxyModel;
2010-07-04 13:34:25 +02:00
class DeviceItemDelegate : public LibraryItemDelegate {
public:
2010-07-04 13:34:25 +02:00
DeviceItemDelegate(QObject* parent);
static const int kIconPadding;
void paint(QPainter* painter, const QStyleOptionViewItem& option,
const QModelIndex& index) const;
2010-07-04 13:34:25 +02:00
};
class DeviceView : public AutoExpandingTreeView {
Q_OBJECT
public:
DeviceView(QWidget* parent = nullptr);
2010-07-04 17:01:24 +02:00
~DeviceView();
void SetApplication(Application* app);
2010-07-04 01:00:07 +02:00
protected:
void contextMenuEvent(QContextMenuEvent*);
void mouseDoubleClickEvent(QMouseEvent* event);
2010-07-04 01:00:07 +02:00
private slots:
// Device menu actions
2010-07-04 01:00:07 +02:00
void Connect();
void Unmount();
void Forget();
2010-07-04 17:01:24 +02:00
void Properties();
2010-07-04 02:33:34 +02:00
// Library menu actions
void Load();
void AddToPlaylist();
void OpenInNewPlaylist();
void Organise();
void Delete();
void DeviceConnected(int row);
2010-07-04 02:33:34 +02:00
void DeviceDisconnected(int row);
2010-07-04 01:00:07 +02:00
void DeleteFinished(const SongList& songs_with_errors);
// AutoExpandingTreeView
bool CanRecursivelyExpand(const QModelIndex& index) const;
private:
2010-07-04 02:58:01 +02:00
QModelIndex MapToDevice(const QModelIndex& merged_model_index) const;
QModelIndex MapToLibrary(const QModelIndex& merged_model_index) const;
QModelIndex FindParentDevice(const QModelIndex& merged_model_index) const;
SongList GetSelectedSongs() const;
2010-07-04 01:00:07 +02:00
private:
Application* app_;
2010-07-04 01:00:07 +02:00
MergedProxyModel* merged_model_;
QSortFilterProxyModel* sort_model_;
std::unique_ptr<DeviceProperties> properties_dialog_;
std::unique_ptr<OrganiseDialog> organise_dialog_;
2010-07-04 17:01:24 +02:00
QMenu* device_menu_;
QAction* eject_action_;
QAction* forget_action_;
2010-07-04 17:01:24 +02:00
QAction* properties_action_;
QMenu* library_menu_;
QAction* load_action_;
QAction* add_to_playlist_action_;
QAction* open_in_new_playlist_;
QAction* organise_action_;
QAction* delete_action_;
2010-07-04 01:00:07 +02:00
QModelIndex menu_index_;
};
#endif // DEVICEVIEW_H