xref: /haiku/src/servers/package/ProblemWindow.h (revision bab64f65bb775dc23060e276f1f1c4498ab7af6c)
1 /*
2  * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef PROBLEM_WINDOW_H
6 #define PROBLEM_WINDOW_H
7 
8 
9 #include <map>
10 #include <set>
11 
12 #include <Window.h>
13 
14 
15 namespace BPackageKit {
16 	class BSolver;
17 	class BSolverPackage;
18 	class BSolverProblem;
19 	class BSolverProblemSolution;
20 	class BSolverProblemSolutionElement;
21 }
22 
23 using BPackageKit::BSolver;
24 using BPackageKit::BSolverPackage;
25 using BPackageKit::BSolverProblem;
26 using BPackageKit::BSolverProblemSolution;
27 using BPackageKit::BSolverProblemSolutionElement;
28 
29 class BButton;
30 class BGroupView;
31 class BRadioButton;
32 
33 
34 class ProblemWindow : public BWindow {
35 public:
36 			typedef std::set<BSolverPackage*> SolverPackageSet;
37 
38 public:
39 								ProblemWindow();
40 	virtual						~ProblemWindow();
41 
42 			bool				Go(BSolver* solver,
43 									const SolverPackageSet& packagesAddedByUser,
44 									const SolverPackageSet&
45 										packagesRemovedByUser);
46 
47 	virtual	bool				QuitRequested();
48 	virtual	void				MessageReceived(BMessage* message);
49 
50 private:
51 			struct Solution;
52 
53 			typedef std::map<BRadioButton*, Solution> SolutionMap;
54 
55 private:
56 			void				_ClearProblemsGui();
57 			void				_AddProblemsGui(BSolver* solver);
58 			void				_AddProblem(BSolverProblem* problem,
59 									const float backgroundTint);
60 			BString				_SolutionElementText(
61 									const BSolverProblemSolutionElement*
62 										element) const;
63 			bool				_AnySolutionSelected() const;
64 
65 private:
66 			sem_id				fDoneSemaphore;
67 			bool				fClientWaiting;
68 			bool				fAccepted;
69 			BGroupView*			fContainerView;
70 			BButton*			fCancelButton;
71 			BButton*			fRetryButton;
72 			SolutionMap			fSolutions;
73 			const SolverPackageSet* fPackagesAddedByUser;
74 			const SolverPackageSet* fPackagesRemovedByUser;
75 };
76 
77 
78 #endif	// PROBLEM_WINDOW_H
79