Browse files

BanList improvements

  • Loading branch information...
1 parent cd23aee commit bf5927ee8d9cab50e0fec8e7f3747626fb71de4b @Zuko Zuko committed with Kissaki Mar 29, 2011
Showing with 401 additions and 190 deletions.
  1. +4 −1 src/Net.cpp
  2. +107 −13 src/mumble/BanEditor.cpp
  3. +8 −1 src/mumble/BanEditor.h
  4. +282 −175 src/mumble/BanEditor.ui
View
5 src/Net.cpp
@@ -166,7 +166,10 @@ bool Ban::isExpired() const {
}
bool Ban::operator <(const Ban &other) const {
- return haAddress < other.haAddress;
+ if (qsUsername == other.qsUsername)
+ return haAddress < other.haAddress;
+ else
+ return qsUsername.localeAwareCompare(other.qsUsername) < 0;
}
bool Ban::operator ==(const Ban &other) const {
View
120 src/mumble/BanEditor.cpp
@@ -39,6 +39,7 @@
BanEditor::BanEditor(const MumbleProto::BanList &msg, QWidget *p) : QDialog(p) {
setupUi(this);
+ qlwBans->setFocus();
qlBans.clear();
for (int i=0;i < msg.bans_size(); ++i) {
@@ -83,6 +84,11 @@ void BanEditor::on_qlwBans_currentRowChanged() {
int idx = qlwBans->currentRow();
if (idx < 0)
return;
+
+ qpbAdd->setDisabled(true);
+ qpbUpdate->setEnabled(false);
+ qpbRemove->setEnabled(true);
+
const Ban &ban = qlBans.at(idx);
int maskbits = ban.iMask;
@@ -92,8 +98,8 @@ void BanEditor::on_qlwBans_currentRowChanged() {
if (! ban.haAddress.isV6())
maskbits -= 96;
qsbMask->setValue(maskbits);
- qlUser->setText(ban.qsUsername);
- qlHash->setText(ban.qsHash);
+ qleUser->setText(ban.qsUsername);
+ qleHash->setText(ban.qsHash);
qleReason->setText(ban.qsReason);
qdteStart->setDateTime(ban.qdtStart.toLocalTime());
qdteEnd->setDateTime(ban.qdtStart.toLocalTime().addSecs(ban.iDuration));
@@ -112,8 +118,8 @@ Ban BanEditor::toBan(bool &ok) {
b.iMask = qsbMask->value();
if (! b.haAddress.isV6())
b.iMask += 96;
- b.qsUsername = qlUser->text();
- b.qsHash = qlHash->text();
+ b.qsUsername = qleUser->text();
+ b.qsHash = qleHash->text();
b.qsReason = qleReason->text();
b.qdtStart = qdteStart->dateTime().toUTC();
const QDateTime &qdte = qdteEnd->dateTime();
@@ -128,21 +134,20 @@ Ban BanEditor::toBan(bool &ok) {
}
void BanEditor::on_qpbAdd_clicked() {
- QHostAddress addr;
-
bool ok;
qdteStart->setDateTime(QDateTime::currentDateTime());
Ban b = toBan(ok);
if (ok) {
- b.qsHash = QString();
- b.qsUsername = QString();
qlBans << b;
refreshBanList();
qlwBans->setCurrentRow(qlBans.indexOf(b));
}
+
+ qlwBans->setCurrentRow(-1);
+ qleSearch->clear();
}
void BanEditor::on_qpbUpdate_clicked() {
@@ -163,6 +168,19 @@ void BanEditor::on_qpbRemove_clicked() {
if (idx >= 0)
qlBans.removeAt(idx);
refreshBanList();
+
+ qlwBans->setCurrentRow(-1);
+ qleUser->clear();
+ qleIP->clear();
+ qleReason->clear();
+ qsbMask->setValue(32);
+ qleHash->clear();
+
+ qdteStart->setDateTime(QDateTime::currentDateTime());
+ qdteEnd->setDateTime(QDateTime::currentDateTime());
+
+ qpbRemove->setDisabled(true);
+ qpbAdd->setDisabled(true);
}
void BanEditor::refreshBanList() {
@@ -171,11 +189,87 @@ void BanEditor::refreshBanList() {
qSort(qlBans);
foreach(const Ban &ban, qlBans) {
- int maskbits = ban.iMask;
const QHostAddress &addr=ban.haAddress.toAddress();
- if (! ban.haAddress.isV6())
- maskbits -= 96;
- QString qs = QString::fromLatin1("%1/%2").arg(addr.toString()).arg(maskbits);
- qlwBans->addItem(qs);
+ if (ban.qsUsername.isEmpty())
+ qlwBans->addItem(addr.toString());
+ else
+ qlwBans->addItem(ban.qsUsername);
}
+
+ int n = qlBans.count();
+ setWindowTitle(tr("Ban List - %n - Banned Users", "", n));
+}
+
+void BanEditor::on_qleSearch_textChanged(QString )
+{
+ qlwBans->clearSelection();
+
+ qpbAdd->setDisabled(true);
+ qpbUpdate->setDisabled(true);
+ qpbRemove->setDisabled(true);
+
+ qleUser->clear();
+ qleIP->clear();
+ qleReason->clear();
+ qsbMask->setValue(32);
+ qleHash->clear();
+
+ qdteStart->setDateTime(QDateTime::currentDateTime());
+ qdteEnd->setDateTime(QDateTime::currentDateTime());
+
+ const QString &match = qleSearch->text();
+ foreach(QListWidgetItem *item, qlwBans->findItems(QString(), Qt::MatchContains)) {
+ if (!item->text().contains(match))
+ item->setHidden(true);
+ else
+ item->setHidden(false);
+ }
+}
+
+void BanEditor::on_qleIP_textChanged(QString )
+{
+ qpbAdd->setEnabled(qleIP->isModified());
+ if (qlwBans->currentRow() >= 0)
+ qpbUpdate->setEnabled(qleIP->isModified());
+}
+
+void BanEditor::on_qleReason_textChanged(QString )
+{
+ if (qlwBans->currentRow() >= 0)
+ qpbUpdate->setEnabled(qleReason->isModified());
+}
+
+void BanEditor::on_qdteEnd_editingFinished()
+{
+ qpbUpdate->setEnabled(!qleIP->text().isEmpty());
+ qpbRemove->setDisabled(true);
+}
+
+void BanEditor::on_qleUser_textChanged(QString )
+{
+ if (qlwBans->currentRow() >= 0)
+ qpbUpdate->setEnabled(qleUser->isModified());
+}
+
+void BanEditor::on_qleHash_textChanged(QString )
+{
+ if (qlwBans->currentRow() >= 0)
+ qpbUpdate->setEnabled(qleHash->isModified());
+}
+
+void BanEditor::on_qpbClear_clicked()
+{
+ qlwBans->setCurrentRow(-1);
+ qleUser->clear();
+ qleIP->clear();
+ qleReason->clear();
+ qsbMask->setValue(32);
+ qleHash->clear();
+
+ qdteStart->setDateTime(QDateTime::currentDateTime());
+ qdteEnd->setDateTime(QDateTime::currentDateTime());
+
+ qpbAdd->setDisabled(true);
+ qpbUpdate->setDisabled(true);
+ qpbRemove->setDisabled(true);
}
View
9 src/mumble/BanEditor.h
@@ -50,12 +50,19 @@ class BanEditor : public QDialog, public Ui::BanEditor {
BanEditor(const MumbleProto::BanList &msbl, QWidget *p = NULL);
public slots:
void accept();
- public slots:
void on_qlwBans_currentRowChanged();
void on_qpbAdd_clicked();
void on_qpbUpdate_clicked();
void on_qpbRemove_clicked();
void refreshBanList();
+ void on_qdteEnd_editingFinished();
+ void on_qpbClear_clicked();
+ private slots:
+ void on_qleHash_textChanged(QString );
+ void on_qleSearch_textChanged(QString );
+ void on_qleReason_textChanged(QString );
+ void on_qleIP_textChanged(QString );
+ void on_qleUser_textChanged(QString );
};
#endif
View
457 src/mumble/BanEditor.ui
@@ -6,186 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
- <width>458</width>
- <height>547</height>
+ <width>454</width>
+ <height>470</height>
</rect>
</property>
<property name="windowTitle">
<string>Mumble - Edit Bans</string>
</property>
- <layout class="QVBoxLayout">
- <item>
- <layout class="QHBoxLayout">
- <item>
- <widget class="QListWidget" name="qlwBans"/>
- </item>
- <item>
- <layout class="QVBoxLayout">
- <item>
- <layout class="QGridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="qlIP">
- <property name="text">
- <string>&amp;Address</string>
- </property>
- <property name="buddy">
- <cstring>qleIP</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="qlMask">
- <property name="text">
- <string>&amp;Mask</string>
- </property>
- <property name="buddy">
- <cstring>qsbMask</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="qleIP">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QSpinBox" name="qsbMask">
- <property name="minimum">
- <number>8</number>
- </property>
- <property name="maximum">
- <number>128</number>
- </property>
- <property name="value">
- <number>128</number>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLineEdit" name="qleReason"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="qlReason">
- <property name="text">
- <string>Reason</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QDateTimeEdit" name="qdteStart">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="readOnly">
- <bool>false</bool>
- </property>
- <property name="calendarPopup">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="qlStart">
- <property name="text">
- <string>Start</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="qlEnd">
- <property name="text">
- <string>End</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QDateTimeEdit" name="qdteEnd">
- <property name="calendarPopup">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="qliUser">
- <property name="text">
- <string>User</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QLabel" name="qlUser">
- <property name="maximumSize">
- <size>
- <width>500</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="6" column="0">
- <widget class="QLabel" name="qliHash">
- <property name="text">
- <string>Hash</string>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <widget class="QLabel" name="qlHash">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout">
- <item>
- <widget class="QPushButton" name="qpbAdd">
- <property name="text">
- <string>&amp;Add</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="qpbUpdate">
- <property name="text">
- <string>&amp;Update</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="qpbRemove">
- <property name="text">
- <string>&amp;Remove</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- <item>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="1" column="0">
<widget class="QDialogButtonBox" name="qbbButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -195,6 +24,284 @@
</property>
</widget>
</item>
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="qgbBanList">
+ <property name="title">
+ <string>Ban List</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="1" column="0" colspan="7">
+ <widget class="QLineEdit" name="qleSearch">
+ <property name="font">
+ <font>
+ <italic>false</italic>
+ </font>
+ </property>
+ <property name="toolTip">
+ <string>Search field</string>
+ </property>
+ <property name="whatsThis">
+ <string>This is search field, use it to find users by simply typing user nickname.</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="placeholderText">
+ <string>Who are you looking for?</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="qlUser">
+ <property name="text">
+ <string>User</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" colspan="5">
+ <widget class="QLineEdit" name="qleUser">
+ <property name="font">
+ <font>
+ <italic>false</italic>
+ </font>
+ </property>
+ <property name="placeholderText">
+ <string>No nickname</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="qlIP">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Address</string>
+ </property>
+ <property name="buddy">
+ <cstring>qleIP</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" colspan="3">
+ <widget class="QLineEdit" name="qleIP">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <italic>false</italic>
+ </font>
+ </property>
+ <property name="toolTip">
+ <string>IP address</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="placeholderText">
+ <string>No IP address</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="4">
+ <widget class="QLabel" name="qlMask">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Mask</string>
+ </property>
+ <property name="buddy">
+ <cstring>qsbMask</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="5">
+ <widget class="QSpinBox" name="qsbMask">
+ <property name="minimum">
+ <number>8</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ <property name="value">
+ <number>128</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="qlReason">
+ <property name="text">
+ <string>Reason</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1" colspan="5">
+ <widget class="QLineEdit" name="qleReason">
+ <property name="toolTip">
+ <string>Reason for the ban</string>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::RightToLeft</enum>
+ </property>
+ <property name="placeholderText">
+ <string>No reason</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="qlStart">
+ <property name="text">
+ <string>Start</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QDateTimeEdit" name="qdteStart">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="readOnly">
+ <bool>false</bool>
+ </property>
+ <property name="calendarPopup">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="2">
+ <widget class="QLabel" name="qlEnd">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>End</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="3" colspan="3">
+ <widget class="QDateTimeEdit" name="qdteEnd">
+ <property name="toolTip">
+ <string>Ban end date</string>
+ </property>
+ <property name="whatsThis">
+ <string>Ban end date. If you set the same date for start and end, ban will be permanent.</string>
+ </property>
+ <property name="calendarPopup">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="qliHash">
+ <property name="text">
+ <string>Hash</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1" colspan="5">
+ <widget class="QLineEdit" name="qleHash">
+ <property name="toolTip">
+ <string>Certificate hash</string>
+ </property>
+ <property name="inputMethodHints">
+ <set>Qt::ImhLowercaseOnly|Qt::ImhNoAutoUppercase</set>
+ </property>
+ <property name="placeholderText">
+ <string>No certificate hash</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="7">
+ <widget class="QListWidget" name="qlwBans">
+ <property name="toolTip">
+ <string>Banned users</string>
+ </property>
+ <property name="whatsThis">
+ <string>This is list with banned users.</string>
+ </property>
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="sortingEnabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="6">
+ <widget class="QPushButton" name="qpbAdd">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string/>
+ </property>
+ <property name="whatsThis">
+ <string>Use this button if you want to add a new ban.</string>
+ </property>
+ <property name="text">
+ <string>&amp;Add</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="6">
+ <widget class="QPushButton" name="qpbUpdate">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string/>
+ </property>
+ <property name="whatsThis">
+ <string>Use this button if you want to update ban information.</string>
+ </property>
+ <property name="text">
+ <string>&amp;Update</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="6">
+ <widget class="QPushButton" name="qpbRemove">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="whatsThis">
+ <string>Use this button if you want to remove user from ban list.</string>
+ </property>
+ <property name="text">
+ <string>&amp;Remove</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="6">
+ <widget class="QPushButton" name="qpbClear">
+ <property name="toolTip">
+ <string>Clear all fields</string>
+ </property>
+ <property name="whatsThis">
+ <string>This button clears all fields, use it if you want to add new ban.</string>
+ </property>
+ <property name="text">
+ <string>Clear</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>

0 comments on commit bf5927e

Please sign in to comment.