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 65 : QScrollArea( parent )
67 QWidget * content =
new QWidget;
68 QVBoxLayout *layout =
new QVBoxLayout();
69 content->setLayout(layout);
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" ), content );
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" ), content );
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();
132 setWidgetResizable(
true);
146 const QString & text,
147 const QPixmap & icon,
148 bool initiallyChecked )
150 QBoxLayout *layout =
dynamic_cast<QBoxLayout*
>(parent->layout());
152 QHBoxLayout *hbox =
new QHBoxLayout;
153 layout->addLayout(hbox);
155 QCheckBox * checkBox =
new QCheckBox( text, parent );
156 Q_CHECK_PTR( checkBox );
157 checkBox->setChecked( initiallyChecked );
159 hbox->addWidget(checkBox);
161 QLabel * label =
new QLabel( parent );
162 Q_CHECK_PTR( label );
163 label->setPixmap( icon );
165 hbox->addWidget(label);
167 layout->addStretch();
169 connect( checkBox, SIGNAL( clicked() ),
170 this, SLOT (
filter() ) );
179 return QSize( 0, 0 );
196 for ( ZyppPoolIterator it = zyppPkgBegin();
200 ZyppSel selectable = *it;
203 check( selectable, selectable->candidateObj() ) ||
204 check( selectable, selectable->installedObj() );
210 ! selectable->candidateObj() &&
211 ! selectable->installedObj() )
212 check( selectable, selectable->theObj() );
228 switch ( selectable->status() )
230 case S_AutoDel: match = _showAutoDel->isChecked();
break;
231 case S_AutoInstall: match = _showAutoInstall->isChecked();
break;
232 case S_AutoUpdate: match = _showAutoUpdate->isChecked();
break;
233 case S_Del: match = _showDel->isChecked();
break;
234 case S_Install: match = _showInstall->isChecked();
break;
235 case S_KeepInstalled: match = _showKeepInstalled->isChecked();
break;
236 case S_NoInst: match = _showNoInst->isChecked();
break;
237 case S_Protected: match = _showProtected->isChecked();
break;
238 case S_Taboo: match = _showTaboo->isChecked();
break;
239 case S_Update: match = _showUpdate->isChecked();
break;
247 ZyppPkg zyppPkg = tryCastToZyppPkg( zyppObj );
260 _showDel->setChecked(
false );
261 _showInstall->setChecked(
false );
262 _showUpdate->setChecked(
false );
263 _showAutoDel->setChecked(
false );
264 _showAutoInstall->setChecked(
false );
265 _showAutoUpdate->setChecked(
false );
266 _showTaboo->setChecked(
false );
267 _showProtected->setChecked(
false );
268 _showKeepInstalled->setChecked(
false );
269 _showNoInst->setChecked(
false );
282 _showDel->setChecked(
true );
283 _showInstall->setChecked(
true );
284 _showUpdate->setChecked(
true );
290 _showAutoDel->setChecked(
true );
291 _showAutoInstall->setChecked(
true );
292 _showAutoUpdate->setChecked(
true );
298 _showTaboo->setChecked(
true );
299 _showProtected->setChecked(
true );
305 _showKeepInstalled->setChecked(
true );
311 _showNoInst->setChecked(
true );
316 #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.
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.
virtual QSize minimumSizeHint() const
Returns the minimum size required for this widget.
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.