UBTeacherGuideWidget.h 6.86 KB
Newer Older
1 2 3
/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
Claudio Valerio's avatar
Claudio Valerio committed
4
 * the Free Software Foundation, either version 2 of the License, or
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef UBTEACHERGUIDEWIDGET_H
#define UBTEACHERGUIDEWIDGET_H

class QTreeWidget;
class QHeaderView;
class QLabel;
class QVBoxLayout;
class QPushButton;
24
class UBDocumentProxy;
25
class UBGraphicsTextItem;
26
class QScrollArea;
27

28 29
#include "UBTeacherGuideWidgetsTools.h"

30 31
#include "interfaces/IDataStorage.h"

32 33 34 35 36 37
typedef enum
{
    tUBTGZeroPageMode_EDITION,
    tUBTGZeroPageMode_PRESENTATION
}tUBTGZeroPageMode;

38 39
#define LOWER_RESIZE_WIDTH 50

40 41 42
/***************************************************************************
 *               class    UBTeacherGuideEditionWidget                      *
 ***************************************************************************/
43
class UBTeacherGuideEditionWidget : public QWidget , public IDataStorage
44 45 46 47 48 49 50 51
{
    Q_OBJECT
public:
    explicit UBTeacherGuideEditionWidget(QWidget* parent = 0, const char* name="UBTeacherGuideEditionWidget");
    ~UBTeacherGuideEditionWidget();
    void cleanData();
    QVector<tUBGEElementNode*> getData();

52
    void load(QString element);
53
    QVector<tIDataStorage*> save(int pageIndex);
54

Claudio Valerio's avatar
Claudio Valerio committed
55 56
    bool isModified();

57
public slots:
58
    void onAddItemClicked(QTreeWidgetItem* widget, int column, QDomElement* element = 0);
59 60
    void onActiveSceneChanged();
    void showEvent(QShowEvent* event);
61 62 63 64 65 66 67

private:
    QList<QTreeWidgetItem*> getChildrenList(QTreeWidgetItem* widgetItem);
    QVector<tUBGEElementNode*> getPageAndCommentData();

    QVBoxLayout* mpLayout;
    QLabel* mpDocumentTitle;
68
    QLabel* mpPageNumberLabel;
69 70
    UBTGAdaptableText* mpPageTitle;
    UBTGAdaptableText* mpComment;
71
    QFrame* mpSeparator;
72 73 74 75 76 77
    QTreeWidget* mpTreeWidget;
    QTreeWidgetItem* mpRootWidgetItem;
    UBAddItem* mpAddAnActionItem;
    UBAddItem* mpAddAMediaItem;
    UBAddItem* mpAddALinkItem;

78 79
private slots:
    void onActiveDocumentChanged();
Claudio Valerio's avatar
Claudio Valerio committed
80 81 82
#ifdef Q_WS_MACX
    void onSliderMoved(int size);
#endif
83 84 85 86 87 88 89 90 91 92 93 94 95
};


/***************************************************************************
 *           class    UBTeacherGuidePresentationWidget                     *
 ***************************************************************************/
class UBTeacherGuidePresentationWidget : public QWidget
{
    Q_OBJECT
public:
    explicit UBTeacherGuidePresentationWidget(QWidget* parent, const char* name = "UBTeacherGuidePresentationName");
    ~UBTeacherGuidePresentationWidget();
    void showData(QVector<tUBGEElementNode*>data);
96
    void cleanData();
97 98 99

public slots:
    void onAddItemClicked(QTreeWidgetItem* widget, int column);
100
    void onActiveSceneChanged();
101 102

private:
103 104
    bool eventFilter(QObject* object, QEvent* event);

105 106 107 108 109 110
    void createMediaButtonItem();

    UBTGAdaptableText* mpPageTitle;
    UBTGAdaptableText* mpComment;
    QVBoxLayout* mpLayout;
    QHBoxLayout* mpButtonTitleLayout;
111 112 113
    QLabel* mpDocumentTitle;
    QLabel* mpPageNumberLabel;
    QFrame* mpSeparator;
114
    QPushButton* mpModePushButton;
115
    UBTGDraggableTreeItem* mpTreeWidget;
116 117 118
    QTreeWidgetItem* mpRootWidgetItem;
    QTreeWidgetItem* mpMediaSwitchItem;

119 120 121 122 123 124

#ifdef Q_WS_MACX
private slots:
    void onSliderMoved(int size);
#endif

125 126
};

127
/***************************************************************************
128
 *                  class    UBTeacherGuidePageZeroWidget                  *
129
 ***************************************************************************/
130
class UBTeacherGuidePageZeroWidget : public QWidget
131 132 133 134
{
    Q_OBJECT

public:
135 136
    explicit UBTeacherGuidePageZeroWidget(QWidget* parent, const char* name = "UBTeacherGuidePageZeroEditionWidget");
    ~UBTeacherGuidePageZeroWidget();
137 138

    QVector<tUBGEElementNode*> getData();
Claudio Valerio's avatar
Claudio Valerio committed
139
    bool isModified();
140

shibakaneki's avatar
shibakaneki committed
141 142
signals:
	void resized();
143

144 145 146 147
public slots:
    void onActiveSceneChanged();
    void switchToMode(tUBTGZeroPageMode mode = tUBTGZeroPageMode_EDITION);

shibakaneki's avatar
shibakaneki committed
148 149 150
protected:
    void resizeEvent(QResizeEvent* ev);

151 152
private:
    void fillComboBoxes();
153 154
    void loadData();
    void hideEvent(QHideEvent* event);
155
    bool eventFilter(QObject* object, QEvent* event);
156
    void updateSceneTitle();
157 158 159

    QVBoxLayout* mpLayout;
    QHBoxLayout* mpButtonTitleLayout;
160
    QVBoxLayout* mpContainerWidgetLayout;
161 162
    QPushButton* mpModePushButton;
    QLabel* mpPageNumberLabel;
163 164 165 166

    QScrollArea* mpScrollArea;
    QWidget* mpContainerWidget;

167 168 169 170 171 172 173 174 175
    UBTGAdaptableText* mpSessionTitle;
    QFrame* mpSeparatorSessionTitle;

    QLabel* mpAuthorsLabel;
    UBTGAdaptableText* mpAuthors;
    QFrame* mpSeparatorAuthors;

    QLabel* mpCreationLabel;
    QLabel* mpLastModifiedLabel;
176 177 178
    QLabel* mpObjectivesLabel;
    UBTGAdaptableText* mpObjectives;
    QFrame* mpSeparatorObjectives;
179 180 181 182 183 184 185 186 187

    QLabel* mpIndexLabel;
    QLabel* mpKeywordsLabel;
    UBTGAdaptableText* mpKeywords;

    QLabel* mpSchoolLevelItemLabel;
    QComboBox* mpSchoolLevelBox;
    QLabel* mpSchoolLevelValueLabel;

188 189 190
    QLabel* mpSchoolSubjectsItemLabel;
    QComboBox* mpSchoolSubjectsBox;
    QLabel* mpSchoolSubjectsValueLabel;
191 192 193 194 195 196 197 198 199 200 201 202

    QLabel* mpSchoolTypeItemLabel;
    QComboBox* mpSchoolTypeBox;
    QLabel* mpSchoolTypeValueLabel;
    QFrame* mpSeparatorIndex;

    QLabel* mpLicenceLabel;
    QComboBox* mpLicenceBox;
    QLabel* mpLicenceValueLabel;
    QLabel* mpLicenceIcon;
    QHBoxLayout* mpLicenceLayout;

203 204
    UBGraphicsTextItem* mpSceneItemSessionTitle;

205 206 207 208 209
    QMap<QString,QString> mGradeLevelsMap;
    QMap<QString,QStringList> mSubjects;

private slots:
    void onSchoolLevelChanged(QString schoolLevel);
210
    void persistData();
211
};
212 213 214 215 216 217 218 219 220 221 222 223

/***************************************************************************
 *                    class    UBTeacherGuideWidget                        *
 ***************************************************************************/

class UBTeacherGuideWidget : public QStackedWidget
{
    Q_OBJECT
public:
    explicit UBTeacherGuideWidget(QWidget* parent = 0, const char* name="UBTeacherGuideWidget");
    ~UBTeacherGuideWidget();

Claudio Valerio's avatar
Claudio Valerio committed
224 225
    bool isModified();

226 227 228 229
public slots:
    void changeMode();
    void showPresentationMode();
    void connectToStylusPalette();
230
    void onActiveSceneChanged();
231 232

private:
233
    UBTeacherGuidePageZeroWidget* mpPageZeroWidget;
234 235
    UBTeacherGuideEditionWidget* mpEditionWidget;
    UBTeacherGuidePresentationWidget* mpPresentationWidget;
236
    QVector<tUBGEElementNode*>mCurrentData;
Claudio Valerio's avatar
Claudio Valerio committed
237 238 239 240 241
    bool mKeyboardActionFired;

private slots:
	void onTriggeredAction(bool checked);
	void onTriggeredKeyboardAction(bool checked);
242 243 244
};

#endif // UBTEACHERGUIDEWIDGET_H