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