collection.h 1.93 KB
Newer Older
1
/***************************************************************************
2
 *   Copyright 2009-2011 Stefan Majewsky <majewsky@gmx.net>
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 *
 *   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; if not, write to the Free Software
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
***************************************************************************/

19
20
#ifndef PALAPELI_COLLECTION_H
#define PALAPELI_COLLECTION_H
21

Laurent Montel's avatar
Laurent Montel committed
22
#include <QStandardItemModel>
Albert Astals Cid's avatar
Albert Astals Cid committed
23
24
#include <QMutex>

25
26
class KConfig;
class KConfigGroup;
27
28
29

namespace Palapeli
{
30
	class Puzzle;
31

32
	class Collection : public QStandardItemModel
33
	{
34
		Q_OBJECT
35
36
		public:
			enum Roles {
37
38
39
				NameRole = Qt::DisplayRole,
				ThumbnailRole = Qt::DecorationRole,
				CommentRole = Qt::UserRole + 1,
40
				AuthorRole,
41
				PieceCountRole,
42
43
				IsDeleteableRole,
				IdentifierRole
44
45
			};

46
			static Palapeli::Collection* instance(QWidget * = nullptr);
47
			Palapeli::Puzzle* puzzleFromIndex(const QModelIndex& index) const;
48

49
			void importPuzzle(Palapeli::Puzzle* puzzle); ///< without copying!
Stefan Majewsky's avatar
Stefan Majewsky committed
50
51
			Palapeli::Puzzle* importPuzzle(const QString& path);
			void exportPuzzle(const QModelIndex& index, const QString& path);
52
			bool deletePuzzle(const QModelIndex& index);
53
		protected:
54
			Collection(QWidget *);
55
			virtual ~Collection();
56
		private:
57
58
59
60
			class Item;

			KConfig* m_config;
			KConfigGroup* m_group;
61
62
63
	};
}

64
#endif // PALAPELI_COLLECTION_H