[Add] Added PageWidget.
This commit is contained in:
parent
9d9dd9ebf4
commit
cdfd9cbbc5
@ -1,5 +1,4 @@
|
||||
#include <QPixmap>
|
||||
#include <QLabel>
|
||||
#include <QSize>
|
||||
#include <QDrag>
|
||||
#include <QDragEnterEvent>
|
||||
@ -9,9 +8,10 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include "file_widget.h"
|
||||
#include "pdf_page_widget.h"
|
||||
|
||||
#define CHILD_AREA_WIDTH 150
|
||||
#define CHILD_AREA_HEIGHT 180
|
||||
#define CHILD_AREA_HEIGHT 150
|
||||
|
||||
FileWidget::FileWidget(QWidget* parent) {
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
@ -30,14 +30,16 @@ int FileWidget::getChildCount() const {
|
||||
}
|
||||
|
||||
QSize FileWidget::sizeHint() const {
|
||||
return QSize(CHILD_AREA_WIDTH*getChildCount(), CHILD_AREA_HEIGHT + 50);
|
||||
return QSize(CHILD_AREA_WIDTH*getChildCount(), CHILD_AREA_HEIGHT + 20);
|
||||
}
|
||||
|
||||
void FileWidget::addChild(QString name) {
|
||||
QLabel* newchild;
|
||||
newchild = new QLabel();
|
||||
newchild->setText(name);
|
||||
newchild->setStyleSheet("QLabel { background-color : red; color : blue; }");
|
||||
PDFPageWidget* newchild;
|
||||
newchild = new PDFPageWidget();
|
||||
newchild->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
newchild->resize(CHILD_AREA_WIDTH, CHILD_AREA_HEIGHT);
|
||||
/*newchild->setText(name);*/
|
||||
/*newchild->setStyleSheet("QLabel { background-color : red; color : blue }");*/
|
||||
|
||||
child.push_back(newchild);
|
||||
|
||||
@ -84,7 +86,7 @@ int FileWidget::findClickEventChild(QPoint pos) {
|
||||
return getChildCount()-1;
|
||||
}
|
||||
|
||||
int FileWidget::findChildPositionInLayout(QLabel* child) {
|
||||
int FileWidget::findChildPositionInLayout(PDFPageWidget* child) {
|
||||
for(int i = 0; i < getChildCount(); i++)
|
||||
if(mainLayout->itemAt(i)->widget() == child)
|
||||
return i;
|
||||
|
@ -2,9 +2,9 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QImage>
|
||||
#include <QString>
|
||||
#include <QLabel>
|
||||
#include <QPoint>
|
||||
#include <vector>
|
||||
#include "pdf_page_widget.h"
|
||||
|
||||
class FileWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
@ -16,13 +16,13 @@ protected:
|
||||
void dropEvent(QDropEvent* event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
private:
|
||||
std::vector<QLabel*> child;
|
||||
std::vector<PDFPageWidget*> child;
|
||||
|
||||
QHBoxLayout* mainLayout;
|
||||
|
||||
void addChild(QString name);
|
||||
int findClickEventChild(QPoint pos);
|
||||
int findChildPositionInLayout(QLabel* child);
|
||||
int findChildPositionInLayout(PDFPageWidget* child);
|
||||
int getChildCount() const;
|
||||
};
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
#include <QtWidgets>
|
||||
#include <QSize>
|
||||
#include "pdf_page_widget.h"
|
||||
|
||||
PDFPageWidget::PDFPageWidget(QWidget* parent) :
|
||||
QWidget(parent) {
|
||||
|
||||
/* Resize widget. */
|
||||
this->resize(500, 500);
|
||||
this->setMinimumHeight(500);
|
||||
this->resize(150, 150);
|
||||
this->setMinimumHeight(150);
|
||||
|
||||
this->setMouseTracking(true);
|
||||
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
@ -73,3 +74,7 @@ void PDFPageWidget::paintEvent(QPaintEvent* event) {
|
||||
painter.drawPixmap(QRect(0, 0, width(), height()), pixmap);
|
||||
}
|
||||
|
||||
QSize PDFPageWidget::sizeHint() const {
|
||||
return QSize(150, 150);
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ public:
|
||||
PDFPageWidget(QWidget* parent = 0);
|
||||
void setPageImage(QImage* pageImage);
|
||||
void setButton(QPushButton* btn);
|
||||
QSize sizeHint() const;
|
||||
/*void setButtonImage(QImage* pageImage);*/
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user