Diffstat (limited to 'noncore/settings/aqpkg/categoryfilterimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/categoryfilterimpl.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/noncore/settings/aqpkg/categoryfilterimpl.cpp b/noncore/settings/aqpkg/categoryfilterimpl.cpp index 0746da6..e8ce7e7 100644 --- a/noncore/settings/aqpkg/categoryfilterimpl.cpp +++ b/noncore/settings/aqpkg/categoryfilterimpl.cpp | |||
@@ -14,34 +14,54 @@ | |||
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | #include <iostream> | 17 | #include <iostream> |
18 | using namespace std; | 18 | using namespace std; |
19 | 19 | ||
20 | #include <qgroupbox.h> | ||
21 | #include <qlayout.h> | ||
20 | #include <qlistbox.h> | 22 | #include <qlistbox.h> |
21 | #include <qstring.h> | 23 | #include <qstring.h> |
22 | 24 | ||
23 | #include "categoryfilterimpl.h" | 25 | #include "categoryfilterimpl.h" |
24 | 26 | ||
25 | CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent, const char *name ) | 27 | CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent, const char *name ) |
26 | : CategoryFilterDlg(parent,name, true) | 28 | : QDialog( parent, name, true ) |
27 | { | 29 | { |
30 | setCaption( tr( "Category Filter" ) ); | ||
31 | |||
32 | QVBoxLayout *layout = new QVBoxLayout( this ); | ||
33 | layout->setMargin( 2 ); | ||
34 | layout->setSpacing( 4 ); | ||
35 | |||
36 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Select one or more groups" ), this ); | ||
37 | grpbox->layout()->setSpacing( 2 ); | ||
38 | grpbox->layout()->setMargin( 4 ); | ||
39 | layout->addWidget( grpbox ); | ||
40 | |||
41 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); | ||
42 | |||
43 | lstCategories = new QListBox( grpbox ); | ||
44 | lstCategories->setSelectionMode( QListBox::Multi ); | ||
45 | grplayout->addWidget( lstCategories ); | ||
46 | |||
28 | // Split up categories and add them to the listbox | 47 | // Split up categories and add them to the listbox |
29 | int start = 1; | 48 | int start = 1; |
30 | 49 | ||
31 | QString item; | 50 | QString item; |
32 | int end; | 51 | int end; |
52 | QString finditem; | ||
33 | do | 53 | do |
34 | { | 54 | { |
35 | end = categories.find( "#", start ); | 55 | end = categories.find( "#", start ); |
36 | item = categories.mid( start, end - start ); | 56 | item = categories.mid( start, end - start ); |
37 | if ( item != "" ) | 57 | if ( item != "" ) |
38 | { | 58 | { |
39 | lstCategories->insertItem( item ); | 59 | lstCategories->insertItem( item ); |
40 | 60 | finditem = QString( "#%1#" ).arg( item ); | |
41 | if ( selectedCategories.find( "#" + item + "#" ) != -1 ) | 61 | if ( selectedCategories.find( finditem ) != -1 ) |
42 | lstCategories->setSelected( lstCategories->count()-1, true ); | 62 | lstCategories->setSelected( lstCategories->count()-1, true ); |
43 | } | 63 | } |
44 | 64 | ||
45 | start = end + 1; | 65 | start = end + 1; |
46 | } while ( start < (int)categories.length() ); | 66 | } while ( start < (int)categories.length() ); |
47 | 67 | ||
@@ -59,13 +79,16 @@ QString CategoryFilterImpl :: getSelectedFilter() | |||
59 | // Grab cetegories from listbox | 79 | // Grab cetegories from listbox |
60 | QString ret = "#"; | 80 | QString ret = "#"; |
61 | 81 | ||
62 | for ( int i = 0 ; i < (int)lstCategories->count() ; ++i ) | 82 | for ( int i = 0 ; i < (int)lstCategories->count() ; ++i ) |
63 | { | 83 | { |
64 | if ( lstCategories->isSelected( i ) ) | 84 | if ( lstCategories->isSelected( i ) ) |
65 | ret += lstCategories->text( i ) + "#"; | 85 | { |
86 | ret.append( lstCategories->text( i ) ); | ||
87 | ret.append( "#" ); | ||
88 | } | ||
66 | } | 89 | } |
67 | 90 | ||
68 | if ( ret == "#" ) | 91 | if ( ret == "#" ) |
69 | ret = ""; | 92 | ret = ""; |
70 | return ret; | 93 | return ret; |
71 | } | 94 | } |