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);
101 iconLabel->setPixmap( QApplication::style().stylePixmap( QStyle::SP_MessageBoxInformation ) );
103 iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) );
106 QLabel * label =
new QLabel( message,
this );
107 Q_CHECK_PTR( label );
108 hbox->addWidget(label);
109 label->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
111 _filter =
new QComboBox(
this);
114 _filter->addItem(_(
"All"), QVariant::fromValue(Filters(FilterAll)));
115 _filter->addItem(_(
"Selected by the user"), QVariant::fromValue(Filters(FilterUser)));
116 _filter->addItem(_(
"Automatic Changes"), QVariant::fromValue(Filters(FilterAutomatic)));
118 _filter->setCurrentIndex(0);
120 layout->addWidget(_filter);
121 connect( _filter, SIGNAL(currentIndexChanged(
int)),
127 Q_CHECK_PTR( _pkgList );
130 layout->addWidget( _pkgList );
135 hbox =
new QHBoxLayout();
137 layout->addLayout( hbox );
142 QPushButton * button =
new QPushButton( acceptButtonLabel,
this );
143 Q_CHECK_PTR( button );
144 hbox->addWidget( button );
145 button->setDefault(
true );
147 connect( button, SIGNAL( clicked() ),
148 this, SLOT ( accept() ) );
152 if ( ! rejectButtonLabel.isEmpty() )
156 button =
new QPushButton( rejectButtonLabel,
this );
157 Q_CHECK_PTR( button );
158 hbox->addWidget(button);
159 connect( button, SIGNAL( clicked() ),
160 this, SLOT ( reject() ) );
169 filter( QRegExp(
"" ), f );
175 yuiMilestone() <<
"filter index changed to: " << index << endl;
176 QVariant v = _filter->itemData(index);
178 if ( v.isValid() && v.canConvert<Filters>() )
180 Filters f = v.value<Filters>();
185 yuiError() <<
"Can't find filter for index " << index << endl;
199 yuiMilestone() <<
"filter changed to: " << f << endl;
202 for (
int k = 0; k < _filter->count(); ++k )
204 QVariant v = _filter->itemData(k);
205 if ( v.isValid() && v.canConvert<Filters>() )
208 Filters setf = v.value<Filters>();
217 _filter->blockSignals(
true);
219 _filter->setCurrentIndex(f);
220 _filter->blockSignals(
false);
225 yuiError() <<
"Can't find index for filter " << f << endl;
233 YQUI::ui()->busyCursor();
236 bool byAuto = f.testFlag(FilterAutomatic);
237 bool byUser = f.testFlag(FilterUser);
238 bool byApp = f.testFlag(FilterUser);
240 int discard_regex = 0;
241 int discard_ignored = 0;
242 int discard_extra = 0;
243 int discard_notmodified = 0;
244 int discard_whomodified = 0;
246 set<string> ignoredNames;
248 if ( ! byUser || ! byApp )
249 ignoredNames = zypp::ui::userWantedPackageNames();
251 for ( ZyppPoolIterator it = zyppPkgBegin();
255 ZyppSel selectable = *it;
257 if ( selectable->toModify() )
259 zypp::ResStatus::TransactByValue modifiedBy = selectable->modifiedBy();
261 if ( ( ( modifiedBy == zypp::ResStatus::SOLVER ) && byAuto ) ||
262 ( ( modifiedBy == zypp::ResStatus::APPL_LOW ||
263 modifiedBy == zypp::ResStatus::APPL_HIGH ) && byApp ) ||
264 ( ( modifiedBy == zypp::ResStatus::USER ) && byUser ) )
266 if ( regexp.isEmpty()
267 || regexp.indexIn( selectable->name().c_str() ) >= 0 )
269 if ( ! contains( ignoredNames, selectable->name() ) )
271 ZyppPkg pkg = tryCastToZyppPkg( selectable->theObj() );
278 { discard_ignored++; }
284 { discard_whomodified++; }
288 { discard_notmodified++; }
292 yuiMilestone() <<
"Filter result summary: " << endl;
293 yuiMilestone() <<
"Discarded by extra filter: " << discard_extra << endl;
294 yuiMilestone() <<
"Discarded by ignored: " << discard_ignored << endl;
295 yuiMilestone() <<
"Discarded by regex: " << discard_regex << endl;
296 yuiMilestone() <<
"Discarded because not modified: " << discard_notmodified << endl;
297 yuiMilestone() <<
"Discarded by who modified: " << discard_whomodified << endl;
298 YQUI::ui()->normalCursor();
310 return _pkgList->topLevelItemCount() == 0;
317 return limitToScreenSize(
this, QDialog::sizeHint() );
323 const QString & message,
324 const QString & acceptButtonLabel,
325 const QString & rejectButtonLabel,
336 if ( dialog.
isEmpty() && o.testFlag(OptionAutoAcceptIfEmpty) )
338 yuiMilestone() <<
"No items to show in changes dialog, accepting it automatically" << endl;
345 return dialog.result() == QDialog::Accepted;
351 const QString & message,
352 const QRegExp & regexp,
353 const QString & acceptButtonLabel,
354 const QString & rejectButtonLabel,
364 if ( dialog.
isEmpty() && o.testFlag(OptionAutoAcceptIfEmpty) )
366 yuiMilestone() <<
"No items to show in dialog, accepting it automatically" << endl;
372 return dialog.result() == QDialog::Accepted;
376 const QString & message,
377 const QString & acceptButtonLabel,
378 const QString & rejectButtonLabel )
388 yuiDebug() <<
"UNSUPPORTED PKG: " << pkg << endl;
389 return pkg->maybeUnsupported() && sel->toInstall();
394 const QString & message,
395 const QString & acceptButtonLabel,
396 const QString & rejectButtonLabel,
407 if ( dialog.
isEmpty() && o.testFlag(OptionAutoAcceptIfEmpty) )
409 yuiMilestone() <<
"No items to show in unsupported packages dialog, accepting it automatically" << endl;
415 return dialog.result() == QDialog::Accepted;
419 #include "YQPkgChangesDialog.moc" 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...