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
27 #include "QY2ListView.h"
29 #include <zypp/Resolver.h>
30 #include <zypp/ResolverProblem.h>
31 #include <zypp/ProblemSolution.h>
36 class YQPkgConflictResolution;
37 class YQPkgConflictDialog;
41 * @short Display package dependency conflicts in a tree list and let the user
42 * choose how to resolve each conflict.
44 class YQPkgConflictList : public QY2ListView
52 YQPkgConflictList( QWidget * parent );
57 virtual ~YQPkgConflictList();
60 * Fill the list with the specified problems.
62 void fill( zypp::ResolverProblemList problemList );
65 * Check if the conflict list is empty.
67 bool isEmpty() const { return topLevelItemCount() == 0; }
70 * Returns the number of conflicts in the list.
72 int count() const { return topLevelItemCount(); }
78 * Apply the choices the user made.
80 void applyResolutions();
83 * Ignore all conflicts.
88 * Ask for a file name and save the current conflict list to file.
90 void askSaveToFile() const;
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.
100 * Posts error popups if 'interactive' is 'true' (only log entries
103 void saveToFile( const QString filename, bool interactive ) const;
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
110 * If 'header' is not empty, it will be added as the parent of the lines.
112 static void dumpList( QTreeWidgetItem * parent,
113 const QString & longText,
114 const QString & header = QString::null,
115 int splitThreshold = 3 );
120 * (Recursively) save one item to file.
122 void saveItemToFile( QFile &file, const QTreeWidgetItem * item ) const;
128 * Update package states - they may have changed.
130 void updatePackages();
136 * @short Root item for each individual conflict
138 class YQPkgConflict: public QY2ListViewItem
145 YQPkgConflict( YQPkgConflictList * parentList,
146 zypp::ResolverProblem_Ptr problem );
151 virtual ~YQPkgConflict() {}
154 * Returns the corresponding ResolverProblem.
156 zypp::ResolverProblem_Ptr problem() const { return _problem; }
159 * Returns the resolution the user selected
160 * or 0 if he didn't select one
162 zypp::ProblemSolution_Ptr userSelectedResolution();
168 * Format the text heading line for this item.
170 void formatHeading();
173 * Add suggestions how to resolve this conflict.
178 * Paint method. Reimplemented from @ref QListViewItem so a different
181 * Reimplemented from QY2ListViewItem.
183 // virtual void paintCell( QPainter * painter,
184 // const QColorGroup & colorGroup,
192 zypp::ResolverProblem_Ptr _problem;
193 QY2CheckListItem * _resolutionsHeader;
198 class YQPkgConflictResolution: public QY2CheckListItem
205 YQPkgConflictResolution( QY2CheckListItem * parent,
206 zypp::ProblemSolution_Ptr _solution );
209 * Return the corresponding ProblemSolution.
211 zypp::ProblemSolution_Ptr solution() const { return _solution; }
218 zypp::ProblemSolution_Ptr _solution;
222 #endif // ifndef YQPkgConflictList_h