Skip to content
Permalink
Browse files

Banlist: PR commit adjustments

* Use localeAwareCompare for string username comparison
* Code improvements
* Textual changes
  • Loading branch information...
Kissaki committed Jun 30, 2013
1 parent bf5927e commit ac65b31a2c03f8897e3127753ba32189d891cb45
Showing with 21 additions and 16 deletions.
  1. +4 −2 src/Net.cpp
  2. +1 −1 src/Net.h
  3. +7 −7 src/mumble/BanEditor.cpp
  4. +4 −1 src/mumble/BanEditor.h
  5. +5 −5 src/mumble/BanEditor.ui
@@ -166,10 +166,12 @@ bool Ban::isExpired() const {
}

bool Ban::operator <(const Ban &other) const {
if (qsUsername == other.qsUsername)
// Compare username primarily and address secondarily
const int unameDifference = qsUsername.localeAwareCompare(other.qsUsername);
if (unameDifference == 0)
return haAddress < other.haAddress;
else
return qsUsername.localeAwareCompare(other.qsUsername) < 0;
return unameDifference < 0;
}

bool Ban::operator ==(const Ban &other) const {
@@ -60,7 +60,7 @@ struct HostAddress {
bool operator < (const HostAddress &) const;
bool operator == (const HostAddress &) const;

bool match(const HostAddress &, int) const;
bool match(const HostAddress &, int bits) const;

QString toString() const;

@@ -37,7 +37,8 @@
#include "Net.h"
#include "ServerHandler.h"

BanEditor::BanEditor(const MumbleProto::BanList &msg, QWidget *p) : QDialog(p) {
BanEditor::BanEditor(const MumbleProto::BanList &msg, QWidget *p) : QDialog(p)
, maskDefaultValue(32) {
setupUi(this);
qlwBans->setFocus();

@@ -173,7 +174,7 @@ void BanEditor::on_qpbRemove_clicked() {
qleUser->clear();
qleIP->clear();
qleReason->clear();
qsbMask->setValue(32);
qsbMask->setValue(maskDefaultValue);
qleHash->clear();

qdteStart->setDateTime(QDateTime::currentDateTime());
@@ -197,10 +198,10 @@ void BanEditor::refreshBanList() {
}

int n = qlBans.count();
setWindowTitle(tr("Ban List - %n - Banned Users", "", n));
setWindowTitle(tr("Ban List - %n Ban(s)", "", n));
}

void BanEditor::on_qleSearch_textChanged(QString )
void BanEditor::on_qleSearch_textChanged(const QString & match)
{
qlwBans->clearSelection();

@@ -211,13 +212,12 @@ void BanEditor::on_qleSearch_textChanged(QString )
qleUser->clear();
qleIP->clear();
qleReason->clear();
qsbMask->setValue(32);
qsbMask->setValue(maskDefaultValue);
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);
@@ -263,7 +263,7 @@ void BanEditor::on_qpbClear_clicked()
qleUser->clear();
qleIP->clear();
qleReason->clear();
qsbMask->setValue(32);
qsbMask->setValue(maskDefaultValue);
qleHash->clear();

qdteStart->setDateTime(QDateTime::currentDateTime());
@@ -45,6 +45,9 @@ class BanEditor : public QDialog, public Ui::BanEditor {
Q_DISABLE_COPY(BanEditor)
protected:
QList<Ban> qlBans;

int maskDefaultValue;

Ban toBan(bool &);
public:
BanEditor(const MumbleProto::BanList &msbl, QWidget *p = NULL);
@@ -59,7 +62,7 @@ class BanEditor : public QDialog, public Ui::BanEditor {
void on_qpbClear_clicked();
private slots:
void on_qleHash_textChanged(QString );
void on_qleSearch_textChanged(QString );
void on_qleSearch_textChanged(const QString & match);
void on_qleReason_textChanged(QString );
void on_qleIP_textChanged(QString );
void on_qleUser_textChanged(QString );
@@ -41,7 +41,7 @@
<string>Search field</string>
</property>
<property name="whatsThis">
<string>This is search field, use it to find users by simply typing user nickname.</string>
<string>This is the search field. Use it to find bans that have this username set in the username field.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@@ -198,7 +198,7 @@
<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>
<string>Ban end date. If you set the same date for start and end, the ban will be permanent (it will not expire).</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
@@ -231,7 +231,7 @@
<string>Banned users</string>
</property>
<property name="whatsThis">
<string>This is list with banned users.</string>
<string>This is a list with banned users.</string>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
@@ -279,7 +279,7 @@
<bool>false</bool>
</property>
<property name="whatsThis">
<string>Use this button if you want to remove user from ban list.</string>
<string>Use this button if you want to remove user from the ban list.</string>
</property>
<property name="text">
<string>&amp;Remove</string>
@@ -292,7 +292,7 @@
<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>
<string>This button clears all fields. Use it if you want to add a new ban.</string>
</property>
<property name="text">
<string>Clear</string>

0 comments on commit ac65b31

Please sign in to comment.
You can’t perform that action at this time.