Skip to content

Commit 1351851

Browse files
committed
changed debugging, fixed warnings
1 parent 4037361 commit 1351851

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

ZoomImage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ZoomImage : public QLabel {
1313

1414
public:
1515
ZoomImage();
16-
void wheelEvent(QWheelEvent *event);
16+
void wheelEvent(QWheelEvent *event) override;
1717
double getScale();
1818

1919
private:

ZoomScrollImage.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public slots:
2626
void zoomChanged(double factor);
2727

2828
protected:
29-
void mousePressEvent(QMouseEvent *e);
30-
void mouseMoveEvent(QMouseEvent *e);
29+
void mousePressEvent(QMouseEvent *e) override;
30+
void mouseMoveEvent(QMouseEvent *e) override;
3131
};
3232

3333
#endif

mainwindow.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include <QtCore/QDebug>
2121
#undef QT_NO_DEBUG
22-
// #include <kdebug.h>
22+
2323

2424
QString getFilePath(QTemporaryDir* dir, const char* file) {
2525
QString path(dir->path());
@@ -28,6 +28,12 @@ QString getFilePath(QTemporaryDir* dir, const char* file) {
2828
return path;
2929
}
3030

31+
inline QDebug operator<<(QDebug dbg, const std::string& str)
32+
{
33+
dbg.nospace() << QString::fromStdString(str);
34+
return dbg.space();
35+
}
36+
3137
void MainWindow::textChanged(KTextEditor::Document *document) {
3238
(void)document;
3339
refreshTimer->start(1000);
@@ -37,7 +43,7 @@ void MainWindow::textChanged(KTextEditor::Document *document) {
3743
void MainWindow::documentSaved(KTextEditor::Document *document, bool saveas) {
3844
(void)document;
3945
(void)saveas;
40-
std::cout << "Document saved" << std::endl;
46+
qDebug() << "Document saved";
4147
usersaved = true;
4248
}
4349

@@ -89,7 +95,7 @@ void MainWindow::compile() {
8995
return;
9096
}
9197
if(texdir.absolutePath() == "") {
92-
std::cout << "need a temporary directory" << std::endl;
98+
qDebug() << "Creating a temporary directory";
9399
texdir = QFileInfo(tmpdir.path());
94100
}
95101
QFileInfo templateDir = QFileInfo(templateFile.path());
@@ -100,8 +106,8 @@ void MainWindow::compile() {
100106

101107
arguments << getFilePath(dir, "_livetikz_preview.tex");
102108

103-
std::cout << "Compiler arguments: " << arguments.join(QChar(' ')).toStdString() << std::endl;
104-
std::cout << "Compiler workdir: " << workdir.absolutePath().toStdString() << std::endl;
109+
qDebug() << "Compiler arguments: " << arguments.join(QChar(' ')).toStdString();
110+
qDebug() << "Compiler workdir: " << workdir.absolutePath().toStdString();
105111

106112
renderProcess = new QProcess(this);
107113
renderProcess->setWorkingDirectory(workdir.absolutePath());
@@ -175,7 +181,7 @@ void MainWindow::refresh() {
175181
}
176182
}
177183
} else if(dir) {
178-
std::cout << "Deleting invalid dir" << dir->path().toStdString() << std::endl;
184+
qDebug() << "Deleting invalid dir" << dir->path().toStdString();
179185
delete dir;
180186
dir = NULL;
181187
}
@@ -203,15 +209,18 @@ void MainWindow::updateLog() {
203209

204210
void MainWindow::renderFailed(QProcess::ProcessError) {
205211
appendLog("Failed to execute compiler\n");
212+
qDebug() << "Could not compile";
206213
renderFinished(1);
207214
}
208215

209216

210217
void MainWindow::renderFinished(int code) {
211218
if (code == 0) {
212219
appendLog("Done!\n");
220+
qDebug() << "Done";
213221
} else {
214222
appendLog("Error!\n");
223+
qDebug() << "Error: " << code;
215224
}
216225

217226
killButton->setVisible(false);
@@ -318,17 +327,17 @@ void MainWindow::watchme(const QString& filename) {
318327
texfileWatcher = new QFileSystemWatcher();
319328
connect(texfileWatcher, SIGNAL(fileChanged(const QString&)), this, SLOT(handleTexfileChanged(const QString&)));
320329

321-
std::cout << "Watching " << filename.toStdString() << std::endl;
330+
qDebug() << "Watching " << filename.toStdString();
322331
int retry_count = 10;
323332
while(!texfileWatcher->addPath(filename) && retry_count--) {
324333
/* If the file has not been re-created yet, wait some time */
325334
std::this_thread::sleep_for(std::chrono::milliseconds(100));
326-
std::cout << "Retrying to watch..." << std::endl;
335+
qDebug() << "Retrying to watch...";
327336
}
328337
}
329338

330339
void MainWindow::load(const QUrl &url) {
331-
std::cout << "Loading " << url.toString().toStdString() << std::endl;
340+
qDebug() << "Loading " << url.toString().toStdString();
332341
texdir = QFileInfo(url.toLocalFile());
333342
watchme(url.toLocalFile());
334343

@@ -439,10 +448,12 @@ void MainWindow::setupEditor() {
439448
view = ((KTextEditor::View *)katePart->widget());
440449
doc = view->document();
441450
} else {
451+
qDebug() << "katePart is NULL";
442452
KMessageBox::error(this, "Could not create editor");
443453
qApp->quit();
444454
}
445455
} else {
456+
qDebug() << "katepart service not found";
446457
KMessageBox::error(this, "Service katepart not found - please install kate");
447458
qApp->quit();
448459
}
@@ -451,13 +462,13 @@ void MainWindow::setupEditor() {
451462
void MainWindow::load() { load(QFileDialog::getOpenFileUrl()); }
452463

453464
void MainWindow::handleTemplateChanged(const QString& filename) {
454-
std::cout << filename.toStdString() << " changed." << std::endl;
465+
qDebug() << filename.toStdString() << " changed.";
455466
updateTemplate(filename);
456467
}
457468

458469
void MainWindow::handleTexfileChanged(const QString& filename) {
459470
if (!usersaved) {
460-
std::cout << "Texfile " << filename.toStdString() << " externally changed." << std::endl;
471+
qDebug() << "Texfile " << filename.toStdString() << " externally changed.";
461472
/* Reloading */
462473
katePart->openUrl(QUrl::fromLocalFile(filename));
463474
}
@@ -475,7 +486,7 @@ void MainWindow::updateTemplate(const QString& filename) {
475486
templateWatcher.removePath(oldTemplateFile.path());
476487

477488
templateFile = QUrl::fromLocalFile(filename);
478-
std::cout << "Loading template " << templateFile.path().toStdString() << std::endl;
489+
qDebug() << "Loading template " << templateFile.path().toStdString();
479490
templateWatcher.addPath(templateFile.path());
480491
settings.setValue("template", filename);
481492
refresh();
@@ -493,7 +504,7 @@ void MainWindow::browse() {
493504
void MainWindow::chooseWorkdir() {
494505
workdir = QFileInfo(QFileDialog::getExistingDirectory(this, QString("Select Working Directory"),
495506
workdir.absolutePath(), QFileDialog::ShowDirsOnly) + "/");
496-
std::cout << "Selected working directory: " << workdir.path().toStdString() << std::endl;
507+
qDebug() << "Selected working directory: " << workdir.path().toStdString();
497508
updateRootDirectory();
498509
refresh();
499510
}

mainwindow.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
#include <QTextEdit>
2222
#include <QTextCursor>
2323
#include <QTimer>
24+
#include <QMessageLogger>
2425
#include <KParts/MainWindow>
2526
#include <KTextEditor/Document>
2627
#include <KTextEditor/View>
2728
#include <poppler-qt5.h>
2829
#include <ZoomScrollImage.h>
2930

31+
3032
class MainWindow : public KParts::MainWindow {
3133
Q_OBJECT
3234
public:

0 commit comments

Comments
 (0)