Skip to content

Commit

Permalink
Remove libtidy dependency (it caused more problems than it solved) &
Browse files Browse the repository at this point in the history
general cleanup to remove warnings & depricated calls.
  • Loading branch information
baumgarr committed Jul 26, 2017
1 parent 685b1a1 commit 3330f9c
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 22 deletions.
10 changes: 5 additions & 5 deletions NixNote2.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ greaterThan(QT_MAJOR_VERSION, 4) {
QT += core gui widgets printsupport webkit webkitwidgets sql network xml dbus qml
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
unix:INCLUDEPATH += /usr/include/poppler/qt5
unix:INCLUDEPATH += /usr/include/tidy
# unix:INCLUDEPATH += /usr/include/tidy
win32:INCLUDEPATH +="$$PWD/winlib/includes/poppler/qt5"
win32:INCLUDEPATH+= "$$PWD/winlib/includes"
win32:LIBS += -L"$$PWD/winlib" -lpoppler-qt5
unix:LIBS += -lcurl \
-lpthread -L/usr/lib -lpoppler-qt5 -ltidy -g -rdynamic
win32:LIBS += -L"$$PWD/winlib" -lpoppler-qt5 -ltidy
-lpthread -L/usr/lib -lpoppler-qt5 -g -rdynamic
win32:LIBS += -L"$$PWD/winlib" -lpoppler-qt5
win32:RC_ICONS += "$$PWD/images/windowIcon.ico"
}


equals(QT_MAJOR_VERSION, 4) {
QT += core gui webkit sql network xml script
INCLUDEPATH += /usr/include/poppler/qt4
INCLUDEPATH += /usr/include/tidy
# INCLUDEPATH += /usr/include/tidy
LIBS += -lcurl \
-lpthread -L/usr/lib -lpoppler-qt4 -ltidy -g -rdynamic
-lpthread -L/usr/lib -lpoppler-qt4 -g -rdynamic
}

TARGET = nixnote2
Expand Down
4 changes: 2 additions & 2 deletions cmdtools/cmdlinetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int CmdLineTool::run(StartupConfig &config) {
if (config.sync()) {
// If the shared memory segment doesn't exist, we just do a sync & exit
if (!global.sharedMemory->attach()) {
return this->sync(config);
return this->sync();
}
global.sharedMemory->write(QString("SNCHRONIZE"));
global.sharedMemory->detach();
Expand Down Expand Up @@ -760,7 +760,7 @@ int CmdLineTool::closeNotebook(StartupConfig config) {
#include "sql/nsqlquery.h"

// Do a sync
int CmdLineTool::sync(StartupConfig config) {
int CmdLineTool::sync() {
if (!global.accountsManager->oauthTokenFound()) {
std::cout << tr("OAuth token not found.").toStdString() << endl;
return 16;
Expand Down
2 changes: 1 addition & 1 deletion cmdtools/cmdlinetool.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CmdLineTool : public QObject
int importNotes(StartupConfig config);
int openNotebook(StartupConfig config);
int closeNotebook(StartupConfig config);
int sync(StartupConfig config);
int sync();
int signalGui(StartupConfig config);

signals:
Expand Down
10 changes: 5 additions & 5 deletions dialog/preferences/debugpreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ DebugPreferences::DebugPreferences(QWidget *parent) :
multiThreadSave->setChecked(global.getMultiThreadSave());
mainLayout->addWidget(multiThreadSave,row++,1);

useLibTidy = new QCheckBox(tr("Use libtidy directly (experimental)."));
useLibTidy->setChecked(global.getUseLibTidy());
mainLayout->addWidget(useLibTidy,row++,1);
// useLibTidy = new QCheckBox(tr("Use libtidy directly (experimental)."));
// useLibTidy->setChecked(global.getUseLibTidy());
// mainLayout->addWidget(useLibTidy,row++,1);

mainLayout->addWidget(new QLabel(tr("Auto-Save Interval (in seconds).")), row,0);
autoSaveInterval = new QSpinBox();
Expand Down Expand Up @@ -141,6 +141,6 @@ void DebugPreferences::saveValues() {
global.setInterceptSigHup(interceptSigHup->isChecked());
#endif

global.setMultiThreadSave(multiThreadSave->isChecked());
global.setUseLibTidy(useLibTidy->isChecked());
// global.setMultiThreadSave(multiThreadSave->isChecked());
// global.setUseLibTidy(useLibTidy->isChecked());
}
2 changes: 1 addition & 1 deletion dialog/preferences/debugpreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DebugPreferences : public QWidget
QCheckBox *forceUTF8;
QCheckBox *interceptSigHup;
QCheckBox *multiThreadSave;
QCheckBox *useLibTidy;
// QCheckBox *useLibTidy;
QSpinBox *autoSaveInterval;
QLabel *debugLevelLabel;
int getMessageLevel();
Expand Down
1 change: 1 addition & 0 deletions global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1432,4 +1432,5 @@ void Global::setUseLibTidy(bool value) {
global.settings->setValue("useLibTidy", value);
global.settings->endGroup();
this->useLibTidy = value;
this->useLibTidy = false; // Removing obsolete setting.
}
5 changes: 4 additions & 1 deletion gui/favoritesviewdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ QSize FavoritesViewDelegate::sizeHint(const QStyleOptionViewItem &option, const


void FavoritesViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {

#if QT_VERSION < 0x050000
QStyleOptionViewItemV4 options = option;
#else
QStyleOptionViewItem options = option;
#endif
initStyleOption(&options, index);

options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter);
Expand Down
4 changes: 4 additions & 0 deletions gui/imagedelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ void ImageDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,

if(filename != "")
{
#if QT_VERSION < 0x050000
QStyleOptionViewItemV4 options = option;
#else
QStyleOptionViewItem options = option;
#endif
initStyleOption(&options, index);

QImage image(filename);
Expand Down
4 changes: 4 additions & 0 deletions gui/nnotebookviewdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ NNotebookViewDelegate::NNotebookViewDelegate(QObject *parent) :


void NNotebookViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
#if QT_VERSION < 0x050000
QStyleOptionViewItemV4 options = option;
#else
QStyleOptionViewItem options = option;
#endif
initStyleOption(&options, index);

options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter);
Expand Down
4 changes: 4 additions & 0 deletions gui/ntagviewdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ NTagViewDelegate::NTagViewDelegate(QObject *parent) :


void NTagViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
#if QT_VERSION < 0x050000
QStyleOptionViewItemV4 options = option;
#else
QStyleOptionViewItem options = option;
#endif
initStyleOption(&options, index);

options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter);
Expand Down
4 changes: 4 additions & 0 deletions gui/ntrashviewdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ NTrashViewDelegate::NTrashViewDelegate(QObject *parent) :


void NTrashViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
#if QT_VERSION < 0x050000
QStyleOptionViewItemV4 options = option;
#else
QStyleOptionViewItem options = option;
#endif
initStyleOption(&options, index);

painter->save();
Expand Down
13 changes: 11 additions & 2 deletions gui/plugins/popplerviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ void PopplerViewer::findNextPage(QStringList searchHits, QList<QRectF> *searchLo

while (page < doc->numPages() && !found) {
for (int i=0; i<searchHits.size(); i++) {
QList<QRectF> results = doc->page(page)->search(searchHits[i], Poppler::Page::CaseInsensitive);
//#if QT_VERSION < 0x050000
// QList<QRectF> results = doc->page(page)->search(searchHits[i], Poppler::Page::CaseInsensitive);
//#else
QList<QRectF> results = doc->page(page)->search(searchHits[i], Poppler::Page::IgnoreCase);
//#endif
searchLocations->append(results);
if (results.size() > 0) {
currentPage = page;
Expand All @@ -179,7 +183,12 @@ QPixmap PopplerViewer::highlightImage() {

QList<QRectF> searchLocations;
for (int i=0; i<searchHits.size(); i++) {
searchLocations.append(doc->page(currentPage)->search(searchHits[i], Poppler::Page::CaseInsensitive));
// searchLocations.append(doc->page(currentPage)->search(searchHits[i], Poppler::Page::CaseInsensitive));
//#if QT_VERSION < 0x050000
// searchLocations.append(doc->page(currentPage)->search(searchHits[i], Poppler::Page::CaseInsensitive));
//#else
searchLocations.append(doc->page(currentPage)->search(searchHits[i],Poppler::Page::IgnoreCase));
//#endif
}
for (int i=0; i<searchLocations.size(); i++) {
QRectF highlightRect = searchLocations[i];
Expand Down
8 changes: 7 additions & 1 deletion html/enmlformatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <QIcon>
#include <QMessageBox>


/*
#include <tidy.h>
#ifndef _WIN32
#include <buffio.h>
#else
#include <tidy/tidybuffio.h>
#endif
*/


#include <iostream>
using namespace std;
Expand Down Expand Up @@ -241,6 +245,8 @@ QByteArray EnmlFormatter::rebuildNoteEnml() {
content = content.replace("<ac:rich-text-body", "<div");
content = content.replace("</ac:rich-text-body", "</div");

bool useLegacyTidy = true;
/*
// Run it through "tidy". It is a program which will fix any invalid HTML
// and give us the results back through stdout. In a perfect world this
// wouldn't be needed, but WebKit doesn't always give back good HTML.
Expand Down Expand Up @@ -310,7 +316,7 @@ QByteArray EnmlFormatter::rebuildNoteEnml() {
tidyBufFree(&errout);
tidyRelease(tdoc);
}

*/

// IF the new tidy had an error, or we choose to use the old method
if ((useLegacyTidy || !global.useLibTidy) && !global.bypassTidy) {
Expand Down
8 changes: 8 additions & 0 deletions html/noteformatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,11 @@ QString NoteFormatter::addImageHighlight(qint32 resLid, QString imgfile) {
// Go through the "item" nodes
bool found=false;
QDomNodeList anchors = doc.elementsByTagName("item");
#if QT_VERSION < 0x050000
for (unsigned int i=0; i<anchors.length(); i++) {
#else
for (int i=0; i<anchors.length(); i++) {
#endif
QDomElement element = anchors.at(i).toElement();
int x = element.attribute("x").toInt();
int y = element.attribute("y").toInt();
Expand All @@ -365,7 +369,11 @@ QString NoteFormatter::addImageHighlight(qint32 resLid, QString imgfile) {

// Get all children ("t" nodes)
QDomNodeList children = element.childNodes();
#if QT_VERSION < 0x050000
for (unsigned int j=0; j<children.length(); j++) {
#else
for (int j=0; j<children.length(); j++) {
#endif
QDomElement child = children.at(j).toElement();
if (child.nodeName().toLower() == "t") {
QString text = child.text();
Expand Down
2 changes: 1 addition & 1 deletion logger/qslog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Logger::Helper::~Helper()
// you shouldn't throw exceptions from a sink
Q_UNUSED(e);
assert(!"exception in logger helper destructor");
throw;
//throw;
}
}

Expand Down
3 changes: 2 additions & 1 deletion logger/qslogdest.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class Destination
virtual ~Destination(){}
virtual void write(const QString& message) = 0;
};
typedef std::auto_ptr<Destination> DestinationPtr;
//typedef std::auto_ptr<Destination> DestinationPtr;
typedef std::unique_ptr<Destination> DestinationPtr;

//! Creates logging destinations/sinks. The caller will have ownership of
//! the newly created destinations.
Expand Down
5 changes: 4 additions & 1 deletion threads/indexrunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,11 @@ void IndexRunner::indexRecognition(qint32 lid, Resource &r) {

// look for text tags
QDomNodeList anchors = doc.documentElement().elementsByTagName("t");

#if QT_VERSION < 0x050000
for (unsigned int i=0; keepRunning && !pauseIndexing && i<anchors.length(); i++) {
#else
for (int i=0; keepRunning && !pauseIndexing && i<anchors.length(); i++) {
#endif
QApplication::processEvents();
QDomElement enmedia = anchors.at(i).toElement();
QString weight = enmedia.attribute("w");
Expand Down
6 changes: 5 additions & 1 deletion utilities/noteindexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ void NoteIndexer::indexRecognition(qint32 reslid, Resource &r) {
QLOG_TRACE() << "Beginning insertion of recognition:";
QLOG_TRACE() << "Anchors found: " << anchors.length();
sql.exec("begin;");
for (int i=0; i<anchors.length(); i++) {
#if QT_VERSION < 0x050000
for (unsigned int i=0; i<anchors.length(); i++) {
#else
for (int i=0; i<anchors.length(); i++) {
#endif
QLOG_TRACE() << "Anchor: " << i;
QApplication::processEvents();
QDomElement enmedia = anchors.at(i).toElement();
Expand Down

0 comments on commit 3330f9c

Please sign in to comment.