Commit e5611747 authored by Simon Persson's avatar Simon Persson
Browse files

Port from KLocale to QLocale

Also update header includes to include KLocalizedString instead.
Since most code was only using KGlobal to get the KLocale object pointer now was also a good time to remove includes of KGlobal. That meant porting KGlobal::charsets() to KCharset::charsets()  in a few places.
parent d06a9340
......@@ -38,9 +38,9 @@
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KComponentData>
#include <KDE/KLocale>
#include <kde_file.h>
#include <KI18n/KLocalizedString>
#include <KIOCore/KFileItem>
#include <KWidgetsAddons/KMessageBox>
#include <KIO/Job>
......
......@@ -18,9 +18,7 @@
#include "actionman.h"
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KI18n/KLocalizedString>
#include <KWidgetsAddons/KMessageBox>
#include "useractionpage.h"
......
......@@ -30,9 +30,9 @@
#include <QtWidgets/QRadioButton>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KDE/KInputDialog>
#include <KI18n/KLocalizedString>
#include <KXmlGui/KActionCollection>
#include <KXmlGui/KKeySequenceWidget>
#include <KCompletion/KComboBox>
......
......@@ -36,9 +36,10 @@
#include <QtWidgets/QFrame>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KDE/KNumInput>
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
#include <KWidgetsAddons/KMessageBox>
#include <KCompletion/KLineEdit>
#include <KCompletion/KComboBox>
......
......@@ -21,9 +21,7 @@
#include <QtCore/QDebug>
#include <QtXml/QDomEntity>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#include "../krglobal.h"
......
......@@ -28,9 +28,7 @@
#include <QtGui/QClipboard>
#include <QtXml/QDomDocumentType>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KI18n/KLocalizedString>
#include <KWidgetsAddons/KStandardGuiItem>
#include <KCompletion/KLineEdit>
#include <KWidgetsAddons/KMessageBox>
......
......@@ -27,9 +27,9 @@
#include <QtWidgets/QGridLayout>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KDE/KInputDialog>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
KrAddBookmarkDlg::KrAddBookmarkDlg(QWidget *parent, QUrl url):
......
......@@ -22,9 +22,7 @@
#include "../VFS/krarchandler.h"
#include "../krtrashhandler.h"
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#include <KXmlGui/KActionCollection>
......
......@@ -25,9 +25,7 @@
#include <QtWidgets/QAction>
#include <QtWidgets/QMenu>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
KrBookmarkButton::KrBookmarkButton(QWidget *parent): QToolButton(parent)
......
......@@ -34,9 +34,8 @@
#include <QtGui/QMouseEvent>
#include <QtGui/QCursor>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#include <KWidgetsAddons/KMessageBox>
#include <KXmlGui/KActionCollection>
......
......@@ -41,11 +41,9 @@
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QGridLayout>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KCoreAddons/KProcess>
#include <KCompletion/KLineEdit>
#include <KI18n/KLocalizedString>
#include <KWidgetsAddons/KCursor>
#include <KWidgetsAddons/KMessageBox>
#include <KIconThemes/KIconLoader>
......
......@@ -31,10 +31,10 @@
#include <QtWidgets/QCheckBox>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KDE/KStandardGuiItem>
#include <kdeversion.h>
#include <KI18n/KLocalizedString>
#include <KIOWidgets/KUrlCompletion>
#include <KCompletion/KLineEdit>
#include <KIOWidgets/KUrlRequester>
......
......@@ -26,10 +26,9 @@
#include <QtWidgets/QPushButton>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KDE/KGlobal>
#include <KDE/KDialog>
#include <KI18n/KLocalizedString>
#include <KWidgetsAddons/KMessageBox>
#include <KConfigCore/KConfig>
#include <KXmlGui/KActionCollection>
......
......@@ -39,10 +39,8 @@
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QLineEdit>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KCompletion/KComboBox>
#include <KI18n/KLocalizedString>
#include "../GUI/krlistwidget.h"
......
......@@ -40,10 +40,10 @@
#include <QtWidgets/QLabel>
#include <QtWidgets/QProgressBar>
#include <KI18n/KLocalizedString>
#include <KWidgetsAddons/KCursor>
#include "../krglobal.h"
#include "klocale.h"
KRPleaseWait::KRPleaseWait(QString msg, QWidget *parent, int count, bool cancel):
QProgressDialog(cancel ? 0 : parent) , inc(true)
......
......@@ -41,9 +41,7 @@ A
#include <QtGui/QKeyEvent>
#include <QtGui/QPaintEvent>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KI18n/KLocalizedString>
#include <KIOCore/KFileItem>
#include <KCompletion/KLineEdit>
#include <KConfigWidgets/KColorScheme>
......
......@@ -43,9 +43,6 @@
#include <QtWidgets/QSpinBox>
#include <qnamespace.h> // missing ?
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KCompletion/KComboBox>
#include <KCompletion/KHistoryComboBox>
#include <KIconThemes/KIconLoader>
......
......@@ -39,9 +39,7 @@
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QMenu>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#include <KWidgetsAddons/KMessageBox>
......
......@@ -28,10 +28,9 @@
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QHBoxLayout>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KConfigCore/KConfigGroup>
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#include <KIOCore/KProtocolInfo>
......@@ -139,7 +138,7 @@ newFTPGUI::newFTPGUI(QWidget* parent) : KDialog(parent)
url, SLOT(addToHistory(const QString &)));
if(!lastUsedProtocol.isEmpty()) {
// update the port field
// update the port field
slotTextChanged(lastUsedProtocol);
}
......
......@@ -41,6 +41,7 @@
#include <QtWidgets/QComboBox>
#include <KCompletion/KHistoryComboBox>
#include <KI18n/KLocalizedString>
#define PS(x) lst.contains(x)>0
......
......@@ -48,6 +48,7 @@
#include <QtWidgets/QFrame>
#include <QtWidgets/QVBoxLayout>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#include <KConfigWidgets/KColorScheme>
#include <KCompletion/KComboBox>
......
......@@ -37,9 +37,6 @@
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QLabel>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
......
......@@ -29,9 +29,8 @@
#include <QtWidgets/QLabel>
#include <QtWidgets/QToolButton>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
#include <KWidgetsAddons/KMessageBox>
#include <KIconThemes/KIconLoader>
#include <KItemViews/KTreeWidgetSearchLine>
......
......@@ -52,10 +52,9 @@
#include <QtWidgets/QMenu>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KDE/KGlobalSettings>
#include <KDE/KGlobal>
#include <KI18n/KLocalizedString>
#include <KWidgetsAddons/KMessageBox>
#include <KIO/Job>
#include <KIO/DeleteJob>
......@@ -1030,7 +1029,7 @@ QString DiskUsage::getToolTip(File *item)
time_t tma = item->time();
struct tm* t = localtime((time_t *) & tma);
QDateTime tmp(QDate(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday), QTime(t->tm_hour, t->tm_min));
QString date = KGlobal::locale()->formatDateTime(tmp);
QString date = QLocale().toString(tmp);
QString str = "<qt><h5><table><tr><td>" + i18n("Name:") + "</td><td>" + item->name() + "</td></tr>" +
"<tr><td>" + i18n("Type:") + "</td><td>" + mime + "</td></tr>" +
......
......@@ -36,8 +36,8 @@
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QLabel>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
#include "../kicons.h"
#include "../krglobal.h"
......
......@@ -36,9 +36,10 @@
#include <QtWidgets/QMenu>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KDE/KInputDialog>
#include <KI18n/KLocalizedString>
#define SCHEME_POPUP_ID 6730
DUFilelight::DUFilelight(DiskUsage *usage)
......
......@@ -46,8 +46,9 @@
#include <QtWidgets/QItemDelegate>
#include <QtWidgets/QMenu>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
class DULinesItemDelegate : public QItemDelegate
{
......
......@@ -42,9 +42,8 @@
#include <QtGui/QKeyEvent>
#include <QtWidgets/QHeaderView>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KDE/KGlobal>
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
DUListView::DUListView(DiskUsage *usage)
: KrTreeWidget(usage), diskUsage(usage)
......@@ -139,7 +138,7 @@ void DUListView::addDirectory(Directory *dirEntry, QTreeWidgetItem *parent)
time_t tma = item->time();
struct tm* t = localtime((time_t *) & tma);
QDateTime tmp(QDate(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday), QTime(t->tm_hour, t->tm_min));
QString date = KGlobal::locale()->formatDateTime(tmp);
QString date = QLocale().toString(tmp);
QString totalSize = KRpermHandler::parseSize(item->size()) + ' ';
QString ownSize = KRpermHandler::parseSize(item->ownSize()) + ' ';
......
......@@ -18,12 +18,9 @@
#include "fileTree.h"
#include <QtCore/QLocale>
#include <QtCore/QString>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KGlobal>
#include <KDE/KLocale>
//static definitions
const FileSize File::DENOMINATOR[4] = { 1ull, 1ull << 10, 1ull << 20, 1ull << 30 };
const char File::PREFIX[5][2] = { "", "K", "M", "G", "T" };
......@@ -67,12 +64,12 @@ File::humanReadableSize(FileSize size, UnitPrefix key /*= mega*/) //static
{
QString s;
double prettySize = (double)size / (double)DENOMINATOR[key];
const KLocale &locale = *KGlobal::locale();
const QLocale locale;
if (prettySize >= 0.01) {
if (prettySize < 1) s = locale.formatNumber(prettySize, 2);
else if (prettySize < 100) s = locale.formatNumber(prettySize, 1);
else s = locale.formatNumber(prettySize, 0);
if (prettySize < 1) s = locale.toString(prettySize, 'f', 2);
else if (prettySize < 100) s = locale.toString(prettySize, 'f', 1);
else s = locale.toString(prettySize, 'f', 0);
s += ' ';
s += PREFIX[key];
......@@ -81,7 +78,7 @@ File::humanReadableSize(FileSize size, UnitPrefix key /*= mega*/) //static
if (prettySize < 0.1) {
s += " (";
s += locale.formatNumber(size / DENOMINATOR[ key ? key - 1 : 0 ], 0);
s += locale.toString(size / DENOMINATOR[ key ? key - 1 : 0 ]);
s += ' ';
s += PREFIX[key];
s += "B)";
......
......@@ -21,9 +21,9 @@
#include "fileTree.h"
#include "widget.h"
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KGlobal> //locale object
#include <KDE/KLocale>
#include <QtCore/QLocale>
#include <KI18n/KLocalizedString>
//**** REMOVE NEED FOR the +1 with MAX_RING_DEPTH uses
//**** add some angle bounds checking (possibly in Segment ctor? can I delete in a ctor?)
......@@ -139,7 +139,7 @@ RadialMap::Builder::build(const Directory* const dir, const unsigned int depth,
else if ((Config::showSmallFiles && hiddenSize > m_limits[depth]) || (depth == 0 && (hiddenSize > dir->size() / 8)) /*|| > size() * 0.75*/) {
//append a segment for unrepresented space - a "fake" segment
const QString s = i18np("%1 file: ~ %2", "%1 files: ~ %2", KGlobal::locale()->formatNumber(hiddenFileCount, 0), File::humanReadableSize(hiddenSize / hiddenFileCount));
const QString s = i18np("%1 file: ~ %2", "%1 files: ~ %2", QLocale().toString(hiddenFileCount), File::humanReadableSize(hiddenSize / hiddenFileCount));
(m_signature + depth)->append(new Segment(new File(s, hiddenSize), a_start, a_end - a_start, true));
}
......
......@@ -24,9 +24,9 @@
#include <QtWidgets/QToolTip> //for its palette
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KGlobal>
#include <KDE/KGlobalSettings>
#include <KDE/KLocale>
#include <KI18n/KLocalizedString>
#include "fileTree.h"
......@@ -109,13 +109,13 @@ SegmentTip::updateTip(const File* const file, const Directory* const root)
{
const QString s1 = file->fullPath(root);
QString s2 = file->humanReadableSize();
KLocale *loc = KGlobal::locale();
QLocale loc;
const uint MARGIN = 3;
const uint pc = 100 * file->size() / root->size();
uint maxw = 0;
uint h = fontMetrics().height() * 2 + 2 * MARGIN;
if (pc > 0) s2 += QString(" (%1%)").arg(loc->formatNumber(pc, 0));
if (pc > 0) s2 += QString(" (%1%)").arg(loc.toString(pc));
m_text = s1;
m_text += '\n';
......@@ -124,9 +124,9 @@ SegmentTip::updateTip(const File* const file, const Directory* const root)
if (file->isDir()) {
double files = static_cast<const Directory*>(file)->fileCount();
const uint pc = uint((100 * files) / (double)root->fileCount());
QString s3 = i18n("Files: %1", loc->formatNumber(files, 0));
QString s3 = i18n("Files: %1", loc.toString(files, 'f', 0));
if (pc > 0) s3 += QString(" (%1%)").arg(loc->formatNumber(pc, 0));
if (pc > 0) s3 += QString(" (%1%)").arg(loc.toString(pc));
maxw = fontMetrics().width(s3);
h += fontMetrics().height();
......
......@@ -27,9 +27,6 @@
#include <QtGui/QPalette>
#include <QtWidgets/QApplication> //sendEvent
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KWidgetsAddons/KCursor> //ctor
#include "fileTree.h"
......
......@@ -31,11 +31,11 @@
#include <QtWidgets/QMenu>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KIO/JobUiDelegate>
#include <KWidgetsAddons/KCursor> //::mouseMoveEvent()
#include <KWidgetsAddons/KMessageBox> //::mousePressEvent()
#include <KI18n/KLocalizedString>
#include <KIO/Job> //::mousePressEvent()
#include <KIconThemes/KIconLoader> //::mousePressEvent()
#include <KIconThemes/KIconEffect> //::mousePressEvent()
......
......@@ -43,9 +43,6 @@
#include <QtWidgets/QLayout>
#include <QtWidgets/QLabel>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KWidgetsAddons/KMessageBox>
#include <KIconThemes/KIconLoader>
......@@ -450,14 +447,14 @@ void AdvancedFilter::notModifiedAfterSetDate()
void AdvancedFilter::changeDate(KLineEdit *p)
{
// check if the current date is valid
QDate d = KGlobal::locale()->readDate(p->text());
QDate d = QLocale().toDate(p->text());
if (!d.isValid()) d = QDate::currentDate();
KRGetDate *gd = new KRGetDate(d, this);
d = gd->getDate();
// if a user pressed ESC or closed the dialog, we'll return an invalid date
if (d.isValid())
p->setText(KGlobal::locale()->formatDate(d, KLocale::ShortDate));
p->setText(QLocale().toString(d, QLocale::ShortFormat));
delete gd;
}
......@@ -505,8 +502,8 @@ bool AdvancedFilter::getSettings(FilterSettings &s)
}
s.modifiedBetweenEnabled = modifiedBetweenEnabled->isChecked();
s.modifiedBetween1 = KGlobal::locale()->readDate(modifiedBetweenData1->text());
s.modifiedBetween2 = KGlobal::locale()->readDate(modifiedBetweenData2->text());
s.modifiedBetween1 = QLocale().toDate(modifiedBetweenData1->text());
s.modifiedBetween2 = QLocale().toDate(modifiedBetweenData2->text());
if (s.modifiedBetweenEnabled) {
// check if date is valid
......@@ -527,7 +524,7 @@ bool AdvancedFilter::getSettings(FilterSettings &s)
}
s.notModifiedAfterEnabled = notModifiedAfterEnabled->isChecked();
s.notModifiedAfter = KGlobal::locale()->readDate(notModifiedAfterData->text());
s.notModifiedAfter = QLocale().toDate(notModifiedAfterData->text());
if(s.notModifiedAfterEnabled && !s.notModifiedAfter.isValid()) {
invalidDateMessage(notModifiedAfterData);
......@@ -588,12 +585,12 @@ void AdvancedFilter::applySettings(const FilterSettings &s)
anyDateEnabled->setChecked(true);
modifiedBetweenData1->setText(
KGlobal::locale()->formatDate(s.modifiedBetween1, KLocale::ShortDate));
QLocale().toString(s.modifiedBetween1, QLocale::ShortFormat));
modifiedBetweenData2->setText(
KGlobal::locale()->formatDate(s.modifiedBetween2, KLocale::ShortDate));
QLocale().toString(s.modifiedBetween2, QLocale::ShortFormat));
notModifiedAfterData->setText(
KGlobal::locale()->formatDate(s.notModifiedAfter, KLocale::ShortDate));
QLocale().toString(s.notModifiedAfter, QLocale::ShortFormat));
modifiedInTheLastData->setValue(s.modifiedInTheLast.amount);
modifiedInTheLastType->setCurrentIndex(s.modifiedInTheLast.unit);
......
......@@ -34,9 +34,6 @@
#include <QtWidgets/QGridLayout>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
FilterDialog::FilterDialog(QWidget *parent, QString caption, QStringList extraOptions, bool modal)
: KDialog(parent)
{
......
......@@ -34,10 +34,6 @@
#include "../krglobal.h"
#include "../krservices.h"
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KLocale>
#include <KDE/KGlobal>
#include <KCodecs/KCharsets>
FilterSettings::FileSize& FilterSettings::FileSize::operator=(const FileSize &other)
......@@ -283,7 +279,7 @@ KRQuery FilterSettings::toQuery() const
QString charset;
if (!contentEncoding.isEmpty())
charset = KGlobal::charsets()->encodingForName(contentEncoding);
charset = KCharsets::charsets()->encodingForName(contentEncoding);
if (!containsText.isEmpty()) {
query.setContent(containsText,
......