Skip to content
Permalink
Browse files

Merge PR #3580: ConnectDialog: create "Unknown" continent, never expa…

…nd it automatically
  • Loading branch information...
davidebeatrici committed Jan 17, 2019
2 parents 8c14906 + f041737 commit 66f5ae918c0bf9e53fa4bc413b9c8c816be43270
Showing with 35 additions and 17 deletions.
  1. +22 −14 src/mumble/ConnectDialog.cpp
  2. +13 −3 src/mumble/mumble_en.ts
@@ -89,10 +89,12 @@ ServerView::ServerView(QWidget *p) : QTreeWidget(p) {
siPublic = new ServerItem(tr("Public Internet"), ServerItem::PublicType);
siPublic->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
addTopLevelItem(siPublic);



siPublic->setExpanded(false);


// The continent code is empty when the server's IP address is not in the GeoIP database
qmContinentNames.insert(QLatin1String(""), tr("Unknown"));

qmContinentNames.insert(QLatin1String("af"), tr("Africa"));
qmContinentNames.insert(QLatin1String("as"), tr("Asia"));
qmContinentNames.insert(QLatin1String("na"), tr("North America"));
@@ -101,7 +103,7 @@ ServerView::ServerView(QWidget *p) : QTreeWidget(p) {
qmContinentNames.insert(QLatin1String("oc"), tr("Oceania"));
} else {
qWarning()<< "Public list disabled";

siPublic = NULL;
}
}
@@ -182,34 +184,40 @@ bool ServerView::dropMimeData(QTreeWidgetItem *, int, const QMimeData *mime, Qt:

ServerItem *ServerView::getParent(const QString &continentcode, const QString &countrycode, const QString &countryname, const QString &usercontinent, const QString &usercountry) {
ServerItem *continent = qmContinent.value(continentcode);
if (! continent) {
if (!continent) {
QString name = qmContinentNames.value(continentcode);
if (name.isEmpty())
name = continentcode;
continent = new ServerItem(name, ServerItem::PublicType, continentcode);
qmContinent.insert(continentcode, continent);
siPublic->addServerItem(continent);

if (continentcode == usercontinent) {
continent->setExpanded(true);
scrollToItem(continent, QAbstractItemView::PositionAtTop);
if (!continentcode.isEmpty()) {
if (continentcode == usercontinent) {
continent->setExpanded(true);
scrollToItem(continent, QAbstractItemView::PositionAtTop);
}
} else {
continent->setExpanded(false);
continent->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
}
}

// If the continent code is empty, we put the server directly into the "Unknown" continent
if (continentcode.isEmpty()) {
return continent;
}

ServerItem *country = qmCountry.value(countrycode);
if (! country) {
if (!country) {
country = new ServerItem(countryname, ServerItem::PublicType, continentcode, countrycode);
qmCountry.insert(countrycode, country);
country->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);

continent->addServerItem(country);

if (countrycode == usercountry) {
if (!countrycode.isEmpty() && countrycode == usercountry) {
country->setExpanded(true);
scrollToItem(country, QAbstractItemView::PositionAtTop);
} else {
country->setExpanded(false);
}
}
return country;
@@ -1770,7 +1778,7 @@ void ConnectDialog::fetched(QByteArray xmlData, QUrl, QMap<QString, QString> hea
pi.quUrl = e.attribute(QLatin1String("url"));
pi.qsIp = e.attribute(QLatin1String("ip"));
pi.usPort = e.attribute(QLatin1String("port")).toUShort();
pi.qsCountry = e.attribute(QLatin1String("country"));
pi.qsCountry = e.attribute(QLatin1String("country"), tr("Unknown"));
pi.qsCountryCode = e.attribute(QLatin1String("country_code")).toLower();
pi.qsContinentCode = e.attribute(QLatin1String("continent_code")).toLower();
pi.bCA = e.attribute(QLatin1String("ca")).toInt() ? true : false;
@@ -3100,7 +3100,7 @@ Are you sure you wish to replace your certificate?
<context>
<name>ConnectDialog</name>
<message>
<location filename="ConnectDialog.cpp" line="+1134"/>
<location filename="ConnectDialog.cpp" line="+1142"/>
<source>Connecting to %1</source>
<translation type="unfinished"></translation>
</message>
@@ -3187,9 +3187,14 @@ Are you sure you wish to replace your certificate?
<source>&amp;Filters</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+740"/>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ConnectDialog.ui"/>
<location filename="ConnectDialog.cpp" line="-505"/>
<location filename="ConnectDialog.cpp" line="-1245"/>
<source>Users</source>
<translation type="unfinished"></translation>
</message>
@@ -8048,7 +8053,7 @@ To upgrade these files to their latest versions, click the button below.</source
<context>
<name>ServerView</name>
<message>
<location filename="ConnectDialog.cpp" line="-753"/>
<location filename="ConnectDialog.cpp" line="-761"/>
<source>Favorite</source>
<translation type="unfinished"></translation>
</message>
@@ -8064,6 +8069,11 @@ To upgrade these files to their latest versions, click the button below.</source
</message>
<message>
<location line="+7"/>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+2"/>
<source>Africa</source>
<translation type="unfinished"></translation>
</message>

0 comments on commit 66f5ae9

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