File indexing completed on 2024-05-12 04:06:26

0001 /*
0002     SPDX-FileCopyrightText: 2009-2011 Stefan Majewsky <majewsky@gmx.net>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef PALAPELI_COLLECTION_H
0008 #define PALAPELI_COLLECTION_H
0009 
0010 #include <QStandardItemModel>
0011 
0012 class KConfig;
0013 class KConfigGroup;
0014 
0015 namespace Palapeli
0016 {
0017     class Puzzle;
0018 
0019     class Collection : public QStandardItemModel
0020     {
0021         Q_OBJECT
0022         public:
0023             enum Roles {
0024                 NameRole = Qt::DisplayRole,
0025                 ThumbnailRole = Qt::DecorationRole,
0026                 CommentRole = Qt::UserRole + 1,
0027                 AuthorRole,
0028                 PieceCountRole,
0029                 IsDeleteableRole,
0030                 IdentifierRole
0031             };
0032 
0033             static Palapeli::Collection* instance(QWidget * = nullptr);
0034             Palapeli::Puzzle* puzzleFromIndex(const QModelIndex& index) const;
0035 
0036             void importPuzzle(Palapeli::Puzzle* puzzle); ///< without copying!
0037             Palapeli::Puzzle* importPuzzle(const QString& path);
0038             void exportPuzzle(const QModelIndex& index, const QString& path);
0039             bool deletePuzzle(const QModelIndex& index);
0040         protected:
0041             Collection(QWidget *);
0042             ~Collection() override;
0043         private:
0044             class Item;
0045 
0046             KConfig* m_config;
0047             KConfigGroup* m_group;
0048     };
0049 }
0050 
0051 #endif // PALAPELI_COLLECTION_H