]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgConflictList.h
make the layout half way working at least
[duncan/yast2-qt4.git] / src / pkg / YQPkgConflictList.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQPkgConflictList.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #ifndef YQPkgConflictList_h
21 #define YQPkgConflictList_h
22
23
24 #include <stdio.h>
25 #include <qmap.h>
26 #include "QY2ListView.h"
27
28 #include <zypp/Resolver.h>
29 #include <zypp/ResolverProblem.h>
30 #include <zypp/ProblemSolution.h>
31
32
33 class Q3Action;
34 class YQPkgConflict;
35 class YQPkgConflictResolution;
36 class YQPkgConflictDialog;
37
38
39 /**
40  * @short Display package dependency conflicts in a tree list and let the user
41  * choose how to resolve each conflict.
42  **/
43 class YQPkgConflictList : public QY2ListView
44 {
45     Q_OBJECT
46
47 public:
48     /**
49      * Constructor.
50      **/
51     YQPkgConflictList( QWidget * parent );
52
53     /**
54      * Destructor.
55      **/
56     virtual ~YQPkgConflictList();
57
58     /**
59      * Fill the list with the specified problems.
60      **/
61     void fill( zypp::ResolverProblemList problemList );
62
63     /**
64      * Check if the conflict list is empty.
65      **/
66     bool isEmpty() const { return topLevelItemCount() == 0; }
67
68     /**
69      * Returns the number of conflicts in the list.
70      **/
71     int count() const { return topLevelItemCount(); }
72
73
74 public slots:
75
76     /**
77      * Apply the choices the user made.
78      **/
79     void applyResolutions();
80
81     /**
82      * Ignore all conflicts.
83      **/
84     void ignoreAll();
85
86     /**
87      * Ask for a file name and save the current conflict list to file.
88      **/
89     void askSaveToFile() const;
90
91
92 public:
93
94     /**
95      * Save the conflict list in its current state to a file. Retains the
96      * current 'expanded' state, i.e. writes only those entries that are
97      * currently open (not collapsed) in the tree.
98      *
99      * Posts error popups if 'interactive' is 'true' (only log entries
100      * otherwise).
101      **/
102     void saveToFile( const QString filename, bool interactive ) const;
103
104     /**
105      * Dump a multi-line text to a QListView as a sequence of separate items.
106      * If 'longText' has considerably more lines than 'splitThreshold', fold
107      * all lines from no. 'splitThreshold' on into a closed list item
108      * "More...".
109      * If 'header' is not empty, it will be added as the parent of the lines.
110      **/
111     static void dumpList( QTreeWidgetItem *     parent,
112                           const QString &       longText,
113                           const QString &       header = QString::null,
114                           int                   splitThreshold = 3 );
115
116 protected:
117
118     /**
119      * (Recursively) save one item to file.
120      **/
121     void saveItemToFile( FILE * file, const QTreeWidgetItem * item ) const;
122
123
124 signals:
125
126     /**
127      * Update package states - they may have changed.
128      **/
129     void updatePackages();
130 };
131
132
133
134 /**
135  * @short Root item for each individual conflict
136  **/
137 class YQPkgConflict: public QY2ListViewItem
138 {
139 public:
140
141     /**
142      * Constructor.
143      **/
144     YQPkgConflict( YQPkgConflictList *          parentList,
145                    zypp::ResolverProblem_Ptr    problem );
146
147     /**
148      * Destructor.
149      **/
150     virtual ~YQPkgConflict() {}
151
152     /**
153      * Returns the corresponding ResolverProblem.
154      **/
155     zypp::ResolverProblem_Ptr problem() const { return _problem; }
156
157     /**
158      * Returns the resolution the user selected
159      * or 0 if he didn't select one
160      **/
161     zypp::ProblemSolution_Ptr userSelectedResolution();
162
163
164 protected:
165
166     /**
167      * Format the text heading line for this item.
168      **/
169     void formatHeading();
170
171     /**
172      * Add suggestions how to resolve this conflict.
173      **/
174     void addSolutions();
175
176     /**
177      * Paint method. Reimplemented from @ref QListViewItem so a different
178      * font can be used.
179      *
180      * Reimplemented from QY2ListViewItem.
181      **/
182 //     virtual void paintCell( QPainter *               painter,
183 //                          const QColorGroup & colorGroup,
184 //                          int                 column,
185 //                          int                 width,
186 //                          int                 alignment );
187
188
189     // Data members
190
191     zypp::ResolverProblem_Ptr   _problem;
192     QY2CheckListItem *          _resolutionsHeader;
193 };
194
195
196
197 class YQPkgConflictResolution: public QY2CheckListItem
198 {
199 public:
200
201     /**
202      * Constructor
203      **/
204     YQPkgConflictResolution( QY2CheckListItem *         parent,
205                              zypp::ProblemSolution_Ptr  _solution );
206
207     /**
208      * Return the corresponding ProblemSolution.
209      **/
210     zypp::ProblemSolution_Ptr solution() const { return _solution; }
211
212
213 protected:
214
215     // Data members
216
217     zypp::ProblemSolution_Ptr   _solution;
218 };
219
220
221 #endif // ifndef YQPkgConflictList_h