Diffstat (limited to 'noncore/settings/aqpkg/categoryfilterimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/categoryfilterimpl.cpp | 33 |
1 files changed, 28 insertions, 5 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 | |||
@@ -1,71 +1,94 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | categoryfilterimpl.cpp - description | 2 | categoryfilterimpl.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Sun Nov 17 2002 | 4 | begin : Sun Nov 17 2002 |
5 | copyright : (C) 2002 by Andy Qua | 5 | copyright : (C) 2002 by Andy Qua |
6 | email : andy.qua@blueyonder.co.uk | 6 | email : andy.qua@blueyonder.co.uk |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
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 | ||
48 | lstCategories->sort( true ); | 68 | lstCategories->sort( true ); |
49 | 69 | ||
50 | showMaximized(); | 70 | showMaximized(); |
51 | } | 71 | } |
52 | 72 | ||
53 | CategoryFilterImpl :: ~CategoryFilterImpl() | 73 | CategoryFilterImpl :: ~CategoryFilterImpl() |
54 | { | 74 | { |
55 | } | 75 | } |
56 | 76 | ||
57 | QString CategoryFilterImpl :: getSelectedFilter() | 77 | QString CategoryFilterImpl :: getSelectedFilter() |
58 | { | 78 | { |
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 | } |