42 #define YUILogComponent "qt-pkg" 45 #include <QApplication> 46 #include <QDesktopWidget> 49 #include <QPushButton> 54 #include <zypp/ResStatus.h> 55 #include <zypp/VendorSupportOptions.h> 56 #include <zypp/ui/UserWantedPackages.h> 58 #include "YQPkgChangesDialog.h" 59 #include "YQPkgList.h" 60 #include "QY2LayoutUtils.h" 69 const QString & message,
70 const QString & acceptButtonLabel,
71 const QString & rejectButtonLabel )
76 setWindowTitle( _(
"Changed Packages" ) );
79 setSizeGripEnabled(
true );
82 setMaximumSize( qApp->desktop()->availableGeometry().size() );
86 QVBoxLayout * layout =
new QVBoxLayout();
87 Q_CHECK_PTR( layout );
90 QHBoxLayout * hbox =
new QHBoxLayout();
92 layout->addLayout( hbox );
97 QLabel * iconLabel =
new QLabel(
this );
98 Q_CHECK_PTR( iconLabel );
99 hbox->addWidget(iconLabel);
100 iconLabel->setPixmap( YQUI::ui()->loadIcon(
"dialog-information" ).pixmap(64) );
101 iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) );
104 QLabel * label =
new QLabel( message,
this );
105 Q_CHECK_PTR( label );
106 hbox->addWidget(label);
107 label->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
109 _filter =
new QComboBox(
this);
112 _filter->addItem(_(
"All"), QVariant::fromValue(Filters(FilterAll)));
113 _filter->addItem(_(
"Selected by the user"), QVariant::fromValue(Filters(FilterUser)));
114 _filter->addItem(_(
"Automatic Changes"), QVariant::fromValue(Filters(FilterAutomatic)));
116 _filter->setCurrentIndex(0);
118 layout->addWidget(_filter);
119 connect( _filter, SIGNAL(currentIndexChanged(
int)),
125 Q_CHECK_PTR( _pkgList );
128 layout->addWidget( _pkgList );
133 hbox =
new QHBoxLayout();
135 layout->addLayout( hbox );
140 QPushButton * button =
new QPushButton( acceptButtonLabel,
this );
141 Q_CHECK_PTR( button );
142 hbox->addWidget( button );
143 button->setDefault(
true );
145 connect( button, SIGNAL( clicked() ),
146 this, SLOT ( accept() ) );
150 if ( ! rejectButtonLabel.isEmpty() )
154 button =
new QPushButton( rejectButtonLabel,
this );
155 Q_CHECK_PTR( button );
156 hbox->addWidget(button);
157 connect( button, SIGNAL( clicked() ),
158 this, SLOT ( reject() ) );
167 filter( QRegExp(
"" ), f );
173 yuiMilestone() <<
"filter index changed to: " << index << endl;
174 QVariant v = _filter->itemData(index);
176 if ( v.isValid() && v.canConvert<Filters>() )
178 Filters f = v.value<Filters>();
183 yuiError() <<
"Can't find filter for index " << index << endl;
197 yuiMilestone() <<
"filter changed to: " << f << endl;
200 for (
int k = 0; k < _filter->count(); ++k )
202 QVariant v = _filter->itemData(k);
203 if ( v.isValid() && v.canConvert<Filters>() )
206 Filters setf = v.value<Filters>();
215 _filter->blockSignals(
true);
217 _filter->setCurrentIndex(f);
218 _filter->blockSignals(
false);
223 yuiError() <<
"Can't find index for filter " << f << endl;
231 YQUI::ui()->busyCursor();
234 bool byAuto = f.testFlag(FilterAutomatic);
235 bool byUser = f.testFlag(FilterUser);
236 bool byApp = f.testFlag(FilterUser);
238 int discard_regex = 0;
239 int discard_ignored = 0;
240 int discard_extra = 0;
241 int discard_notmodified = 0;
242 int discard_whomodified = 0;
244 set<string> ignoredNames;
246 if ( ! byUser || ! byApp )
247 ignoredNames = zypp::ui::userWantedPackageNames();
249 for ( ZyppPoolIterator it = zyppPkgBegin();
253 ZyppSel selectable = *it;
255 if ( selectable->toModify() )
257 zypp::ResStatus::TransactByValue modifiedBy = selectable->modifiedBy();
259 if ( ( ( modifiedBy == zypp::ResStatus::SOLVER ) && byAuto ) ||
260 ( ( modifiedBy == zypp::ResStatus::APPL_LOW ||
261 modifiedBy == zypp::ResStatus::APPL_HIGH ) && byApp ) ||
262 ( ( modifiedBy == zypp::ResStatus::USER ) && byUser ) )
264 if ( regexp.isEmpty()
265 || regexp.indexIn( selectable->name().c_str() ) >= 0 )
267 if ( ! contains( ignoredNames, selectable->name() ) )
269 ZyppPkg pkg = tryCastToZyppPkg( selectable->theObj() );
276 { discard_ignored++; }
282 { discard_whomodified++; }
286 { discard_notmodified++; }
290 yuiMilestone() <<
"Filter result summary: " << endl;
291 yuiMilestone() <<
"Discarded by extra filter: " << discard_extra << endl;
292 yuiMilestone() <<
"Discarded by ignored: " << discard_ignored << endl;
293 yuiMilestone() <<
"Discarded by regex: " << discard_regex << endl;
294 yuiMilestone() <<
"Discarded because not modified: " << discard_notmodified << endl;
295 yuiMilestone() <<
"Discarded by who modified: " << discard_whomodified << endl;
296 YQUI::ui()->normalCursor();
308 return _pkgList->topLevelItemCount() == 0;
315 return limitToScreenSize(
this, QDialog::sizeHint() );
321 const QString & message,
322 const QString & acceptButtonLabel,
323 const QString & rejectButtonLabel,
334 if ( dialog.
isEmpty() && o.testFlag(OptionAutoAcceptIfEmpty) )
336 yuiMilestone() <<
"No items to show in changes dialog, accepting it automatically" << endl;
343 return dialog.result() == QDialog::Accepted;
349 const QString & message,
350 const QRegExp & regexp,
351 const QString & acceptButtonLabel,
352 const QString & rejectButtonLabel,
362 if ( dialog.
isEmpty() && o.testFlag(OptionAutoAcceptIfEmpty) )
364 yuiMilestone() <<
"No items to show in dialog, accepting it automatically" << endl;
370 return dialog.result() == QDialog::Accepted;
374 const QString & message,
375 const QString & acceptButtonLabel,
376 const QString & rejectButtonLabel )
386 yuiDebug() <<
"UNSUPPORTED PKG: " << pkg << endl;
387 return pkg->maybeUnsupported() && sel->toInstall();
392 const QString & message,
393 const QString & acceptButtonLabel,
394 const QString & rejectButtonLabel,
405 if ( dialog.
isEmpty() && o.testFlag(OptionAutoAcceptIfEmpty) )
407 yuiMilestone() <<
"No items to show in unsupported packages dialog, accepting it automatically" << endl;
413 return dialog.result() == QDialog::Accepted;
void setFilter(Filters f)
Set the current filter This will change the combo box current selected filter and update the list...
void addPkgItem(ZyppSel selectable, ZyppPkg zyppPkg)
Add a pkg to the list.
virtual bool extraFilter(ZyppSel sel, ZyppPkg pkg)
extra filter for child classes
void slotFilterChanged(int index)
called when the filter is changed
Changes dialog: Show a dialog with a list of packages that are changed.
bool isEmpty() const
Returns 'true' if the pkg list is empty.
virtual QSize sizeHint() const
Returns the preferred size.
void setEditable(bool editable=true)
Set the list's editable status.
Display a list of zypp::Package objects.
YQPkgUnsupportedPackagesDialog(QWidget *parent, const QString &message, const QString &acceptButtonLabel, const QString &rejectButtonLabel=QString::null)
Constructor: Creates a changes dialog with text 'message' on top, a list packages with an "auto" stat...
void clear()
Clears the tree-widgets content, resets the optimal column width values.
YQPkgChangesDialog(QWidget *parent, const QString &message, const QString &acceptButtonLabel, const QString &rejectButtonLabel=QString::null)
Constructor: Creates a changes dialog with text 'message' on top, a list packages with an "auto" stat...
virtual bool extraFilter(ZyppSel sel, ZyppPkg pkg)
leave supported packages out.
static bool showChangesDialog(QWidget *parent, const QString &message, const QString &acceptButtonLabel, const QString &rejectButtonLabel=QString::null, Filters f=FilterAutomatic, Options o=OptionAutoAcceptIfEmpty)
Static convenience method: Post a changes dialog with text 'message', a list of changed packages and ...
static bool showUnsupportedPackagesDialog(QWidget *parent, const QString &message, const QString &acceptButtonLabel, const QString &rejectButtonLabel=QString::null, Filters f=FilterAutomatic, Options o=OptionAutoAcceptIfEmpty)
Static convenience method: Post a changes dialog with text 'message', a list of changed packages and ...
void filter(Filters f=FilterAutomatic)
Apply the filter criteria: Fill the pkg list with pkgs that have a "modify" status ( install...