2#include <QItemSelectionModel>
4#include "ParameterFilterUI.h"
5#include "ui_ParameterFilterUI.h"
7CParameterFilterUI::CParameterFilterUI(QWidget *parent)
13 ui->lsFilter->setModel(&m_Model);
15 m_szFilteListPrompt = tr(
"The IP address and the netmask must be separated by a slash (/).") +
"\n\n"
17 +
"- 123.123.123.123/n " + tr(
"where n is any value between 0 and 32") +
"\n"
18 +
"- 123.123.123.123/255.255.255.255" +
"\n"
19 +
"- <ipv6-address>/n " + tr(
"where n is any value between 0 and 128") +
"\n\n"
20 + tr(
"For IP version 4, accepts as well missing trailing components") +
"\n"
21 + tr(
"(i.e., less than 4 octets, like \"192.168.1\"), followed or not by a dot. ") +
"\n"
22 + tr(
"If the netmask is also missing in that case,") +
"\n"
23 + tr(
"it is set to the number of octets actually passed") +
"\n"
24 + tr(
"(in the example above, it would be 24, for 3 octets).") +
"\n\n"
25 + tr(
"Add IP address and the netmask:");
27 bool check = connect(ui->lsFilter, SIGNAL(customContextMenuRequested(
const QPoint&)),
28 this, SLOT(slotContextMenuRequested(
const QPoint&)));
32CParameterFilterUI::~CParameterFilterUI()
40 m_pPara = qobject_cast<CParameterFilter*>(pParameter);
41 if(!m_pPara)
return -1;
42 m_pPara->OnProcess([&](
const QString & key)->
int {
43 m_Model.appendRow(
new QStandardItem(key));
52 if(!m_pPara)
return -1;
56 for (
int i = 0; i < m_Model.rowCount(); ++i) {
57 m_pPara->AddKey(m_Model.item(i)->text());
63void CParameterFilterUI::slotContextMenuRequested(
const QPoint &pos)
66 QItemSelectionModel* pSelect = ui->lsFilter->selectionModel();
67 QModelIndexList lstIndex = pSelect->selectedRows();
68 m.addAction(tr(
"Add"),
this, SLOT(on_pbAdd_clicked()));
69 if(!lstIndex.isEmpty()) {
70 m.addAction(tr(
"Delete"),
this, SLOT(on_pbDelete_clicked()));
73 QPoint p = ui->lsFilter->mapToGlobal(pos);
77void CParameterFilterUI::on_pbAdd_clicked()
79 QString szIp = QInputDialog::getText(
this, tr(
"Add"), m_szFilteListPrompt);
80 QStandardItem* item =
new QStandardItem(szIp);
81 m_Model.appendRow(item);
84void CParameterFilterUI::on_pbDelete_clicked()
86 QItemSelectionModel* pSelect = ui->lsFilter->selectionModel();
88 QModelIndexList lstIndex = pSelect->selectedRows();
89 foreach(
auto idx, lstIndex) {
90 m_Model.removeRow(idx.row());
virtual int SetParameter(CParameter *pParameter) override
[override functions]
virtual int Accept() override
Accept parameters.
The parameter UI interface.