2010-05-20 16:12:15 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-05-20 16:12:15 +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 PLAYLISTTABBAR_H
|
|
|
|
#define PLAYLISTTABBAR_H
|
|
|
|
|
2010-07-17 14:47:59 +02:00
|
|
|
#include <QBasicTimer>
|
2011-04-28 19:50:45 +02:00
|
|
|
#include <QIcon>
|
2010-05-20 16:12:15 +02:00
|
|
|
#include <QTabBar>
|
|
|
|
|
2010-07-17 14:47:59 +02:00
|
|
|
class PlaylistManager;
|
2011-04-02 16:46:56 +02:00
|
|
|
class RenameTabLineEdit;
|
2010-07-17 14:47:59 +02:00
|
|
|
|
2010-05-20 16:12:15 +02:00
|
|
|
class QMenu;
|
|
|
|
|
|
|
|
class PlaylistTabBar : public QTabBar {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
PlaylistTabBar(QWidget *parent = 0);
|
|
|
|
|
2010-07-17 14:47:59 +02:00
|
|
|
static const int kDragHoverTimeout = 500;
|
|
|
|
|
2010-05-23 00:20:00 +02:00
|
|
|
void SetActions(QAction* new_playlist, QAction* load_playlist);
|
2010-07-17 14:47:59 +02:00
|
|
|
void SetManager(PlaylistManager* manager);
|
2010-05-20 16:12:15 +02:00
|
|
|
|
2010-05-21 12:29:17 +02:00
|
|
|
// We use IDs to refer to tabs so the tabs can be moved around (and their
|
|
|
|
// indexes change).
|
|
|
|
int index_of(int id) const;
|
|
|
|
int current_id() const;
|
2011-04-19 22:11:24 +02:00
|
|
|
int id_of(int index) const;
|
2010-05-21 12:29:17 +02:00
|
|
|
|
|
|
|
// Utility functions that use IDs rather than indexes
|
|
|
|
void set_current_id(int id);
|
|
|
|
void set_icon_by_id(int id, const QIcon& icon);
|
|
|
|
void set_text_by_id(int id, const QString& text);
|
|
|
|
|
|
|
|
void RemoveTab(int id);
|
2011-04-28 19:50:45 +02:00
|
|
|
void InsertTab(int id, int index, const QString& text,
|
|
|
|
const QIcon& icon = QIcon());
|
2010-05-21 12:29:17 +02:00
|
|
|
|
2010-05-20 16:12:15 +02:00
|
|
|
signals:
|
2010-05-21 12:29:17 +02:00
|
|
|
void CurrentIdChanged(int id);
|
|
|
|
void Rename(int id, const QString& name);
|
|
|
|
void Remove(int id);
|
2010-05-23 00:20:00 +02:00
|
|
|
void Save(int id);
|
2010-05-21 12:37:24 +02:00
|
|
|
void PlaylistOrderChanged(const QList<int>& ids);
|
2010-05-20 16:12:15 +02:00
|
|
|
|
2010-07-17 14:47:59 +02:00
|
|
|
protected:
|
|
|
|
void contextMenuEvent(QContextMenuEvent* e);
|
|
|
|
void mouseReleaseEvent(QMouseEvent* e);
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent* e);
|
|
|
|
void dragEnterEvent(QDragEnterEvent* e);
|
|
|
|
void dragMoveEvent(QDragMoveEvent* e);
|
|
|
|
void dragLeaveEvent(QDragLeaveEvent* e);
|
|
|
|
void dropEvent(QDropEvent* e);
|
2011-02-09 19:48:31 +01:00
|
|
|
void timerEvent(QTimerEvent* e);
|
2011-04-13 21:15:30 +02:00
|
|
|
bool event(QEvent* e);
|
2010-07-17 14:47:59 +02:00
|
|
|
|
2010-05-20 16:12:15 +02:00
|
|
|
private slots:
|
2010-05-21 12:29:17 +02:00
|
|
|
void CurrentIndexChanged(int index);
|
2010-05-20 16:12:15 +02:00
|
|
|
void Rename();
|
2011-04-02 16:46:56 +02:00
|
|
|
void RenameInline();
|
|
|
|
void HideEditor();
|
2010-05-20 16:12:15 +02:00
|
|
|
void Remove();
|
2011-06-19 10:44:10 +02:00
|
|
|
void RemoveFromTabIndex(int index);
|
2010-05-21 12:37:24 +02:00
|
|
|
void TabMoved();
|
2010-05-23 00:20:00 +02:00
|
|
|
void Save();
|
2010-05-20 16:12:15 +02:00
|
|
|
|
|
|
|
private:
|
2010-07-17 14:47:59 +02:00
|
|
|
PlaylistManager* manager_;
|
|
|
|
|
2010-05-20 16:12:15 +02:00
|
|
|
QMenu* menu_;
|
|
|
|
int menu_index_;
|
2010-05-22 16:33:17 +02:00
|
|
|
QAction* new_;
|
2010-05-20 16:12:15 +02:00
|
|
|
QAction* rename_;
|
|
|
|
QAction* remove_;
|
2010-05-23 00:20:00 +02:00
|
|
|
QAction* save_;
|
2010-05-21 12:29:17 +02:00
|
|
|
|
2010-07-17 14:47:59 +02:00
|
|
|
QBasicTimer drag_hover_timer_;
|
|
|
|
int drag_hover_tab_;
|
|
|
|
|
2010-05-21 12:29:17 +02:00
|
|
|
bool suppress_current_changed_;
|
2011-04-02 16:46:56 +02:00
|
|
|
|
2011-06-19 10:44:10 +02:00
|
|
|
// Editor for inline renaming
|
2011-04-02 16:46:56 +02:00
|
|
|
RenameTabLineEdit* rename_editor_;
|
2011-06-19 10:44:10 +02:00
|
|
|
|
|
|
|
// We want to ask confirmation only after a menu click
|
|
|
|
bool removing_from_menu_;
|
2010-05-20 16:12:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PLAYLISTTABBAR_H
|