Diffstat (limited to 'noncore/settings/aqpkg/categoryfilterimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/categoryfilterimpl.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/categoryfilterimpl.cpp b/noncore/settings/aqpkg/categoryfilterimpl.cpp new file mode 100644 index 0000000..0746da6 --- a/dev/null +++ b/noncore/settings/aqpkg/categoryfilterimpl.cpp | |||
@@ -0,0 +1,71 @@ | |||
1 | /*************************************************************************** | ||
2 | categoryfilterimpl.cpp - description | ||
3 | ------------------- | ||
4 | begin : Sun Nov 17 2002 | ||
5 | copyright : (C) 2002 by Andy Qua | ||
6 | email : andy.qua@blueyonder.co.uk | ||
7 | ***************************************************************************/ | ||
8 | |||
9 | /*************************************************************************** | ||
10 | * * | ||
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 * | ||
13 | * the Free Software Foundation; either version 2 of the License, or * | ||
14 | * (at your option) any later version. * | ||
15 | * * | ||
16 | ***************************************************************************/ | ||
17 | #include <iostream> | ||
18 | using namespace std; | ||
19 | |||
20 | #include <qlistbox.h> | ||
21 | #include <qstring.h> | ||
22 | |||
23 | #include "categoryfilterimpl.h" | ||
24 | |||
25 | CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent, const char *name ) | ||
26 | : CategoryFilterDlg(parent,name, true) | ||
27 | { | ||
28 | // Split up categories and add them to the listbox | ||
29 | int start = 1; | ||
30 | |||
31 | QString item; | ||
32 | int end; | ||
33 | do | ||
34 | { | ||
35 | end = categories.find( "#", start ); | ||
36 | item = categories.mid( start, end - start ); | ||
37 | if ( item != "" ) | ||
38 | { | ||
39 | lstCategories->insertItem( item ); | ||
40 | |||
41 | if ( selectedCategories.find( "#" + item + "#" ) != -1 ) | ||
42 | lstCategories->setSelected( lstCategories->count()-1, true ); | ||
43 | } | ||
44 | |||
45 | start = end + 1; | ||
46 | } while ( start < (int)categories.length() ); | ||
47 | |||
48 | lstCategories->sort( true ); | ||
49 | |||
50 | showMaximized(); | ||
51 | } | ||
52 | |||
53 | CategoryFilterImpl :: ~CategoryFilterImpl() | ||
54 | { | ||
55 | } | ||
56 | |||
57 | QString CategoryFilterImpl :: getSelectedFilter() | ||
58 | { | ||
59 | // Grab cetegories from listbox | ||
60 | QString ret = "#"; | ||
61 | |||
62 | for ( int i = 0 ; i < (int)lstCategories->count() ; ++i ) | ||
63 | { | ||
64 | if ( lstCategories->isSelected( i ) ) | ||
65 | ret += lstCategories->text( i ) + "#"; | ||
66 | } | ||
67 | |||
68 | if ( ret == "#" ) | ||
69 | ret = ""; | ||
70 | return ret; | ||
71 | } | ||