-rw-r--r-- | library/backend/categories.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/backend/categories.cpp b/library/backend/categories.cpp index e37b3b9..2e84089 100644 --- a/library/backend/categories.cpp +++ b/library/backend/categories.cpp | |||
@@ -1,116 +1,116 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qtopia/categories.h> | 20 | #include <qtopia/private/categories.h> |
21 | #include <qtopia/stringutil.h> | 21 | #include <qtopia/stringutil.h> |
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qcstring.h> | 23 | #include <qcstring.h> |
24 | #include <qtextstream.h> | 24 | #include <qtextstream.h> |
25 | 25 | ||
26 | using namespace Qtopia; | 26 | using namespace Qtopia; |
27 | 27 | ||
28 | /*********************************************************** | 28 | /*********************************************************** |
29 | * | 29 | * |
30 | * CategoryGroup | 30 | * CategoryGroup |
31 | * | 31 | * |
32 | **********************************************************/ | 32 | **********************************************************/ |
33 | 33 | ||
34 | #ifdef PALMTOPCENTER | 34 | #ifdef PALMTOPCENTER |
35 | UidGen CategoryGroup::sUidGen( UidGen::PalmtopCenter ); | 35 | UidGen CategoryGroup::sUidGen( UidGen::PalmtopCenter ); |
36 | #else | 36 | #else |
37 | UidGen CategoryGroup::sUidGen( UidGen::Qtopia ); | 37 | UidGen CategoryGroup::sUidGen( UidGen::Qtopia ); |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | /*! \class CategoryGroup categories.h | 40 | /*! \class CategoryGroup categories.h |
41 | \brief Helper class that is used by Categories | 41 | \brief Helper class that is used by Categories |
42 | 42 | ||
43 | CategoryGroup is a group of categories that is associated with an | 43 | CategoryGroup is a group of categories that is associated with an |
44 | application or global set. Mainly it defines a map of ids to | 44 | application or global set. Mainly it defines a map of ids to |
45 | category labels and category labels to ids. Lookups can be done with | 45 | category labels and category labels to ids. Lookups can be done with |
46 | labels or unique idenifiers. | 46 | labels or unique idenifiers. |
47 | 47 | ||
48 | \ingroup qtopiaemb | 48 | \ingroup qtopiaemb |
49 | \ingroup qtopiadesktop | 49 | \ingroup qtopiadesktop |
50 | \warning Categories API will likely change between Qtopia 1.5 and Qtopia 3 | 50 | \warning Categories API will likely change between Qtopia 1.5 and Qtopia 3 |
51 | \sa Categories::appGroupMap(), Categories::globalGroup() | 51 | \sa Categories::appGroupMap(), Categories::globalGroup() |
52 | */ | 52 | */ |
53 | 53 | ||
54 | /*! Add \a label and return the UID. If failure, then 0 is returned. Note | 54 | /*! Add \a label and return the UID. If failure, then 0 is returned. Note |
55 | that All and Unfiled are reserved labels. | 55 | that All and Unfiled are reserved labels. |
56 | \internal | 56 | \internal |
57 | */ | 57 | */ |
58 | int CategoryGroup::add( const QString &label ) | 58 | int CategoryGroup::add( const QString &label ) |
59 | { | 59 | { |
60 | if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") ) | 60 | if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") ) |
61 | return 0; | 61 | return 0; |
62 | 62 | ||
63 | QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label ); | 63 | QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label ); |
64 | if ( findIt != mLabelIdMap.end() ) | 64 | if ( findIt != mLabelIdMap.end() ) |
65 | return 0; | 65 | return 0; |
66 | int newUid = uidGen().generate(); | 66 | int newUid = uidGen().generate(); |
67 | insert( newUid, label ); | 67 | insert( newUid, label ); |
68 | return newUid; | 68 | return newUid; |
69 | } | 69 | } |
70 | 70 | ||
71 | void CategoryGroup::insert( int uid, const QString &label ) | 71 | void CategoryGroup::insert( int uid, const QString &label ) |
72 | { | 72 | { |
73 | uidGen().store( uid ); | 73 | uidGen().store( uid ); |
74 | mIdLabelMap[uid] = label; | 74 | mIdLabelMap[uid] = label; |
75 | mLabelIdMap[label] = uid; | 75 | mLabelIdMap[label] = uid; |
76 | } | 76 | } |
77 | 77 | ||
78 | /*! \internal | 78 | /*! \internal |
79 | */ | 79 | */ |
80 | bool CategoryGroup::add( int uid, const QString &label ) | 80 | bool CategoryGroup::add( int uid, const QString &label ) |
81 | { | 81 | { |
82 | if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") ) | 82 | if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") ) |
83 | return FALSE; | 83 | return FALSE; |
84 | 84 | ||
85 | QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); | 85 | QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); |
86 | if ( labelIt != mLabelIdMap.end() ) | 86 | if ( labelIt != mLabelIdMap.end() ) |
87 | return FALSE; | 87 | return FALSE; |
88 | QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); | 88 | QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); |
89 | if ( idIt != mIdLabelMap.end() ) | 89 | if ( idIt != mIdLabelMap.end() ) |
90 | return FALSE; | 90 | return FALSE; |
91 | insert( uid, label ); | 91 | insert( uid, label ); |
92 | return TRUE; | 92 | return TRUE; |
93 | } | 93 | } |
94 | 94 | ||
95 | /*! Returns TRUE if \a label was removed from the group, FALSE if not. | 95 | /*! Returns TRUE if \a label was removed from the group, FALSE if not. |
96 | \internal | 96 | \internal |
97 | */ | 97 | */ |
98 | bool CategoryGroup::remove( const QString &label ) | 98 | bool CategoryGroup::remove( const QString &label ) |
99 | { | 99 | { |
100 | QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label ); | 100 | QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label ); |
101 | if ( findIt == mLabelIdMap.end() ) | 101 | if ( findIt == mLabelIdMap.end() ) |
102 | return FALSE; | 102 | return FALSE; |
103 | 103 | ||
104 | mIdLabelMap.remove( *findIt ); | 104 | mIdLabelMap.remove( *findIt ); |
105 | mLabelIdMap.remove( findIt ); | 105 | mLabelIdMap.remove( findIt ); |
106 | 106 | ||
107 | return TRUE; | 107 | return TRUE; |
108 | } | 108 | } |
109 | 109 | ||
110 | /*! Returns TRUE if \a uid was removed from the group, FALSE if not. | 110 | /*! Returns TRUE if \a uid was removed from the group, FALSE if not. |
111 | \internal | 111 | \internal |
112 | */ | 112 | */ |
113 | bool CategoryGroup::remove( int uid ) | 113 | bool CategoryGroup::remove( int uid ) |
114 | { | 114 | { |
115 | QMap<int,QString>::Iterator idIt = mIdLabelMap.find( uid ); | 115 | QMap<int,QString>::Iterator idIt = mIdLabelMap.find( uid ); |
116 | if ( idIt == mIdLabelMap.end() ) | 116 | if ( idIt == mIdLabelMap.end() ) |