30
30
#include <KpkStrings.h>
31
31
#include <KpkIcons.h>
33
35
#define UNIVERSAL_PADDING 6
35
KpkAddRm::KpkAddRm( QWidget *parent )
36
: QWidget( parent ),m_mTransRuning(false), m_findIcon("edit-find"),
37
m_cancelIcon("dialog-cancel")
37
KCONFIGGROUP_DECLARE_ENUM_QOBJECT(Client, Filter)
39
KpkAddRm::KpkAddRm(QWidget *parent)
40
: QWidget(parent), m_currentAction(0), m_mTransRuning(false), m_findIcon("edit-find"),
41
m_cancelIcon("dialog-cancel"), m_filterIcon("view-filter")
46
gridLayout_2->addWidget(toolBar = new QToolBar);
47
toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
49
Client::instance()->setLocale(KGlobal::locale()->language() + "." + KGlobal::locale()->encoding());
41
51
// Create a new daemon
42
52
m_client = Client::instance();
44
54
//initialize the model, delegate, client and connect it's signals
45
packageView->setItemDelegate(pkg_delegate = new KpkDelegate(this));
46
packageView->setModel( m_pkg_model_main = new KpkPackageModel(this, packageView) );
55
packageView->setItemDelegate(pkg_delegate = new KpkDelegate(packageView));
56
packageView->setModel(m_pkg_model_main = new KpkPackageModel(this, packageView));
47
57
packageView->viewport()->setAttribute(Qt::WA_Hover);
49
59
// check to see if the backend support these actions
50
60
m_actions = m_client->getActions();
51
if ( m_actions.contains(Client::ActionInstallPackages) || m_actions.contains(Client::ActionRemovePackages) )
52
connect( m_pkg_model_main, SIGNAL( dataChanged(const QModelIndex, const QModelIndex) ), this, SLOT( checkChanged() ) );
54
if ( m_actions.contains(Client::ActionGetDetails) )
55
connect(this, SIGNAL( getInfo(PackageKit::Package *) ), this, SLOT( getDetails(PackageKit::Package *) ) );
57
tabWidget->setTabEnabled(0, false);
59
if ( m_actions.contains(Client::ActionGetFiles) )
60
connect(this, SIGNAL( getInfo(PackageKit::Package *) ), this, SLOT( getFiles(PackageKit::Package *) ) );
62
tabWidget->setTabEnabled(1, false);
64
if ( m_actions.contains(Client::ActionGetDepends) ) {
65
dependsOnLV->setModel( m_pkg_model_dep = new KpkPackageModel(this, packageView) );
66
connect(this, SIGNAL( getInfo(PackageKit::Package *) ), this, SLOT( getDepends(PackageKit::Package *) ) );
69
tabWidget->setTabEnabled(2, false);
71
if ( m_actions.contains(Client::ActionGetRequires) ) {
72
requiredByLV->setModel( m_pkg_model_req = new KpkPackageModel(this, packageView ));
73
connect(this, SIGNAL( getInfo(PackageKit::Package *) ), this, SLOT( getRequires(PackageKit::Package *) ) );
76
tabWidget->setTabEnabled(3, false);
78
if ( !m_actions.contains(Client::ActionSearchName) )
79
findPB->setEnabled(false);
81
if ( !m_actions.contains(Client::ActionSearchGroup) )
61
if (m_actions.contains(Client::ActionInstallPackages) || m_actions.contains(Client::ActionRemovePackages)) {
62
connect(m_pkg_model_main, SIGNAL(dataChanged(const QModelIndex, const QModelIndex)),
63
this, SLOT(checkChanged()) );
66
m_findMenu = new QMenu(this);
68
// find is just a generic name in case we don't have any search method
69
m_genericActionK = new KToolBarPopupAction(m_findIcon, i18n("Find"), this);
70
toolBar->addAction(m_genericActionK);
72
// Add actions that the backend supports
73
if (m_actions.contains(Client::ActionSearchName)) {
74
m_findMenu->addAction(actionFindName);
75
setCurrentAction(actionFindName);
77
if (m_actions.contains(Client::ActionSearchDetails)) {
78
m_findMenu->addAction(actionFindDescription);
79
if (!m_currentAction) {
80
setCurrentAction(actionFindDescription);
83
if (m_actions.contains(Client::ActionSearchFile)) {
84
m_findMenu->addAction(actionFindFile);
85
if (!m_currentAction) {
86
setCurrentAction(actionFindFile);
90
// If no action was set we can't use this search
91
if (m_currentAction == 0) {
92
m_genericActionK->setEnabled(false);
94
// Check to see if we need the KToolBarPopupAction
95
if (m_findMenu->actions().size() > 1) {
96
m_currentAction->setVisible(false);
97
m_genericActionK->setMenu(m_findMenu);
99
toolBar->removeAction(m_genericActionK);
100
toolBar->addAction(m_currentAction);
102
connect(m_genericActionK, SIGNAL(triggered()),
103
this, SLOT(genericActionKTriggered()));
106
if (!m_actions.contains(Client::ActionSearchGroup)) {
82
107
groupsCB->setEnabled(false);
84
110
//initialize the groups
85
foreach (Client::Group group, m_client->getGroups() ) {
86
groupsCB->addItem( KpkIcons::groupsIcon(group), KpkStrings::groups(group), group );
111
// TODO add non selectable groups if Client::ActionSearchGroup
113
foreach (Client::Group group, m_client->getGroups()) {
114
groupsCB->addItem(KpkIcons::groupsIcon(group), KpkStrings::groups(group), group);
89
117
// install the backend filters
90
filterMenu( m_client->getFilters() );
93
connect( &m_notifyT, SIGNAL( timeout() ), this, SLOT( notifyUpdate() ) );
95
// set fucus on the search lineEdit
118
filterMenu(m_client->getFilters());
119
filtersTB->setIcon(m_filterIcon);
121
// set focus on the search lineEdit
96
122
searchKLE->setFocus(Qt::OtherFocusReason);
97
findPB->setDefault(true);
98
findPB->setIcon(m_findIcon);
100
// hides the description to have more space.
101
descriptionDW->setVisible(false);
123
transactionBar->setBehaviors(KpkTransactionBar::AutoHide);
126
void KpkAddRm::genericActionKTriggered()
128
m_currentAction->trigger();
131
void KpkAddRm::setCurrentAction(QAction *action)
134
// just load the new action if it changes this
135
// also ensures that our menu has more than one action
136
if (m_currentAction != action) {
137
// ensures the current action was created
138
if (m_currentAction) {
139
m_currentAction->setVisible(true);
141
m_currentAction = action;
142
// hides the item from the list
143
m_currentAction->setVisible(false);
144
// copy data from the curront action
145
m_genericActionK->setText(m_currentAction->text());
146
m_genericActionK->setIcon(m_currentAction->icon());
150
void KpkAddRm::setActionsDefaults()
152
actionFindName->setText(i18n("Find by &Name"));
153
actionFindFile->setText(i18n("Find by f&ile name"));
154
actionFindDescription->setText(i18n("Find by &description"));
155
// Define actions icon
156
actionFindFile->setIcon(m_findIcon);
157
actionFindDescription->setIcon(m_findIcon);
158
actionFindName->setIcon(m_findIcon);
159
if (m_currentAction) {
160
m_genericActionK->setText(m_currentAction->text());
161
actionFindName->setIcon(m_currentAction->icon());
105
165
void KpkAddRm::checkChanged()
107
if (m_pkg_model_main->selectedPackages().size()>0)
167
if (m_pkg_model_main->selectedPackages().size() > 0) {
108
168
emit changed(true);
110
170
emit changed(false);
113
void KpkAddRm::getDetails(PackageKit::Package *p)
115
// create the description transaction
116
Transaction *t = m_client->getDetails(p);
117
connect( t, SIGNAL(details(PackageKit::Package *) ),
118
this, SLOT( description(PackageKit::Package *) ) );
119
connect( t, SIGNAL( finished(PackageKit::Transaction::ExitStatus, uint) ),
120
this, SLOT( getInfoFinished(PackageKit::Transaction::ExitStatus, uint) ) );
123
void KpkAddRm::getFiles(PackageKit::Package *p)
125
// create the files transaction
126
Transaction *t = m_client->getFiles(p);
127
connect( t, SIGNAL( files(PackageKit::Package *, const QStringList &) ),
128
this, SLOT( files(PackageKit::Package *, const QStringList &) ) );
129
connect( t, SIGNAL( finished(PackageKit::Transaction::ExitStatus, uint) ),
130
this, SLOT( getInfoFinished(PackageKit::Transaction::ExitStatus, uint) ) );
133
void KpkAddRm::getDepends(PackageKit::Package *p)
135
// create a transaction for the dependecies, and its model.
136
Transaction *t = m_client->getDepends(p);
137
m_pkg_model_dep->clear();
138
connect( t, SIGNAL( package(PackageKit::Package *) ),
139
m_pkg_model_dep, SLOT( addPackage(PackageKit::Package *) ) );
140
connect( t, SIGNAL( finished(PackageKit::Transaction::ExitStatus, uint) ),
141
this, SLOT( getInfoFinished(PackageKit::Transaction::ExitStatus, uint) ) );
144
void KpkAddRm::getRequires(PackageKit::Package *p)
146
// create a transaction for the requirements, and its model.
147
Transaction *t = m_client->getRequires(p);
148
m_pkg_model_req->clear();
149
connect( t, SIGNAL( package(PackageKit::Package *) ),
150
m_pkg_model_req, SLOT( addPackage(PackageKit::Package *) ) );
151
connect( t, SIGNAL( finished(PackageKit::Transaction::ExitStatus, uint) ),
152
this, SLOT( getInfoFinished(PackageKit::Transaction::ExitStatus, uint) ) );
155
void KpkAddRm::getInfoFinished(PackageKit::Transaction::ExitStatus status, uint runtime)
158
if (status == Transaction::Success)
159
descriptionDW->setVisible(true);
162
void KpkAddRm::on_packageView_pressed( const QModelIndex & index )
164
if ( index.column() == 0 ) {
174
void KpkAddRm::on_packageView_pressed(const QModelIndex &index)
176
if (index.column() == 0) {
165
177
Package *p = m_pkg_model_main->package(index);
179
if (pkg_delegate->isExtended(index)) {
180
pkg_delegate->contractItem(index);
182
pkg_delegate->extendItem(new KpkPackageDetails(p, m_actions), index);
171
void KpkAddRm::statusChanged(PackageKit::Transaction::Status status)
174
notifyL->setText( KpkStrings::status(status) );
175
busyPB->setMaximum(0);
178
void KpkAddRm::progressChanged(PackageKit::Transaction::ProgressInfo info)
180
busyPB->setMaximum(100);
181
busyPB->setValue(info.percentage);
184
188
void KpkAddRm::errorCode(PackageKit::Client::ErrorType error, const QString &details)
186
KMessageBox::detailedSorry( this, KpkStrings::errorMessage(error), details, KpkStrings::error(error), KMessageBox::Notify );
189
void KpkAddRm::resizeEvent ( QResizeEvent * event )
191
QWidget::resizeEvent(event);
192
updateColumnsWidth();
195
bool KpkAddRm::event ( QEvent * event )
197
switch (event->type()) {
199
case QEvent::PolishRequest:
201
updateColumnsWidth(true);
206
return QWidget::event(event);
209
void KpkAddRm::updateColumnsWidth(bool force)
211
int m_viewWidth = packageView->viewport()->width();
214
m_viewWidth -= style()->pixelMetric(QStyle::PM_ScrollBarExtent) + UNIVERSAL_PADDING;
217
packageView->setColumnWidth(0, pkg_delegate->columnWidth(0, m_viewWidth));
218
packageView->setColumnWidth(1, pkg_delegate->columnWidth(1, m_viewWidth));
190
KMessageBox::detailedSorry(this, KpkStrings::errorMessage(error), details, KpkStrings::error(error), KMessageBox::Notify);
221
193
KpkAddRm::~KpkAddRm()
225
void KpkAddRm::on_findPB_clicked()
227
if ( m_mTransRuning ) {
228
m_pkClient_main->cancel();
230
else if ( !searchKLE->text().isEmpty() ) {
232
m_searchAction = Client::ActionSearchName;
233
m_searchString = searchKLE->text();
234
m_searchFilters = filters();
235
// select "All Packages"
236
groupsCB->setCurrentIndex(0);
237
// create the main transaction
242
void KpkAddRm::on_groupsCB_currentIndexChanged( int index )
244
if ( groupsCB->itemData( index, Qt::UserRole ).isValid() ) {
246
m_searchAction = Client::ActionSearchGroup;
247
m_searchGroup = (Client::Group) groupsCB->itemData( index, Qt::UserRole ).toUInt();
248
m_searchFilters = filters();
249
// create the main transaction
195
KConfig config("KPackageKit");
196
KConfigGroup filterMenuGroup(&config, "FilterMenu");
198
kDebug() << "Saving filters settings";
200
// filterMenuGroup.writeEntry("OnlyNewestPackages", m_actionNewestOnly->isChecked());
201
// filterMenuGroup.writeEntry("HideSubpackages", m_actionBasename->isChecked());
202
// This entry does not depend on the backend it's ok to call this pointer
203
filterMenuGroup.writeEntry("ViewInGroups", m_actionViewInGroups->isChecked());
204
// We call filters so we can save all of them, although i'm not sure
205
// most people will want to save them
206
// TODO make the filter bold when it's has not the default filters
207
// this way people can see that their old filter were loaded
208
// writeEntry(filterMenuGroup, "SelectedFilters", Client::FilterNotCollections);
209
// writeEntry(filterMenuGroup, "SelectedFilters", filters().toList());
212
void KpkAddRm::on_actionFindName_triggered()
215
setCurrentAction(actionFindName);
216
if (m_mTransRuning) {
217
m_pkClient_main->cancel();
218
} else if (!searchKLE->text().isEmpty()) {
220
m_searchAction = Client::ActionSearchName;
221
m_searchString = searchKLE->text();
222
m_searchFilters = filters();
223
// select "All Packages"
224
groupsCB->setCurrentIndex(0);
225
// create the main transaction
230
void KpkAddRm::on_actionFindDescription_triggered()
233
setCurrentAction(actionFindDescription);
234
if (m_mTransRuning) {
235
m_pkClient_main->cancel();
236
} else if (!searchKLE->text().isEmpty()) {
238
m_searchAction = Client::ActionSearchDetails;
239
m_searchString = searchKLE->text();
240
m_searchFilters = filters();
241
// select "All Packages"
242
groupsCB->setCurrentIndex(0);
243
// create the main transaction
248
void KpkAddRm::on_actionFindFile_triggered()
251
setCurrentAction(actionFindFile);
252
if (m_mTransRuning) {
253
m_pkClient_main->cancel();
254
} else if (!searchKLE->text().isEmpty()) {
256
m_searchAction = Client::ActionSearchFile;
257
m_searchString = searchKLE->text();
258
m_searchFilters = filters();
259
// select "All Packages"
260
groupsCB->setCurrentIndex(0);
261
// create the main transaction
266
void KpkAddRm::on_groupsCB_currentIndexChanged(int index)
268
if (groupsCB->itemData(index, Qt::UserRole).isValid()) {
270
m_searchAction = Client::ActionSearchGroup;
271
m_searchGroup = (Client::Group) groupsCB->itemData(index, Qt::UserRole).toUInt();
272
m_searchFilters = filters();
273
// create the main transaction
254
278
void KpkAddRm::search()
257
if ( m_searchAction == Client::ActionSearchGroup )
258
m_pkClient_main = m_client->searchGroup( m_searchGroup, m_searchFilters );
259
else if ( m_searchAction == Client::ActionSearchName )
260
m_pkClient_main = m_client->searchName( m_searchString, m_searchFilters );
281
if (m_searchAction == Client::ActionSearchName) {
282
m_pkClient_main = m_client->searchName(m_searchString, m_searchFilters );
283
} else if (m_searchAction == Client::ActionSearchDetails) {
284
m_pkClient_main = m_client->searchDetails(m_searchString, m_searchFilters);
285
} else if (m_searchAction == Client::ActionSearchFile) {
286
m_pkClient_main = m_client->searchFile(m_searchString, m_searchFilters);
287
} else if (m_searchAction == Client::ActionSearchGroup) {
288
m_pkClient_main = m_client->searchGroup(m_searchGroup, m_searchFilters);
290
kWarning() << "Search type not implemented yet";
261
294
connectTransaction(m_pkClient_main);
262
statusChanged( m_pkClient_main->status() );
263
// hides the description to have more space.
264
descriptionDW->setVisible(false);
295
transactionBar->addTransaction(m_pkClient_main);
296
// contract and delete and details widgets
297
pkg_delegate->contractAll();
266
298
// cleans the models
267
299
m_pkg_model_main->clear();
268
busyPB->setMaximum(0);
270
300
m_mTransRuning = true;
271
findPB->setText( i18n("&Cancel") );
272
findPB->setIcon(m_cancelIcon);
273
findPB->setEnabled(false);
276
303
void KpkAddRm::connectTransaction(Transaction *transaction)
278
connect( transaction, SIGNAL( package(PackageKit::Package *)),
279
m_pkg_model_main, SLOT( addPackage(PackageKit::Package *)) );
280
connect( transaction, SIGNAL( finished(PackageKit::Transaction::ExitStatus, uint)),
281
this, SLOT( finished(PackageKit::Transaction::ExitStatus, uint)) );
282
connect( transaction, SIGNAL( errorCode(PackageKit::Client::ErrorType, const QString&) ),
283
this, SLOT( errorCode(PackageKit::Client::ErrorType, const QString &) ) );
284
connect( transaction, SIGNAL( message(PackageKit::Client::MessageType, const QString&) ),
285
this, SLOT( message(PackageKit::Client::MessageType, const QString &) ) );
286
connect( transaction, SIGNAL( statusChanged(PackageKit::Transaction::Status) ),
287
this, SLOT( statusChanged(PackageKit::Transaction::Status) ) );
288
connect( transaction, SIGNAL( allowCancelChanged(bool) ),
289
findPB, SLOT( setEnabled(bool) ) );
290
connect( transaction, SIGNAL( progressChanged(PackageKit::Transaction::ProgressInfo) ),
291
this, SLOT( progressChanged(PackageKit::Transaction::ProgressInfo) ) );
305
connect(transaction, SIGNAL(package(PackageKit::Package *)),
306
m_pkg_model_main, SLOT(addPackage(PackageKit::Package *)));
307
connect(transaction, SIGNAL(finished(PackageKit::Transaction::ExitStatus, uint)),
308
this, SLOT(finished(PackageKit::Transaction::ExitStatus, uint)));
309
connect(transaction, SIGNAL(errorCode(PackageKit::Client::ErrorType, const QString &)),
310
this, SLOT(errorCode(PackageKit::Client::ErrorType, const QString &)));
294
313
void KpkAddRm::message(PackageKit::Client::MessageType message, const QString &details)
315
335
void KpkAddRm::finished(PackageKit::Transaction::ExitStatus status, uint runtime)
319
busyPB->setMaximum(100);
320
busyPB->setValue(100);
321
339
m_mTransRuning = false;
322
findPB->setEnabled(true);
323
findPB->setText( i18n("&Find") );
324
findPB->setIcon(m_findIcon);
326
case Transaction::Success :
327
notifyL->setText(i18n("Search finished in %1", KGlobal::locale()->formatDuration(runtime)) );
328
teste.setColor( QPalette::Normal, QPalette::Window, QColor(0,255,0,150));
329
notifyL->setPalette(teste);
330
notifyL->setAutoFillBackground(true);
331
m_notifyT.start(100);
333
case Transaction::Failed :
334
notifyL->setText(i18n("Search failed"));
335
teste.setColor(QPalette::Normal, QPalette::Window, QColor(255,0,0,150));
336
notifyL->setPalette(teste);
337
notifyL->setAutoFillBackground(true);
340
case Transaction::Cancelled :
341
notifyL->setText(i18n("Search canceled"));
342
teste.setColor( QPalette::Normal, QPalette::Window, QColor(0,255,0,150));
343
notifyL->setPalette(teste);
344
notifyL->setAutoFillBackground(true);
345
m_notifyT.start(100);
347
case Transaction::KeyRequired :
348
notifyL->setText(i18n("Search finished in %1",KGlobal::locale()->formatDuration(runtime)) );
349
teste.setColor( QPalette::Normal, QPalette::Window, QColor(0,255,0,150));
350
notifyL->setPalette(teste);
351
notifyL->setAutoFillBackground(true);
352
m_notifyT.start(100);
354
case Transaction::EulaRequired :
355
notifyL->setText(i18n("Search finished in %1", KGlobal::locale()->formatDuration(runtime)) );
356
teste.setColor( QPalette::Normal, QPalette::Window, QColor(0,255,0,150));
357
notifyL->setPalette(teste);
358
notifyL->setAutoFillBackground(true);
359
m_notifyT.start(100);
361
case Transaction::Killed :
362
notifyL->setText(i18n("Search killed"));
363
teste.setColor( QPalette::Normal, QPalette::Window, QColor(0,255,0,150));
364
notifyL->setPalette(teste);
365
notifyL->setAutoFillBackground(true);
366
m_notifyT.start(100);
368
case Transaction::UnknownExitStatus :
369
notifyL->setText(i18n("Search finished with unknown status"));
370
teste.setColor( QPalette::Normal, QPalette::Window, QColor(0,255,0,150));
371
notifyL->setPalette(teste);
372
notifyL->setAutoFillBackground(true);
373
m_notifyT.start(100);
378
void KpkAddRm::notifyUpdate()
380
QPalette palleteN(notifyL->palette());
381
QColor colorN(palleteN.color(QPalette::Normal, QPalette::Window));
382
if ( colorN.alpha() <= 0 ) {
384
notifyL->setAutoFillBackground(false);
388
colorN.setAlpha(colorN.alpha() - 5);
389
palleteN.setColor(QPalette::Normal, QPalette::Window, colorN);
390
notifyL->setPalette(palleteN);
394
void KpkAddRm::description(PackageKit::Package *p)
396
//format and show description
397
Package::Details *details = p->details();
399
description += "<b>" + i18n("Package Name") + ":</b> " + p->name() + "<br />";
400
if ( details->license() != Package::UnknownLicense )
401
description += "<b>" + i18n("License") + ":</b> " + details->license() + "<br />";
402
if ( details->group() != Client::UnknownGroup )
403
description += "<b>" + i18n("Group") + ":</b> " +
404
KpkStrings::groups( details->group() ) + "<br />";
405
if ( !details->description().isEmpty() )
406
description += "<b>" + i18n("Details") + ":</b> " + details->description() + "<br />";
407
if ( !details->url().isEmpty() )
408
description += "<b>" + i18n("Home Page") + ":</b> <a href=\"" + details->url() + "\">" + details->url() + "</a><br />";
409
if ( details->size() > 0 )
410
description += "<b>" + i18n("Size") + ":</b> " + KGlobal::locale()->formatByteSize( details->size() );
411
descriptionKTB->setHtml(description);
414
void KpkAddRm::files(PackageKit::Package *package, const QStringList &files)
418
for (int i = 0; i < files.size(); ++i)
419
filesPTE->appendPlainText(files.at(i));
422
342
void KpkAddRm::filterMenu(Client::Filters filters)
424
344
m_filtersQM = new QMenu(this);
425
345
filtersTB->setMenu(m_filtersQM);
427
if(!filters.isEmpty()) {
347
// Loads the filter menu settings
348
KConfig config("KPackageKit");
349
KConfigGroup filterMenuGroup(&config, "FilterMenu");
351
if (!filters.isEmpty()) {
428
352
if (filters.contains(Client::FilterCollections) || filters.contains(Client::FilterNotCollections)) {
429
353
QMenu *menuCollections = new QMenu(i18n("Collections"), m_filtersQM);
430
354
m_filtersQM->addMenu(menuCollections);
431
355
QActionGroup *collectionGroup = new QActionGroup(menuCollections);
432
356
collectionGroup->setExclusive(true);
434
358
QAction *collectionTrue = new QAction(i18n("Only collections"), collectionGroup);
435
359
collectionTrue->setCheckable(true);
436
360
m_filtersAction[collectionTrue] = Client::FilterCollections;
437
361
collectionGroup->addAction(collectionTrue);
438
362
menuCollections->addAction(collectionTrue);
439
363
actions << collectionTrue;
441
365
QAction *collectionFalse = new QAction(i18n("Exclude collections"), collectionGroup);
442
366
collectionFalse->setCheckable(true);
443
367
m_filtersAction[collectionFalse] = Client::FilterNotCollections;
651
575
m_filtersQM->addSeparator();
652
576
QAction *newest = new QAction(i18n("Only newest packages"), m_filtersQM);
653
577
newest->setCheckable(true);
654
newest->setToolTip( i18n("Only show the newest available package") );
655
m_filtersAction[newest] = Client::FilterNewest;
578
newest->setToolTip( i18n("Only show the newest available package") );
579
m_filtersAction[newest] = Client::FilterNewest;
656
580
m_filtersQM->addAction(newest);
658
582
actions << newest;
661
585
m_filtersQM->addSeparator();
664
//filtersTB->setDisabled(true);
588
m_actionViewInGroups = new QAction(i18n("View in groups"), m_filtersQM);
589
m_actionViewInGroups->setCheckable(true);
590
m_filtersQM->addAction(m_actionViewInGroups);
591
m_actionViewInGroups->setToolTip(i18n("Display packages in groups according to status"));
592
if (filterMenuGroup.readEntry("ViewInGroups", false)) {
593
m_pkg_model_main->setGrouped(true);
594
packageViewSetRootIsDecorated(true);
595
m_actionViewInGroups->setChecked(true);
666
QAction *groupResults = new QAction(i18n("View in groups"), m_filtersQM);
667
groupResults->setCheckable(true);
668
m_filtersQM->addAction(groupResults);
669
groupResults->setToolTip( i18n("Display packages in groups according to status") );
670
connect(groupResults, SIGNAL( toggled(bool) ), m_pkg_model_main, SLOT( setGrouped(bool) ) );
671
connect(groupResults, SIGNAL( toggled(bool) ), this, SLOT( packageViewSetRootIsDecorated(bool) ) );
598
connect(m_actionViewInGroups, SIGNAL(toggled(bool)),
599
m_pkg_model_main, SLOT(setGrouped(bool)));
600
connect(m_actionViewInGroups, SIGNAL(toggled(bool)),
601
this, SLOT(packageViewSetRootIsDecorated(bool)));
674
604
void KpkAddRm::packageViewSetRootIsDecorated(bool value)
606
// contract and delete and details widgets
607
pkg_delegate->contractAll();
676
608
packageView->setRootIsDecorated(value);
679
611
Client::Filters KpkAddRm::filters()
681
613
Client::Filters buffer;
682
for(int i = 0 ; i < actions.size() ; ++i) {
683
if( actions.at(i)->isChecked() )
684
if( m_filtersAction.contains( actions.at(i) ))
685
buffer << m_filtersAction[ actions.at(i) ];
687
if(buffer.size() == 0) buffer << Client::NoFilter;
688
return m_searchFilters = buffer;
614
for (int i = 0 ; i < actions.size(); ++i) {
615
if (actions.at(i)->isChecked()) {
616
if (m_filtersAction.contains(actions.at(i))) {
617
buffer << m_filtersAction[actions.at(i)];
621
if (buffer.size() == 0) {
622
buffer << Client::NoFilter;
624
return m_searchFilters = buffer;
627
void KpkAddRm::resizeEvent(QResizeEvent *event)
629
QWidget::resizeEvent(event);
630
updateColumnsWidth();
633
bool KpkAddRm::event(QEvent *event)
635
switch (event->type()) {
636
case QEvent::KeyPress:
637
// use bracktes to don't cross initialization og keyEvent
639
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
640
if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) {
641
// special tab handling here
642
m_currentAction->trigger();
648
case QEvent::PolishRequest:
650
updateColumnsWidth(true);
655
return QWidget::event(event);
658
void KpkAddRm::updateColumnsWidth(bool force)
660
int m_viewWidth = packageView->viewport()->width();
663
m_viewWidth -= style()->pixelMetric(QStyle::PM_ScrollBarExtent) + UNIVERSAL_PADDING;
666
packageView->setColumnWidth(0, pkg_delegate->columnWidth(0, m_viewWidth));
667
packageView->setColumnWidth(1, pkg_delegate->columnWidth(1, m_viewWidth));
691
670
#include "KpkAddRm.moc"