Files
cantata/widgets/playqueueview.h

113 lines
3.0 KiB
C++

/*
* Cantata
*
* Copyright (c) 2011-2013 Craig Drummond <craig.p.drummond@gmail.com>
*
* ----
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef PLAYQUEUEVIEW_H
#define PLAYQUEUEVIEW_H
#include <QStackedWidget>
#include <QAbstractItemView>
#include <QSet>
#include "treeview.h"
#include "song.h"
class GroupedView;
class QAbstractItemModel;
class QAction;
class QItemSelectionModel;
class QHeaderView;
class QModelIndex;
class QMenu;
class Spinner;
class PlayQueueTreeView : public TreeView
{
Q_OBJECT
public:
PlayQueueTreeView(QWidget *p);
virtual ~PlayQueueTreeView();
void initHeader();
void saveHeader();
private Q_SLOTS:
void showMenu();
void toggleHeaderItem(bool visible);
private:
QMenu *menu;
};
class PlayQueueView : public QStackedWidget
{
Q_OBJECT
public:
PlayQueueView(QWidget *parent=0);
virtual ~PlayQueueView();
void initHeader() { treeView->initHeader(); }
void saveHeader();
void setGrouped(bool g);
bool isGrouped() const { return currentWidget()==(QWidget *)groupedView; }
void setAutoExpand(bool ae);
bool isAutoExpand() const;
void setStartClosed(bool sc);
bool isStartClosed() const;
void setFilterActive(bool f);
void updateRows(qint32 row, quint16 curAlbum, bool scroll);
void scrollTo(const QModelIndex &index, QAbstractItemView::ScrollHint hint);
void setModel(QAbstractItemModel *m) { view()->setModel(m); }
void addAction(QAction *a);
void setFocus();
bool hasFocus();
QAbstractItemModel * model() { return view()->model(); }
void setContextMenuPolicy(Qt::ContextMenuPolicy policy);
bool haveSelectedItems();
bool haveUnSelectedItems();
QItemSelectionModel * selectionModel() const { return view()->selectionModel(); }
void setCurrentIndex(const QModelIndex &idx) { view()->setCurrentIndex(idx); }
QHeaderView * header();
QAbstractItemView * tree() const;
QAbstractItemView * list() const;
QAbstractItemView * view() const;
bool hasFocus() const;
QModelIndexList selectedIndexes() const;
QList<Song> selectedSongs() const;
public Q_SLOTS:
void showSpinner();
void hideSpinner();
Q_SIGNALS:
void itemsSelected(bool);
void doubleClicked(const QModelIndex &);
private:
GroupedView *groupedView;
PlayQueueTreeView *treeView;
Spinner *spinner;
};
#endif