1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#ifndef UBLIBRARYCONTROLLER_H_
#define UBLIBRARYCONTROLLER_H_
#include <QtGui>
#include <QtWebKit>
#include "web/UBWebPage.h"
class UBGraphicsScene;
class UBBoardController;
class QGraphicsSvgItem;
class UBLibraryWebView;
class UBWebView;
typedef enum
{
eUBLibElementType_Category = 0,
eUBLibElementType_VirtualFolder,
eUBLibElementType_Folder,
eUBLibElementType_InteractiveItem,
eUBLibElementType_Item
}eUBLibElementType;
class UBLibElement
{
public:
UBLibElement();
UBLibElement(eUBLibElementType type, const QUrl& path, const QString& name);
~UBLibElement();
static UBLibElement* trashElement();
eUBLibElementType type(){return mType;}
void setType(eUBLibElementType type) {mType = type;}
QUrl path(){return mPath;}
void setPath(QUrl path){mPath = path;}
QImage* thumbnail(){return &mThumbnail;}
void setThumbnail(QImage* pThumb){mThumbnail = *pThumb;}
QString information(){return mInfo;}
void setInformation(QString info){mInfo = info;}
QString name(){return mName;}
void setName(QString name){mName = name;}
QString extension(){return mExtension;}
void setExtension(QString &extension){ mExtension = extension;}
bool isMoveable(){return mbMoveable;}
void setMoveable(bool bState){mbMoveable = bState;}
private:
eUBLibElementType mType;
QUrl mPath;
QImage mThumbnail;
QString mInfo;
QString mName;
QString mExtension;
bool mbMoveable;
};
class UBChainedLibElement
{
public:
UBChainedLibElement(UBLibElement* pElem, UBChainedLibElement* pNextElem=NULL);
~UBChainedLibElement();
UBChainedLibElement* nextElement(){return mpNextElem;}
void setNextElement(UBChainedLibElement* nextElem);
UBLibElement* element(){return mpElem;}
private:
UBLibElement* mpElem;
UBChainedLibElement* mpNextElem;
};
class UBLibraryController : public QObject
{
Q_OBJECT;
public:
UBLibraryController(QWidget *parentWidget, UBBoardController *boardController);
virtual ~UBLibraryController();
QList<UBLibElement*> getContent(UBLibElement* pElement);
void moveContent(QList<UBLibElement*> sourceList, UBLibElement *pDestination);
void trashElements(QList<UBLibElement*> trashList);
void emptyElementsOnTrash(QList<UBLibElement*> elementsList);
void addNativeToolToFavorites(const QUrl& url);
void setItemAsBackground(UBLibElement* image);
void addItemToPage(UBLibElement* item);
void addToFavorite(QList<UBLibElement*> elementList);
void removeFromFavorite(QList<UBLibElement*> elementList);
void importItemOnLibrary(QString& pItemString);
void importImageOnLibrary(QImage &pImage);
QString favoritePath();
void createNewFolder(QString name, UBLibElement* parentElem);
bool canItemsOnElementBeDeleted(UBLibElement *pElement);
signals:
void dialogClosed(int state);
void setResource(QString &pathResource,QString &mimetype);
public slots:
void removeBackground();
void addImagesToCurrentPage(const QList<QUrl>& images);
void addVideosToCurrentPage(const QList<QUrl>& videos);
void addAudiosToCurrentPage(const QList<QUrl>& sounds);
void addInteractivesToCurrentPage(const QList<QUrl>& interactiveWidgets);
protected:
UBGraphicsScene* activeScene();
QRectF visibleSceneRect();
QList<UBLibElement*> mFavoriteList;
void persistFavoriteList();
void readFavoriteList();
QList<UBLibElement*> mInternalLibElements;
private:
QList<UBLibElement*> rootCategoriesList();
QList<UBLibElement*> listElementsInPath(const QString& pPath);
QList<UBLibElement*> listElementsInVirtualForlder(UBLibElement* pElement);
void userPath(QUrl &pPath);
QImage* thumbnailForFile(UBLibElement* pPath);
QImage* createThumbnail(UBLibElement* pPath);
QList<UBLibElement*> addVirtualElementsForItemPath(const QString& pPath);
void createInternalWidgetItems();
void routeItem(QString& pItem, QString pMiddleDirectory = QString());
void createDirectory(QUrl& pDirPath);
QUrl mAudioStandardDirectoryPath;
QUrl mVideoStandardDirectoryPath;
QUrl mPicturesStandardDirectoryPath;
QUrl mInteractiveUserDirectoryPath;
QUrl mInteractiveCategoryPath;
QStringList addItemsToCurrentLibrary(const QDir& pSelectedFolder, const QStringList& pExtensions);
UBLibElement* isOnFavoriteList(UBLibElement * element);
QWidget *mParentWidget;
UBBoardController *mBoardController;
int mLastItemOffsetIndex;
};
#endif /* UBLIBRARYCONTROLLER_H_ */