From e8f1d2ce3f9378f1ff581a5090225851b74a89b2 Mon Sep 17 00:00:00 2001 From: Rtch90 Date: Fri, 19 Dec 2014 17:44:34 +0000 Subject: [PATCH] [Add] Add a slot to clipboard. --- src/pdf_jam.cpp | 22 ++++++++++++---------- src/pdf_jam.h | 7 ++++--- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/pdf_jam.cpp b/src/pdf_jam.cpp index 7278e9e..b7c232f 100644 --- a/src/pdf_jam.cpp +++ b/src/pdf_jam.cpp @@ -54,22 +54,23 @@ bool PDFJam::removePage(int fileIndex, int numPages, int deletedPageIndex) { pushCommand(cmd); } -void PDFJam::cutPage(int fileIndex, int numPages, int pageIndex) { +void PDFJam::cutPage(int fileIndex, int numPages, int pageIndex, int slot) { if((pageIndex < 0) || (pageIndex >= numPages)) { return; } - copyPage(fileIndex, numPages, pageIndex); + copyPage(fileIndex, numPages, pageIndex, 0); removePage(fileIndex, numPages, pageIndex); } -void PDFJam::copyPage(int fileIndex, int numPages, int pageIndex) { - QString cpTmp = "cp /tmp/hpdf/%1%2.pdf /tmp/hpdf/clipboard.pdf "; - QString cmd = cpTmp.arg(QString::number(fileIndex)).arg(QString::number(pageIndex)); +void PDFJam::copyPage(int fileIndex, int numPages, int pageIndex, int slot) { + QString cpTmp = "cp /tmp/hpdf/%1/%2.pdf /tmp/hpdf/clipboard%3.pdf"; + QString cmd = cpTmp.arg(QString::number(fileIndex)).arg(QString::number(pageIndex)) + .arg(QString::number(slot)); pushCommand(cmd); } -void PDFJam::pastePage(int fileIndex, int numPages, int pageIndex) { +void PDFJam::pastePage(int fileIndex, int numPages, int pageIndex, int slot) { /* TODO: Check if the clipboard file exists. */ QString cmd = ""; QString mvTmp = "mv /tmp/hpdf/%1/%2.pdf /tmp/hpdf/%3/%4.pdf "; @@ -79,8 +80,9 @@ void PDFJam::pastePage(int fileIndex, int numPages, int pageIndex) { if(i > pageIndex) cmd += " && "; } - QString pasteTmp = "cp /tmp/hpdf/clipboard.pdf /tmp/hpdf/%1/%2.pdf "; - cmd += " && " + pasteTmp.arg(QString::number(fileIndex)).arg(QString::number(pageIndex)); + QString pasteTmp = "cp /tmp/hpdf/clipboard%3.pdf /tmp/hpdf/%1/%2.pdf "; + cmd += " && " + pasteTmp.arg(QString::number(fileIndex)) + .arg(QString::number(pageIndex)).arg(QString::number(slot)); pushCommand(cmd); } @@ -95,8 +97,8 @@ void PDFJam::movePage(int fromFileIndex, int fromFileNumPage, int fromPageIndex, toPageIndex--; } - cutPage(fromFileIndex, fromFileNumPage, fromPageIndex); - pastePage(toFileIndex, toFileNumPage, toPageIndex); + cutPage(fromFileIndex, fromFileNumPage, fromPageIndex, 0); + pastePage(toFileIndex, toFileNumPage, toPageIndex, 0); } void PDFJam::savePageAsImage(Poppler::Page pp, QString dst, double dpi = 72) { diff --git a/src/pdf_jam.h b/src/pdf_jam.h index e19909e..b1b6487 100644 --- a/src/pdf_jam.h +++ b/src/pdf_jam.h @@ -17,9 +17,10 @@ public: void exportFile(int, int, QString, QSize, bool, bool, int, int); void savePageAsImage(Poppler::Page pp, QString dst, double); void movePage(int, int, int, int, int, int); - void pastePage(int, int, int); - void copyPage(int, int, int); - void cutPage(int, int, int); + + void pastePage(int, int, int, int); + void copyPage(int, int, int, int); + void cutPage(int, int, int, int); bool removePage(int, int, int); bool rotatePage(int, int, int);