Commit afdf3891 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Remove dependency on kdelibs4support

It was use for two things:
 * Getting the name of a country from the country code
 * Getting the flag of a country from the country code

The second part wasn't working since the country code is in capital
letters and the flags kdelibs4support installs are in lowercase, so I
have just removed it, given the use is super minor and there's no bug
about it

The first part i've just used the new KCountry class
parent a8d2ff6c
Pipeline #130186 passed with stage
in 2 minutes and 52 seconds
......@@ -58,7 +58,6 @@ find_package(KF5 ${KF5_VERSION} REQUIRED
WidgetsAddons
WindowSystem
XmlGui
KDELibs4Support # KLocale
)
#include(CheckIncludeFile)
......@@ -240,6 +239,7 @@ target_link_libraries(kgetcore
KF5::CoreAddons
KF5::DBusAddons
KF5::I18n
KF5::I18nLocaleData
KF5::IconThemes
KF5::KIOCore
KF5::KIOWidgets
......@@ -373,7 +373,6 @@ target_link_libraries(kget
KF5::KCMUtils
KF5::NotifyConfig
KF5::WindowSystem
KF5::KDELibs4Support
Qt::Core
Qt::Widgets
Qt::Sql
......
......@@ -42,7 +42,8 @@ namespace kt
void TorrentFileModel::missingFilesMarkedDND()
{
reset();
beginResetModel();
endResetModel();
}
void TorrentFileModel::update()
......@@ -50,7 +51,8 @@ namespace kt
void TorrentFileModel::onCodecChange()
{
reset();
beginResetModel();
endResetModel();
}
Qt::ItemFlags TorrentFileModel::flags(const QModelIndex & index) const
......
......@@ -20,7 +20,7 @@
#include "localemodels.h"
#include <KLanguageName>
#include <KLocale>
#include <KCountry>
#include <QLocale>
#include <QStandardPaths>
......@@ -42,10 +42,6 @@ QVariant CountryModel::data(const QModelIndex &index, int role) const
{
return m_countryNames.value(index.row());
}
else if (role == Qt::DecorationRole)
{
return m_countryIcons.value(index.row());
}
else if (role == Qt::UserRole)
{
return m_countryCodes.value(index.row());
......@@ -81,22 +77,12 @@ void CountryModel::setupModelData()
countryCode = localeName.mid(idx + 1);
}
}
const QString countryName = KLocale::global()->countryCodeToName(countryCode);
const QString countryName = KCountry::fromAlpha2(countryCode).name();
if (!countryName.isEmpty())
{
m_countryCodes.append(countryCode);
m_countryNames.append(countryName);
QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("locale/") + QString::fromLatin1("l10n/%1/flag.png").arg(countryCode));
if (path.isEmpty())
{
m_countryIcons.append(QIcon());
}
else
{
m_countryIcons.append(QIcon::fromTheme(path));
}
}
}
endResetModel();
......
......@@ -47,7 +47,6 @@ class CountryModel : public QAbstractListModel
private:
QStringList m_countryCodes;
QStringList m_countryNames;
QList<QIcon> m_countryIcons;
};
/**
......
......@@ -23,10 +23,9 @@
#include <QSpinBox>
#include <QStandardPaths>
#include <KCountry>
#include <KLineEdit>
#include <KLocalizedString>
#include <KLocale>
MirrorDelegate::MirrorDelegate(QObject *parent)
: QStyledItemDelegate(parent),
......@@ -243,10 +242,6 @@ QVariant MirrorItem::data(int column, int role) const
{
return m_countryName;
}
else if (role == Qt::DecorationRole)
{
return m_countryFlag;
}
else if ((role == Qt::UserRole) || (role == Qt::EditRole))
{
return m_countryCode;
......@@ -321,24 +316,7 @@ bool MirrorItem::setData(int column, const QVariant &value, int role)
else if ((column == MirrorItem::Country) && (role == Qt::EditRole))
{
m_countryCode = value.toString();
m_countryName = KLocale::global()->countryCodeToName(m_countryCode);
if (!m_countryName.isEmpty())
{
QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("locale/") + QString::fromLatin1("l10n/%1/flag.png").arg(m_countryCode));
if (path.isEmpty())
{
m_countryFlag = QIcon();
}
else
{
m_countryFlag = QIcon::fromTheme(path);
}
}
else
{
m_countryFlag = QIcon();
}
m_countryName = KCountry::fromAlpha2(m_countryCode).name();
return true;
}
......
......@@ -82,7 +82,6 @@ class MirrorItem
int m_priority;
QString m_countryCode;
QString m_countryName;
QIcon m_countryFlag;
};
class MirrorModel : public QAbstractTableModel
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment