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