diff --git a/src/autotest/autotest.pro b/src/autotest/autotest.pro index d3d6e38..961ae19 100644 --- a/src/autotest/autotest.pro +++ b/src/autotest/autotest.pro @@ -1,6 +1,13 @@ -QT += testlib xml +QT += testlib +CONFIG += c++11 strict_c++ +CONFIG(release, debug|release):CONFIG += optimize_full + +# For Appveyor because it dumps includes in the project root +APPVEYOR_BUILD_FOLDER=$$(APPVEYOR_BUILD_FOLDER) +!isEmpty(APPVEYOR_BUILD_FOLDER) { + INCLUDEPATH += $$APPVEYOR_BUILD_FOLDER +} -CONFIG += optimize_full c++11 CONFIG += qt console warn_on depend_includepath testcase CONFIG -= app_bundle @@ -20,7 +27,7 @@ DEPENDPATH += $$SOURCE_ROOT/kicad $$SOURCE_ROOT/pdf_extract SOURCES += tst_pdf_extract.cpp -unix:{ +unix { QMAKE_LFLAGS_RPATH= QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\'" } diff --git a/src/kicad/kicad.pro b/src/kicad/kicad.pro index b02314f..740e4eb 100644 --- a/src/kicad/kicad.pro +++ b/src/kicad/kicad.pro @@ -1,13 +1,15 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2014-08-05T17:49:45 -# -#------------------------------------------------- +QT += core gui widgets +QT += printsupport +# printer support is for PDF output -QT += gui printsupport -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +CONFIG += c++11 strict_c++ +CONFIG(release, debug|release):CONFIG += optimize_full -CONFIG += optimize_full c++11 +# For Appveyor because it dumps includes in the project root +APPVEYOR_BUILD_FOLDER=$$(APPVEYOR_BUILD_FOLDER) +!isEmpty(APPVEYOR_BUILD_FOLDER) { + INCLUDEPATH += $$APPVEYOR_BUILD_FOLDER +} TARGET = kicad TEMPLATE = lib diff --git a/src/pdf_extract/controller/pdfloader.cpp b/src/pdf_extract/controller/pdfloader.cpp deleted file mode 100644 index 06ec863..0000000 --- a/src/pdf_extract/controller/pdfloader.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/** - ** This file is part of the uConfig project. - ** Copyright 2017-2020 Robotips, Sebastien CAUX (sebcaux) - ** - ** This program is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** This program is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with this program. If not, see . - **/ - -#include "pdfloader.h" - -#include -#include - -#include - -PDFLoader::PDFLoader(PDFDatasheet *pdfDatasheet) - : _pdfDatasheet(pdfDatasheet) -{ - _document = Poppler::Document::load(_pdfDatasheet->_fileName); - _pdfDatasheet->_pageCount = _document->numPages(); - _pdfDatasheet->_title = _document->info("Title"); - - _document->setRenderBackend(Poppler::Document::ArthurBackend); - _document->setRenderHint(Poppler::Document::Antialiasing, true); - _document->setRenderHint(Poppler::Document::TextAntialiasing, true); -} - -PDFLoader::~PDFLoader() -{ - delete _document; -} - -bool PDFLoader::loadPage(PDFPage *pdfPage) -{ - if (pdfPage->numPage() >= _document->numPages()) - { - return false; - } - - Poppler::Page *page = _document->page(pdfPage->numPage()); - if (page == nullptr) - { - return false; - } - pdfPage->_page = page; - pdfPage->_pageRect = QRect(QPoint(0, 0), page->pageSize()); - - return true; -} - -void PDFLoader::loadBoxes(PDFPage *pdfPage) -{ - PDFTextBox *parentTextBox = nullptr; - for (Poppler::TextBox *ptextBox : pdfPage->page()->textList()) - { - PDFTextBox *textBox = new PDFTextBox(ptextBox->text(), ptextBox->boundingBox()); - textBox->_page = pdfPage; - - bool padName = textBox->isPadName(); - if (padName) - { - textBox->_type = PDFTextBox::Pad; - } - if (parentTextBox == nullptr) - { - if (ptextBox->nextWord() == nullptr || padName) - { - pdfPage->_textBoxes.append(textBox); - } - else - { - parentTextBox = new PDFTextBox(QString(), ptextBox->boundingBox()); - parentTextBox->_page = pdfPage; - if (ptextBox->hasSpaceAfter()) - { - textBox->_text.append(QChar(' ')); - } - textBox->_parentBox = parentTextBox; - textBox->_type = PDFTextBox::SubText; - parentTextBox->_subBoxes.append(textBox); - } - } - else - { - if (padName) - { - pdfPage->_textBoxes.append(textBox); - } - else - { - textBox->_parentBox = parentTextBox; - textBox->_type = PDFTextBox::SubText; - parentTextBox->_subBoxes.append(textBox); - } - if (ptextBox->nextWord() == nullptr || padName) - { - QRectF boundingRect; - QString text; - for (PDFTextBox *subBox : parentTextBox->subBoxes()) - { - text.append(subBox->text()); - boundingRect = boundingRect.united(subBox->boundingRect()); - } - parentTextBox->_text = text; - parentTextBox->_boundingRect = boundingRect.adjusted(-1, -1, 1, 1); - - pdfPage->_textBoxes.append(parentTextBox); - parentTextBox = nullptr; - } - else - { - if (ptextBox->hasSpaceAfter()) - { - textBox->_text.append(QChar(' ')); - } - } - } - delete ptextBox; - } - pdfPage->_boxesLoaded = true; -} diff --git a/src/pdf_extract/controller/pdfloader.h b/src/pdf_extract/controller/pdfloader.h deleted file mode 100644 index 97437d8..0000000 --- a/src/pdf_extract/controller/pdfloader.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - ** This file is part of the uConfig project. - ** Copyright 2017-2020 Robotips, Sebastien CAUX (sebcaux) - ** - ** This program is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** This program is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with this program. If not, see . - **/ - -#ifndef PAGELOADER_H -#define PAGELOADER_H - -#include - -#include "model/pdfdatasheet.h" - -namespace Poppler -{ -class Document; -} - -class DATASHEET_EXTRACTOR_EXPORT PDFLoader -{ -public: - PDFLoader(PDFDatasheet *pdfDatasheet); - ~PDFLoader(); - - bool loadPage(PDFPage *pdfPage); - void loadBoxes(PDFPage *pdfPage); - -protected: - Poppler::Document *_document; - PDFDatasheet *_pdfDatasheet; -}; - -#endif // PAGELOADER_H diff --git a/src/pdf_extract/controller/pdfpackagesearcher.cpp b/src/pdf_extract/controller/pdfpackagesearcher.cpp deleted file mode 100644 index d543c33..0000000 --- a/src/pdf_extract/controller/pdfpackagesearcher.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/** - ** This file is part of the uConfig project. - ** Copyright 2017-2020 Robotips, Sebastien CAUX (sebcaux) - ** - ** This program is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** This program is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with this program. If not, see . - **/ - -#include "pdfpackagesearcher.h" - -PDFPackageSearcher::PDFPackageSearcher() -{ -} diff --git a/src/pdf_extract/controller/pdfpackagesearcher.h b/src/pdf_extract/controller/pdfpackagesearcher.h deleted file mode 100644 index 4962cab..0000000 --- a/src/pdf_extract/controller/pdfpackagesearcher.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - ** This file is part of the uConfig project. - ** Copyright 2017-2020 Robotips, Sebastien CAUX (sebcaux) - ** - ** This program is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** This program is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with this program. If not, see . - **/ - -#ifndef PDFPACKAGESEARCHER_H -#define PDFPACKAGESEARCHER_H - -#include - -class DATASHEET_EXTRACTOR_EXPORT PDFPackageSearcher -{ -public: - PDFPackageSearcher(); -}; - -#endif // PDFPACKAGESEARCHER_H diff --git a/src/pdf_extract/datasheet.cpp b/src/pdf_extract/datasheet.cpp index 07d3b13..d910e2a 100644 --- a/src/pdf_extract/datasheet.cpp +++ b/src/pdf_extract/datasheet.cpp @@ -21,12 +21,11 @@ #include #include #include -#include +//#include #include #include #include -#include #include using namespace Poppler; diff --git a/src/pdf_extract/model/pdfcomponent.cpp b/src/pdf_extract/model/pdfcomponent.cpp deleted file mode 100644 index d48d129..0000000 --- a/src/pdf_extract/model/pdfcomponent.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/** - ** This file is part of the uConfig project. - ** Copyright 2017-2020 Robotips, Sebastien CAUX (sebcaux) - ** - ** This program is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** This program is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with this program. If not, see . - **/ - -#include "pdfcomponent.h" - -PDFComponent::PDFComponent() -{ -} diff --git a/src/pdf_extract/model/pdfcomponent.h b/src/pdf_extract/model/pdfcomponent.h deleted file mode 100644 index bc72637..0000000 --- a/src/pdf_extract/model/pdfcomponent.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - ** This file is part of the uConfig project. - ** Copyright 2017-2020 Robotips, Sebastien CAUX (sebcaux) - ** - ** This program is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** This program is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with this program. If not, see . - **/ - -#ifndef PDFCOMPONENT_H -#define PDFCOMPONENT_H - -#include - -class DATASHEET_EXTRACTOR_EXPORT PDFComponent -{ -public: - PDFComponent(); -}; - -#endif // PDFCOMPONENT_H diff --git a/src/pdf_extract/model/pdfdatasheet.cpp b/src/pdf_extract/model/pdfdatasheet.cpp index 3732325..4fac9f2 100644 --- a/src/pdf_extract/model/pdfdatasheet.cpp +++ b/src/pdf_extract/model/pdfdatasheet.cpp @@ -18,19 +18,20 @@ #include "pdfdatasheet.h" -#include - -#include "controller/pdfloader.h" - -PDFDatasheet::PDFDatasheet(QString fileName) - : _fileName(std::move(fileName)) +PDFDatasheet::PDFDatasheet(const QString& fileName) + : std::unique_ptr(Poppler::Document::load(fileName)), + _fileName(fileName) { - _pdfLoader = new PDFLoader(this); + if(*this) + { + get()->setRenderBackend(Poppler::Document::ArthurBackend); + get()->setRenderHint(Poppler::Document::Antialiasing, true); + get()->setRenderHint(Poppler::Document::TextAntialiasing, true); + } } PDFDatasheet::~PDFDatasheet() { - delete _pdfLoader; } const QString &PDFDatasheet::fileName() const @@ -38,30 +39,32 @@ const QString &PDFDatasheet::fileName() const return _fileName; } -const QString &PDFDatasheet::title() const +QString PDFDatasheet::title() const { - return _title; + return get()->info("Title"); } bool PDFDatasheet::loadPage(int numPage) { - if (numPage >= _pageCount || numPage < 0) + if (numPage >= pageCount() || numPage < 0) { return false; } - if (page(numPage) != nullptr) + + PDFPage *pdfPage = page(numPage); + + if (pdfPage == nullptr) { - return true; + pdfPage = new PDFPage(get()->page(numPage)); + _pagesLoaded.insert(numPage, pdfPage); } - PDFPage *page = new PDFPage(this, numPage); - _pagesLoaded.insert(numPage, page); - return _pdfLoader->loadPage(page); + return pdfPage->numPage() < pageCount(); } int PDFDatasheet::pageCount() const { - return _pageCount; + return get()->numPages(); } int PDFDatasheet::loadedPageCount() const @@ -78,8 +81,3 @@ PDFPage *PDFDatasheet::page(int numPage) } return *itFind; } - -PDFLoader *PDFDatasheet::pdfLoader() const -{ - return _pdfLoader; -} diff --git a/src/pdf_extract/model/pdfdatasheet.h b/src/pdf_extract/model/pdfdatasheet.h index d101a87..8455b87 100644 --- a/src/pdf_extract/model/pdfdatasheet.h +++ b/src/pdf_extract/model/pdfdatasheet.h @@ -21,21 +21,22 @@ #include +#include +#include + #include "pdfpage.h" #include #include -class PDFLoader; - -class DATASHEET_EXTRACTOR_EXPORT PDFDatasheet +class DATASHEET_EXTRACTOR_EXPORT PDFDatasheet : protected std::unique_ptr { public: - PDFDatasheet(QString fileName); + PDFDatasheet(const QString& fileName); ~PDFDatasheet(); const QString &fileName() const; - const QString &title() const; + QString title() const; bool loadPage(int numPage); @@ -43,16 +44,9 @@ class DATASHEET_EXTRACTOR_EXPORT PDFDatasheet int loadedPageCount() const; PDFPage *page(int numPage); - PDFLoader *pdfLoader() const; - protected: - int _pageCount; QMap _pagesLoaded; QString _fileName; - QString _title; - - friend class PDFLoader; - PDFLoader *_pdfLoader; }; #endif // PDFDATASHEET_H diff --git a/src/pdf_extract/model/pdfpage.cpp b/src/pdf_extract/model/pdfpage.cpp index 5cfb75a..ece688b 100644 --- a/src/pdf_extract/model/pdfpage.cpp +++ b/src/pdf_extract/model/pdfpage.cpp @@ -17,64 +17,67 @@ **/ #include "pdfpage.h" -#include "controller/pdfloader.h" -#include "pdfdatasheet.h" -#include - -PDFPage::PDFPage(PDFDatasheet *datasheet, int numPage) - : _datasheet(datasheet), - _numPage(numPage), - _boxesLoaded(false), - _page(nullptr) +PDFPage::PDFPage(Poppler::Page *page) + : std::unique_ptr(page) { + loadBoxes(); } PDFPage::~PDFPage() { - for (PDFTextBox *textBox : _textBoxes) + for (PDFTextBox *textBox : qAsConst(_textBoxes)) { delete textBox; + textBox = nullptr; } - delete _page; -} - -PDFDatasheet *PDFPage::datasheet() const -{ - return _datasheet; } int PDFPage::numPage() const { - return _numPage; + return get()->index(); } -const QRect &PDFPage::pageRect() const +QRect PDFPage::pageRect() const { - return _pageRect; -} - -const QImage &PDFPage::image() const -{ - return _image; -} - -Poppler::Page *PDFPage::page() const -{ - return _page; + return QRect(QPoint(0, 0), get()->pageSize()); } void PDFPage::loadBoxes() { - if (!_boxesLoaded) + QString fullText; + QRectF fullBoundingRect; + const auto& texts = get()->textList(); + for (Poppler::TextBox *ptextBox : texts) { - _datasheet->pdfLoader()->loadBoxes(this); - } -} + bool isNumber = false; + QString text = ptextBox->text(); + text.toInt(&isNumber); -bool PDFPage::boxesLoaded() const -{ - return _boxesLoaded; + if(fullText.isEmpty() || isNumber) + { + _textBoxes.append(new PDFTextBox(text, ptextBox->boundingBox())); + } + else + { + fullBoundingRect = fullBoundingRect.united(ptextBox->boundingBox()); + fullText += text; + + if(ptextBox->nextWord() != nullptr) + { + if(!ptextBox->hasSpaceAfter()) + fullText.append(QChar(' ')); + } + else + { + _textBoxes.append(new PDFTextBox(fullText, fullBoundingRect.adjusted(-1, -1, 1, 1))); + fullText.clear(); + fullBoundingRect = QRectF(); + } + } + delete ptextBox; + ptextBox = nullptr; + } } const QList &PDFPage::textBoxes() const diff --git a/src/pdf_extract/model/pdfpage.h b/src/pdf_extract/model/pdfpage.h index 04db0aa..7a458fb 100644 --- a/src/pdf_extract/model/pdfpage.h +++ b/src/pdf_extract/model/pdfpage.h @@ -21,48 +21,30 @@ #include +#include +#include + #include "pdftextbox.h" #include #include #include -namespace Poppler -{ -class Page; -} - -class PDFDatasheet; - -class DATASHEET_EXTRACTOR_EXPORT PDFPage +class DATASHEET_EXTRACTOR_EXPORT PDFPage : public std::unique_ptr { public: - PDFPage(PDFDatasheet *datasheet, int numPage = 0); + PDFPage(Poppler::Page *page); ~PDFPage(); - PDFDatasheet *datasheet() const; - int numPage() const; - const QRect &pageRect() const; - const QImage &image() const; + QRect pageRect() const; - Poppler::Page *page() const; - - void loadBoxes(); - bool boxesLoaded() const; const QList &textBoxes() const; protected: - PDFDatasheet *_datasheet; - int _numPage; - QRect _pageRect; - QImage _image; + void loadBoxes(); - bool _boxesLoaded; QList _textBoxes; - - friend class PDFLoader; - Poppler::Page *_page; }; #endif // PDFPAGE_H diff --git a/src/pdf_extract/model/pdfpin.cpp b/src/pdf_extract/model/pdfpin.cpp deleted file mode 100644 index 2655c4f..0000000 --- a/src/pdf_extract/model/pdfpin.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/** - ** This file is part of the uConfig project. - ** Copyright 2017-2020 Robotips, Sebastien CAUX (sebcaux) - ** - ** This program is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** This program is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with this program. If not, see . - **/ - -#include "pdfpin.h" - -PDFPin::PDFPin() -{ -} diff --git a/src/pdf_extract/model/pdfpin.h b/src/pdf_extract/model/pdfpin.h deleted file mode 100644 index c2016d1..0000000 --- a/src/pdf_extract/model/pdfpin.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - ** This file is part of the uConfig project. - ** Copyright 2017-2020 Robotips, Sebastien CAUX (sebcaux) - ** - ** This program is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** This program is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with this program. If not, see . - **/ - -#ifndef PDFPIN_H -#define PDFPIN_H - -#include - -class DATASHEET_EXTRACTOR_EXPORT PDFPin -{ -public: - PDFPin(); -}; - -#endif // PDFPIN_H diff --git a/src/pdf_extract/model/pdftextbox.cpp b/src/pdf_extract/model/pdftextbox.cpp index 5243f14..a162c47 100644 --- a/src/pdf_extract/model/pdftextbox.cpp +++ b/src/pdf_extract/model/pdftextbox.cpp @@ -18,15 +18,15 @@ #include "pdftextbox.h" -#include - -PDFTextBox::PDFTextBox(QString text, const QRectF &boundingRect) - : _text(std::move(text)), - _boundingRect(boundingRect) +PDFTextBox::PDFTextBox(const QString& text, const QRectF &boundingRect) + : _text(text), + _boundingRect(boundingRect), + _type(Text) { - _page = nullptr; - _parentBox = nullptr; - _type = Text; + if(isPadName()) + { + _type = PDFTextBox::Pad; + } } PDFTextBox::~PDFTextBox() @@ -68,13 +68,3 @@ PDFTextBox::Type PDFTextBox::type() const { return _type; } - -PDFTextBox *PDFTextBox::parentBox() const -{ - return _parentBox; -} - -PDFPage *PDFTextBox::page() const -{ - return _page; -} diff --git a/src/pdf_extract/model/pdftextbox.h b/src/pdf_extract/model/pdftextbox.h index 1492648..2343272 100644 --- a/src/pdf_extract/model/pdftextbox.h +++ b/src/pdf_extract/model/pdftextbox.h @@ -21,8 +21,6 @@ #include -class PDFPage; - #include #include #include @@ -30,7 +28,7 @@ class PDFPage; class DATASHEET_EXTRACTOR_EXPORT PDFTextBox { public: - PDFTextBox(QString text, const QRectF &boundingRect); + PDFTextBox(const QString& text, const QRectF &boundingRect); ~PDFTextBox(); const QString &text() const; @@ -46,18 +44,12 @@ class DATASHEET_EXTRACTOR_EXPORT PDFTextBox Type type() const; const QList &subBoxes() const; - PDFTextBox *parentBox() const; - PDFPage *page() const; - protected: QString _text; QRectF _boundingRect; Type _type; QList _subBoxes; - PDFPage *_page; - PDFTextBox *_parentBox; - friend class PDFLoader; }; #endif // PDFTEXTBOX_H diff --git a/src/pdf_extract/pdf_extract.pro b/src/pdf_extract/pdf_extract.pro index 5d3caf2..373c5b4 100644 --- a/src/pdf_extract/pdf_extract.pro +++ b/src/pdf_extract/pdf_extract.pro @@ -1,4 +1,12 @@ -QT += core gui widgets xml +QT += core gui widgets +CONFIG += c++11 strict_c++ +CONFIG(release, debug|release):CONFIG += optimize_full + +# For Appveyor because it dumps includes in the project root +APPVEYOR_BUILD_FOLDER=$$(APPVEYOR_BUILD_FOLDER) +!isEmpty(APPVEYOR_BUILD_FOLDER) { + INCLUDEPATH += $$APPVEYOR_BUILD_FOLDER +} TARGET = pdf_extract TEMPLATE = lib @@ -11,11 +19,6 @@ INCLUDEPATH += $$SOURCE_ROOT DEFINES += KICAD_EXPORT=Q_DECL_IMPORT DEFINES += DATASHEET_EXTRACTOR_EXPORT_LIB -CONFIG(release, debug|release) { - CONFIG += optimize_full -} -CONFIG += c++11 - SOURCES += \ $$PWD/datasheet.cpp \ $$PWD/datasheetpackage.cpp \ @@ -30,10 +33,6 @@ SOURCES += \ $$PWD/model/pdfdatasheet.cpp \ $$PWD/model/pdfpage.cpp \ $$PWD/model/pdftextbox.cpp \ - $$PWD/model/pdfpin.cpp \ - $$PWD/model/pdfcomponent.cpp \ - $$PWD/controller/pdfloader.cpp \ - $$PWD/controller/pdfpackagesearcher.cpp HEADERS += \ $$PWD/pdf_extract_common.h \ @@ -49,11 +48,7 @@ HEADERS += \ $$PWD/pdfdebugwidget/pdfdebugitemtextbox.h \ $$PWD/model/pdfdatasheet.h \ $$PWD/model/pdfpage.h \ - $$PWD/model/pdftextbox.h \ - $$PWD/model/pdfpin.h \ - $$PWD/model/pdfcomponent.h \ - $$PWD/controller/pdfloader.h \ - $$PWD/controller/pdfpackagesearcher.h + $$PWD/model/pdftextbox.h LIBS += -L"$$PROJECT_ROOT/bin" INCLUDEPATH += $$PROJECT_ROOT/ diff --git a/src/pdf_extract/pdfdebugwidget/pdfdebugitempage.cpp b/src/pdf_extract/pdfdebugwidget/pdfdebugitempage.cpp index 3a6d7b3..71be97b 100644 --- a/src/pdf_extract/pdfdebugwidget/pdfdebugitempage.cpp +++ b/src/pdf_extract/pdfdebugwidget/pdfdebugitempage.cpp @@ -56,7 +56,7 @@ void PdfDebugItemPage::paint(QPainter *painter, const QStyleOptionGraphicsItem * painter->setPen(Qt::black); - _page->page()->renderToPainter(painter, 72.0, 72.0, 0, 0, _page->pageRect().width(), _page->pageRect().width(), Poppler::Page::Rotate0); + _page->get()->renderToPainter(painter, 72.0, 72.0, 0, 0, _page->pageRect().width(), _page->pageRect().width(), Poppler::Page::Rotate0); // const qreal lod = option->levelOfDetailFromTransform(painter->worldTransform()); // QImage image = _page->page()->renderToImage(72.0 * lod, 72.0 * lod, 0 ,0); diff --git a/src/pdf_extract/pdfdebugwidget/pdfdebugwidget.cpp b/src/pdf_extract/pdfdebugwidget/pdfdebugwidget.cpp index 4d89d7e..f4f2138 100644 --- a/src/pdf_extract/pdfdebugwidget/pdfdebugwidget.cpp +++ b/src/pdf_extract/pdfdebugwidget/pdfdebugwidget.cpp @@ -69,23 +69,9 @@ void PdfDebugWidget::showPage(int page) { return; } - showPage(pdfPage); -} - -void PdfDebugWidget::showPage(PDFPage *page) -{ - if (page->datasheet() != _datasheet) - { - setDatasheet(page->datasheet()); - } - - if (!page->boxesLoaded()) - { - page->loadBoxes(); - } - _currentPage = page; - _viewer->setPage(page); + _currentPage = pdfPage; + _viewer->setPage(pdfPage); _pageLineEdit->setText(QString::number(_currentPage->numPage() + 1)); emit pageChanged(_currentPage->numPage()); } diff --git a/src/pdf_extract/pdfdebugwidget/pdfdebugwidget.h b/src/pdf_extract/pdfdebugwidget/pdfdebugwidget.h index 77b16fb..f015881 100644 --- a/src/pdf_extract/pdfdebugwidget/pdfdebugwidget.h +++ b/src/pdf_extract/pdfdebugwidget/pdfdebugwidget.h @@ -47,7 +47,6 @@ class DATASHEET_EXTRACTOR_EXPORT PdfDebugWidget : public QWidget public slots: void showPage(int page); - void showPage(PDFPage *page); void previous(); void next(); diff --git a/src/test/main.cpp b/src/test/main.cpp index 9d3f073..4d32a2d 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -112,6 +112,9 @@ int main(int argc, char *argv[]) // PDFDatasheet pdf("../src/autotest/ATmega328P_pins.pdf"); // PDFDatasheet pdf("C:/Users/seb/Seafile/UniSwarm/DataSheets/Microchip/PIC16b/dsPIC33EP/PIC24-dsPIC33-EPxxxGP-MC-20x-50x_revH.pdf"); + Q_ASSERT(pdf.pageCount() > 0); + qDebug("page count: %u", pdf.pageCount()); + PdfDebugWidget viewer(&pdf); viewer.showPage(0); viewer.show(); diff --git a/src/test/test.pro b/src/test/test.pro index 6e58871..e928f9d 100644 --- a/src/test/test.pro +++ b/src/test/test.pro @@ -1,13 +1,12 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2014-08-06T09:40:31 -# -#------------------------------------------------- - -QT += core gui printsupport -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += optimize_full c++11 +QT += core gui widgets +CONFIG += c++11 strict_c++ +CONFIG(release, debug|release):CONFIG += optimize_full + +# For Appveyor because it dumps includes in the project root +APPVEYOR_BUILD_FOLDER=$$(APPVEYOR_BUILD_FOLDER) +!isEmpty(APPVEYOR_BUILD_FOLDER) { + INCLUDEPATH += $$APPVEYOR_BUILD_FOLDER +} TARGET = test TEMPLATE = app diff --git a/src/uconfig/uconfig.pro b/src/uconfig/uconfig.pro index 82d2b80..60801e8 100644 --- a/src/uconfig/uconfig.pro +++ b/src/uconfig/uconfig.pro @@ -1,6 +1,12 @@ -QT += core gui xml widgets - -CONFIG += optimize_full c++11 +QT += core gui widgets +CONFIG += c++11 strict_c++ +CONFIG(release, debug|release):CONFIG += optimize_full + +# For Appveyor because it dumps includes in the project root +APPVEYOR_BUILD_FOLDER=$$(APPVEYOR_BUILD_FOLDER) +!isEmpty(APPVEYOR_BUILD_FOLDER) { + INCLUDEPATH += $$APPVEYOR_BUILD_FOLDER +} TARGET = uconfig TEMPLATE = app @@ -14,9 +20,7 @@ DEFINES += KICAD_EXPORT=Q_DECL_IMPORT SOURCES += $$PWD/uconfig.cpp -HEADERS += - -unix:{ +unix { QMAKE_LFLAGS_RPATH= QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\'" } diff --git a/src/uconfig_gui/uconfig_gui.pro b/src/uconfig_gui/uconfig_gui.pro index 561de26..01e66c8 100644 --- a/src/uconfig_gui/uconfig_gui.pro +++ b/src/uconfig_gui/uconfig_gui.pro @@ -1,6 +1,12 @@ -QT += core gui xml widgets - -CONFIG += optimize_full c++11 +QT += core gui widgets +CONFIG += c++11 strict_c++ +CONFIG(release, debug|release):CONFIG += optimize_full + +# For Appveyor because it dumps includes in the project root +APPVEYOR_BUILD_FOLDER=$$(APPVEYOR_BUILD_FOLDER) +!isEmpty(APPVEYOR_BUILD_FOLDER) { + INCLUDEPATH += $$APPVEYOR_BUILD_FOLDER +} TARGET = uconfig_gui TEMPLATE = app @@ -42,7 +48,7 @@ HEADERS += \ RESOURCES += \ $$PWD/img.qrc -unix:{ +unix { QMAKE_LFLAGS_RPATH= QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\'" } @@ -52,4 +58,4 @@ LIBS += -lkicad -lpdf_extract INCLUDEPATH += $$SOURCE_ROOT/kicad DEPENDPATH += $$SOURCE_ROOT/kicad -win32 : RC_FILE = uconfig_gui.rc +win32:RC_FILE = uconfig_gui.rc