1 /*
2  Copyright (C) 2010-2014 Kristian Duske
3 
4  This file is part of TrenchBroom.
5 
6  TrenchBroom is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  TrenchBroom is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef TrenchBroom_IssueBrowserView
21 #define TrenchBroom_IssueBrowserView
22 
23 #include "View/ViewTypes.h"
24 
25 #include "Model/Issue.h"
26 #include "Model/ModelTypes.h"
27 
28 #include <wx/listctrl.h>
29 
30 #include <vector>
31 
32 class wxWindow;
33 
34 namespace TrenchBroom {
35     namespace View {
36         class IssueBrowserView : public wxListCtrl {
37         private:
38             static const int ShowIssuesCommandId = 1;
39             static const int HideIssuesCommandId = 2;
40             static const int FixObjectsBaseId = 3;
41 
42             typedef std::vector<size_t> IndexList;
43 
44             MapDocumentWPtr m_document;
45             Model::IssueList m_issues;
46 
47             Model::IssueType m_hiddenGenerators;
48             bool m_showHiddenIssues;
49         public:
50             IssueBrowserView(wxWindow* parent, MapDocumentWPtr document);
51 
52             int hiddenGenerators() const;
53             void setHiddenGenerators(int hiddenGenerators);
54             void setShowHiddenIssues(bool show);
55             void reset();
56 
57             void OnSize(wxSizeEvent& event);
58 
59             void OnItemRightClick(wxListEvent& event);
60             void OnItemSelectionChanged(wxListEvent& event);
61             void OnShowIssues(wxCommandEvent& event);
62             void OnHideIssues(wxCommandEvent& event);
63             void OnApplyQuickFix(wxCommandEvent& event);
64         private:
65             class IssueVisible;
66             class IssueCmp;
67 
68             void updateIssues();
69 
70             Model::IssueList collectIssues(const IndexList& indices) const;
71             Model::IssueQuickFixList collectQuickFixes(const IndexList& indices) const;
72             Model::IssueType issueTypeMask() const;
73 
74             void setIssueVisibility(bool show);
75 
76             void updateSelection();
77             IndexList getSelection() const;
78 
79             wxListItemAttr* OnGetItemAttr(long item) const;
80             wxString OnGetItemText(long item, long column) const;
81 
82             void bindEvents();
83         };
84     }
85 }
86 
87 #endif /* defined(TrenchBroom_IssueBrowserView) */
88