mirror of
https://github.com/tnodir/fort
synced 2024-11-15 06:06:30 +00:00
UI: Options: IP Addresses: Show Zones count
This commit is contained in:
parent
ae63c79a31
commit
cd8f152b92
@ -15,7 +15,7 @@ static int fort_memcmp(const void *p1, const void *p2, size_t len)
|
||||
}
|
||||
#endif
|
||||
|
||||
FORT_API int bit_scan_forward(unsigned long mask)
|
||||
FORT_API int bit_scan_forward(ULONG mask)
|
||||
{
|
||||
unsigned long index;
|
||||
return _BitScanForward(&index, mask) ? index : -1;
|
||||
|
@ -241,7 +241,7 @@ typedef BOOL fort_conf_zones_ip_included_func(
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
FORT_API int bit_scan_forward(unsigned long mask);
|
||||
FORT_API int bit_scan_forward(ULONG mask);
|
||||
|
||||
FORT_API BOOL is_time_in_period(FORT_TIME time, FORT_PERIOD period);
|
||||
|
||||
|
@ -7,6 +7,9 @@ TableView::TableView(QWidget *parent) : QTableView(parent) { }
|
||||
|
||||
void TableView::setModel(QAbstractItemModel *model)
|
||||
{
|
||||
setWordWrap(false);
|
||||
setTextElideMode(Qt::ElideMiddle);
|
||||
|
||||
QTableView::setModel(model);
|
||||
|
||||
connect(model, &QAbstractItemModel::modelReset, this,
|
||||
|
@ -17,14 +17,29 @@ AddressesColumn::AddressesColumn(QWidget *parent) : QWidget(parent)
|
||||
setupUi();
|
||||
}
|
||||
|
||||
void AddressesColumn::setZonesCount(qint8 v)
|
||||
{
|
||||
if (m_zonesCount == v)
|
||||
return;
|
||||
|
||||
m_zonesCount = v;
|
||||
|
||||
retranslateZonesText();
|
||||
}
|
||||
|
||||
void AddressesColumn::retranslateUi()
|
||||
{
|
||||
m_btOpenZones->setToolTip(tr("Show Zones"));
|
||||
|
||||
m_btSelectZones->setText(tr("Zones"));
|
||||
retranslateZonesText();
|
||||
m_btSelectZones->setToolTip(tr("Select Zones"));
|
||||
}
|
||||
|
||||
void AddressesColumn::retranslateZonesText()
|
||||
{
|
||||
m_btSelectZones->setText(tr("Zones") + QString(" (%1)").arg(zonesCount()));
|
||||
}
|
||||
|
||||
void AddressesColumn::setupUi()
|
||||
{
|
||||
auto layout = new QVBoxLayout();
|
||||
@ -63,19 +78,13 @@ QLayout *AddressesColumn::setupZonesRow()
|
||||
// Open Zones
|
||||
m_btOpenZones = ControlUtil::createFlatToolButton(
|
||||
":/icons/application_go.png", [&] { IoC<WindowManager>()->showZonesWindow(); });
|
||||
layout->addWidget(m_btOpenZones);
|
||||
|
||||
// Select Zones
|
||||
m_btSelectZones = ControlUtil::createButton(":/icons/ip_class.png");
|
||||
|
||||
layout->addWidget(m_btOpenZones);
|
||||
layout->addWidget(m_btSelectZones);
|
||||
|
||||
m_labelZones = ControlUtil::createLabel();
|
||||
m_labelZones->setWordWrap(true);
|
||||
|
||||
auto font = ControlUtil::fontDemiBold();
|
||||
m_labelZones->setFont(font);
|
||||
|
||||
layout->addWidget(m_labelZones, 1);
|
||||
layout->addStretch();
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
@ -16,25 +16,30 @@ class AddressesColumn : public QWidget
|
||||
public:
|
||||
explicit AddressesColumn(QWidget *parent = nullptr);
|
||||
|
||||
qint8 zonesCount() const { return m_zonesCount; }
|
||||
void setZonesCount(qint8 v);
|
||||
|
||||
QLabel *labelTitle() const { return m_labelTitle; }
|
||||
QCheckBox *cbUseAll() const { return m_cbUseAll; }
|
||||
QPushButton *btSelectZones() const { return m_btSelectZones; }
|
||||
QLabel *labelZones() const { return m_labelZones; }
|
||||
PlainTextEdit *editIpText() const { return m_editIpText; }
|
||||
|
||||
public slots:
|
||||
void retranslateUi();
|
||||
|
||||
private:
|
||||
void retranslateZonesText();
|
||||
|
||||
void setupUi();
|
||||
QLayout *setupZonesRow();
|
||||
|
||||
private:
|
||||
qint8 m_zonesCount = 0;
|
||||
|
||||
QLabel *m_labelTitle = nullptr;
|
||||
QCheckBox *m_cbUseAll = nullptr;
|
||||
QToolButton *m_btOpenZones = nullptr;
|
||||
QPushButton *m_btSelectZones = nullptr;
|
||||
QLabel *m_labelZones = nullptr;
|
||||
PlainTextEdit *m_editIpText = nullptr;
|
||||
};
|
||||
|
||||
|
@ -318,17 +318,15 @@ void AddressesPage::updateZonesMenuEnabled()
|
||||
|
||||
void AddressesPage::updateZonesText(bool include)
|
||||
{
|
||||
if (include) {
|
||||
m_includeAddresses->labelZones()->setText(zonesText(true));
|
||||
} else {
|
||||
m_excludeAddresses->labelZones()->setText(zonesText(false));
|
||||
}
|
||||
AddressesColumn *addressesColumn = include ? m_includeAddresses : m_excludeAddresses;
|
||||
|
||||
addressesColumn->setZonesCount(zonesCount(include));
|
||||
}
|
||||
|
||||
void AddressesPage::updateZonesTextAll()
|
||||
{
|
||||
updateZonesText(true);
|
||||
updateZonesText(false);
|
||||
updateZonesText(/*include=*/true);
|
||||
updateZonesText(/*include=*/false);
|
||||
}
|
||||
|
||||
void AddressesPage::setupZones()
|
||||
@ -376,22 +374,11 @@ quint32 AddressesPage::addressGroupZones(bool include) const
|
||||
return include ? addressGroup()->includeZones() : addressGroup()->excludeZones();
|
||||
}
|
||||
|
||||
QString AddressesPage::zonesText(bool include) const
|
||||
qint8 AddressesPage::zonesCount(bool include) const
|
||||
{
|
||||
QStringList list;
|
||||
const quint32 zonesMask = addressGroupZones(include);
|
||||
|
||||
quint32 zonesMask = addressGroupZones(include);
|
||||
while (zonesMask != 0) {
|
||||
const int zoneIndex = DriverCommon::bitScanForward(zonesMask);
|
||||
const int zoneId = zoneIndex + 1;
|
||||
const auto zoneName = zoneListModel()->zoneNameById(zoneId);
|
||||
|
||||
list.append(zoneName);
|
||||
|
||||
zonesMask ^= (quint32(1) << zoneIndex);
|
||||
}
|
||||
|
||||
return list.join(", ");
|
||||
return __popcnt(zonesMask);
|
||||
}
|
||||
|
||||
QString AddressesPage::localNetworks()
|
||||
|
@ -52,7 +52,7 @@ private:
|
||||
|
||||
quint32 addressGroupZones(bool include) const;
|
||||
|
||||
QString zonesText(bool include) const;
|
||||
qint8 zonesCount(bool include) const;
|
||||
|
||||
static QString localNetworks();
|
||||
|
||||
|
@ -265,8 +265,6 @@ void ProgramsWindow::setupTableApps()
|
||||
m_appListView->setAlternatingRowColors(true);
|
||||
m_appListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_appListView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||
m_appListView->setWordWrap(false);
|
||||
m_appListView->setTextElideMode(Qt::ElideMiddle);
|
||||
|
||||
m_appListView->setSortingEnabled(true);
|
||||
m_appListView->setModel(appListModel());
|
||||
|
Loading…
Reference in New Issue
Block a user