~ubuntu-branches/ubuntu/jaunty/kpackagekit/jaunty

« back to all changes in this revision

Viewing changes to AddRm/KpkAddRm.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2009-02-24 11:16:02 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090224111602-cskv8iurzafe9x0x
Tags: 0.4-0ubuntu1
* New upstream release
* Fixed kubuntu_01_editsources.patches to apply correctly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include <KpkStrings.h>
31
31
#include <KpkIcons.h>
32
32
 
 
33
#include <KDebug>
 
34
 
33
35
#define UNIVERSAL_PADDING 6
34
36
 
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)
 
38
 
 
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")
38
42
{
39
43
    setupUi( this );
40
44
 
 
45
    // create our toolbar
 
46
    gridLayout_2->addWidget(toolBar = new QToolBar);
 
47
    toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
 
48
 
 
49
    Client::instance()->setLocale(KGlobal::locale()->language() + "." + KGlobal::locale()->encoding());
 
50
 
41
51
    // Create a new daemon
42
52
    m_client = Client::instance();
43
53
 
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);
48
58
 
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() ) );
53
 
 
54
 
    if ( m_actions.contains(Client::ActionGetDetails) )
55
 
        connect(this, SIGNAL( getInfo(PackageKit::Package *) ), this, SLOT( getDetails(PackageKit::Package *) ) );
56
 
    else
57
 
        tabWidget->setTabEnabled(0, false);
58
 
 
59
 
    if ( m_actions.contains(Client::ActionGetFiles) )
60
 
        connect(this, SIGNAL( getInfo(PackageKit::Package *) ), this, SLOT( getFiles(PackageKit::Package *) ) );
61
 
    else
62
 
        tabWidget->setTabEnabled(1, false);
63
 
 
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 *) ) );
67
 
    }
68
 
    else
69
 
        tabWidget->setTabEnabled(2, false);
70
 
 
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 *) ) );
74
 
    }
75
 
    else
76
 
        tabWidget->setTabEnabled(3, false);
77
 
 
78
 
    if ( !m_actions.contains(Client::ActionSearchName) )
79
 
        findPB->setEnabled(false);
80
 
 
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()) );
 
64
    }
 
65
 
 
66
    m_findMenu = new QMenu(this);
 
67
    setActionsDefaults();
 
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);
 
71
 
 
72
    // Add actions that the backend supports
 
73
    if (m_actions.contains(Client::ActionSearchName)) {
 
74
        m_findMenu->addAction(actionFindName);
 
75
        setCurrentAction(actionFindName);
 
76
    }
 
77
    if (m_actions.contains(Client::ActionSearchDetails)) {
 
78
        m_findMenu->addAction(actionFindDescription);
 
79
        if (!m_currentAction) {
 
80
            setCurrentAction(actionFindDescription);
 
81
        }
 
82
    }
 
83
    if (m_actions.contains(Client::ActionSearchFile)) {
 
84
        m_findMenu->addAction(actionFindFile);
 
85
        if (!m_currentAction) {
 
86
            setCurrentAction(actionFindFile);
 
87
        }
 
88
    }
 
89
 
 
90
    // If no action was set we can't use this search
 
91
    if (m_currentAction == 0) {
 
92
        m_genericActionK->setEnabled(false);
 
93
    } else {
 
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);
 
98
        } else {
 
99
            toolBar->removeAction(m_genericActionK);
 
100
            toolBar->addAction(m_currentAction);
 
101
        }
 
102
        connect(m_genericActionK, SIGNAL(triggered()),
 
103
                this, SLOT(genericActionKTriggered()));
 
104
    }
 
105
 
 
106
    if (!m_actions.contains(Client::ActionSearchGroup)) {
82
107
        groupsCB->setEnabled(false);
 
108
    }
83
109
 
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
 
112
    // is not supported
 
113
    foreach (Client::Group group, m_client->getGroups()) {
 
114
        groupsCB->addItem(KpkIcons::groupsIcon(group), KpkStrings::groups(group), group);
87
115
    }
88
116
 
89
117
    // install the backend filters
90
 
    filterMenu( m_client->getFilters() );
91
 
 
92
 
    // connect the notify
93
 
    connect( &m_notifyT, SIGNAL( timeout() ), this, SLOT( notifyUpdate() ) );
94
 
 
95
 
    // set fucus on the search lineEdit
 
118
    filterMenu(m_client->getFilters());
 
119
    filtersTB->setIcon(m_filterIcon);
 
120
 
 
121
    // set focus on the search lineEdit
96
122
    searchKLE->setFocus(Qt::OtherFocusReason);
97
 
    findPB->setDefault(true);
98
 
    findPB->setIcon(m_findIcon);
99
 
 
100
 
    // hides the description to have more space.
101
 
    descriptionDW->setVisible(false);
102
 
    notifyF->hide();
 
123
    transactionBar->setBehaviors(KpkTransactionBar::AutoHide);
 
124
}
 
125
 
 
126
void KpkAddRm::genericActionKTriggered()
 
127
{
 
128
    m_currentAction->trigger();
 
129
}
 
130
 
 
131
void KpkAddRm::setCurrentAction(QAction *action)
 
132
{
 
133
    kDebug();
 
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);
 
140
        }
 
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());
 
147
    }
 
148
}
 
149
 
 
150
void KpkAddRm::setActionsDefaults()
 
151
{
 
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());
 
162
    }
103
163
}
104
164
 
105
165
void KpkAddRm::checkChanged()
106
166
{
107
 
    if (m_pkg_model_main->selectedPackages().size()>0)
 
167
    if (m_pkg_model_main->selectedPackages().size() > 0) {
108
168
      emit changed(true);
109
 
    else
 
169
    } else {
110
170
      emit changed(false);
111
 
}
112
 
 
113
 
void KpkAddRm::getDetails(PackageKit::Package *p)
114
 
{
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) ) );
121
 
}
122
 
 
123
 
void KpkAddRm::getFiles(PackageKit::Package *p)
124
 
{
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) ) );
131
 
}
132
 
 
133
 
void KpkAddRm::getDepends(PackageKit::Package *p)
134
 
{
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) ) );
142
 
}
143
 
 
144
 
void KpkAddRm::getRequires(PackageKit::Package *p)
145
 
{  
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) ) );
153
 
}
154
 
 
155
 
void KpkAddRm::getInfoFinished(PackageKit::Transaction::ExitStatus status, uint runtime)
156
 
{
157
 
    Q_UNUSED(runtime);
158
 
    if (status == Transaction::Success)
159
 
        descriptionDW->setVisible(true);
160
 
}
161
 
 
162
 
void KpkAddRm::on_packageView_pressed( const QModelIndex & index )
163
 
{
164
 
    if ( index.column() == 0 ) {
 
171
    }
 
172
}
 
173
 
 
174
void KpkAddRm::on_packageView_pressed(const QModelIndex &index)
 
175
{
 
176
    if (index.column() == 0) {
165
177
        Package *p = m_pkg_model_main->package(index);
166
 
        if (p)
167
 
            emit getInfo(p);
 
178
        if (p) {
 
179
            if (pkg_delegate->isExtended(index)) {
 
180
                pkg_delegate->contractItem(index);
 
181
            } else {
 
182
                pkg_delegate->extendItem(new KpkPackageDetails(p, m_actions), index);
 
183
            }
 
184
        }
168
185
    }
169
186
}
170
187
 
171
 
void KpkAddRm::statusChanged(PackageKit::Transaction::Status status)
172
 
{
173
 
    notifyF->show();
174
 
    notifyL->setText( KpkStrings::status(status) );
175
 
    busyPB->setMaximum(0);
176
 
}
177
 
 
178
 
void KpkAddRm::progressChanged(PackageKit::Transaction::ProgressInfo info)
179
 
{
180
 
    busyPB->setMaximum(100);
181
 
    busyPB->setValue(info.percentage);
182
 
}
183
 
 
184
188
void KpkAddRm::errorCode(PackageKit::Client::ErrorType error, const QString &details)
185
189
{
186
 
    KMessageBox::detailedSorry( this, KpkStrings::errorMessage(error), details, KpkStrings::error(error), KMessageBox::Notify );
187
 
}
188
 
 
189
 
void KpkAddRm::resizeEvent ( QResizeEvent * event )
190
 
{
191
 
    QWidget::resizeEvent(event);
192
 
    updateColumnsWidth();
193
 
}
194
 
 
195
 
bool KpkAddRm::event ( QEvent * event )
196
 
{
197
 
    switch (event->type()) {
198
 
        case QEvent::Paint:
199
 
        case QEvent::PolishRequest:
200
 
        case QEvent::Polish:
201
 
            updateColumnsWidth(true);
202
 
            break;
203
 
        default:
204
 
            break;
205
 
    }
206
 
    return QWidget::event(event);
207
 
}
208
 
 
209
 
void KpkAddRm::updateColumnsWidth(bool force)
210
 
{
211
 
    int m_viewWidth = packageView->viewport()->width();
212
 
 
213
 
    if (force) {
214
 
        m_viewWidth -= style()->pixelMetric(QStyle::PM_ScrollBarExtent) + UNIVERSAL_PADDING;
215
 
    }
216
 
 
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);
219
191
}
220
192
 
221
193
KpkAddRm::~KpkAddRm()
222
194
{
223
 
}
224
 
 
225
 
void KpkAddRm::on_findPB_clicked()
226
 
{
227
 
    if ( m_mTransRuning ) {
228
 
        m_pkClient_main->cancel();
229
 
    }
230
 
    else if ( !searchKLE->text().isEmpty() ) {
231
 
        // cache the search
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
238
 
        search();
239
 
    }
240
 
}
241
 
 
242
 
void KpkAddRm::on_groupsCB_currentIndexChanged( int index )
243
 
{
244
 
    if ( groupsCB->itemData( index, Qt::UserRole ).isValid() ) {
245
 
        // cache the search
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
250
 
        search();
 
195
    KConfig config("KPackageKit");
 
196
    KConfigGroup filterMenuGroup(&config, "FilterMenu");
 
197
 
 
198
    kDebug() << "Saving filters settings";
 
199
 
 
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());
 
210
}
 
211
 
 
212
void KpkAddRm::on_actionFindName_triggered()
 
213
{
 
214
    kDebug();
 
215
    setCurrentAction(actionFindName);
 
216
    if (m_mTransRuning) {
 
217
        m_pkClient_main->cancel();
 
218
    } else if (!searchKLE->text().isEmpty()) {
 
219
        // cache the search
 
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
 
226
        search();
 
227
    }
 
228
}
 
229
 
 
230
void KpkAddRm::on_actionFindDescription_triggered()
 
231
{
 
232
    kDebug();
 
233
    setCurrentAction(actionFindDescription);
 
234
    if (m_mTransRuning) {
 
235
        m_pkClient_main->cancel();
 
236
    } else if (!searchKLE->text().isEmpty()) {
 
237
        // cache the search
 
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
 
244
        search();
 
245
    }
 
246
}
 
247
 
 
248
void KpkAddRm::on_actionFindFile_triggered()
 
249
{
 
250
    kDebug();
 
251
    setCurrentAction(actionFindFile);
 
252
    if (m_mTransRuning) {
 
253
        m_pkClient_main->cancel();
 
254
    } else if (!searchKLE->text().isEmpty()) {
 
255
        // cache the search
 
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
 
262
        search();
 
263
    }
 
264
}
 
265
 
 
266
void KpkAddRm::on_groupsCB_currentIndexChanged(int index)
 
267
{
 
268
    if (groupsCB->itemData(index, Qt::UserRole).isValid()) {
 
269
        // cache the search
 
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
 
274
        search();
251
275
    }
252
276
}
253
277
 
254
278
void KpkAddRm::search()
255
279
{
256
280
    // 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);
 
289
    } else {
 
290
        kWarning() << "Search type not implemented yet";
 
291
        return;
 
292
    }
 
293
 
261
294
    connectTransaction(m_pkClient_main);
262
 
    statusChanged( m_pkClient_main->status() );
263
 
    // hides the description to have more space.
264
 
    descriptionDW->setVisible(false);
265
 
    notifyF->hide();
 
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);
269
 
    busyPB->setValue(0);
270
300
    m_mTransRuning = true;
271
 
    findPB->setText( i18n("&Cancel") );
272
 
    findPB->setIcon(m_cancelIcon);
273
 
    findPB->setEnabled(false);
274
301
}
275
302
 
276
303
void KpkAddRm::connectTransaction(Transaction *transaction)
277
304
{
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 &)));
292
311
}
293
312
 
294
313
void KpkAddRm::message(PackageKit::Client::MessageType message, const QString &details)
299
318
void KpkAddRm::save()
300
319
{
301
320
    KpkReviewChanges *frm = new KpkReviewChanges( m_pkg_model_main->selectedPackages(), this);
302
 
    if ( frm->exec() == QDialog::Accepted )
 
321
    if (frm->exec() == QDialog::Accepted) {
303
322
        m_pkg_model_main->uncheckAll();
304
 
    else
305
 
        QTimer::singleShot(1, this, SLOT( checkChanged() ) );
 
323
    } else {
 
324
        QTimer::singleShot(0, this, SLOT(checkChanged()));
 
325
    }
306
326
    delete frm;
307
327
    search();
308
328
}
314
334
 
315
335
void KpkAddRm::finished(PackageKit::Transaction::ExitStatus status, uint runtime)
316
336
{
317
 
    notifyF->show();
318
 
    QPalette teste;
319
 
    busyPB->setMaximum(100);
320
 
    busyPB->setValue(100);
 
337
    Q_UNUSED(runtime)
 
338
    Q_UNUSED(status)
321
339
    m_mTransRuning = false;
322
 
    findPB->setEnabled(true);
323
 
    findPB->setText( i18n("&Find") );
324
 
    findPB->setIcon(m_findIcon);
325
 
    switch(status) {
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);
332
 
            break;
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);
338
 
            m_notifyT.start(50);
339
 
            break;
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);
346
 
            break;
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);
353
 
            break;
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);
360
 
            break;
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);
367
 
            break;
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);
374
 
            break;
375
 
    }
376
 
}
377
 
 
378
 
void KpkAddRm::notifyUpdate()
379
 
{
380
 
    QPalette palleteN(notifyL->palette());
381
 
    QColor colorN(palleteN.color(QPalette::Normal, QPalette::Window));
382
 
    if ( colorN.alpha() <= 0 ) {
383
 
        m_notifyT.stop();
384
 
        notifyL->setAutoFillBackground(false);
385
 
        notifyF->hide();
386
 
    }
387
 
    else {
388
 
        colorN.setAlpha(colorN.alpha() - 5);
389
 
        palleteN.setColor(QPalette::Normal, QPalette::Window, colorN);
390
 
        notifyL->setPalette(palleteN);
391
 
    }
392
 
}
393
 
 
394
 
void KpkAddRm::description(PackageKit::Package *p)
395
 
{
396
 
    //format and show description
397
 
    Package::Details *details = p->details();
398
 
    QString description;
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);
412
 
}
413
 
 
414
 
void KpkAddRm::files(PackageKit::Package *package, const QStringList &files)
415
 
{
416
 
    Q_UNUSED(package);
417
 
    filesPTE->clear();
418
 
    for (int i = 0; i < files.size(); ++i)
419
 
        filesPTE->appendPlainText(files.at(i));
420
340
}
421
341
 
422
342
void KpkAddRm::filterMenu(Client::Filters filters)
423
343
{
424
344
    m_filtersQM = new QMenu(this);
425
345
    filtersTB->setMenu(m_filtersQM);
426
 
    
427
 
    if(!filters.isEmpty()) {
 
346
 
 
347
    // Loads the filter menu settings
 
348
    KConfig config("KPackageKit");
 
349
    KConfigGroup filterMenuGroup(&config, "FilterMenu");
 
350
 
 
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);
433
 
            
 
357
 
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;
440
 
            
 
364
 
441
365
            QAction *collectionFalse = new QAction(i18n("Exclude collections"), collectionGroup);
442
366
            collectionFalse->setCheckable(true);
443
367
            m_filtersAction[collectionFalse] = Client::FilterNotCollections;
445
369
            menuCollections->addAction(collectionFalse);
446
370
            actions << collectionFalse;
447
371
        }
448
 
        if ( filters.contains(Client::FilterInstalled)  || filters.contains(Client::FilterNotInstalled) ) {
 
372
        if (filters.contains(Client::FilterInstalled)  || filters.contains(Client::FilterNotInstalled)) {
449
373
            // Installed
450
374
            QMenu *menuInstalled = new QMenu(i18n("Installed"), m_filtersQM);
451
375
            m_filtersQM->addMenu(menuInstalled);
453
377
            installedGroup->setExclusive(true);
454
378
 
455
379
//             if ( filters.contains(Client::FilterInstalled) ) {
456
 
                QAction *installedTrue = new QAction(i18n("Only installed"), installedGroup);
457
 
                installedTrue->setCheckable(true);
458
 
                m_filtersAction[installedTrue] = Client::FilterInstalled;
459
 
                installedGroup->addAction(installedTrue);
460
 
                menuInstalled->addAction(installedTrue);
461
 
                actions << installedTrue;
462
 
//          }
 
380
                QAction *installedTrue = new QAction(i18n("Only installed"), installedGroup);
 
381
                installedTrue->setCheckable(true);
 
382
                m_filtersAction[installedTrue] = Client::FilterInstalled;
 
383
                installedGroup->addAction(installedTrue);
 
384
                menuInstalled->addAction(installedTrue);
 
385
                actions << installedTrue;
 
386
//             }
463
387
 
464
388
//             if ( filters.contains(Client::FilterNotInstalled) ) {
465
 
                QAction *installedFalse = new QAction(i18n("Only available"), installedGroup);
466
 
                installedFalse->setCheckable(true);
467
 
                m_filtersAction[installedFalse] = Client::FilterNotInstalled;
468
 
                installedGroup->addAction(installedFalse);
469
 
                menuInstalled->addAction(installedFalse);
470
 
                actions << installedFalse;
471
 
//          }
 
389
                QAction *installedFalse = new QAction(i18n("Only available"), installedGroup);
 
390
                installedFalse->setCheckable(true);
 
391
                m_filtersAction[installedFalse] = Client::FilterNotInstalled;
 
392
                installedGroup->addAction(installedFalse);
 
393
                menuInstalled->addAction(installedFalse);
 
394
                actions << installedFalse;
 
395
//             }
472
396
 
473
397
            QAction *installedNone = new QAction(i18n("No filter"), installedGroup);
474
398
            installedNone->setCheckable(true);
477
401
            menuInstalled->addAction(installedNone);
478
402
            actions << installedNone;
479
403
        }
480
 
        if ( filters.contains(Client::FilterDevelopment) || filters.contains(Client::FilterNotDevelopment) ) {
 
404
        if (filters.contains(Client::FilterDevelopment) || filters.contains(Client::FilterNotDevelopment)) {
481
405
            // Development
482
406
            QMenu *menuDevelopment = new QMenu(i18n("Development"), m_filtersQM);
483
407
            m_filtersQM->addMenu(menuDevelopment);
485
409
            developmentGroup->setExclusive(true);
486
410
 
487
411
//             if ( filters.contains(Client::FilterDevelopment) ) {
488
 
                QAction *developmentTrue = new QAction(i18n("Only development"), developmentGroup);
489
 
                developmentTrue->setCheckable(true);
490
 
                m_filtersAction[developmentTrue] = Client::FilterDevelopment;
491
 
                developmentGroup->addAction(developmentTrue);
492
 
                menuDevelopment->addAction(developmentTrue);
493
 
                actions << developmentTrue;
494
 
//          }
 
412
                QAction *developmentTrue = new QAction(i18n("Only development"), developmentGroup);
 
413
                developmentTrue->setCheckable(true);
 
414
                m_filtersAction[developmentTrue] = Client::FilterDevelopment;
 
415
                developmentGroup->addAction(developmentTrue);
 
416
                menuDevelopment->addAction(developmentTrue);
 
417
                actions << developmentTrue;
 
418
//             }
495
419
 
496
420
//             if ( filters.contains(Client::FilterNotDevelopment) ) {
497
 
                QAction *developmentFalse = new QAction(i18n("Only end user files"), developmentGroup);
498
 
                developmentFalse->setCheckable(true);
499
 
                m_filtersAction[developmentFalse] = Client::FilterNotDevelopment;
500
 
                developmentGroup->addAction(developmentFalse);
501
 
                menuDevelopment->addAction(developmentFalse);
502
 
                actions << developmentFalse;
503
 
//          }
 
421
                QAction *developmentFalse = new QAction(i18n("Only end user files"), developmentGroup);
 
422
                developmentFalse->setCheckable(true);
 
423
                m_filtersAction[developmentFalse] = Client::FilterNotDevelopment;
 
424
                developmentGroup->addAction(developmentFalse);
 
425
                menuDevelopment->addAction(developmentFalse);
 
426
                actions << developmentFalse;
 
427
//             }
504
428
 
505
429
            QAction *developmentNone = new QAction(i18n("No filter"), developmentGroup);
506
430
            developmentNone->setCheckable(true);
509
433
            menuDevelopment->addAction(developmentNone);
510
434
            actions << developmentNone;
511
435
        }
512
 
        if ( filters.contains(Client::FilterGui) || filters.contains(Client::FilterNotGui) ) {
 
436
        if (filters.contains(Client::FilterGui) || filters.contains(Client::FilterNotGui)) {
513
437
            // Graphical
514
438
            QMenu *menuGui = new QMenu(i18n("Graphical"), m_filtersQM);
515
439
            m_filtersQM->addMenu(menuGui);
517
441
            guiGroup->setExclusive(true);
518
442
 
519
443
//             if ( filters.contains(Client::FilterGui) ) {
520
 
                QAction *guiTrue = new QAction(i18n("Only graphical"), guiGroup);
521
 
                guiTrue->setCheckable(true);
522
 
                m_filtersAction[guiTrue] = Client::FilterGui;
523
 
                guiGroup->addAction(guiTrue);
524
 
                menuGui->addAction(guiTrue);
525
 
                actions << guiTrue;
526
 
//          }
 
444
                QAction *guiTrue = new QAction(i18n("Only graphical"), guiGroup);
 
445
                guiTrue->setCheckable(true);
 
446
                m_filtersAction[guiTrue] = Client::FilterGui;
 
447
                guiGroup->addAction(guiTrue);
 
448
                menuGui->addAction(guiTrue);
 
449
                actions << guiTrue;
 
450
//             }
527
451
 
528
452
//             if ( filters.contains(Client::FilterNotGui) ) {
529
 
                QAction *guiFalse = new QAction(i18n("Only text"), guiGroup);
530
 
                guiFalse->setCheckable(true);
531
 
                m_filtersAction[guiFalse] = Client::FilterNotGui;
532
 
                guiGroup->addAction(guiFalse);
533
 
                menuGui->addAction(guiFalse);
534
 
                actions << guiFalse;
535
 
//          }
536
 
            
 
453
                QAction *guiFalse = new QAction(i18n("Only text"), guiGroup);
 
454
                guiFalse->setCheckable(true);
 
455
                m_filtersAction[guiFalse] = Client::FilterNotGui;
 
456
                guiGroup->addAction(guiFalse);
 
457
                menuGui->addAction(guiFalse);
 
458
                actions << guiFalse;
 
459
//             }
 
460
 
537
461
            QAction *guiNone = new QAction(i18n("No filter"), guiGroup);
538
462
            guiNone->setCheckable(true);
539
463
            guiNone->setChecked(true);
541
465
            menuGui->addAction(guiNone);
542
466
            actions << guiNone;
543
467
        }
544
 
        if ( filters.contains(Client::FilterFree) || filters.contains(Client::FilterNotFree) ) {
 
468
        if (filters.contains(Client::FilterFree) || filters.contains(Client::FilterNotFree)) {
545
469
            // Free
546
470
            QMenu *menuFree = new QMenu(i18n("Free"), m_filtersQM);
547
471
            m_filtersQM->addMenu(menuFree);
549
473
            freeGroup->setExclusive(true);
550
474
 
551
475
//             if ( filters.contains(Client::FilterFree) ) {
552
 
                QAction *freeTrue = new QAction(i18n("Only free software"), freeGroup);
553
 
                freeTrue->setCheckable(true);
554
 
                m_filtersAction[freeTrue] = Client::FilterFree;
555
 
                freeGroup->addAction(freeTrue);
556
 
                menuFree->addAction(freeTrue);
557
 
                actions << freeTrue;
558
 
//          }
 
476
                QAction *freeTrue = new QAction(i18n("Only free software"), freeGroup);
 
477
                freeTrue->setCheckable(true);
 
478
                m_filtersAction[freeTrue] = Client::FilterFree;
 
479
                freeGroup->addAction(freeTrue);
 
480
                menuFree->addAction(freeTrue);
 
481
                actions << freeTrue;
 
482
//             }
559
483
 
560
484
//             if ( filters.contains(Client::FilterNotFree) ) {
561
 
                QAction *freeFalse = new QAction(i18n("Only non-free software"), freeGroup);
562
 
                freeFalse->setCheckable(true);
563
 
                m_filtersAction[freeFalse] = Client::FilterNotFree;
564
 
                freeGroup->addAction(freeFalse);
565
 
                menuFree->addAction(freeFalse);
566
 
                actions << freeFalse;
567
 
//          }
 
485
                QAction *freeFalse = new QAction(i18n("Only non-free software"), freeGroup);
 
486
                freeFalse->setCheckable(true);
 
487
                m_filtersAction[freeFalse] = Client::FilterNotFree;
 
488
                freeGroup->addAction(freeFalse);
 
489
                menuFree->addAction(freeFalse);
 
490
                actions << freeFalse;
 
491
//             }
568
492
 
569
493
            QAction *freeNone = new QAction(i18n("No filter"), freeGroup);
570
494
            freeNone->setCheckable(true);
573
497
            menuFree->addAction(freeNone);
574
498
            actions << freeNone;
575
499
        }
576
 
        if ( filters.contains(Client::FilterArch) || filters.contains(Client::FilterNotArch) ) {
 
500
        if (filters.contains(Client::FilterArch) || filters.contains(Client::FilterNotArch)) {
577
501
            // Arch
578
502
            QMenu *menuArch = new QMenu(i18n("Architectures"), m_filtersQM);
579
503
            m_filtersQM->addMenu(menuArch);
581
505
            archGroup->setExclusive(true);
582
506
 
583
507
//             if ( filters.contains(Client::FilterArch) ) {
584
 
                QAction *archTrue = new QAction(i18n("Only native architectures"), archGroup);
585
 
                archTrue->setCheckable(true);
586
 
                m_filtersAction[archTrue] = Client::FilterArch;
587
 
                archGroup->addAction(archTrue);
588
 
                menuArch->addAction(archTrue);
589
 
                actions << archTrue;
590
 
//          }
 
508
                QAction *archTrue = new QAction(i18n("Only native architectures"), archGroup);
 
509
                archTrue->setCheckable(true);
 
510
                m_filtersAction[archTrue] = Client::FilterArch;
 
511
                archGroup->addAction(archTrue);
 
512
                menuArch->addAction(archTrue);
 
513
                actions << archTrue;
 
514
//             }
591
515
 
592
516
//             if ( filters.contains(Client::FilterNotArch) ) {
593
 
                QAction *archFalse = new QAction(i18n("Only non-native architectures"), archGroup);
594
 
                archFalse->setCheckable(true);
595
 
                m_filtersAction[archFalse] = Client::FilterNotArch;
596
 
                archGroup->addAction(archFalse);
597
 
                menuArch->addAction(archFalse);
598
 
                actions << archFalse;
599
 
//          }
 
517
                QAction *archFalse = new QAction(i18n("Only non-native architectures"), archGroup);
 
518
                archFalse->setCheckable(true);
 
519
                m_filtersAction[archFalse] = Client::FilterNotArch;
 
520
                archGroup->addAction(archFalse);
 
521
                menuArch->addAction(archFalse);
 
522
                actions << archFalse;
 
523
//             }
600
524
 
601
525
            QAction *archNone = new QAction(i18n("No filter"), archGroup);
602
526
            archNone->setCheckable(true);
605
529
            menuArch->addAction(archNone);
606
530
            actions << archNone;
607
531
        }
608
 
        if ( filters.contains(Client::FilterSource) || filters.contains(Client::FilterNotSource) ) {
 
532
        if (filters.contains(Client::FilterSource) || filters.contains(Client::FilterNotSource)) {
609
533
            // Source
610
534
            QMenu *menuSource = new QMenu(i18n("Source"), m_filtersQM);
611
535
            m_filtersQM->addMenu(menuSource);
613
537
            sourceGroup->setExclusive(true);
614
538
 
615
539
//             if ( filters.contains(Client::FilterSource) ) {
616
 
                QAction *sourceTrue = new QAction(i18n("Only sourcecode"), sourceGroup);
617
 
                sourceTrue->setCheckable(true);
618
 
                m_filtersAction[sourceTrue] = Client::FilterSource;
619
 
                sourceGroup->addAction(sourceTrue);
620
 
                menuSource->addAction(sourceTrue);
621
 
                actions << sourceTrue;
622
 
//          }
 
540
                QAction *sourceTrue = new QAction(i18n("Only sourcecode"), sourceGroup);
 
541
                sourceTrue->setCheckable(true);
 
542
                m_filtersAction[sourceTrue] = Client::FilterSource;
 
543
                sourceGroup->addAction(sourceTrue);
 
544
                menuSource->addAction(sourceTrue);
 
545
                actions << sourceTrue;
 
546
//             }
623
547
 
624
548
//             if ( filters.contains(Client::FilterNotSource) ) {
625
 
                QAction *sourceFalse = new QAction(i18n("Only non-sourcecode"), sourceGroup);
626
 
                sourceFalse->setCheckable(true);
627
 
                m_filtersAction[sourceFalse] = Client::FilterNotSource;
628
 
                sourceGroup->addAction(sourceFalse);
629
 
                menuSource->addAction(sourceFalse);
630
 
                actions << sourceFalse;
631
 
//          }
 
549
                QAction *sourceFalse = new QAction(i18n("Only non-sourcecode"), sourceGroup);
 
550
                sourceFalse->setCheckable(true);
 
551
                m_filtersAction[sourceFalse] = Client::FilterNotSource;
 
552
                sourceGroup->addAction(sourceFalse);
 
553
                menuSource->addAction(sourceFalse);
 
554
                actions << sourceFalse;
 
555
//             }
632
556
 
633
557
            QAction *sourceNone = new QAction(i18n("No filter"), sourceGroup);
634
558
            sourceNone->setCheckable(true);
641
565
            m_filtersQM->addSeparator();
642
566
            QAction *basename = new QAction(i18n("Hide subpackages"), m_filtersQM);
643
567
            basename->setCheckable(true);
644
 
            basename->setToolTip( i18n("Only show one package, not subpackages") );
645
 
            m_filtersAction[basename] = Client::FilterBasename;
 
568
            basename->setToolTip( i18n("Only show one package, not subpackages") );
 
569
            m_filtersAction[basename] = Client::FilterBasename;
646
570
            m_filtersQM->addAction(basename);
647
571
 
648
572
            actions << basename;
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);
657
581
 
658
582
            actions << newest;
659
583
        }
660
 
        
 
584
 
661
585
        m_filtersQM->addSeparator();
662
586
    }
663
 
    else {
664
 
        //filtersTB->setDisabled(true);
 
587
 
 
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);
665
596
    }
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) ) );
 
597
 
 
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)));
672
602
}
673
603
 
674
604
void KpkAddRm::packageViewSetRootIsDecorated(bool value)
675
605
{
 
606
    // contract and delete and details widgets
 
607
    pkg_delegate->contractAll();
676
608
    packageView->setRootIsDecorated(value);
677
609
}
678
610
 
679
611
Client::Filters KpkAddRm::filters()
680
612
{
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) ];
686
 
    }
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)];
 
618
            }
 
619
        }
 
620
    }
 
621
    if (buffer.size() == 0) {
 
622
        buffer << Client::NoFilter;
 
623
    }
 
624
    return m_searchFilters = buffer;
 
625
}
 
626
 
 
627
void KpkAddRm::resizeEvent(QResizeEvent *event)
 
628
{
 
629
    QWidget::resizeEvent(event);
 
630
    updateColumnsWidth();
 
631
}
 
632
 
 
633
bool KpkAddRm::event(QEvent *event)
 
634
{
 
635
    switch (event->type()) {
 
636
        case QEvent::KeyPress:
 
637
            // use bracktes to don't cross initialization og keyEvent
 
638
            {
 
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();
 
643
                    return true;
 
644
                }
 
645
            }
 
646
            break;
 
647
        case QEvent::Paint:
 
648
        case QEvent::PolishRequest:
 
649
        case QEvent::Polish:
 
650
            updateColumnsWidth(true);
 
651
            break;
 
652
        default:
 
653
            break;
 
654
    }
 
655
    return QWidget::event(event);
 
656
}
 
657
 
 
658
void KpkAddRm::updateColumnsWidth(bool force)
 
659
{
 
660
    int m_viewWidth = packageView->viewport()->width();
 
661
 
 
662
    if (force) {
 
663
        m_viewWidth -= style()->pixelMetric(QStyle::PM_ScrollBarExtent) + UNIVERSAL_PADDING;
 
664
    }
 
665
 
 
666
    packageView->setColumnWidth(0, pkg_delegate->columnWidth(0, m_viewWidth));
 
667
    packageView->setColumnWidth(1, pkg_delegate->columnWidth(1, m_viewWidth));
689
668
}
690
669
 
691
670
#include "KpkAddRm.moc"