Implemented data filtering.
parent
d2f391558a
commit
ac931e17a9
@ -0,0 +1,64 @@
|
||||
#include "filterdialog.h"
|
||||
#include "ui_filterdialog.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QToolButton>
|
||||
|
||||
#include "context.h"
|
||||
|
||||
FilterDialog::FilterDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::FilterDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
FilterDialog::~FilterDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QString FilterDialog::pluginId() const
|
||||
{
|
||||
return m_pluginId;
|
||||
}
|
||||
|
||||
void FilterDialog::setPluginId(const QString &pluginId)
|
||||
{
|
||||
m_pluginId = pluginId;
|
||||
fillTable();
|
||||
}
|
||||
|
||||
QTableWidget *FilterDialog::table()
|
||||
{
|
||||
return ui->tableWidget;
|
||||
}
|
||||
|
||||
void FilterDialog::fillTable()
|
||||
{
|
||||
ui->tableWidget->clear();
|
||||
QMap<QString, QVariant> filters = Context::instance().settings()->value("filters/" + pluginId()).toMap();
|
||||
|
||||
int row = 0;
|
||||
ui->tableWidget->setRowCount(filters.keys().size());
|
||||
foreach (QString name, filters.keys()) {
|
||||
QTableWidgetItem *itemName = new QTableWidgetItem(name);
|
||||
ui->tableWidget->setItem(row, 0, itemName);
|
||||
QTableWidgetItem *itemFilter = new QTableWidgetItem(filters[name].toString());
|
||||
ui->tableWidget->setItem(row, 1, itemFilter);
|
||||
|
||||
QToolButton *btnRemove = new QToolButton();
|
||||
btnRemove->setText("Remove");
|
||||
ui->tableWidget->setCellWidget(row, 2, btnRemove);
|
||||
connect(btnRemove, &QToolButton::clicked, [this, btnRemove](){
|
||||
int rowToDel = ui->tableWidget->rowAt(btnRemove->y());
|
||||
ui->tableWidget->removeRow(rowToDel);
|
||||
});
|
||||
|
||||
row++;
|
||||
}
|
||||
|
||||
ui->tableWidget->setColumnWidth(1, 200);
|
||||
ui->tableWidget->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("Filter") << "");
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
#ifndef FILTERDIALOG_H
|
||||
#define FILTERDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
#include <QTableWidget>
|
||||
|
||||
namespace Ui {
|
||||
class FilterDialog;
|
||||
}
|
||||
|
||||
class FilterDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FilterDialog(QWidget *parent = 0);
|
||||
~FilterDialog();
|
||||
|
||||
QString pluginId() const;
|
||||
void setPluginId(const QString &pluginId);
|
||||
QTableWidget *table();
|
||||
|
||||
private:
|
||||
Ui::FilterDialog *ui;
|
||||
QString m_pluginId;
|
||||
|
||||
void fillTable();
|
||||
};
|
||||
|
||||
#endif // FILTERDIALOG_H
|
@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FilterDialog</class>
|
||||
<widget class="QDialog" name="FilterDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>556</width>
|
||||
<height>370</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Manage filters</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="gridStyle">
|
||||
<enum>Qt::SolidLine</enum>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
</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>FilterDialog</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>FilterDialog</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>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" ?><svg clip-rule="evenodd" fill-rule="evenodd" image-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg"><defs><style type="text/css"><![CDATA[
|
||||
.str0 {stroke:#434242;stroke-width:10}
|
||||
.fil2 {fill:#434242}
|
||||
.fil1 {fill:#FFFFFF}
|
||||
.fil0 {fill:url(#id0)}
|
||||
]]></style><linearGradient gradientUnits="userSpaceOnUse" id="id0" x1="449.998" x2="50" y1="250" y2="250"><stop offset="0" stop-color="#008BFF"/><stop offset="1" stop-color="#0af"/></linearGradient></defs><g id="Layer_x0020_1"><rect class="fil0 str0" height="420" rx="20" ry="20" width="400" x="50" y="40"/><path class="fil1 str0" d="M80 105h340c6 0 10 5 10 10v315c0 5-4 10-10 10h-340c-6 0-10-4-10-10v-315c0-5 4-10 10-10z"/><rect class="fil2" height="30" width="30" x="100" y="140"/><rect class="fil2" height="30" width="239.999" x="160" y="140"/><rect class="fil2" height="30" width="30" x="100" y="220"/><rect class="fil2" height="30" width="239.999" x="160" y="220"/><rect class="fil2" height="30" width="30" x="100" y="300"/><rect class="fil2" height="30" width="239.999" x="160" y="300"/><rect class="fil2" height="30" width="30" x="100" y="380"/><rect class="fil2" height="30" width="239.999" x="160" y="380"/></g></svg>
|
After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" ?><svg clip-rule="evenodd" fill-rule="evenodd" image-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg"><defs><style type="text/css"><![CDATA[
|
||||
.str0 {stroke:#434242;stroke-width:10}
|
||||
.fil0 {fill:url(#id0)}
|
||||
]]></style><linearGradient gradientUnits="userSpaceOnUse" id="id0" x1="457.572" x2="42.428" y1="42.428" y2="457.572"><stop offset="0" stop-color="#008BFF"/><stop offset="1" stop-color="#0af"/></linearGradient></defs><path class="fil0 str0" d="M34 240l59-59c5-5 14-5 20 0l78 79c5 5 15 5 20 0l176-177c6-5 15-5 20 0l59 59c5 5 5 14 0 20l-255 255c-6 5-14 6-20 0l-157-157c-5-6-5-14 0-20z" id="Layer_x0020_1"/></svg>
|
After Width: | Height: | Size: 752 B |
@ -0,0 +1 @@
|
||||
<?xml version="1.0" ?><svg clip-rule="evenodd" fill-rule="evenodd" image-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient gradientUnits="userSpaceOnUse" id="a" x1="249.999" x2="249.999" y1="30.694" y2="470.692"><stop offset="0" stop-color="#008BFF"/><stop offset="1" stop-color="#0af"/></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="b" x1="284.421" x2="215.575" y1="130.457" y2="70.929"><stop offset="0" stop-color="#EBECEC"/><stop offset="1" stop-color="#FEFEFE"/></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="c" x1="249.997" x2="249.997" y1="448.641" y2="272.235"><stop offset="0" stop-color="#EBECEC"/><stop offset="1" stop-color="#FEFEFE"/></linearGradient></defs><g><path d="M55 31h365l50 50v365c0 13-11 25-25 25h-390c-14 0-25-12-25-25v-390c0-14 11-25 25-25z" fill="url(#a)" stroke="#434242" stroke-linejoin="round" stroke-width="10"/><path d="M110 31h280v125c0 8-7 15-15 15h-250c-8 0-15-7-15-15v-125z" fill="url(#b)" stroke="#434242" stroke-linejoin="round" stroke-width="10"/><rect fill="url(#c)" height="221" stroke="#434242" stroke-linejoin="round" stroke-width="10" width="320" x="90" y="250"/><path d="M290 29h70v102c0 2-2 5-5 5h-60c-3 0-5-3-5-5v-102z" fill="#434242"/><line fill="none" stroke="#434242" stroke-linecap="round" stroke-width="15" x1="370" x2="130" y1="295" y2="295"/><line fill="none" stroke="#434242" stroke-linecap="round" stroke-width="15" x1="370" x2="130" y1="335" y2="335"/><line fill="none" stroke="#434242" stroke-linecap="round" stroke-width="15" x1="370" x2="130" y1="375" y2="375"/><line fill="none" stroke="#434242" stroke-linecap="round" stroke-width="15" x1="370" x2="130" y1="415" y2="415"/></g></svg>
|
After Width: | Height: | Size: 1.8 KiB |
@ -0,0 +1,18 @@
|
||||
#include "itablemodel.h"
|
||||
|
||||
ITableModel::ITableModel(QObject *parent)
|
||||
:QAbstractTableModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ITableModel::filter(const QString &filter)
|
||||
{
|
||||
handleFilter(filter);
|
||||
}
|
||||
|
||||
void ITableModel::restore()
|
||||
{
|
||||
handleRestore();
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
#ifndef ITABLEMODEL_H
|
||||
#define ITABLEMODEL_H
|
||||
|
||||
#include <QString>
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
class ITableModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ITableModel(QObject *parent = NULL);
|
||||
|
||||
protected:
|
||||
virtual void handleFilter(const QString &filter) = 0;
|
||||
virtual void handleRestore() = 0;
|
||||
|
||||
public slots:
|
||||
void filter(const QString &filter);
|
||||
void restore();
|
||||
};
|
||||
|
||||
#endif // ITABLEMODEL_H
|
@ -0,0 +1,19 @@
|
||||
#include "savefilterdialog.h"
|
||||
#include "ui_savefilterdialog.h"
|
||||
|
||||
SaveFilterDialog::SaveFilterDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::SaveFilterDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
SaveFilterDialog::~SaveFilterDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QString SaveFilterDialog::filterName()
|
||||
{
|
||||
return ui->filterName->text();
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
#ifndef SAVEFILTERDIALOG_H
|
||||
#define SAVEFILTERDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
|
||||
namespace Ui {
|
||||
class SaveFilterDialog;
|
||||
}
|
||||
|
||||
class SaveFilterDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SaveFilterDialog(QWidget *parent = 0);
|
||||
~SaveFilterDialog();
|
||||
|
||||
QString filterName();
|
||||
|
||||
private slots:
|
||||
|
||||
private:
|
||||
Ui::SaveFilterDialog *ui;
|
||||
};
|
||||
|
||||
#endif // SAVEFILTERDIALOG_H
|
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SaveFilterDialog</class>
|
||||
<widget class="QDialog" name="SaveFilterDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>395</width>
|
||||
<height>158</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Filter name</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Filter name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="filterName"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<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>SaveFilterDialog</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>SaveFilterDialog</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>
|
Loading…
Reference in New Issue