LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
iconheap.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2011-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef ICONHEAP_H_
23 #define ICONHEAP_H_
24 
25 #include <QObject>
26 #include <QUuid>
27 #include <QString>
28 #include <QMap>
29 #include <QPointer>
30 #include <QList>
31 #include <QSize>
32 
33 class PixmapObject;
34 class IconBase;
35 
36 //IconAttributes is essentially just a public version of IconWrapper
37 // (use it to be able to filter out stuff returned to clients while being able to keep some
38 // data hidden in IconWrapper)
40 {
41 public:
43  IconAttributes(const QUuid& _uidOfOriginal, const QString& _appId, const QString& _launchPtId);
45  QString appId;
46  QString launchPtId;
47 };
48 
50 {
51 public:
52  IconWrapper();
53  IconWrapper(const QUuid& _uid,IconBase * p_icon);
54  IconWrapper(const QUuid& _uid,const QString& _appId,const QString& _lptId,IconBase * p_icon);
55  IconWrapper(const QUuid& _uid,const QString& _appId,const QString& _lptId,IconBase * p_icon,const QUuid& _originalUid);
56  QUuid uid;
57  QString appId;
58  QString launchPtId;
59  QPointer<IconBase> pIcon;
60  QUuid copyOf; //if not null, then the icon is a copy, and this is its original's uid
61  QUuid locationTag; // the page or other entity where the icon currently resides; this is JUST AN OPTIONAL HINT!
62  // that's set voluntarily; it's mostly just for initial scan and page distribution of icons
63  // for GEMSTONE-RD
65 
66 };
67 
68 namespace FindIconHint
69 {
70  enum Enum
71  {
75  };
76 }
77 
78 namespace CommonlyUsedImages
79 {
80  enum Enum
81  {
89  };
90 }
91 
92 class IconHeap : public QObject
93 {
94  Q_OBJECT
95 
96 public:
97 
98  static IconHeap * iconHeap();
99 
100  IconBase * getIcon(const QUuid& iconUid,FindIconHint::Enum searchHint = FindIconHint::Original);
101 // IconBase * getIcon(const QString& appId);
102  IconBase * getIcon(const QString& appId,const QString& launchPointId);
103 
104  IconBase * getIconEx(const QUuid& iconUid,IconAttributes& r_attr,FindIconHint::Enum searchHint = FindIconHint::Original);
105 
106  IconBase * copyIcon(const QUuid& iconUid);
107 
108  QList<IconBase *> findCopies(const QUuid& masterUid);
109 
110  bool addIcon(IconBase * p_icon);
111  bool addIcon(IconBase * p_icon,const QString& appId,const QString& launchPointId = QString());
112 
113  void annotateIcon(const QUuid& iconUid,const QString& appId,const QString& launchPointId = QString());
114  bool tagIconWithLocationUid(const QUuid& iconUid,const QUuid& tagUid,bool overwriteExistingTag=false);
115  QUuid iconLocationTag(const QUuid& iconUid);
116 
117  void deleteIconUnguarded(const QUuid& iconUid);
118 
119  //this one will only delete icons that are copies
120  // TODO: make this one public, and protect the Unguarded variant
121  void deleteIconCopy(const QUuid& copiedIconUid);
122 
124  static IconBase * makeIcon(const QString& mainIconFilePath,const QString& frameIconFilePath,const QList<QString>& decoratorsFilePaths, const QString& feedbackIconFilePath);
125  static IconBase * makeIconStandardFrameAndDecorators(const QString& mainIconFilePath);
126 
127  static IconBase * makeIconConstrained(const QString& mainIconFilePath,const QString& frameIconFilePath,
128  const QList<QString>& decoratorsFilePaths, const QString& feedbackIconFilePath,
129  const QSize& size,bool limitOnly=true);
130 
131  static IconBase * makeIconConstrainedStandardFrameAndDecorators(const QString& mainIconFilePath,const QSize& size,bool limitOnly=true);
132 
134  // TODO: this belongs in a pixmap (pmo) heap. Since I'm running short on time and don't have any other need to write one at the moment
135  // i'll just do it here. But when the pixpager and a pixmapheap get added, move this code there
136 
138 
139  //convenience accessors
145 
146  //actually is a PixmapFilmstripObject...and a bit different in how it loads (see .cpp file)
148 
149 
150 private:
151 
152  IconBase * find(const QUuid& iconUid);
153  IconBase * findInCopies(const QUuid& iconUid);
154  IconBase * find(const QString& combinedAppLpId);
155  bool find(const QUuid& iconUid,IconWrapper& r_wrap);
156  bool find(const QUuid& iconUid,IconWrapper** r_wrap);
157  bool findInCopies(const QUuid& iconUid,IconWrapper& r_wrap);
158  bool find(const QString& combinedAppLpId,IconWrapper& r_wrap);
159 
160  IconHeap();
161  ~IconHeap();
162 
163 private:
164 
165  static QPointer<IconHeap> s_qp_instance;
166  static QString s_standardFrameFilePath;
167  static QString s_standardFeedbackFilePath;
168  static QList<QString> s_standardDecoratorsFilePaths;
169 
170  typedef QMap<CommonlyUsedImages::Enum,QPointer<PixmapObject> >::const_iterator CommonIconImageNameMapConstIter;
171  QMap<CommonlyUsedImages::Enum,QPointer<PixmapObject> > m_commonIconImagesMapById;
172 
173  typedef QMap<QUuid,IconWrapper>::iterator MainMapIter;
174  QMap<QUuid,IconWrapper> m_mainMapByUid;
175  typedef QMap<QString,IconWrapper>::iterator AliasMapIter;
176  QMap<QString,IconWrapper> m_aliasMapByAppLaunchPointCombinedId;
177 
178  typedef QMap<QUuid,IconWrapper>::iterator CopyMapIter;
179  QMap<QUuid,IconWrapper> m_copyMapByUid; //copies of the icons of the main map go here.
180  // it is the responsibility of the thing that requested the copy to maintain
181  // the uid handle to it so it can request it to be cleaned out later when no
182  // longer needed
183 
184 };
185 
186 #endif /* ICONHEAP_H_ */