45 #include <QPushButton>
49 #define YUILogComponent "qt-pkg"
52 #include "YQPkgStatusFilterView.h"
53 #include "YQIconPool.h"
55 #include "QY2LayoutUtils.h"
60 #define SPACING 6 // between subwidgets
61 #define MARGIN 4 // around the widget
67 QVBoxLayout *layout =
new QVBoxLayout();
70 layout->setMargin( MARGIN );
71 layout->setSpacing( SPACING );
77 QLabel * label =
new QLabel( _(
"Changes Overview" ),
this );
79 label->setFont( YQUI::ui()->headingFont() );
87 QGroupBox * gbox =
new QGroupBox( _(
"Show packages with status" ),
this );
90 QVBoxLayout *box =
new QVBoxLayout;
92 layout->addWidget(gbox);
94 _showDel =
addStatusCheckBox( gbox, _(
"Delete" ), YQIconPool::disabledPkgDel(),
true );
95 _showInstall =
addStatusCheckBox( gbox, _(
"Install" ), YQIconPool::disabledPkgInstall(),
true );
96 _showUpdate =
addStatusCheckBox( gbox, _(
"Update" ), YQIconPool::disabledPkgUpdate(),
true );
97 _showAutoDel =
addStatusCheckBox( gbox, _(
"Autodelete" ), YQIconPool::disabledPkgAutoDel(),
true );
98 _showAutoInstall =
addStatusCheckBox( gbox, _(
"Autoinstall" ), YQIconPool::disabledPkgAutoInstall(),
true );
99 _showAutoUpdate =
addStatusCheckBox( gbox, _(
"Autoupdate" ), YQIconPool::disabledPkgAutoUpdate(),
true );
100 _showTaboo =
addStatusCheckBox( gbox, _(
"Taboo" ), YQIconPool::disabledPkgTaboo(),
true );
101 _showProtected =
addStatusCheckBox( gbox, _(
"Protected" ), YQIconPool::disabledPkgProtected(),
true );
103 box->addSpacing( 8 );
107 _showKeepInstalled =
addStatusCheckBox( gbox, _(
"Keep" ), YQIconPool::disabledPkgKeepInstalled(),
false );
108 _showNoInst =
addStatusCheckBox( gbox, _(
"Do not install" ), YQIconPool::disabledPkgNoInst(),
false );
110 layout->addStretch();
114 QHBoxLayout *hbox =
new QHBoxLayout();
115 layout->addLayout(hbox);
120 _refreshButton =
new QPushButton( _(
"&Refresh List" ),
this );
121 Q_CHECK_PTR( _refreshButton );
122 hbox->addWidget(_refreshButton);
126 connect( _refreshButton, SIGNAL( clicked() ),
127 this, SLOT (
filter() ) );
129 for (
int i=0; i < 6; i++ )
130 layout->addStretch();
143 const QString & text,
144 const QPixmap & icon,
145 bool initiallyChecked )
147 QBoxLayout *layout =
dynamic_cast<QBoxLayout*
>(parent->layout());
149 QHBoxLayout *hbox =
new QHBoxLayout;
150 layout->addLayout(hbox);
152 QCheckBox * checkBox =
new QCheckBox( text, parent );
153 Q_CHECK_PTR( checkBox );
154 checkBox->setChecked( initiallyChecked );
156 hbox->addWidget(checkBox);
158 QLabel * label =
new QLabel( parent );
159 Q_CHECK_PTR( label );
160 label->setPixmap( icon );
162 hbox->addWidget(label);
164 layout->addStretch();
166 connect( checkBox, SIGNAL( clicked() ),
167 this, SLOT (
filter() ) );
176 return QSize( 0, 0 );
193 for ( ZyppPoolIterator it = zyppPkgBegin();
197 ZyppSel selectable = *it;
200 check( selectable, selectable->candidateObj() ) ||
201 check( selectable, selectable->installedObj() );
207 ! selectable->candidateObj() &&
208 ! selectable->installedObj() )
209 check( selectable, selectable->theObj() );
225 switch ( selectable->status() )
227 case S_AutoDel: match = _showAutoDel->isChecked();
break;
228 case S_AutoInstall: match = _showAutoInstall->isChecked();
break;
229 case S_AutoUpdate: match = _showAutoUpdate->isChecked();
break;
230 case S_Del: match = _showDel->isChecked();
break;
231 case S_Install: match = _showInstall->isChecked();
break;
232 case S_KeepInstalled: match = _showKeepInstalled->isChecked();
break;
233 case S_NoInst: match = _showNoInst->isChecked();
break;
234 case S_Protected: match = _showProtected->isChecked();
break;
235 case S_Taboo: match = _showTaboo->isChecked();
break;
236 case S_Update: match = _showUpdate->isChecked();
break;
244 ZyppPkg zyppPkg = tryCastToZyppPkg( zyppObj );
257 _showDel->setChecked(
false );
258 _showInstall->setChecked(
false );
259 _showUpdate->setChecked(
false );
260 _showAutoDel->setChecked(
false );
261 _showAutoInstall->setChecked(
false );
262 _showAutoUpdate->setChecked(
false );
263 _showTaboo->setChecked(
false );
264 _showProtected->setChecked(
false );
265 _showKeepInstalled->setChecked(
false );
266 _showNoInst->setChecked(
false );
279 _showDel->setChecked(
true );
280 _showInstall->setChecked(
true );
281 _showUpdate->setChecked(
true );
287 _showAutoDel->setChecked(
true );
288 _showAutoInstall->setChecked(
true );
289 _showAutoUpdate->setChecked(
true );
295 _showTaboo->setChecked(
true );
296 _showProtected->setChecked(
true );
302 _showKeepInstalled->setChecked(
true );
308 _showNoInst->setChecked(
true );
313 #include "YQPkgStatusFilterView.moc"
void filterStart()
Emitted when the filtering starts.
void filterIfVisible()
Same as filter(), but only if this widget is currently visible.
void filterFinished()
Emitted when filtering is finished.
virtual QSize minimumSizeHint() const
Returns the minimum size required for this widget.
QCheckBox * addStatusCheckBox(QWidget *parent, const QString &label, const QPixmap &icon, bool initiallyChecked)
Add a check box.
virtual ~YQPkgStatusFilterView()
Destructor.
void showManualTransactions()
Set up the check boxes so pending manual transactions (no "auto" states) are displayed.
void showLocks()
Set the check boxes for locked packages ("Taboo" and "Protected") to "on".
void showInstalled()
Set the check box for installed packages to "on".
void showAutoTransactions()
Set up the check boxes so pending automatic transactions (the "auto" states) are displayed.
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
Emitted during filtering for each pkg that matches the filter.
void clear()
Reset all check boxes (set them all to "off")
void showTransactions()
Set up the check boxes so all pending transactions are displayed.
YQPkgStatusFilterView(QWidget *parent)
Constructor.
void filter()
Filter according to the view's rules and current selection.
void showNotInstalled()
Set the check box for not installed packages to "on".
bool check(ZyppSel selectable, ZyppObj pkg)
Check if pkg matches the filter criteria.