UBLibActionBar.h 2.6 KB
Newer Older
Claudio Valerio's avatar
Claudio Valerio committed
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
#ifndef UBLIBACTIONBAR_H
#define UBLIBACTIONBAR_H

#include <QWidget>
#include <QButtonGroup>
#include <QHBoxLayout>
#include <QList>
#include <QAction>
#include <QLineEdit>
#include <QToolButton>
#include <QStackedWidget>
#include <QDropEvent>
#include <QDragEnterEvent>
#include <QDragMoveEvent>

#include "board/UBLibraryController.h"

#define BUTTON_SIZE 24
#define ACTIONBAR_HEIGHT 42

typedef enum
{
    eButtonSet_Default,
    eButtonSet_Properties,
    eButtonSet_Favorite
} eButtonSet;

class UBActionButton : public QToolButton
{
public:
    UBActionButton(QWidget* parent=0, QAction* action=0, const char* name="UBActionButton");
    ~UBActionButton();
};

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

    void setButtons(eButtonSet setID);
    eButtonSet previousButtonSet(){return mPreviousButtonSet;}

signals:
    void deleteDone();
    void showFolderContent();
    void searchElement(QString text);
    void newFolderToCreate();

public slots:
    void onSelectionChanged(QList<UBLibElement*> itemList, bool isInTrash);
    void onFavoritesEntered(bool bFav);
    void onNavigbarUpdate(UBLibElement* crntElem);

protected:
    void enterEvent(QEvent *event);
    void leaveEvent(QEvent *event);
    void dragEnterEvent(QDragEnterEvent *event);
    void dragMoveEvent(QDragMoveEvent *event);
    void dropEvent(QDropEvent *event);

private slots:
    void onActionFavorite();
    void onActionSocial();
    void onActionSearch();
    void onActionTrash();
    void onActionClose();
    void onActionRemoveFavorite();
    void onSearchTextChanged(QString txt);
    void onActionNewFolder();

private:
    QWidget* widgetAtPos(const QPoint p);
    UBLibraryController* libraryController();

    eButtonSet mCrntButtonSet;
    eButtonSet mPreviousButtonSet;
    QButtonGroup* mButtonGroup;
    QList<UBLibElement*> mSelectedElements;
    QLineEdit* mSearchBar;
    QHBoxLayout* mLayout;
    QAction* mpFavoriteAction;
    QAction* mpSocialAction;
    QAction* mpDeleteAction;
    QAction* mpSearchAction;
    QAction* mpCloseAction;
    QAction* mpRemoveFavorite;
    QAction* mpNewFolderAction;
    UBActionButton* mpFavoriteBtn;
    UBActionButton* mpSocialBtn;
    UBActionButton* mpDeleteBtn;
    UBActionButton* mpSearchBtn;
    UBActionButton* mpCloseBtn;
    UBActionButton* mpRemoveFavoriteBtn;
    UBActionButton* mpNewFolderBtn;

    // This flag will be removed after the test, normally we should ask
    // the selected item if it is in favorite or not
    bool bFavorite;
    bool bIsInTrash;

};

#endif // UBLIBACTIONBAR_H