UBTBPageEditWidget.h 3.37 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#ifndef UBTBPAGEEDITWIDGET_H
#define UBTBPAGEEDITWIDGET_H

#include <QString>
#include <QTextEdit>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QComboBox>
#include <QLabel>
#include <QPushButton>

#include "core/UBPersistenceManager.h"
#include "customWidgets/UBWidgetList.h"
#include "interfaces/IDropable.h"
#include "UBTeacherBarDataMgr.h"

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
class UBTeacherStudentAction : public QWidget
{
    Q_OBJECT

public:
    UBTeacherStudentAction(QWidget* parent=0, const char* name="UBTeacherStudentAction");
    ~UBTeacherStudentAction();
    QString text();
    QString comboValue();
    void setComboValue(int value);
    void setText(const QString& text);

private:
    QTextEdit* mpText;
    QHBoxLayout* mpLayout;
    QVBoxLayout* mpComboLayout;
    QComboBox* mpCombo;
};

class UBUrlWidget : public QWidget
{
public:
    UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget");
    ~UBUrlWidget();

    QString url();
    void setUrl(const QString& url);

    QString title(){return mpTitle->text();}
    void setTitle(const QString& title){mpTitle->setText(title);}

private:
    QVBoxLayout* mpLayout;
    QHBoxLayout* mpLabelLayout;
    QHBoxLayout* mpTitleLayout;
    QLabel* mpUrlLabel;
    QLineEdit* mpUrl;

    QLabel* mpTitleLabel;
    QLineEdit* mpTitle;
};

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
class UBTBMediaContainer : public UBWidgetList
    , public IDropable
{
    Q_OBJECT
public:
    UBTBMediaContainer(QWidget* parent=0, const char* name="UBTBMediaContainer");
    ~UBTBMediaContainer();
    QStringList mediaUrls();
    QWidget* generateMediaWidget(const QString& url);
    void cleanMedias();

signals:
    void mediaDropped(const QString& url);

protected:
    void dropEvent(QDropEvent* pEvent);
    void dragEnterEvent(QDragEnterEvent* pEvent);
    void dragMoveEvent(QDragMoveEvent* pEvent);
    void dragLeaveEvent(QDragLeaveEvent* pEvent);

private:
    void addMedia(const QString& mediaPath);

    QStringList mMediaList;
};

class UBTBPageEditWidget : public QWidget
{
    Q_OBJECT
public:
    UBTBPageEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBPageEditWidget");
    ~UBTBPageEditWidget();
91 92 93
    void saveFields();
    void updateFields();
    void clearFields();
94 95 96 97 98 99

signals:
    void valueChanged();
    void changeTBState(eTeacherBarState state);

private slots:
100 101
    void onTitleChanged();
    void onCommentsChanged();
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
    void onActionButton();
    void onLinkButton();
    void onMediaDropped(const QString& url);
    void onDocumentEditClicked();
    void onPagePreviewClicked();

private:
    QVBoxLayout mLayout;
    QHBoxLayout mTitleLayout;
    QVBoxLayout mContainerLayout;
    QHBoxLayout mActionLayout;
    QHBoxLayout mLinkLayout;
    QHBoxLayout mDocumentViewLayout;
    QHBoxLayout mPagePreviewLayout;

    UBTeacherBarDataMgr* mpDataMgr;
    QLabel* mpTitleLabel;
    QLineEdit* mpTitle;
    QLabel* mpMediaLabel;
    UBTBMediaContainer* mpMediaContainer;
    QLabel* mpActionLabel;
    UBWidgetList* mpActions;
    QPushButton* mpActionButton;
    QLabel* mpLinkLabel;
    UBWidgetList* mpLinks;
    QPushButton* mpLinkButton;
    QLabel* mpCommentLabel;
    QTextEdit* mpComments;
    QPushButton* mpDocumentEditbutton;
    QPushButton* mpPagePreviewButton;
    QWidget* mpContainer;
133 134 135

    QVector<UBTeacherStudentAction*> mActions;
    QVector<UBUrlWidget*> mUrls;
136 137 138
    QVector<QWidget*> mMedias;
    QStringList mMediaUrls;
    bool mClearingFields;
139 140 141
};

#endif // UBTBPAGEEDITWIDGET_H