@@ -57,6 +57,18 @@ CDlgSettings::CDlgSettings(QSharedPointer<CParameterFtpServer> para, QWidget *pa
5757 }
5858 }
5959
60+ m_szFilteListPrompt = tr (" The IP address and the netmask must be separated by a slash (/)." ) + " \n\n "
61+ + tr (" ag:" ) + " \n "
62+ + " - 123.123.123.123/n " + tr (" where n is any value between 0 and 32" ) + " \n "
63+ + " - 123.123.123.123/255.255.255.255" + " \n "
64+ + " - <ipv6-address>/n " + tr (" where n is any value between 0 and 128" ) + " \n\n "
65+ + tr (" For IP version 4, accepts as well missing trailing components" ) + " \n "
66+ + tr (" (i.e., less than 4 octets, like \" 192.168.1\" ), followed or not by a dot. " ) + " \n "
67+ + tr (" If the netmask is also missing in that case," ) + " \n "
68+ + tr (" it is set to the number of octets actually passed" ) + " \n "
69+ + tr (" (in the example above, it would be 24, for 3 octets)." ) + " \n\n "
70+ + tr (" Add IP address and the netmask:" );
71+
6072 ui->lvBlacklist ->setModel (&m_ModelBlack);
6173 check = connect (ui->lvBlacklist , SIGNAL (customContextMenuRequested (const QPoint&)),
6274 this , SLOT (slotBlackListContextMenuRequested (const QPoint&)));
@@ -137,17 +149,9 @@ void CDlgSettings::slotWhiteListContextMenuRequested(const QPoint& pos)
137149 QMenu m;
138150 QItemSelectionModel* pSelect = ui->lvWhtelist ->selectionModel ();
139151 QModelIndexList lstIndex = pSelect->selectedRows ();
140- m.addAction (tr (" Add" ), [this ](){
141- QString szIp = QInputDialog::getText (this , tr (" Add whilte list" ), tr (" Add ip address:" ));
142- QStandardItem* item = new QStandardItem (szIp);
143- m_ModelWhite.appendRow (item);
144- });
152+ m.addAction (tr (" Add" ), this , SLOT (on_pbAddWhitelist_clicked ()));
145153 if (!lstIndex.isEmpty ()) {
146- m.addAction (tr (" Remove" ), [this , lstIndex]() {
147- foreach (auto idx, lstIndex) {
148- m_ModelWhite.removeRow (idx.row ());
149- }
150- });
154+ m.addAction (tr (" Remove" ), this , SLOT (on_pbDeleteWhitelist_clicked ()));
151155 }
152156
153157 QPoint p = ui->lvWhtelist ->mapToGlobal (pos);
@@ -159,19 +163,44 @@ void CDlgSettings::slotBlackListContextMenuRequested(const QPoint& pos)
159163 QMenu m;
160164 QItemSelectionModel* pSelect = ui->lvBlacklist ->selectionModel ();
161165 QModelIndexList lstIndex = pSelect->selectedRows ();
162- m.addAction (tr (" Add" ), [this ](){
163- QString szIp = QInputDialog::getText (this , tr (" Add black list" ), tr (" Add ip address:" ));
164- QStandardItem* item = new QStandardItem (szIp);
165- m_ModelBlack.appendRow (item);
166- });
166+ m.addAction (tr (" Add" ), this , SLOT (on_pbAddBlacklist_clicked ()));
167167 if (!lstIndex.isEmpty ()) {
168- m.addAction (tr (" Remove" ), [this , lstIndex]() {
169- foreach (auto idx, lstIndex) {
170- m_ModelBlack.removeRow (idx.row ());
171- }
172- });
168+ m.addAction (tr (" Remove" ), this , SLOT (on_pbDeleteBlacklist_clicked ()));
173169 }
174170
175171 QPoint p = ui->lvBlacklist ->mapToGlobal (pos);
176172 m.exec (p);
177173}
174+
175+ void CDlgSettings::on_pbAddWhitelist_clicked ()
176+ {
177+ QString szIp = QInputDialog::getText (this , tr (" Add whilte list" ), m_szFilteListPrompt);
178+ QStandardItem* item = new QStandardItem (szIp);
179+ m_ModelWhite.appendRow (item);
180+ }
181+
182+ void CDlgSettings::on_pbDeleteWhitelist_clicked ()
183+ {
184+ QItemSelectionModel* pSelect = ui->lvBlacklist ->selectionModel ();
185+ QModelIndexList lstIndex = pSelect->selectedRows ();
186+ foreach (auto idx, lstIndex) {
187+ m_ModelWhite.removeRow (idx.row ());
188+ }
189+ }
190+
191+ void CDlgSettings::on_pbAddBlacklist_clicked ()
192+ {
193+ QString szIp = QInputDialog::getText (this , tr (" Add black list" ), m_szFilteListPrompt);
194+ QStandardItem* item = new QStandardItem (szIp);
195+ m_ModelBlack.appendRow (item);
196+ }
197+
198+ void CDlgSettings::on_pbDeleteBlacklist_clicked ()
199+ {
200+ QItemSelectionModel* pSelect = ui->lvBlacklist ->selectionModel ();
201+ if (!pSelect) return ;
202+ QModelIndexList lstIndex = pSelect->selectedRows ();
203+ foreach (auto idx, lstIndex) {
204+ m_ModelBlack.removeRow (idx.row ());
205+ }
206+ }
0 commit comments