1 /*
2  * Copyright (C) 2006-2019 Christopho, Solarus - http://www.solarus-games.org
3  *
4  * Solarus Quest Editor is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Solarus Quest Editor is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #ifndef SOLARUS_GUI_QUESTS_VIEW_H
18 #define SOLARUS_GUI_QUESTS_VIEW_H
19 
20 #include "solarus/gui/gui_common.h"
21 #include "solarus/core/QuestProperties.h"
22 #include <QSortFilterProxyModel>
23 #include <QTableView>
24 
25 namespace SolarusGui {
26 
27 class QuestsModel;
28 class QuestsItemDelegate;
29 
30 /**
31  * @brief A widget where the user can select a quest.
32  */
33 class SOLARUS_GUI_API QuestsView : public QTableView {
34 
35 public:
36 
37   QuestsView(QWidget* parent = nullptr);
38 
39   int path_to_index(const QString& path) const;
40   QString index_to_path(int index) const;
41 
42   int get_num_quests() const;
43   QStringList get_paths() const;
44   bool has_quest(const QString& path);
45   bool add_quest(const QString& path);
46   bool remove_quest(int index);
47 
48   Solarus::QuestProperties get_selected_quest_properties() const;
49   Solarus::QuestProperties get_quest_properties(int index) const;
50 
51   const QPixmap& get_selected_logo() const;
52   const QPixmap& get_quest_logo(int index) const;
53 
54   int get_selected_index() const;
55   QString get_selected_path() const;
56   void select_quest(int index);
57   void select_quest(const QString& path);
58 
59 private:
60 
61   QuestsModel* quests_model;
62   QSortFilterProxyModel* proxy_model;
63   QuestsItemDelegate* item_delegate;
64 };
65 
66 }
67 
68 #endif
69