1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQPkgConflictList.h
15 Author: Stefan Hundhammer <sh@suse.de>
20 #ifndef YQPkgConflictList_h
21 #define YQPkgConflictList_h
26 #include "QY2ListView.h"
28 #include <zypp/Resolver.h>
29 #include <zypp/ResolverProblem.h>
30 #include <zypp/ProblemSolution.h>
35 class YQPkgConflictResolution;
36 class YQPkgConflictDialog;
40 * @short Display package dependency conflicts in a tree list and let the user
41 * choose how to resolve each conflict.
43 class YQPkgConflictList : public QY2ListView
51 YQPkgConflictList( QWidget * parent );
56 virtual ~YQPkgConflictList();
59 * Fill the list with the specified problems.
61 void fill( zypp::ResolverProblemList problemList );
64 * Check if the conflict list is empty.
66 bool isEmpty() const { return childCount() == 0; }
69 * Returns the number of conflicts in the list.
71 int count() const { return childCount(); }
77 * Apply the choices the user made.
79 void applyResolutions();
82 * Ignore all conflicts.
87 * Ask for a file name and save the current conflict list to file.
89 void askSaveToFile() const;
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.
99 * Posts error popups if 'interactive' is 'true' (only log entries
102 void saveToFile( const QString filename, bool interactive ) const;
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
109 * If 'header' is not empty, it will be added as the parent of the lines.
111 static void dumpList( Q3ListViewItem * parent,
112 const QString & longText,
113 const QString & header = QString::null,
114 int splitThreshold = 5 );
119 * (Recursively) save one item to file.
121 void saveItemToFile( FILE * file, const Q3ListViewItem * item ) const;
127 * Update package states - they may have changed.
129 void updatePackages();
135 * @short Root item for each individual conflict
137 class YQPkgConflict: public QY2ListViewItem
144 YQPkgConflict( YQPkgConflictList * parentList,
145 zypp::ResolverProblem_Ptr problem );
150 virtual ~YQPkgConflict() {}
153 * Returns the corresponding ResolverProblem.
155 zypp::ResolverProblem_Ptr problem() const { return _problem; }
158 * Returns the resolution the user selected
159 * or 0 if he didn't select one
161 zypp::ProblemSolution_Ptr userSelectedResolution();
167 * Format the text heading line for this item.
169 void formatHeading();
172 * Add suggestions how to resolve this conflict.
177 * Paint method. Reimplemented from @ref QListViewItem so a different
180 * Reimplemented from QY2ListViewItem.
182 virtual void paintCell( QPainter * painter,
183 const QColorGroup & colorGroup,
191 zypp::ResolverProblem_Ptr _problem;
192 QY2CheckListItem * _resolutionsHeader;
197 class YQPkgConflictResolution: public QY2CheckListItem
204 YQPkgConflictResolution( QY2CheckListItem * parent,
205 zypp::ProblemSolution_Ptr _solution );
208 * Return the corresponding ProblemSolution.
210 zypp::ProblemSolution_Ptr solution() const { return _solution; }
217 zypp::ProblemSolution_Ptr _solution;
221 #endif // ifndef YQPkgConflictList_h