diff options
| author | Tannin <devnull@localhost> | 2014-05-31 13:43:48 +0200 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2014-05-31 13:43:48 +0200 |
| commit | 1eb783aae348f906056cee17cb65dfd507429901 (patch) | |
| tree | d9e5b93c1d528a2182416d971b27e49cb524532b /src/logbuffer.cpp | |
| parent | 93a19799b86dd6e12a186e84eb43699b318b214d (diff) | |
- added a new mod type that represents files handled externally (i.e. DLCs) as mods in MO
- hashes of file names in bsa files are no longer checked all the time
- author and description is now read from esp files
- rewrote the code that fixes modlists after a rename, should be a bit more robust
- fixes to qt 5 and msvc 2013 compatibility
- started to update the tutorial (not done yet!)
- bugfix: counter for the problems badge wasn't calculated correctly
Diffstat (limited to 'src/logbuffer.cpp')
| -rw-r--r-- | src/logbuffer.cpp | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/src/logbuffer.cpp b/src/logbuffer.cpp index 1bf9cd85..ef0549b0 100644 --- a/src/logbuffer.cpp +++ b/src/logbuffer.cpp @@ -21,6 +21,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include "report.h" #include <QMutexLocker> #include <QFile> +#include <QIcon> #include <QDateTime> #include <Windows.h> @@ -108,6 +109,17 @@ void LogBuffer::init(int messageCount, QtMsgType minMsgType, const QString &outp #endif } +char LogBuffer::msgTypeID(QtMsgType type) +{ + switch (type) { + case QtDebugMsg: return 'D'; + case QtWarningMsg: return 'W'; + case QtCriticalMsg: return 'C'; + case QtFatalMsg: return 'F'; + default: return '?'; + } +} + #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) void LogBuffer::log(QtMsgType type, const QMessageLogContext &context, const QString &message) @@ -116,24 +128,31 @@ void LogBuffer::log(QtMsgType type, const QMessageLogContext &context, const QSt if (!s_Instance.isNull()) { s_Instance->logMessage(type, message); } - fprintf(stdout, "(%s:%u) %s\n", context.file, context.line, qPrintable(message)); +// fprintf(stdout, "(%s:%u) %s\n", context.file, context.line, qPrintable(message)); + if (type == QtDebugMsg) { + fprintf(stdout, "%s [%c] %s\n", qPrintable(QTime::currentTime().toString()), msgTypeID(type), qPrintable(message)); + } else { + fprintf(stdout, "%s [%c] (%s:%u) %s\n", qPrintable(QTime::currentTime().toString()), msgTypeID(type), + context.file, context.line, qPrintable(message)); + } fflush(stdout); } #else - -char LogBuffer::msgTypeID(QtMsgType type) +void LogBuffer::log(QtMsgType type, const char *message) { - switch (type) { - case QtDebugMsg: return 'D'; - case QtWarningMsg: return 'W'; - case QtCriticalMsg: return 'C'; - case QtFatalMsg: return 'F'; - default: return '?'; + QMutexLocker guard(&s_Mutex); + if (!s_Instance.isNull()) { + s_Instance->logMessage(type, message); } + fprintf(stdout, "%s [%c] %s\n", qPrintable(QTime::currentTime().toString()), msgTypeID(type), message); + fflush(stdout); } +#endif + + QModelIndex LogBuffer::index(int row, int column, const QModelIndex&) const { return createIndex(row, column, row); @@ -162,7 +181,7 @@ QVariant LogBuffer::data(const QModelIndex &index, int role) const { unsigned offset = m_NumMessages < m_Messages.size() ? 0 : m_NumMessages - m_Messages.size(); - unsigned int msgIndex = (offset + index.row()) % m_Messages.size(); + unsigned int msgIndex = (offset + index.row() + 1) % m_Messages.size(); switch (role) { case Qt::DisplayRole: { if (index.column() == 0) { @@ -200,18 +219,6 @@ QVariant LogBuffer::data(const QModelIndex &index, int role) const return QVariant(); } -void LogBuffer::log(QtMsgType type, const char *message) -{ - QMutexLocker guard(&s_Mutex); - if (!s_Instance.isNull()) { - s_Instance->logMessage(type, message); - } - fprintf(stdout, "%s [%c] %s\n", qPrintable(QTime::currentTime().toString()), msgTypeID(type), message); - fflush(stdout); -} - -#endif - void LogBuffer::writeNow() { QMutexLocker guard(&s_Mutex); |
