mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 21:45:34 +08:00
refs #506, status filter bar/dialog for status messages
This commit is contained in:
committed by
Mathew Sutcliffe
parent
67125a1ecc
commit
67216876f1
74
src/blackgui/filters/statusmessagefilterbar.cpp
Normal file
74
src/blackgui/filters/statusmessagefilterbar.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "statusmessagefilterbar.h"
|
||||
#include "blackmisc/logpattern.h"
|
||||
#include "ui_statusmessagefilterbar.h"
|
||||
#include "blackgui/models/statusmessagefilter.h"
|
||||
#include <QCompleter>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Filters
|
||||
{
|
||||
CStatusMessageFilterBar::CStatusMessageFilterBar(QWidget *parent) :
|
||||
CFilterWidget(parent),
|
||||
ui(new Ui::CStatusMessageFilterBar)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setButtonsAndCount(ui->filter_Buttons);
|
||||
connect(ui->le_Category, &QLineEdit::returnPressed, this, &CFilterWidget::triggerFilter);
|
||||
connect(ui->le_MessageText, &QLineEdit::returnPressed, this, &CFilterWidget::triggerFilter);
|
||||
|
||||
ui->le_Category->setCompleter(new QCompleter(CLogPattern::allHumanReadableNames(), this));
|
||||
|
||||
// reset form
|
||||
this->clearForm();
|
||||
}
|
||||
|
||||
void CStatusMessageFilterBar::displayCount(bool show)
|
||||
{
|
||||
ui->filter_Buttons->displayCount(show);
|
||||
}
|
||||
|
||||
CStatusMessageFilterBar::~CStatusMessageFilterBar()
|
||||
{ }
|
||||
|
||||
std::unique_ptr<BlackGui::Models::IModelFilter<BlackMisc::CStatusMessageList> > CStatusMessageFilterBar::createModelFilter() const
|
||||
{
|
||||
return std::make_unique<CStatusMessageFilter>(
|
||||
this->getSelectedSeverity(),
|
||||
ui->le_MessageText->text(),
|
||||
ui->le_Category->text()
|
||||
);
|
||||
}
|
||||
|
||||
void CStatusMessageFilterBar::onRowCountChanged(int count, bool withFilter)
|
||||
{
|
||||
ui->filter_Buttons->onRowCountChanged(count, withFilter);
|
||||
}
|
||||
|
||||
void CStatusMessageFilterBar::clearForm()
|
||||
{
|
||||
ui->le_MessageText->clear();
|
||||
ui->le_Category->clear();
|
||||
ui->rb_Info->setChecked(true);
|
||||
}
|
||||
|
||||
CStatusMessage::StatusSeverity CStatusMessageFilterBar::getSelectedSeverity() const
|
||||
{
|
||||
if (ui->rb_Error->isChecked()) { return CStatusMessage::SeverityError; }
|
||||
if (ui->rb_Warning->isChecked()) { return CStatusMessage::SeverityWarning; }
|
||||
return CStatusMessage::SeverityInfo;
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
63
src/blackgui/filters/statusmessagefilterbar.h
Normal file
63
src/blackgui/filters/statusmessagefilterbar.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_FILTERS_STATUSMESSAGEFILTERBAR_H
|
||||
#define BLACKGUI_FILTERS_STATUSMESSAGEFILTERBAR_H
|
||||
|
||||
#include "blackgui/filters/filterwidget.h"
|
||||
#include "blackgui/models/modelfilter.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui { class CStatusMessageFilterBar; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Filters
|
||||
{
|
||||
/*!
|
||||
* Filter status messages
|
||||
*/
|
||||
class CStatusMessageFilterBar :
|
||||
public CFilterWidget,
|
||||
public BlackGui::Models::IModelFilterProvider<BlackMisc::CStatusMessageList>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CStatusMessageFilterBar(QWidget *parent = nullptr);
|
||||
|
||||
//! Show count
|
||||
void displayCount(bool show);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CStatusMessageFilterBar();
|
||||
|
||||
//! \copydoc Models::IModelFilterProvider::createModelFilter
|
||||
virtual std::unique_ptr<BlackGui::Models::IModelFilter<BlackMisc::CStatusMessageList>> createModelFilter() const override;
|
||||
|
||||
public slots:
|
||||
//! \copydoc CFilterWidget::onRowCountChanged
|
||||
virtual void onRowCountChanged(int count, bool withFilter) override;
|
||||
|
||||
protected:
|
||||
//! \copydoc CFilterWidget::clearForm
|
||||
virtual void clearForm() override;
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CStatusMessageFilterBar> ui;
|
||||
|
||||
//! Get the selected severity
|
||||
BlackMisc::CStatusMessage::StatusSeverity getSelectedSeverity() const;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
94
src/blackgui/filters/statusmessagefilterbar.ui
Normal file
94
src/blackgui/filters/statusmessagefilterbar.ui
Normal file
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CStatusMessageFilterBar</class>
|
||||
<widget class="QFrame" name="CStatusMessageFilterBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>302</width>
|
||||
<height>68</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Status message filter</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_StatusMessageFilter">
|
||||
<item row="0" column="1">
|
||||
<widget class="QFrame" name="fr_Severity">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hl_Severity">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_Info">
|
||||
<property name="text">
|
||||
<string>info</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_Warning">
|
||||
<property name="text">
|
||||
<string>warning</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_Error">
|
||||
<property name="text">
|
||||
<string>error</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="BlackGui::Filters::CFilterBarButtons" name="filter_Buttons"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLineEdit" name="le_Category">
|
||||
<property name="placeholderText">
|
||||
<string>category</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QLineEdit" name="le_MessageText">
|
||||
<property name="placeholderText">
|
||||
<string>message text</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Filters::CFilterBarButtons</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/filters/filterbarbuttons.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
42
src/blackgui/filters/statusmessagefilterdialog.cpp
Normal file
42
src/blackgui/filters/statusmessagefilterdialog.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackgui/filters/statusmessagefilterdialog.h"
|
||||
#include "blackgui/filters/statusmessagefilterbar.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "ui_statusmessagefilterdialog.h"
|
||||
|
||||
using namespace BlackGui::Models;
|
||||
using namespace BlackGui::Filters;
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Filters
|
||||
{
|
||||
CStatusMessageFilterDialog::CStatusMessageFilterDialog(QWidget *parent) :
|
||||
CFilterDialog(parent),
|
||||
ui(new Ui::CStatusMessageFilterDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowTitle("Filter status messages");
|
||||
this->resize(480, 75);
|
||||
ui->filter_Messages->displayCount(false);
|
||||
connect(ui->filter_Messages, &CStatusMessageFilterBar::rejectDialog, this, &CStatusMessageFilterDialog::reject);
|
||||
}
|
||||
|
||||
CStatusMessageFilterDialog::~CStatusMessageFilterDialog()
|
||||
{ }
|
||||
|
||||
std::unique_ptr<IModelFilter<CStatusMessageList>> CStatusMessageFilterDialog::createModelFilter() const
|
||||
{
|
||||
return ui->filter_Messages->createModelFilter();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
56
src/blackgui/filters/statusmessagefilterdialog.h
Normal file
56
src/blackgui/filters/statusmessagefilterdialog.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_FILTERS_STATUSMESSAGEFILTERDIALOG_H
|
||||
#define BLACKGUI_FILTERS_STATUSMESSAGEFILTERDIALOG_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/filters/filterdialog.h"
|
||||
#include "blackgui/models/modelfilter.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
#include <memory>
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace BlackMisc { class CStatusMessageList; }
|
||||
namespace Ui { class CStatusMessageFilterDialog; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Filters
|
||||
{
|
||||
//! Form for a status message filter
|
||||
class BLACKGUI_EXPORT CStatusMessageFilterDialog :
|
||||
public CFilterDialog,
|
||||
public BlackGui::Models::IModelFilterProvider<BlackMisc::CStatusMessageList>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CStatusMessageFilterDialog(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CStatusMessageFilterDialog();
|
||||
|
||||
//! \copydoc Models::IModelFilterProvider::createModelFilter
|
||||
virtual std::unique_ptr<BlackGui::Models::IModelFilter<BlackMisc::CStatusMessageList>> createModelFilter() const override;
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CStatusMessageFilterDialog> ui;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
82
src/blackgui/filters/statusmessagefilterdialog.ui
Normal file
82
src/blackgui/filters/statusmessagefilterdialog.ui
Normal file
@@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CStatusMessageFilterDialog</class>
|
||||
<widget class="QDialog" name="CStatusMessageFilterDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>184</width>
|
||||
<height>56</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="BlackGui::Filters::CStatusMessageFilterBar" name="filter_Messages">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="bb_FilterDialog">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Filters::CStatusMessageFilterBar</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/filters/statusmessagefilterbar.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>bb_FilterDialog</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CStatusMessageFilterDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>bb_FilterDialog</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CStatusMessageFilterDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user