mirror-chatterino2/widgets/notebookpage.h

78 lines
1.8 KiB
C
Raw Normal View History

2016-12-29 17:31:07 +01:00
#ifndef NOTEBOOKPAGE_H
#define NOTEBOOKPAGE_H
2017-01-18 21:30:23 +01:00
#include "widgets/chatwidget.h"
#include "widgets/notebookpage.h"
#include "widgets/notebookpagedroppreview.h"
#include "widgets/notebooktab.h"
2016-12-30 12:20:26 +01:00
2017-01-18 04:52:47 +01:00
#include <QDragEnterEvent>
#include <QHBoxLayout>
#include <QRect>
#include <QVBoxLayout>
#include <QVector>
#include <QWidget>
2017-01-18 21:30:23 +01:00
namespace chatterino {
namespace widgets {
2016-12-29 17:31:07 +01:00
class NotebookPage : public QWidget
{
2017-01-11 18:52:09 +01:00
Q_OBJECT
2016-12-29 17:31:07 +01:00
public:
2017-01-01 02:30:42 +01:00
NotebookPage(QWidget *parent, NotebookTab *tab);
2017-01-11 18:52:09 +01:00
NotebookTab *tab;
2017-01-01 02:30:42 +01:00
2017-01-11 18:52:09 +01:00
std::pair<int, int> removeFromLayout(ChatWidget *widget);
void addToLayout(ChatWidget *widget, std::pair<int, int> position);
2017-01-01 02:30:42 +01:00
const std::vector<ChatWidget *> &
2017-01-18 04:33:30 +01:00
getChatWidgets() const
{
2017-01-18 04:33:30 +01:00
return chatWidgets;
}
2017-01-01 02:30:42 +01:00
static bool isDraggingSplit;
2017-01-11 18:52:09 +01:00
static ChatWidget *draggingSplit;
2017-01-01 02:30:42 +01:00
static std::pair<int, int> dropPosition;
2016-12-30 18:00:25 +01:00
protected:
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
2017-01-01 02:30:42 +01:00
2017-01-18 14:48:42 +01:00
void enterEvent(QEvent *) override;
void leaveEvent(QEvent *) override;
void mouseReleaseEvent(QMouseEvent *event) override;
2017-01-01 02:30:42 +01:00
void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE;
void dragLeaveEvent(QDragLeaveEvent *event) Q_DECL_OVERRIDE;
void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
2017-01-11 18:52:09 +01:00
struct DropRegion {
2017-01-01 02:30:42 +01:00
QRect rect;
std::pair<int, int> position;
DropRegion(QRect rect, std::pair<int, int> position)
{
this->rect = rect;
this->position = position;
}
};
2017-01-18 04:33:30 +01:00
QVBoxLayout parentbox;
QHBoxLayout hbox;
2017-01-18 04:33:30 +01:00
std::vector<ChatWidget *> chatWidgets;
std::vector<DropRegion> dropRegions;
2017-01-01 02:30:42 +01:00
2017-01-18 04:33:30 +01:00
NotebookPageDropPreview preview;
2017-01-01 02:30:42 +01:00
private:
void setPreviewRect(QPoint mousePos);
2016-12-29 17:31:07 +01:00
};
2017-01-18 21:30:23 +01:00
}
}
2016-12-29 17:31:07 +01:00
2017-01-11 18:52:09 +01:00
#endif // NOTEBOOKPAGE_H