0.7.1
[fapman] / sortselector.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 "sortselector.h"
21 #include "ui_sortselector.h"
22 #include "packageview.h"
23
24 SortSelector::SortSelector(PackageView::sortOrder currOrder, QWidget *parent) :
25     QDialog(parent),
26     ui(new Ui::SortSelector)
27 {
28     ui->setupUi(this);
29
30         if( currOrder == PackageView::SortAlpha )
31                 ui->radioButton_name->setChecked(true);
32         else if( currOrder == PackageView::SortDateDesc )
33                 ui->radioButton_date->setChecked(true);
34         else if( currOrder == PackageView::SortSizeDesc )
35                 ui->radioButton_size->setChecked(true);
36 }
37
38 SortSelector::~SortSelector()
39 {
40     delete ui;
41 }
42
43 void SortSelector::changeEvent(QEvent *e)
44 {
45     QDialog::changeEvent(e);
46     switch (e->type()) {
47     case QEvent::LanguageChange:
48         ui->retranslateUi(this);
49         break;
50     default:
51         break;
52     }
53 }
54
55 PackageView::sortOrder SortSelector::selectedOperation()
56 {
57         if( ui->radioButton_name->isChecked() )
58                 return PackageView::SortAlpha;
59         else if( ui->radioButton_date->isChecked() )
60                 return PackageView::SortDateDesc;
61         else if( ui->radioButton_size->isChecked() )
62                 return PackageView::SortSizeDesc;
63
64         return PackageView::SortAlpha;
65 }