summaryrefslogtreecommitdiff
path: root/library
authorzecke <zecke>2003-08-25 15:06:32 (UTC)
committer zecke <zecke>2003-08-25 15:06:32 (UTC)
commit44b9e62c1e5071fc6e5f8e80204b9974dbc704b6 (patch) (unidiff)
tree2ed47cff84f9b9cfb94fd38f6931ba69316f32aa /library
parentbf3c4abb9dff716e098f05852d9a3d8ac8cbcb44 (diff)
downloadopie-44b9e62c1e5071fc6e5f8e80204b9974dbc704b6.zip
opie-44b9e62c1e5071fc6e5f8e80204b9974dbc704b6.tar.gz
opie-44b9e62c1e5071fc6e5f8e80204b9974dbc704b6.tar.bz2
add a qtopia method we need for the new launcher
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/categories.cpp8
-rw-r--r--library/backend/categories.h3
2 files changed, 11 insertions, 0 deletions
diff --git a/library/backend/categories.cpp b/library/backend/categories.cpp
index cce9f38..34ff6fe 100644
--- a/library/backend/categories.cpp
+++ b/library/backend/categories.cpp
@@ -868,64 +868,72 @@ void CheckedListView::setChecked( const QStringList &checked )
868/*! \fn void Categories::categoryAdded( const Categories &cats, const QString &appname, int uid) 868/*! \fn void Categories::categoryAdded( const Categories &cats, const QString &appname, int uid)
869 869
870 Emitted if a category is added. 870 Emitted if a category is added.
871 871
872 \a cats is a const reference to this object 872 \a cats is a const reference to this object
873 \a appname is the CategoryGroup application name that the category was added to or QString::null if it was global 873 \a appname is the CategoryGroup application name that the category was added to or QString::null if it was global
874 \a uid is the unique identifier associated with the added category 874 \a uid is the unique identifier associated with the added category
875*/ 875*/
876 876
877/*! \fn void Categories::categoryRemoved( const Categories &cats, const QString &appname, 877/*! \fn void Categories::categoryRemoved( const Categories &cats, const QString &appname,
878 int uid) 878 int uid)
879 879
880 Emitted if removed category is removed. 880 Emitted if removed category is removed.
881 881
882 \a cats is a const reference to this object 882 \a cats is a const reference to this object
883 \a appname is the CategoryGroup application name that the category was removed from or QString::null if it was the global CategoryGroup 883 \a appname is the CategoryGroup application name that the category was removed from or QString::null if it was the global CategoryGroup
884 \a uid is the unique identifier associated with the removed category 884 \a uid is the unique identifier associated with the removed category
885*/ 885*/
886 886
887 887
888/*! \fn void Categories::categoryRenamed( const Categories &cats, const QString &appname, 888/*! \fn void Categories::categoryRenamed( const Categories &cats, const QString &appname,
889 int uid) 889 int uid)
890 890
891 Emitted if \a uid in the \a appname CategoryGroup is renamed in \a cats 891 Emitted if \a uid in the \a appname CategoryGroup is renamed in \a cats
892 object. 892 object.
893 893
894 \a cats is a const reference to this object 894 \a cats is a const reference to this object
895 \a appname is the CategoryGroup application name that the category was renamed in or QString::null if it was the global CategoryGroup 895 \a appname is the CategoryGroup application name that the category was renamed in or QString::null if it was the global CategoryGroup
896 \a uid is the unique identifier associated with the renamed category 896 \a uid is the unique identifier associated with the renamed category
897*/ 897*/
898 898
899/*! \fn Categories::Categories( QObject *parent=0, const char *name = 0 ) 899/*! \fn Categories::Categories( QObject *parent=0, const char *name = 0 )
900 900
901 Constructor for an empty Categories object. 901 Constructor for an empty Categories object.
902*/ 902*/
903 903
904/*! \fn Categories::Categories( const Categories &copyFrom ) 904/*! \fn Categories::Categories( const Categories &copyFrom )
905 905
906 Deep copy constructor 906 Deep copy constructor
907*/ 907*/
908 908
909/*! \fn Categories::~Categories() 909/*! \fn Categories::~Categories()
910 910
911 Empty destructor. Call save() before destruction if there are changes 911 Empty destructor. Call save() before destruction if there are changes
912 that need to be saved. 912 that need to be saved.
913*/ 913*/
914 914
915/*! \fn CategoryGroup::clear() 915/*! \fn CategoryGroup::clear()
916 \internal 916 \internal
917*/ 917*/
918 918
919/*! \fn const QMap<int, QString> &CategoryGroup::idMap() const 919/*! \fn const QMap<int, QString> &CategoryGroup::idMap() const
920 920
921 Returns a const reference to the id to label QMap 921 Returns a const reference to the id to label QMap
922*/ 922*/
923 923
924/*! \fn CategoryGroup::CategoryGroup() 924/*! \fn CategoryGroup::CategoryGroup()
925 \internal 925 \internal
926*/ 926*/
927 927
928/*! \fn CategoryGroup::CategoryGroup(const CategoryGroup &c) 928/*! \fn CategoryGroup::CategoryGroup(const CategoryGroup &c)
929 \internal 929 \internal
930*/ 930*/
931 931
932
933/* ### FIXME properly merge */
934QStringList Categories::labels( const QString & app, const QArray<int> &catids ) const
935{
936 QStringList strs = mGlobalCats.labels( catids );
937 strs += mAppCats[app].labels( catids );
938 return strs;
939}
diff --git a/library/backend/categories.h b/library/backend/categories.h
index d5b3669..91c93e7 100644
--- a/library/backend/categories.h
+++ b/library/backend/categories.h
@@ -90,128 +90,131 @@ class QPC_EXPORT Categories : public QObject
90{ 90{
91 Q_OBJECT 91 Q_OBJECT
92public: 92public:
93 Categories( QObject *parent=0, const char *name = 0 ) 93 Categories( QObject *parent=0, const char *name = 0 )
94 : QObject( parent, name ), mGlobalCats(), mAppCats() { } 94 : QObject( parent, name ), mGlobalCats(), mAppCats() { }
95 Categories( const Categories &copyFrom ) : QObject( copyFrom.parent() ), 95 Categories( const Categories &copyFrom ) : QObject( copyFrom.parent() ),
96 mGlobalCats( copyFrom.mGlobalCats ), 96 mGlobalCats( copyFrom.mGlobalCats ),
97 mAppCats( copyFrom.mAppCats ) { } 97 mAppCats( copyFrom.mAppCats ) { }
98 virtual ~Categories() { } 98 virtual ~Categories() { }
99 99
100 Categories &operator= ( const Categories &c ) 100 Categories &operator= ( const Categories &c )
101{ mAppCats = c.mAppCats; mGlobalCats = c.mGlobalCats; return *this; } 101{ mAppCats = c.mAppCats; mGlobalCats = c.mGlobalCats; return *this; }
102 102
103 void clear(); 103 void clear();
104 104
105 /** Add the category name as long as it doesn't already exist 105 /** Add the category name as long as it doesn't already exist
106 * locally or globally. Return UID if added, 0 if conflicts 106 * locally or globally. Return UID if added, 0 if conflicts
107 * (error). 107 * (error).
108 */ 108 */
109 int addCategory( const QString &appname, const QString &catname); 109 int addCategory( const QString &appname, const QString &catname);
110 /** Add the category name as long as it doesn't already exist 110 /** Add the category name as long as it doesn't already exist
111 * locally or globally. Return UID if added, 0 if conflicts 111 * locally or globally. Return UID if added, 0 if conflicts
112 * (error). 112 * (error).
113 */ 113 */
114 int addCategory( const QString &appname, const QString &catname, int uid); 114 int addCategory( const QString &appname, const QString &catname, int uid);
115 /** Add the global category just checking that it doesn't 115 /** Add the global category just checking that it doesn't
116 * already exist globally. Return UID if added, 0 if conflicts. 116 * already exist globally. Return UID if added, 0 if conflicts.
117 */ 117 */
118 int addGlobalCategory( const QString &catname ); 118 int addGlobalCategory( const QString &catname );
119 /** Add the global category just checking that it doesn't 119 /** Add the global category just checking that it doesn't
120 * already exist globally. Return UID if added, 0 if conflicts. 120 * already exist globally. Return UID if added, 0 if conflicts.
121 */ 121 */
122 int addGlobalCategory( const QString &catname, int uid ); 122 int addGlobalCategory( const QString &catname, int uid );
123 /** Removes the category from the application; if it is not found 123 /** Removes the category from the application; if it is not found
124 * in the application, then it removes it from the global list 124 * in the application, then it removes it from the global list
125 */ 125 */
126 bool removeCategory( const QString &appName, const QString &catName, 126 bool removeCategory( const QString &appName, const QString &catName,
127 bool checkGlobal = TRUE); 127 bool checkGlobal = TRUE);
128 bool removeCategory( const QString &appName, int uid ); 128 bool removeCategory( const QString &appName, int uid );
129 bool removeGlobalCategory( const QString &catName ); 129 bool removeGlobalCategory( const QString &catName );
130 bool removeGlobalCategory( int uid ); 130 bool removeGlobalCategory( int uid );
131 131
132 QArray<int> ids( const QString &app, const QStringList &labels) const; 132 QArray<int> ids( const QString &app, const QStringList &labels) const;
133 133
134 /** Returns the id associated with the app */ 134 /** Returns the id associated with the app */
135 int id( const QString &app, const QString &cat ) const; 135 int id( const QString &app, const QString &cat ) const;
136 /** Returns the label associated with the id */ 136 /** Returns the label associated with the id */
137 QString label( const QString &app, int id ) const; 137 QString label( const QString &app, int id ) const;
138 138
139 enum ExtraLabels { NoExtra, AllUnfiled, AllLabel, UnfiledLabel }; 139 enum ExtraLabels { NoExtra, AllUnfiled, AllLabel, UnfiledLabel };
140 /** Returns the sorted list of all categories that are 140 /** Returns the sorted list of all categories that are
141 * associated with the app. 141 * associated with the app.
142 * If includeGlobal parameter is TRUE then the returned 142 * If includeGlobal parameter is TRUE then the returned
143 * categories will include the global category items. 143 * categories will include the global category items.
144 * If extra = NoExtra, then 144 * If extra = NoExtra, then
145 * If extra = AllUnfiled, then All and Unfiled will be prepended to 145 * If extra = AllUnfiled, then All and Unfiled will be prepended to
146 * the list 146 * the list
147 * If extra = AllLabel, then All is prepended 147 * If extra = AllLabel, then All is prepended
148 * If extra = UnfiledLabel, then Unfiled is prepended 148 * If extra = UnfiledLabel, then Unfiled is prepended
149 */ 149 */
150 QStringList labels( const QString &app, 150 QStringList labels( const QString &app,
151 bool includeGlobal = TRUE, 151 bool includeGlobal = TRUE,
152 ExtraLabels extra = NoExtra ) const; 152 ExtraLabels extra = NoExtra ) const;
153 153
154 QStringList labels( const QString &app,
155 const QArray<int> &catids ) const;
156
154 enum DisplaySingle { ShowMulti, ShowAll, ShowFirst }; 157 enum DisplaySingle { ShowMulti, ShowAll, ShowFirst };
155 158
156 /** Returns a single string associated with the cat ids for display in 159 /** Returns a single string associated with the cat ids for display in
157 * a combobox or any area that requires one string. If catids are empty 160 * a combobox or any area that requires one string. If catids are empty
158 * then "Unfiled" will be returned. If multiple categories are assigned 161 * then "Unfiled" will be returned. If multiple categories are assigned
159 * then the behavior depends on the DisplaySingle type. 162 * then the behavior depends on the DisplaySingle type.
160 * If /a display is set to ShowMulti then " (multi)" appended to the 163 * If /a display is set to ShowMulti then " (multi)" appended to the
161 * first string. If /a display is set to ShowAll, then a space seperated 164 * first string. If /a display is set to ShowAll, then a space seperated
162 * string is returned with all categories. If ShowFirst is returned, 165 * string is returned with all categories. If ShowFirst is returned,
163 * the just the first string is returned. 166 * the just the first string is returned.
164 */ 167 */
165 QString displaySingle( const QString &app, 168 QString displaySingle( const QString &app,
166 const QArray<int> &catids, 169 const QArray<int> &catids,
167 DisplaySingle display ) const; 170 DisplaySingle display ) const;
168 171
169 QStringList globalCategories() const { return mGlobalCats.labels();} 172 QStringList globalCategories() const { return mGlobalCats.labels();}
170 173
171 bool renameCategory( const QString &appname, 174 bool renameCategory( const QString &appname,
172 const QString &oldName, 175 const QString &oldName,
173 const QString &newName ); 176 const QString &newName );
174 bool renameGlobalCategory( const QString &oldName, 177 bool renameGlobalCategory( const QString &oldName,
175 const QString &newName ); 178 const QString &newName );
176 179
177 void setGlobal( const QString &appname, const QString &catname, 180 void setGlobal( const QString &appname, const QString &catname,
178 bool value ); 181 bool value );
179 bool isGlobal( const QString &catname ) const; 182 bool isGlobal( const QString &catname ) const;
180 183
181 184
182 /** Returns true if the catname is associated with any application 185 /** Returns true if the catname is associated with any application
183 */ 186 */
184 bool exists( const QString &catname ) const; 187 bool exists( const QString &catname ) const;
185 bool exists( const QString &appname, const QString &catname) const; 188 bool exists( const QString &appname, const QString &catname) const;
186 189
187 bool save( const QString &fname ) const; 190 bool save( const QString &fname ) const;
188 bool load( const QString &fname ); 191 bool load( const QString &fname );
189 192
190 // for debugging 193 // for debugging
191 void dump() const; 194 void dump() const;
192 195
193 const QMap<QString, CategoryGroup> &appGroupMap() const{ return mAppCats; } 196 const QMap<QString, CategoryGroup> &appGroupMap() const{ return mAppCats; }
194 const CategoryGroup &globalGroup() const { return mGlobalCats; } 197 const CategoryGroup &globalGroup() const { return mGlobalCats; }
195 198
196signals: 199signals:
197 /** emitted if added a category; 200 /** emitted if added a category;
198 * the second param is the application the category was added to 201 * the second param is the application the category was added to
199 * or null if global 202 * or null if global
200 * the third param is the uid of the newly added category 203 * the third param is the uid of the newly added category
201 */ 204 */
202 void categoryAdded( const Categories &, const QString &, int ); 205 void categoryAdded( const Categories &, const QString &, int );
203 /** emitted if removed a category 206 /** emitted if removed a category
204 * the second param is the application the category was removed from 207 * the second param is the application the category was removed from
205 * or null if global 208 * or null if global
206 * the third param is the uid of the removed category 209 * the third param is the uid of the removed category
207 */ 210 */
208 void categoryRemoved( const Categories &, const QString &, int ); 211 void categoryRemoved( const Categories &, const QString &, int );
209 /** emitted if a category is renamed; the second param is the uid of 212 /** emitted if a category is renamed; the second param is the uid of
210 * the removed category */ 213 * the removed category */
211 void categoryRenamed( const Categories &, const QString &, int ); 214 void categoryRenamed( const Categories &, const QString &, int );
212 215
213private: 216private:
214 CategoryGroup mGlobalCats; 217 CategoryGroup mGlobalCats;
215 QMap< QString, CategoryGroup > mAppCats; 218 QMap< QString, CategoryGroup > mAppCats;
216}; 219};
217 220