Ali Hatami Tajik
4 months ago
15 changed files with 358 additions and 23 deletions
@ -0,0 +1,65 @@ |
|||
#include "AdvancedFilterDialog.h" |
|||
#include "ui_AdvancedFilterDialog.h" |
|||
|
|||
AdvancedFilterDialog::AdvancedFilterDialog(QWidget* parent) : |
|||
QDialog(parent), |
|||
ui(new Ui::AdvancedFilterDialog) |
|||
{ |
|||
ui->setupUi(this); |
|||
makeConnections(); |
|||
} |
|||
|
|||
AdvancedFilterDialog::~AdvancedFilterDialog() |
|||
{ |
|||
delete ui; |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
void AdvancedFilterDialog::setActiveScopes(QMap<QString, bool> options) |
|||
{ |
|||
QMap<QString, bool>::const_iterator i; |
|||
for(i = options.constBegin(); i != options.constEnd(); i++) |
|||
{ |
|||
auto item = new QListWidgetItem(i.key(), ui->listWidget); |
|||
item->setCheckState(i.value() ? Qt::Checked : Qt::Unchecked); |
|||
ui->listWidget->addItem(item); |
|||
} |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
QMap<QString, bool> AdvancedFilterDialog::getActiveScopes() const |
|||
{ |
|||
QMap<QString, bool> options; |
|||
for(int i = 0; i < ui->listWidget->count(); ++i) |
|||
{ |
|||
QListWidgetItem* item = ui->listWidget->item(i); |
|||
options[item->text()] = item->checkState() == Qt::Checked; |
|||
} |
|||
|
|||
return options; |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
void AdvancedFilterDialog::checkAll() |
|||
{ |
|||
for(int i = 0; i < ui->listWidget->count(); ++i) |
|||
{ |
|||
ui->listWidget->item(i)->setCheckState(Qt::Checked); |
|||
} |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
void AdvancedFilterDialog::uncheckAll() |
|||
{ |
|||
for(int i = 0; i < ui->listWidget->count(); ++i) |
|||
{ |
|||
ui->listWidget->item(i)->setCheckState(Qt::Unchecked); |
|||
} |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
void AdvancedFilterDialog::makeConnections() |
|||
{ |
|||
connect(ui->checkAllButton, &QPushButton::clicked, this, &AdvancedFilterDialog::checkAll); |
|||
connect(ui->uncheckAllButton, &QPushButton::clicked, this, &AdvancedFilterDialog::uncheckAll); |
|||
} |
@ -0,0 +1,33 @@ |
|||
#ifndef ADVANCEDFILTERDIALOG_H |
|||
#define ADVANCEDFILTERDIALOG_H |
|||
|
|||
#include <QDialog> |
|||
|
|||
namespace Ui { |
|||
class AdvancedFilterDialog; |
|||
} |
|||
|
|||
class AdvancedFilterDialog : public QDialog |
|||
{ |
|||
Q_OBJECT |
|||
|
|||
public: |
|||
explicit AdvancedFilterDialog(QWidget* parent = nullptr); |
|||
~AdvancedFilterDialog(); |
|||
|
|||
void setActiveScopes(QMap<QString, bool> options); |
|||
QMap<QString, bool> getActiveScopes() const; |
|||
|
|||
//uncrustify off
|
|||
public slots: |
|||
//uncrustify on
|
|||
void checkAll(); |
|||
void uncheckAll(); |
|||
|
|||
private: |
|||
Ui::AdvancedFilterDialog* ui; |
|||
|
|||
void makeConnections(); |
|||
}; |
|||
|
|||
#endif //ADVANCEDFILTERDIALOG_H
|
@ -0,0 +1,104 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<ui version="4.0"> |
|||
<class>AdvancedFilterDialog</class> |
|||
<widget class="QDialog" name="AdvancedFilterDialog"> |
|||
<property name="geometry"> |
|||
<rect> |
|||
<x>0</x> |
|||
<y>0</y> |
|||
<width>630</width> |
|||
<height>527</height> |
|||
</rect> |
|||
</property> |
|||
<property name="windowTitle"> |
|||
<string>Dialog</string> |
|||
</property> |
|||
<layout class="QVBoxLayout" name="verticalLayout"> |
|||
<item> |
|||
<widget class="QTabWidget" name="tabWidget"> |
|||
<property name="currentIndex"> |
|||
<number>0</number> |
|||
</property> |
|||
<widget class="QWidget" name="tab"> |
|||
<attribute name="title"> |
|||
<string>Active Scopes</string> |
|||
</attribute> |
|||
<layout class="QVBoxLayout" name="verticalLayout_2"> |
|||
<item> |
|||
<widget class="QListWidget" name="listWidget"/> |
|||
</item> |
|||
<item> |
|||
<layout class="QHBoxLayout" name="horizontalLayout"> |
|||
<item> |
|||
<widget class="QPushButton" name="checkAllButton"> |
|||
<property name="text"> |
|||
<string>Check All</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<widget class="QPushButton" name="uncheckAllButton"> |
|||
<property name="text"> |
|||
<string>Uncheck All</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
</layout> |
|||
</item> |
|||
</layout> |
|||
</widget> |
|||
<widget class="QWidget" name="tab_2"> |
|||
<attribute name="title"> |
|||
<string>TODO</string> |
|||
</attribute> |
|||
</widget> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<widget class="QDialogButtonBox" name="buttonBox"> |
|||
<property name="orientation"> |
|||
<enum>Qt::Horizontal</enum> |
|||
</property> |
|||
<property name="standardButtons"> |
|||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
</layout> |
|||
</widget> |
|||
<resources/> |
|||
<connections> |
|||
<connection> |
|||
<sender>buttonBox</sender> |
|||
<signal>accepted()</signal> |
|||
<receiver>AdvancedFilterDialog</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>buttonBox</sender> |
|||
<signal>rejected()</signal> |
|||
<receiver>AdvancedFilterDialog</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> |
@ -1 +1 @@ |
|||
Subproject commit 20bb40c9e53a350e237a6b436a69a3e578e4f39b |
|||
Subproject commit 5d8ca71f73c1f80326dbdfaafb6a8a6d3a74bf40 |
@ -0,0 +1,23 @@ |
|||
#ifndef ADVANCEDFILTER_H |
|||
#define ADVANCEDFILTER_H |
|||
|
|||
#include "type/Log.h" |
|||
#include "data/filter/IFilter.h" |
|||
#include "type/AdvancedFilterDto.h" |
|||
|
|||
class AdvancedFilter : public IFilter<Log_ptr> |
|||
{ |
|||
public: |
|||
AdvancedFilter(AdvancedFilterDto dto); |
|||
~AdvancedFilter() override; |
|||
|
|||
bool isAccepted(Log_ptr input) const override; |
|||
|
|||
private: |
|||
QList<QString> _acceptedScopes; |
|||
|
|||
void initAcceptedScopes(const QMap<QString, bool>& acceptanceMap); |
|||
bool isScopesAccepted(const Log_ptr& input) const; |
|||
}; |
|||
|
|||
#endif //AdvancedFilter_H
|
@ -0,0 +1,12 @@ |
|||
#ifndef ADVANCEDFILTERDTO_H |
|||
#define ADVANCEDFILTERDTO_H |
|||
|
|||
#include <QMap> |
|||
#include <QString> |
|||
|
|||
struct AdvancedFilterDto |
|||
{ |
|||
QMap<QString, bool> _activeScopes; |
|||
}; |
|||
|
|||
#endif // ADVANCEDFILTERDTO_H
|
@ -0,0 +1,41 @@ |
|||
#include "data/filter/AdvancedFilter.h" |
|||
|
|||
/*************************************************************************************************/ |
|||
AdvancedFilter::AdvancedFilter(AdvancedFilterDto dto) |
|||
{ |
|||
initAcceptedScopes(dto._activeScopes); |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
AdvancedFilter::~AdvancedFilter() |
|||
{ |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
bool AdvancedFilter::isAccepted(Log_ptr input) const |
|||
{ |
|||
bool isPassed = true; |
|||
|
|||
isPassed &= isScopesAccepted(input); |
|||
|
|||
return isPassed; |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
void AdvancedFilter::initAcceptedScopes(const QMap<QString, bool>& acceptanceMap) |
|||
{ |
|||
QMap<QString, bool>::const_iterator i; |
|||
for(i = acceptanceMap.constBegin(); i != acceptanceMap.constEnd(); i++) |
|||
{ |
|||
if(i.value()) |
|||
{ |
|||
_acceptedScopes.append(i.key()); |
|||
} |
|||
} |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
bool AdvancedFilter::isScopesAccepted(const Log_ptr& input) const |
|||
{ |
|||
return _acceptedScopes.contains(input->scope.value_or("")); |
|||
} |
Loading…
Reference in new issue