Diffstat (limited to 'noncore/settings/aqpkg/categoryfilterimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/categoryfilterimpl.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/noncore/settings/aqpkg/categoryfilterimpl.cpp b/noncore/settings/aqpkg/categoryfilterimpl.cpp index 61e1f93..217d2c9 100644 --- a/noncore/settings/aqpkg/categoryfilterimpl.cpp +++ b/noncore/settings/aqpkg/categoryfilterimpl.cpp | |||
@@ -6,102 +6,108 @@ | |||
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <iostream> | 30 | #include "categoryfilterimpl.h" |
31 | using namespace std; | 31 | |
32 | /* OPIE */ | ||
33 | #include <qpe/qpeapplication.h> | ||
32 | 34 | ||
35 | /* QT */ | ||
33 | #include <qgroupbox.h> | 36 | #include <qgroupbox.h> |
34 | #include <qlayout.h> | 37 | #include <qlayout.h> |
35 | #include <qlistbox.h> | 38 | #include <qlistbox.h> |
36 | #include <qstring.h> | 39 | #include <qstring.h> |
37 | 40 | ||
38 | #include "categoryfilterimpl.h" | 41 | /* STD */ |
42 | #include <iostream> | ||
43 | using namespace std; | ||
44 | |||
39 | 45 | ||
40 | CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent, const char *name ) | 46 | CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent, const char *name ) |
41 | : QDialog( parent, name, true ) | 47 | : QDialog( parent, name, true ) |
42 | { | 48 | { |
43 | setCaption( tr( "Category Filter" ) ); | 49 | setCaption( tr( "Category Filter" ) ); |
44 | 50 | ||
45 | QVBoxLayout *layout = new QVBoxLayout( this ); | 51 | QVBoxLayout *layout = new QVBoxLayout( this ); |
46 | layout->setMargin( 2 ); | 52 | layout->setMargin( 2 ); |
47 | layout->setSpacing( 4 ); | 53 | layout->setSpacing( 4 ); |
48 | 54 | ||
49 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Select one or more groups" ), this ); | 55 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Select one or more groups" ), this ); |
50 | grpbox->layout()->setSpacing( 2 ); | 56 | grpbox->layout()->setSpacing( 2 ); |
51 | grpbox->layout()->setMargin( 4 ); | 57 | grpbox->layout()->setMargin( 4 ); |
52 | layout->addWidget( grpbox ); | 58 | layout->addWidget( grpbox ); |
53 | 59 | ||
54 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); | 60 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); |
55 | 61 | ||
56 | lstCategories = new QListBox( grpbox ); | 62 | lstCategories = new QListBox( grpbox ); |
57 | lstCategories->setSelectionMode( QListBox::Multi ); | 63 | lstCategories->setSelectionMode( QListBox::Multi ); |
58 | grplayout->addWidget( lstCategories ); | 64 | grplayout->addWidget( lstCategories ); |
59 | 65 | ||
60 | // Split up categories and add them to the listbox | 66 | // Split up categories and add them to the listbox |
61 | int start = 1; | 67 | int start = 1; |
62 | 68 | ||
63 | QString item; | 69 | QString item; |
64 | int end; | 70 | int end; |
65 | QString finditem; | 71 | QString finditem; |
66 | do | 72 | do |
67 | { | 73 | { |
68 | end = categories.find( "#", start ); | 74 | end = categories.find( "#", start ); |
69 | item = categories.mid( start, end - start ); | 75 | item = categories.mid( start, end - start ); |
70 | if ( item != "" ) | 76 | if ( item != "" ) |
71 | { | 77 | { |
72 | lstCategories->insertItem( item ); | 78 | lstCategories->insertItem( item ); |
73 | finditem = QString( "#%1#" ).arg( item ); | 79 | finditem = QString( "#%1#" ).arg( item ); |
74 | if ( selectedCategories.find( finditem ) != -1 ) | 80 | if ( selectedCategories.find( finditem ) != -1 ) |
75 | lstCategories->setSelected( lstCategories->count()-1, true ); | 81 | lstCategories->setSelected( lstCategories->count()-1, true ); |
76 | } | 82 | } |
77 | 83 | ||
78 | start = end + 1; | 84 | start = end + 1; |
79 | } while ( start < (int)categories.length() ); | 85 | } |
86 | while ( start < (int)categories.length() ); | ||
80 | 87 | ||
81 | lstCategories->sort( true ); | 88 | lstCategories->sort( true ); |
82 | 89 | ||
83 | showMaximized(); | 90 | QPEApplication::showDialog( this ); |
84 | } | 91 | } |
85 | 92 | ||
86 | CategoryFilterImpl :: ~CategoryFilterImpl() | 93 | CategoryFilterImpl :: ~CategoryFilterImpl() |
87 | { | 94 | {} |
88 | } | ||
89 | 95 | ||
90 | QString CategoryFilterImpl :: getSelectedFilter() | 96 | QString CategoryFilterImpl :: getSelectedFilter() |
91 | { | 97 | { |
92 | // Grab cetegories from listbox | 98 | // Grab cetegories from listbox |
93 | QString ret = "#"; | 99 | QString ret = "#"; |
94 | 100 | ||
95 | for ( int i = 0 ; i < (int)lstCategories->count() ; ++i ) | 101 | for ( int i = 0 ; i < (int)lstCategories->count() ; ++i ) |
96 | { | 102 | { |
97 | if ( lstCategories->isSelected( i ) ) | 103 | if ( lstCategories->isSelected( i ) ) |
98 | { | 104 | { |
99 | ret.append( lstCategories->text( i ) ); | 105 | ret.append( lstCategories->text( i ) ); |
100 | ret.append( "#" ); | 106 | ret.append( "#" ); |
101 | } | 107 | } |
102 | } | 108 | } |
103 | 109 | ||
104 | if ( ret == "#" ) | 110 | if ( ret == "#" ) |
105 | ret = ""; | 111 | ret = ""; |
106 | return ret; | 112 | return ret; |
107 | } | 113 | } |