1 change: 1 addition & 0 deletions cmake/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ else
fi

$cmakebin ../kst/cmake/ \
-Dkst_console=1 \
-Dkst_release=1 \
-Dkst_version_string=$versionname \
-Dkst_install_prefix=./$versionname \
Expand Down
3 changes: 3 additions & 0 deletions src/datasources/ascii/asciisource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "kst_atof.h"
#include "measuretime.h"
#include "debug.h"

#include <QFile>
#include <QFileInfo>
Expand Down Expand Up @@ -297,6 +298,8 @@ int AsciiSource::readField(double *v, const QString& field, int s, int n)
emitProgress(0, tr("Reading field: ") + field);
}

Debug::trace(QString("AsciiSource::readField() %1 s=%2 n=%3").arg(field.leftJustified(15)).arg(QString("%1").arg(s, 10)).arg(n));

int read = tryReadField(v, field, s, n);

if (isTime(field)) {
Expand Down
12 changes: 6 additions & 6 deletions src/libkst/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ void Debug::clear() {

QString Debug::label(LogLevel level) const {
switch (level) {
case Notice:
return tr("Notice");
case Warning:
return tr("Warning");
case Error:
return tr("Error");
case DebugLog:
return tr("Debug");
case Warning:
return tr("Warning");
case Notice:
return tr("Notice");
case Trace:
return tr("Trace");
default:
return tr("Other");
}
Expand Down
13 changes: 12 additions & 1 deletion src/libkst/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ namespace Kst {
class KSTCORE_EXPORT Debug : public QObject {
Q_OBJECT
public:
enum LogLevel { Unknown = 0, Notice = 1, Warning = 2, Error = 4, DebugLog = 8, None = 16384 };
enum LogLevel {
Trace = 1,
Notice = 2,
Warning = 4,
Error = 8
};
struct LogMessage {
QDateTime date;
QString msg;
Expand All @@ -43,6 +48,12 @@ class KSTCORE_EXPORT Debug : public QObject {
void setLimit(bool applyLimit, int limit);
QString text();

#define DEBUG_LOG_FUNC(X, T) static void X(const QString& msg) { self()->log(msg, T); }
DEBUG_LOG_FUNC(error, Error);
DEBUG_LOG_FUNC(warning, Warning);
DEBUG_LOG_FUNC(notice, Notice);
DEBUG_LOG_FUNC(trace, Trace);

int logLength() const;
QList<LogMessage> messages() const;
Debug::LogMessage message(unsigned n) const;
Expand Down
2 changes: 1 addition & 1 deletion src/libkst/measuretime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void MeasureTime::print()
{
measure();
qWarning("MeasureTime in %s: %g sec", qPrintable(name), interval);
Kst::Debug::self()->log(QString("Timing: %2 sec, Scope: %1").arg(name).arg(interval), Kst::Debug::DebugLog);
Kst::Debug::trace(QString("Timing: %2 sec, Scope: %1").arg(name).arg(interval));
}


Expand Down
5 changes: 3 additions & 2 deletions src/libkstapp/debugdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ DebugDialog::DebugDialog(QWidget *parent)
_logTabLayout->addWidget(_log,0,0);

connect(_clear, SIGNAL(clicked()), this, SLOT(clear()));
connect(_showDebug, SIGNAL(toggled(bool)), _log, SLOT(setShowDebug(bool)));

connect(_showError, SIGNAL(toggled(bool)), _log, SLOT(setShowError(bool)));
connect(_showWarning, SIGNAL(toggled(bool)), _log, SLOT(setShowWarning(bool)));
connect(_showNotice, SIGNAL(toggled(bool)), _log, SLOT(setShowNotice(bool)));
connect(_showError, SIGNAL(toggled(bool)), _log, SLOT(setShowError(bool)));
connect(_showTrace, SIGNAL(toggled(bool)), _log, SLOT(setShowTrace(bool)));

if (!Debug::self()->kstRevision().isEmpty())
_buildInfo->setText(tr("<h1>Kst</h1> Version %1 (%2)").arg(KSTVERSION).arg(Debug::self()->kstRevision()));
Expand Down
23 changes: 13 additions & 10 deletions src/libkstapp/debugdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="_tabs">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="_buildInfoTab">
<attribute name="title">
Expand Down Expand Up @@ -102,42 +102,45 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="_showDebug">
<widget class="QCheckBox" name="_showError">
<property name="text">
<string>&amp;Debug</string>
<string>&amp;Error</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_showNotice">
<widget class="QCheckBox" name="_showWarning">
<property name="text">
<string>&amp;Notice</string>
<string>&amp;Warning</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_showWarning">
<widget class="QCheckBox" name="_showNotice">
<property name="text">
<string>&amp;Warning</string>
<string>&amp;Notice</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_showError">
<widget class="QCheckBox" name="_showTrace">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Error</string>
<string>&amp;Trace</string>
</property>
<property name="checked">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
Expand Down
56 changes: 19 additions & 37 deletions src/libkstapp/logwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@

namespace Kst {


LogWidget::LogWidget(QWidget *parent)
: QTextBrowser(parent) {
_show = Debug::Warning | Debug::Error | Debug::Notice | Debug::DebugLog;
_show = Debug::Warning | Debug::Error | Debug::Notice | Debug::Trace;
}


Expand All @@ -43,9 +44,9 @@ void LogWidget::logAdded(const Debug::LogMessage& msg) {
case Debug::Notice:
sym = "<img src=\"DebugNotice\"/> ";
break;
case Debug::DebugLog:
sym = "<img src=\"DebugDebug\"/> ";
break;
case Debug::Trace:
sym = "<img src=\"DebugTrace\"/> ";
break;
default:
return;
}
Expand All @@ -58,55 +59,36 @@ void LogWidget::logAdded(const Debug::LogMessage& msg) {
}


void LogWidget::setShowDebug(bool show) {
int old = _show;
void LogWidget::setShowLevel(Debug::LogLevel level, bool show) {
const int old = _show;
if (show) {
_show |= Debug::DebugLog;
_show |= level;
} else {
_show &= ~Debug::DebugLog;
_show &= ~level;
}
if (_show != old) {
regenerate();
}
}


void LogWidget::setShowNotice(bool show) {
int old = _show;
if (show) {
_show |= Debug::Notice;
} else {
_show &= ~Debug::Notice;
}
if (_show != old) {
regenerate();
}
void LogWidget::setShowError(bool show) {
setShowLevel(Debug::Error, show);
}


void LogWidget::setShowWarning(bool show) {
int old = _show;
if (show) {
_show |= Debug::Warning;
} else {
_show &= ~Debug::Warning;
}
if (_show != old) {
regenerate();
}
setShowLevel(Debug::Warning, show);
}


void LogWidget::setShowError(bool show) {
int old = _show;
if (show) {
_show |= Debug::Error;
} else {
_show &= ~Debug::Error;
}
if (_show != old) {
regenerate();
}
void LogWidget::setShowNotice(bool show) {
setShowLevel(Debug::Notice, show);
}


void LogWidget::setShowTrace(bool show) {
setShowLevel(Debug::Trace, show);
}


Expand Down
8 changes: 5 additions & 3 deletions src/libkstapp/logwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ class LogWidget : public QTextBrowser

public Q_SLOTS:
void logAdded(const Debug::LogMessage&);
void setShowDebug(bool show);
void setShowNotice(bool show);
void setShowWarning(bool show);

void setShowError(bool show);
void setShowWarning(bool show);
void setShowNotice(bool show);
void setShowTrace(bool show);

private slots:
void regenerate();

private:
int _show;
void setShowLevel(Debug::LogLevel, bool show);
};

}
Expand Down