libyui-qt-pkg  2.45.6
YQPkgConflictList.h
1 /**************************************************************************
2 Copyright (C) 2000 - 2010 Novell, Inc.
3 All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 
19 **************************************************************************/
20 
21 
22 /*---------------------------------------------------------------------\
23 | |
24 | __ __ ____ _____ ____ |
25 | \ \ / /_ _/ ___|_ _|___ \ |
26 | \ V / _` \___ \ | | __) | |
27 | | | (_| |___) || | / __/ |
28 | |_|\__,_|____/ |_| |_____| |
29 | |
30 | core system |
31 | (C) SuSE GmbH |
32 \----------------------------------------------------------------------/
33 
34  File: YQPkgConflictList.h
35 
36  Author: Stefan Hundhammer <sh@suse.de>
37 
38 /-*/
39 
40 
41 #ifndef YQPkgConflictList_h
42 #define YQPkgConflictList_h
43 
44 
45 #include <stdio.h>
46 #include <QMap>
47 #include <QFile>
48 #include <QScrollArea>
49 
50 #include <zypp/Resolver.h>
51 #include <zypp/ResolverProblem.h>
52 #include <zypp/ProblemSolution.h>
53 
54 class QVBoxLayout;
55 class QRadioButton;
56 class QAction;
57 class YQPkgConflict;
58 class YQPkgConflictResolution;
60 
61 
62 /**
63  * @short Display package dependency conflicts in a tree list and let the user
64  * choose how to resolve each conflict.
65  **/
66 class YQPkgConflictList : public QScrollArea
67 {
68  Q_OBJECT
69 
70 public:
71  /**
72  * Constructor.
73  **/
74  YQPkgConflictList( QWidget * parent );
75 
76  /**
77  * Destructor.
78  **/
79  virtual ~YQPkgConflictList();
80 
81  /**
82  * Fill the list with the specified problems.
83  **/
84  void fill( zypp::ResolverProblemList problemList );
85 
86  /**
87  * Check if the conflict list is empty.
88  **/
89  bool isEmpty() const { return count() == 0; }
90 
91  /**
92  * Returns the number of conflicts in the list.
93  **/
94  int count() const { return _conflicts.count(); }
95 
96 
97 public slots:
98 
99  /**
100  * Apply the choices the user made.
101  **/
102  void applyResolutions();
103 
104  /**
105  * Ask for a file name and save the current conflict list to file.
106  **/
107  void askSaveToFile() const;
108 
109  void clear();
110 
111  void relayout();
112 
113 public:
114 
115  /**
116  * Save the conflict list in its current state to a file. Retains the
117  * current 'expanded' state, i.e. writes only those entries that are
118  * currently open (not collapsed) in the tree.
119  *
120  * Posts error popups if 'interactive' is 'true' (only log entries
121  * otherwise).
122  **/
123  void saveToFile( const QString filename, bool interactive ) const;
124 
125 protected:
126 
127  QList<YQPkgConflict*> _conflicts;
128  QVBoxLayout *_layout;
129 
130 signals:
131 
132  /**
133  * Update package states - they may have changed.
134  **/
135  void updatePackages();
136 
137 };
138 
139 
140 
141 /**
142  * @short Root item for each individual conflict
143  **/
144 class YQPkgConflict: public QFrame
145 {
146  Q_OBJECT
147 
148 public:
149 
150  /**
151  * Constructor.
152  **/
153  YQPkgConflict( QWidget * parent,
154  zypp::ResolverProblem_Ptr problem );
155 
156  /**
157  * Destructor.
158  **/
159  virtual ~YQPkgConflict() {}
160 
161  /**
162  * Returns the corresponding ResolverProblem.
163  **/
164  zypp::ResolverProblem_Ptr problem() const { return _problem; }
165 
166  /**
167  * Returns the resolution the user selected
168  * or 0 if he didn't select one
169  **/
170  zypp::ProblemSolution_Ptr userSelectedResolution();
171 
172  /**
173  * save one item to file.
174  **/
175  void saveToFile( QFile &file ) const;
176 
177 
178 protected slots:
179 
180  void detailsExpanded();
181 
182 signals:
183 
184  void expanded();
185 
186 protected:
187 
188  /**
189  * Format the text heading line for this item.
190  **/
191  void formatHeading();
192 
193  /**
194  * Add suggestions how to resolve this conflict.
195  **/
196  void addSolutions();
197 
198  //
199  // Data members
200  //
201 
202  zypp::ResolverProblem_Ptr _problem;
203  QLabel * _resolutionsHeader;
204  QList<zypp::ProblemSolution_Ptr> _resolutions;
205  QMap<QRadioButton *, zypp::ProblemSolution_Ptr> _solutions;
206  QMap<QLabel *, zypp::ProblemSolution_Ptr> _details;
207  QVBoxLayout * _layout;
208 };
209 
210 #endif // ifndef YQPkgConflictList_h
YQPkgConflictList(QWidget *parent)
Constructor.
void applyResolutions()
Apply the choices the user made.
Display package dependency conflicts in a tree list and let the user choose how to resolve each confl...
void saveToFile(const QString filename, bool interactive) const
Save the conflict list in its current state to a file.
bool isEmpty() const
Check if the conflict list is empty.
virtual ~YQPkgConflict()
Destructor.
zypp::ResolverProblem_Ptr problem() const
Returns the corresponding ResolverProblem.
int count() const
Returns the number of conflicts in the list.
virtual ~YQPkgConflictList()
Destructor.
void askSaveToFile() const
Ask for a file name and save the current conflict list to file.
void fill(zypp::ResolverProblemList problemList)
Fill the list with the specified problems.
Root item for each individual conflict.
Dialog that takes care of dependency checking and resolving conflicts.
void updatePackages()
Update package states - they may have changed.