LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
testiconfactory.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2010-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 TESTICONFACTORY_H_
23 #define TESTICONFACTORY_H_
24 
25 #include <QObject>
26 #include <QList>
27 #include <QMap>
28 #include <QString>
29 #include <QPointer>
30 #include "icon.h"
31 
32 namespace DimensionsUITest
33 {
34 
35 class IconFactory : public QObject
36 {
37  Q_OBJECT
38 public:
39 
40  static IconFactory * instance();
41  static void destroy();
42 
43  QList<IconBase *> quickCreateFromDir(const QString& directoryPath);
44  QList<IconBase *> quickCreateFromDir(const QString& directoryPath,
45  quint32 minWidth,quint32 maxWidth,
46  quint32 minHeight,quint32 maxHeight,
47  bool squareOnly);
48 
49  QList<IconBase *> quickCreateFromDirWithFrame(const QString& directoryPath,const QString& framePicAbsFilename);
50  QList<IconBase *> quickCreateFromDirWithFrame(const QString& directoryPath,const QString& framePicAbsFilename,
51  quint32 minWidth,quint32 maxWidth,
52  quint32 minHeight,quint32 maxHeight,
53  bool squareOnly);
54 
55  //modifies in place...returns true if successfully applied frame to everyone
56  bool addFrameToIcons(const QString& framePicPath,QList<IconBase *>& icons);
57 
58  //modifies in place...returns true if successfully applied label to everyone
59  // maxCharsPerWord = 0 -> unlimited word size
60  // does not guarantee uniqueness of labels...will wrap around if the word file doesn't have enough
61  // usable lines
62  bool addLabelsToIcons(const QString& wordFileAbsPath,const quint32 maxCharsPerWord,QList<IconBase *>& icons);
63  //randSeed is there for repeatability. use 0 to use time()
64  bool addLabelsToIconsAtRandom(const QString& dictionaryFileAbsPath,const quint32 maxCharsPerWord,int randSeed,QList<IconBase *>& icons);
65 
66 public Q_SLOTS:
67 
68  void slotPmoDestroyed(QObject * p_qobject);
69 
70 protected:
71 
72  virtual ~IconFactory();
73 
74  PixmapObject * loadPixmapObject(const QString& absFilePath);
75  void releasePixmapObject(PixmapObject * p_pix); //oh yeah, v.dangerous
76  void releasePixmapObject(const QString& absFilePath);
77 
79  typedef QMap<QString,QPointer<PixmapObject> >::const_iterator LoadedPmoMapConstIter;
80  typedef QMap<QString,QPointer<PixmapObject> >::iterator LoadedPmoMapIter;
81  QMap<QString,QPointer<PixmapObject> > m_loadedPmoMap;
82 };
83 
84 } //end namespace
85 
86 #endif /* TESTICONFACTORY_H_ */