0.7.1
[fapman] / blacklistselect.cpp
1 /*
2         This file is part of Faster Application Manager.
3
4         Faster Application Manager is free software: you can redistribute it and/or modify
5         it under the terms of the GNU General Public License as published by
6         the Free Software Foundation, either version 3 of the License, or
7         (at your option) any later version.
8
9         Faster Application Manager is distributed in the hope that it will be useful,
10         but WITHOUT ANY WARRANTY; without even the implied warranty of
11         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12         GNU General Public License for more details.
13
14         You should have received a copy of the GNU General Public License
15         along with Faster Application Manager.  If not, see <http://www.gnu.org/licenses/>.
16
17         (C) Heikki Holstila 2010
18 */
19
20 #include "blacklistselect.h"
21 #include "ui_blacklistselect.h"
22 #include "package.h"
23
24 BlacklistSelect::BlacklistSelect(Package* pkg, QWidget *parent) :
25     QDialog(parent),
26     ui(new Ui::BlacklistSelect)
27 {
28     ui->setupUi(this);
29         iPkg = pkg;
30
31         if( iPkg->blacklisted() == BlacklistNone ) {
32                 ui->label->setText("This package has not been blacklisted");
33                 ui->pushButton_Restore->setEnabled(false);
34         } else if( iPkg->blacklisted() == BlacklistThis ) {
35                 ui->label->setText("This version of the package has been blacklisted");
36                 ui->pushButton_This->setEnabled(false);
37         } else if( iPkg->blacklisted() == BlacklistAll ) {
38                 ui->label->setText("All versions of this package have been blacklisted");
39                 ui->pushButton_Forever->setEnabled(false);
40         }
41
42         if( iPkg->isInstalled() && !iPkg->isUpgradeable() )
43                 ui->pushButton_This->setEnabled(false);
44 }
45
46 BlacklistSelect::~BlacklistSelect()
47 {
48     delete ui;
49 }
50
51 void BlacklistSelect::changeEvent(QEvent *e)
52 {
53     QDialog::changeEvent(e);
54     switch (e->type()) {
55     case QEvent::LanguageChange:
56         ui->retranslateUi(this);
57         break;
58     default:
59         break;
60     }
61 }
62
63 void BlacklistSelect::on_pushButton_Forever_clicked()
64 {
65         iPkg->setBlacklisted( BlacklistAll );
66         accept();
67 }
68
69 void BlacklistSelect::on_pushButton_This_clicked()
70 {
71         iPkg->setBlacklisted( BlacklistThis );
72         accept();
73 }
74
75 void BlacklistSelect::on_pushButton_Restore_clicked()
76 {
77         iPkg->setBlacklisted( BlacklistNone );
78         accept();
79 }