[Fix] Fixed Drag&Drop properly.
This commit is contained in:
parent
33f4a245a7
commit
cf26c34e91
@ -10,11 +10,11 @@
|
||||
#define CHILD_AREA_WIDTH 150
|
||||
#define CHILD_AREA_HEIGHT 150
|
||||
|
||||
#define CHILD_AREA_SIDE_MARGIN 6
|
||||
#define CHILD_AREA_SIDE_MARGIN 20
|
||||
|
||||
PagesContainerWidget::PagesContainerWidget(QWidget* parent) {
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
/*setAcceptDrops(true);*/
|
||||
setAcceptDrops(true);
|
||||
mainLayout = new QHBoxLayout();
|
||||
|
||||
setLayout(mainLayout);
|
||||
@ -39,40 +39,12 @@ void PagesContainerWidget::dragEnterEvent(QDragEnterEvent* event) {
|
||||
}
|
||||
|
||||
void PagesContainerWidget::dropEvent(QDropEvent* event) {
|
||||
QPoint pos = event->pos();
|
||||
qDebug() << "FILE DROP";
|
||||
qDebug() << (pos.x() / (CHILD_AREA_SIDE_MARGIN + CHILD_AREA_WIDTH));
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
void PagesContainerWidget::mousePressEvent(QMouseEvent* event) {
|
||||
if(event->button() == Qt::LeftButton) {
|
||||
int draggedChild = (findPageContainingClickEvent(event->pos()));
|
||||
|
||||
QDrag* drag = new QDrag(this);
|
||||
QMimeData* mimeData = new QMimeData;
|
||||
|
||||
mimeData->setText(QString::number(draggedChild));
|
||||
drag->setMimeData(mimeData);
|
||||
drag->setPixmap(QPixmap(":/img/copy.png"));
|
||||
|
||||
Qt::DropAction dropAction = drag->exec();
|
||||
}
|
||||
}
|
||||
|
||||
int PagesContainerWidget::findPageContainingClickEvent(QPoint pos) {
|
||||
for(int i = 0; i < getPagesCount(); i++)
|
||||
if(pageWidgets[i]->geometry().contains(pos))
|
||||
return i;
|
||||
|
||||
return getPagesCount()-1;
|
||||
}
|
||||
|
||||
int PagesContainerWidget::findPageWidgetInLayout(PDFPageWidget* pageWidget) {
|
||||
for(int i = 0; i < getPagesCount(); i++)
|
||||
if(mainLayout->itemAt(i)->widget() == pageWidget)
|
||||
return i;
|
||||
|
||||
return getPagesCount()-1;
|
||||
}
|
||||
|
||||
PDFFileWidget::PDFFileWidget(QWidget* parent) {
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
@ -141,8 +113,6 @@ void PDFFileWidget::setDocument(Poppler::Document* document, QString fileName) {
|
||||
tgen.render(pageWidget, pdfPage);
|
||||
|
||||
pagesContainerWidget->addPageWidget(pageWidget);
|
||||
/* Process event. */
|
||||
/*qApp->processEvents();*/
|
||||
}
|
||||
tgen.start();
|
||||
fileNameLabel->setText(fileName);
|
||||
|
@ -32,11 +32,8 @@ public:
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dropEvent(QDropEvent* event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
|
||||
private:
|
||||
int findPageContainingClickEvent(QPoint pos);
|
||||
int findPageWidgetInLayout(PDFPageWidget* pageWidgets);
|
||||
int getPagesCount() const;
|
||||
};
|
||||
|
||||
|
@ -12,8 +12,8 @@ PDFJam::PDFJam(void) {
|
||||
void PDFJam::makeFolder(QString path) {
|
||||
QString tmp = "mksir -p %1 && rm %2*";
|
||||
int value = system(tmp.arg(path).arg(path).toStdString().c_str());
|
||||
if(value != 0)
|
||||
qDebug() << "ERROR: Failed to make " << path;
|
||||
/*if(value != 0)
|
||||
qDebug() << "ERROR: Failed to make " << path;*/
|
||||
}
|
||||
|
||||
void PDFJam::pushCommand(QString cmd) {
|
||||
@ -53,10 +53,10 @@ void PDFJam::run(void) {
|
||||
while(!isQueueEmpty()) {
|
||||
QString cmd = nextCommand();
|
||||
int value = system(cmd.toStdString().c_str());
|
||||
if(value != 0)
|
||||
/*if(value != 0)
|
||||
qDebug() << "ERROR: Failed to execute " << cmd;
|
||||
else
|
||||
qDebug() << "SUCCESS: executed " << cmd;
|
||||
qDebug() << "SUCCESS: executed " << cmd;*/
|
||||
}
|
||||
|
||||
/*system("echo 'tata' > /tmp/test.txt");*/
|
||||
|
@ -51,6 +51,8 @@ void PDFTableWidget::loadFile(QString fileName) {
|
||||
void PDFTableWidget::registerPage(PDFPageWidget* child) {
|
||||
/* Need new name? */
|
||||
QString name = QString("/home/pdfpage").append(QString::number(pageChilds.size()));
|
||||
qDebug() << "Registering name:";
|
||||
qDebug() << name;
|
||||
pageChilds[name] = child;
|
||||
child->registerName(name);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user