-rw-r--r-- | library/categorymenu.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/library/categorymenu.cpp b/library/categorymenu.cpp index e733107..5d7adf7 100644 --- a/library/categorymenu.cpp +++ b/library/categorymenu.cpp | |||
@@ -24,6 +24,35 @@ | |||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qmap.h> | 25 | #include <qmap.h> |
26 | 26 | ||
27 | /*! | ||
28 | \class CategoryMenu | ||
29 | \brief The CategoryMenu widget aids in filtering records or files by Category. | ||
30 | |||
31 | The CategoryMenu widget provides a popup menu that will make filtering records | ||
32 | or files by category much easier. The widget will lookup the available | ||
33 | categories for an application, populate the menu, and keep a track of which | ||
34 | categories are being filtered against. A set of categories can be tested | ||
35 | by the isSelected() function to see if a record or file containing those | ||
36 | categories would be allowed through by the filter. | ||
37 | |||
38 | \warning Currently this class is not suitable for extending. | ||
39 | |||
40 | \ingroup qtopiaemb | ||
41 | */ | ||
42 | |||
43 | /*! | ||
44 | \fn void CategoryMenu::categoryChange() | ||
45 | This signal is emitted when the user selects a different category in the | ||
46 | menu, hence changing what records or files should be selected. | ||
47 | */ | ||
48 | |||
49 | /*! | ||
50 | Creates a new CategoryMenu with \a parent and \a name. The menu will be | ||
51 | populated with the available categories for \a application. | ||
52 | |||
53 | If \a globals is TRUE then it will also poplulate the menu with the | ||
54 | global categories. | ||
55 | */ | ||
27 | CategoryMenu::CategoryMenu( const QString &n, bool ig = TRUE, | 56 | CategoryMenu::CategoryMenu( const QString &n, bool ig = TRUE, |
28 | QWidget *parent, const char *name ) : | 57 | QWidget *parent, const char *name ) : |
29 | QPopupMenu(parent, name), | 58 | QPopupMenu(parent, name), |
@@ -35,10 +64,16 @@ CategoryMenu::CategoryMenu( const QString &n, bool ig = TRUE, | |||
35 | connect(this, SIGNAL(activated(int)), this, SLOT(mapMenuId(int))); | 64 | connect(this, SIGNAL(activated(int)), this, SLOT(mapMenuId(int))); |
36 | } | 65 | } |
37 | 66 | ||
67 | /*! | ||
68 | Destroys a CategoryMenu. | ||
69 | */ | ||
38 | CategoryMenu::~CategoryMenu( ) | 70 | CategoryMenu::~CategoryMenu( ) |
39 | { | 71 | { |
40 | } | 72 | } |
41 | 73 | ||
74 | /*! | ||
75 | Repopulates the widget's list of available categories. | ||
76 | */ | ||
42 | void CategoryMenu::reload() | 77 | void CategoryMenu::reload() |
43 | { | 78 | { |
44 | clear(); | 79 | clear(); |
@@ -66,6 +101,9 @@ void CategoryMenu::reload() | |||
66 | setItemChecked(currentMid, TRUE ); | 101 | setItemChecked(currentMid, TRUE ); |
67 | } | 102 | } |
68 | 103 | ||
104 | /*! | ||
105 | \internal | ||
106 | */ | ||
69 | void CategoryMenu::mapMenuId(int id) | 107 | void CategoryMenu::mapMenuId(int id) |
70 | { | 108 | { |
71 | if (id == currentMid) | 109 | if (id == currentMid) |
@@ -77,6 +115,11 @@ void CategoryMenu::mapMenuId(int id) | |||
77 | emit categoryChange(); | 115 | emit categoryChange(); |
78 | } | 116 | } |
79 | 117 | ||
118 | /*! | ||
119 | Returns TRUE if a record or file with the set of category ids \a cUids | ||
120 | is allowed by the current selection in the CategoryMenu. | ||
121 | Otherwise returns FALSE. | ||
122 | */ | ||
80 | bool CategoryMenu::isSelected(const QArray<int> &cUids) const | 123 | bool CategoryMenu::isSelected(const QArray<int> &cUids) const |
81 | { | 124 | { |
82 | if (currentMid == 1) | 125 | if (currentMid == 1) |
@@ -91,6 +134,9 @@ bool CategoryMenu::isSelected(const QArray<int> &cUids) const | |||
91 | return FALSE; | 134 | return FALSE; |
92 | } | 135 | } |
93 | 136 | ||
137 | /*! | ||
138 | Sets the menu to have \a newCatUid as the currently selected Category. | ||
139 | */ | ||
94 | void CategoryMenu::setCurrentCategory( int newCatUid ) | 140 | void CategoryMenu::setCurrentCategory( int newCatUid ) |
95 | { | 141 | { |
96 | if (!idToMenu.contains(newCatUid)) | 142 | if (!idToMenu.contains(newCatUid)) |
@@ -99,11 +145,17 @@ void CategoryMenu::setCurrentCategory( int newCatUid ) | |||
99 | mapMenuId(idToMenu[newCatUid]); | 145 | mapMenuId(idToMenu[newCatUid]); |
100 | } | 146 | } |
101 | 147 | ||
148 | /*! | ||
149 | Sets the menu to allow all category sets. | ||
150 | */ | ||
102 | void CategoryMenu::setCurrentCategoryAll( ) | 151 | void CategoryMenu::setCurrentCategoryAll( ) |
103 | { | 152 | { |
104 | mapMenuId(1); | 153 | mapMenuId(1); |
105 | } | 154 | } |
106 | 155 | ||
156 | /*! | ||
157 | Sets the menu to allow only empty category sets. | ||
158 | */ | ||
107 | void CategoryMenu::setCurrentCategoryUnfiled( ) | 159 | void CategoryMenu::setCurrentCategoryUnfiled( ) |
108 | { | 160 | { |
109 | mapMenuId(2); | 161 | mapMenuId(2); |