swift
Loading...
Searching...
No Matches
logcomponent.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#include <QAction>
7#include <QMenu>
8#include <QTabWidget>
9#include <Qt>
10#include <QtGlobal>
11
12#include "ui_logcomponent.h"
13
14#include "core/application.h"
16#include "gui/guiutility.h"
17#include "gui/menus/menuaction.h"
19#include "gui/views/viewbase.h"
20#include "misc/icons.h"
21#include "misc/logpattern.h"
23
24using namespace swift::misc;
25using namespace swift::core;
26using namespace swift::gui;
27using namespace swift::gui::views;
28using namespace swift::gui::menus;
29
31{
40
42 {
44 menu->addAction(CIcons::delete16(), "Clear console", this, &QPlainTextEdit::clear);
45 menu->exec(this->mapToGlobal(pos));
46 }
47
49 {
50 ui->setupUi(this);
51
53 [this](const CStatusMessage &message) { ui->comp_StatusMessages->appendStatusMessageToList(message); });
54 connect(&m_history, &CLogHistoryReplica::elementsReplaced, this, [this](const CStatusMessageList &messages) {
55 ui->comp_StatusMessages->appendStatusMessagesToList(messages);
56 });
57 connect(ui->comp_StatusMessages, &CStatusMessagesDetail::filterChanged, this, [this](const CVariant &filter) {
58 clearMessages();
59 m_history.setFilter(filter.value<CLogPattern>());
60 });
61 m_history.setFilter(CLogPattern().withSeverityAtOrAbove(CStatusMessage::SeverityInfo));
62 m_history.initialize(sApp->getDataLinkDBus());
63 }
64
66
67 void CLogComponent::displayLog(bool attention)
68 {
69 if (attention)
70 {
71 emit this->requestAttention();
72 }
73 }
74
76 {
77 ui->comp_StatusMessages->filterUseRadioButtonDescriptiveIcons(oneLetterText);
78 }
79
80 void CLogComponent::showFilterDialog() { ui->comp_StatusMessages->showFilterDialog(); }
81
82 void CLogComponent::showFilterBar() { ui->comp_StatusMessages->showFilterBar(); }
83
84 void CLogComponent::hideFilterBar() { ui->comp_StatusMessages->hideFilterBar(); }
85
86 void CLogComponent::showDetails(bool details) { ui->comp_StatusMessages->showDetails(details); }
87
88 void CLogComponent::setMaxLogMessages(int max) { ui->comp_StatusMessages->setMaxLogMessages(max); }
89
90 void CLogComponent::setNoSorting() { ui->comp_StatusMessages->setNoSorting(); }
91
92 void CLogComponent::setSorting(const CPropertyIndex &propertyIndex, Qt::SortOrder order)
93 {
94 ui->comp_StatusMessages->setSorting(propertyIndex, order);
95 }
96
97 void CLogComponent::clear() { ui->comp_StatusMessages->clear(); }
98
99 void CLogComponent::clearMessages() { ui->comp_StatusMessages->clear(); }
100} // namespace swift::gui::components
CConsoleTextEdit(QWidget *parent=nullptr)
Constructor.
void customMenuRequested(const QPoint &pos)
Custom menu.
void displayLog(bool attention=false)
Display log.
void filterUseRadioButtonDescriptiveIcons(bool oneLetterText)
Use icons with radio buttons.
void showDetails(bool details)
Show log details.
void setSorting(const swift::misc::CPropertyIndex &propertyIndex, Qt::SortOrder order)
Sorting for view.
void requestAttention()
Make me visible.
void setMaxLogMessages(int max)
Set max.log messages.
void showFilterBar()
Show a filter bar.
void hideFilterBar()
Hide a filter bar.
CLogComponent(QWidget *parent=nullptr)
Constructor.
void showFilterDialog()
Show filter dialog and disable bar.
void filterChanged(const swift::misc::CVariant &filter)
The user changed their message filter.
static const QPixmap & delete16()
Delete.
void elementAdded(const swift::misc::CStatusMessage &msg)
Signal emitted for each new log message.
void elementsReplaced(const swift::misc::CStatusMessageList &msgs)
Signal emitted when the whole history is updated wholesale.
Value class for matching log messages based on their categories.
Definition logpattern.h:49
Streamable status message, e.g.
static constexpr auto SeverityInfo
Status severities.
Status messages, e.g. from Core -> GUI.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Definition variant.h:69
Backend services of the swift project, like dealing with the network or the simulators.
Definition actionbind.cpp:7
High level reusable GUI components.
Views, mainly QTableView.
GUI related classes.
Free functions in swift::misc.
QFrame(QWidget *parent, Qt::WindowFlags f)
QAction * addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut)
QAction * exec()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
QPlainTextEdit(QWidget *parent)
QMenu * createStandardContextMenu()
CustomContextMenu
SortOrder
QWidget(QWidget *parent, Qt::WindowFlags f)
void setContextMenuPolicy(Qt::ContextMenuPolicy policy)
void customContextMenuRequested(const QPoint &pos)
QPoint mapToGlobal(const QPoint &pos) const const