Skip to content

Commit

Permalink
use DBG to enable/disable qDebug output
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhendricks committed Aug 21, 2019
1 parent 31abbbd commit 67a5b99
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 37 deletions.
5 changes: 3 additions & 2 deletions Inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
#include <QtWebEngineWidgets/QWebEnginePage>
#include <QtWebEngineWidgets/QWebEngineSettings>
#include <QApplication>
#include <QDebug>

#include "SettingsStore.h"
#include "Inspector.h"


static const QString SETTINGS_GROUP = "inspect_dialog";

#define DBG if(0)

Inspector::Inspector(QWidget *parent) :
QDockWidget(parent),
Expand Down Expand Up @@ -118,7 +119,7 @@ QSize Inspector::sizeHint()

void Inspector::closeEvent(QCloseEvent* event)
{
// qDebug() << "Inspector Close Event";
DBG qDebug() << "Inspector Close Event";
StopInspection();
QDockWidget::closeEvent(event);
}
Expand Down
54 changes: 24 additions & 30 deletions MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "SearchToolbar.h"
#include "OPFReader.h"

#define DBG if(0)

static const QString SETTINGS_GROUP = "mainwindow";

Expand Down Expand Up @@ -153,7 +154,7 @@ void MainWindow::SetupFileList(const QString &filepath)
}
m_ListPtr = 0;
m_CurrentFilePath = m_Base + m_SpineList.at(m_ListPtr);
qDebug() << "in SetupFileList" << m_CurrentFilePath;
DBG qDebug() << "in SetupFileList" << m_CurrentFilePath;
}

void MainWindow::SetupNavigationComboBox()
Expand Down Expand Up @@ -592,7 +593,7 @@ void MainWindow::UpdatePage(const QString &filename_url)
QString inject_userstyles =
"<link rel=\"stylesheet\" type=\"text/css\" "
"href=\"" + m_usercssurl + "\" />";
// qDebug() << "WebView injecting stylesheet: " << inject_userstyles;
DBG qDebug() << "WebView injecting stylesheet: " << inject_userstyles;
text.insert(endheadpos, inject_userstyles);
}
}
Expand Down Expand Up @@ -627,13 +628,8 @@ void MainWindow::UpdatePage(const QString &filename_url)

if (!m_WebView->WasLoadOkay()) qDebug() << "WV loadFinished with okay set to false!";

// qDebug() << "WebViewWindow UpdatePage load is Finished";
// qDebug() << "WebViewWindow UpdatePage final step scroll to location";
DBG qDebug() << "WebViewWindow UpdatePage load is Finished";

#if 0
m_WebView->StoreCaretLocationUpdate(location);
m_WebView->ExecuteCaretUpdate();
#endif
UpdateWindowTitle();
m_source = GetSource();
m_WebView->show();
Expand All @@ -646,7 +642,7 @@ void MainWindow::UpdatePage(const QString &filename_url)

void MainWindow::ScrollTo(QList<ElementIndex> location)
{
// qDebug() << "received a WebViewWindow ScrollTo event";
DBG qDebug() << "received a WebViewWindow ScrollTo event";
if (!m_WebView->isVisible()) {
return;
}
Expand All @@ -669,9 +665,9 @@ void MainWindow::UpdateWindowTitle()

QList<ElementIndex> MainWindow::GetCaretLocation()
{
// qDebug() << "WebView in GetCaretLocation";
DBG qDebug() << "WebView in GetCaretLocation";
QList<ElementIndex> hierarchy = m_WebView->GetCaretLocation();
// foreach(ElementIndex ei, hierarchy) qDebug() << "name: " << ei.name << " index: " << ei.index;
DBG foreach(ElementIndex ei, hierarchy) qDebug() << "name: " << ei.name << " index: " << ei.index;
return hierarchy;
}

Expand All @@ -682,7 +678,7 @@ void MainWindow::SetZoomFactor(float factor)

void MainWindow::EmitGoToPreviewLocationRequest()
{
// qDebug() << "EmitGoToPreviewLocationRequest request: " << m_GoToRequestPending;
DBG qDebug() << "EmitGoToPreviewLocationRequest request: " << m_GoToRequestPending;
if (m_GoToRequestPending) {
m_GoToRequestPending = false;
emit GoToPreviewLocationRequest();
Expand All @@ -694,7 +690,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
switch (event->type()) {
case QEvent::ChildAdded:
if (object == m_WebView) {
qDebug() << "child add event";
DBG qDebug() << "child add event";
const QChildEvent *childEvent(static_cast<QChildEvent*>(event));
if (childEvent->child()) {
childEvent->child()->installEventFilter(this);
Expand All @@ -703,31 +699,31 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
break;
case QEvent::MouseButtonPress:
{
qDebug() << "Preview mouse button press event " << object;
DBG qDebug() << "Preview mouse button press event " << object;
const QMouseEvent *mouseEvent(static_cast<QMouseEvent*>(event));
if (mouseEvent) {
if (mouseEvent->button() == Qt::LeftButton) {
qDebug() << "Detected Left Mouse Button Press Event";
DBG qDebug() << "Detected Left Mouse Button Press Event";
QString hoverurl = m_WebView->GetHoverUrl();
qDebug() << "hover url is: " << hoverurl;
DBG qDebug() << "hover url is: " << hoverurl;
}
if (mouseEvent->button() == Qt::RightButton) {
qDebug() << "Detected Right Mouse Button Press Event";
DBG qDebug() << "Detected Right Mouse Button Press Event";
}

}
}
break;
case QEvent::MouseButtonRelease:
{
qDebug() << "Preview mouse button release event " << object;
DBG qDebug() << "Preview mouse button release event " << object;
const QMouseEvent *mouseEvent(static_cast<QMouseEvent*>(event));
if (mouseEvent) {
if (mouseEvent->button() == Qt::LeftButton) {
qDebug() << "Detected Left Mouse Button Release Event";
DBG qDebug() << "Detected Left Mouse Button Release Event";
}
if (mouseEvent->button() == Qt::RightButton) {
qDebug() << "Detected Right Mouse Button Release Event";
DBG qDebug() << "Detected Right Mouse Button Release Event";
}
}
}
Expand All @@ -737,9 +733,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
if (object == m_WebView) {
const QResizeEvent *resizeEvent(static_cast<QResizeEvent*>(event));
if (resizeEvent) {
// QSize oldsize = resizeEvent->oldSize();
// QSize newsize = resizeEvent->size();
// qDebug() << "Detected ResizeEvent: " << oldsize << newsize;
DBG qDebug() << "Detected ResizeEvent: " << resizeEvent->oldSize() << resizeEvent->size();
QTimer::singleShot(100, this, SLOT(UpdateWindowTitle()));
}
}
Expand All @@ -758,7 +752,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)

void MainWindow::LinkClicked(const QUrl &url)
{
qDebug() << " In Link Clicked with url: " << url.toString();
DBG qDebug() << " In Link Clicked with url: " << url.toString();
QUrl toUrl(url);

if (toUrl.toString().isEmpty()) {
Expand All @@ -781,7 +775,7 @@ void MainWindow::LinkClicked(const QUrl &url)
if (toUrl.scheme() == "file") {
QString filepath = toUrl.toLocalFile();
QString fragment = toUrl.fragment();
qDebug() << "in Link Clicked: " << filepath << fragment;
DBG qDebug() << "in Link Clicked: " << filepath << fragment;

if (filepath.startsWith(m_Base)) {
filepath = filepath.right(filepath.length() - m_Base.length());
Expand Down Expand Up @@ -811,17 +805,17 @@ void MainWindow::LinkClicked(const QUrl &url)

void MainWindow::InspectPreviewPage()
{
//qDebug() << "InspectPreviewPage()";
DBG qDebug() << "InspectPreviewPage()";
// non-modal dialog
if (!m_Inspector->isVisible()) {
// qDebug() << "inspecting";
DBG qDebug() << "inspecting";
m_Inspector->InspectPageofView(m_WebView);
m_Inspector->show();
m_Inspector->raise();
m_Inspector->activateWindow();
// if needed resulting m_WebView resize event will UpdateWindowTitle();
} else {
// qDebug() << "stopping inspection()";
DBG qDebug() << "stopping inspection()";
m_Inspector->StopInspection();
m_Inspector->close();
// if needed resulting m_WebView resize event will UpdateWindowTitle();
Expand Down Expand Up @@ -1255,7 +1249,7 @@ bool MainWindow::SaveAs()

QString text = GetCleanHtml();

// qDebug() << "Save As: " << text;
DBG qDebug() << "Save As: " << text;
QFileInfo fi(m_CurrentFilePath);
if (fi.exists() && !fi.isWritable()) {
Utility::DisplayStdErrorDialog(tr("File Save-As Failed!"), m_CurrentFilePath + " " + tr("is not writeable"));
Expand Down Expand Up @@ -1284,7 +1278,7 @@ bool MainWindow::Save()
{
QString text = GetCleanHtml();

// qDebug() << "Saving: " << text;
DBG qDebug() << "Saving: " << text;
QFileInfo fi(m_CurrentFilePath);

if (!fi.exists() || !fi.isWritable()) {
Expand Down
6 changes: 4 additions & 2 deletions OPFReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "Utility.h"
#include "OPFReader.h"

#define DBG if(0)

OPFReader::OPFReader()
:
m_opfDir(QDir()),
Expand Down Expand Up @@ -56,9 +58,9 @@ void OPFReader::ReadManifestItemElement(QXmlStreamReader *opf_reader)
QString type = opf_reader->attributes().value("", "media-type").toString();
href = Utility::URLDecodePath(href);
QString file_path = m_opfDir.absolutePath() + "/" + href;
qDebug() << "file path as built from opf info: " << file_path;
DBG qDebug() << "file path as built from opf info: " << file_path;
file_path = Utility::resolveRelativeSegmentsInFilePath(file_path, "/");
qDebug() << "file path after resolving relative segments: " << file_path;
DBG qDebug() << "file path after resolving relative segments: " << file_path;
if (!m_ManifestFilePaths.contains(file_path)) {
m_IDMap[ id ] = file_path;
m_FileMimeTypes[ id ] = type;
Expand Down
3 changes: 2 additions & 1 deletion Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ QString Utility::longestCommonPath(const QStringList& filepaths, const QString&
return res.join(sep) + sep;
}

// fixme this should also remove multiple path separators in a row after the first
QString Utility::resolveRelativeSegmentsInFilePath(const QString& file_path, const QString &sep)
{
const QStringList segs = file_path.split(sep);
Expand All @@ -628,7 +629,7 @@ QString Utility::resolveRelativeSegmentsInFilePath(const QString& file_path, con
if (!res.isEmpty()) {
res.removeLast();
} else {
qDebug() << "Error resolving relative path segments";
qDebug() << "Utility.cpp: Error resolving relative path segments";
}
} else {
res << segs.at(i);
Expand Down
2 changes: 1 addition & 1 deletion WebPageEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ WebPageEdit::WebPageEdit(QObject *parent)
bool WebPageEdit::acceptNavigationRequest(const QUrl & url, QWebEnginePage::NavigationType type, bool isMainFrame)
{
if (type == QWebEnginePage::NavigationTypeLinkClicked) {
qDebug() << "acceptNavigationRequest " << url.toString() << " , " << type << " , " << isMainFrame;
DBG qDebug() << "acceptNavigationRequest " << url.toString() << " , " << type << " , " << isMainFrame;
m_url = url;
QTimer::singleShot(20,this,SLOT(EmitLinkClicked()));
return false;
Expand Down
2 changes: 1 addition & 1 deletion WebViewEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void WebViewEdit::contextMenuEvent(QContextMenuEvent *event)

void WebViewEdit::LinkHovered(const QString &url)
{
qDebug() << "linkHovered received " << url;;
DBG qDebug() << "linkHovered received " << url;;
m_hoverUrl = url;
}

Expand Down

0 comments on commit 67a5b99

Please sign in to comment.