File indexing completed on 2024-05-19 04:07:52

0001 /*
0002     SPDX-FileCopyrightText: 2009 Stefan Majewsky <majewsky@gmx.net>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef PALAPELI_COLLECTIONVIEW_H
0008 #define PALAPELI_COLLECTIONVIEW_H
0009 
0010 #include <QListView>
0011 class QSortFilterProxyModel;
0012 class QAction;
0013 
0014 namespace Palapeli
0015 {
0016     class CollectionDelegate;
0017     class Puzzle;
0018 
0019     class CollectionView : public QWidget
0020     {
0021         Q_OBJECT
0022         public:
0023             explicit CollectionView(QWidget* parent = nullptr);
0024 
0025             void setModel(QAbstractItemModel* model);
0026             QModelIndexList selectedIndexes() const;
0027         Q_SIGNALS:
0028             void canDeleteChanged(bool canDelete);
0029             void canExportChanged(bool canExport);
0030             void playRequest(Palapeli::Puzzle* puzzle);
0031         private Q_SLOTS:
0032             void handleActivated(const QModelIndex& index);
0033             void handleSelectionChanged();
0034             void sortMenuTriggered(QAction* action);
0035             void slotTextChanged(const QString &str);
0036         private:
0037             QListView* m_view;
0038             Palapeli::CollectionDelegate* m_delegate;
0039             QSortFilterProxyModel* m_proxyModel;
0040             QAction* m_sortByTitle;
0041             QAction* m_sortByPieceCount;
0042     };
0043 }
0044 
0045 #endif // PALAPELI_COLLECTIONVIEW_H