#90 Added capability to print messages with custom timestamp

master
Tomatix 3 years ago
parent d2974336de
commit 72de07fb30
  1. 8
      IWin/IWin.cpp
  2. 4
      IWin/IWin.h
  3. 4
      IWin/IWinChannel.cpp
  4. 2
      IWin/IWinChannel.h
  5. 4
      IWin/IWinPrivate.cpp
  6. 2
      IWin/IWinPrivate.h
  7. 4
      IWin/IWinStatus.cpp
  8. 2
      IWin/IWinStatus.h
  9. 5
      Widgets/IIRCView.cpp
  10. 2
      Widgets/IIRCView.h

@ -6,7 +6,7 @@
*/
#include "IWin.h"
#include <QDebug>
#include <QDateTime>
const QString IWin::InvalidWindowTypeString { "Invalid" };
@ -28,6 +28,12 @@ IWin* IWin::getStatusParent()
return (m_type == Type::Status) ? this : m_parent;
}
bool IWin::print(PrintType ptype, const QString& text)
{
const auto timestamp = QDateTime::currentDateTime();
return printWithCustomTime(timestamp, ptype, text);
}
const QString& IWin::getButtonText() const
{
return m_buttonText;

@ -34,13 +34,13 @@ public:
IWin* getParent() const { return m_parent; }
IWin* getStatusParent();
virtual bool print(PrintType ptype, const QString& text) = 0;
bool print(PrintType ptype, const QString& text);
virtual bool printWithCustomTime(const QDateTime& timestamp, PrintType ptype, const QString& text) = 0;
virtual void refreshWindowTitle() = 0;
virtual void clear() = 0;
const QString& getButtonText() const;
void setButtonText(const QString& text);
bool operator==(const IWin& other); // TODO implementation
protected:
explicit IWin(Type type, IWin* parentWindow = nullptr);

@ -104,9 +104,9 @@ IWinChannel::IWinChannel(IWinStatus* statusParent, const QString& channelName)
});
}
bool IWinChannel::print(const PrintType ptype, const QString& text)
bool IWinChannel::printWithCustomTime(const QDateTime& timestamp, PrintType ptype, const QString& text)
{
view->print(ptype, text);
view->print(timestamp, ptype, text);
MdiManager::instance().highlight(this, HL_Activity);
ConfigMgr& conf = ConfigMgr::instance();

@ -29,7 +29,7 @@ class IWinChannel : public IWin
public:
IWinChannel(IWinStatus* statusParent, const QString& channelName);
bool print(const PrintType ptype, const QString& text) override;
bool printWithCustomTime(const QDateTime& timestamp, PrintType ptype, const QString& text) override;
void refreshWindowTitle() override;
void clear() override { view->resetView(); }
void resetNicklist();

@ -41,9 +41,9 @@ IWinPrivate::IWinPrivate(IWinStatus* statusParent, const QString& targetName)
});
}
bool IWinPrivate::print(const PrintType ptype, const QString& text)
bool IWinPrivate::printWithCustomTime(const QDateTime& timestamp, PrintType ptype, const QString& text)
{
view->print(ptype, text);
view->print(timestamp, ptype, text);
MdiManager::instance().highlight(this, HL_Activity);
ConfigMgr& conf = ConfigMgr::instance();

@ -23,7 +23,7 @@ class IWinPrivate : public IWin
public:
IWinPrivate(IWinStatus* statusParent, const QString& targetName);
bool print(const PrintType ptype, const QString& text) override;
bool printWithCustomTime(const QDateTime& timestamp, PrintType ptype, const QString& text) override;
void refreshWindowTitle() override;
void clear() override { view->resetView(); }

@ -62,9 +62,9 @@ IWinStatus::IWinStatus(const QString& buttonText)
Qt_Eventloop_Hook();
}
bool IWinStatus::print(const PrintType ptype, const QString& text)
bool IWinStatus::printWithCustomTime(const QDateTime& timestamp, PrintType ptype, const QString& text)
{
view->print(ptype, text);
view->print(timestamp, ptype, text);
MdiManager::instance().highlight(this, HL_Activity);
return true;

@ -28,7 +28,7 @@ class IWinStatus : public IWin
public:
explicit IWinStatus(const QString& buttonText);
bool print(const PrintType ptype, const QString& text) override;
bool printWithCustomTime(const QDateTime& timestamp, PrintType ptype, const QString& text) override;
void refreshWindowTitle() override;
void clear() override { view->resetView(); }
void printTo(const QString& target, const PrintType ptype, const QString& text);

@ -106,7 +106,7 @@ IIRCView::IIRCView()
connect(this, &QTextBrowser::customContextMenuRequested, this, &IIRCView::customContextMenuRequested);
}
void IIRCView::print(const PrintType ptype, const QString& text)
void IIRCView::print(const QDateTime& timestamp, const PrintType ptype, const QString& text)
{
QString textFormatted = stripTags(text);
QString styleclass = typeToString(ptype, "Normal");
@ -114,8 +114,7 @@ void IIRCView::print(const PrintType ptype, const QString& text)
ConfigMgr& conf = ConfigMgr::instance();
if (conf.common("ShowTimestamp") == "1" && !conf.common("TimestampFormat").isEmpty()) {
QDateTime dt = QDateTime::currentDateTime();
QString ts = dt.toString(conf.common("TimestampFormat")) + " ";
QString ts = timestamp.toString(conf.common("TimestampFormat")) + " ";
textFormatted.prepend(ts);
}

@ -71,7 +71,7 @@ class IIRCView : public QTextBrowser
public:
IIRCView();
void print(PrintType ptype, const QString& text);
void print(const QDateTime& timestamp, PrintType ptype, const QString& text);
void resetView();
static QString stripTags(const QString& text);
static QString formatType(PrintType ptype, const QString& text);

Loading…
Cancel
Save