summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Cullmann <cullmann@kde.org>2014-01-20 11:17:00 (GMT)
committerChristoph Cullmann <cullmann@kde.org>2014-01-20 11:17:00 (GMT)
commit1811dea1ddc6bb649f2339d8f40e76dc5b3d7a87 (patch)
tree6b99e1706dd3bb461b8611b6113ab54655a72e97
parent01ee01427750604a80a41510e470f790847cc3e8 (diff)
more ported
-rw-r--r--addons/kate/katesql/dataoutputmodel.cpp17
-rw-r--r--addons/kate/katesql/dataoutputwidget.cpp67
-rw-r--r--addons/kate/katesql/outputstylewidget.cpp6
3 files changed, 47 insertions, 43 deletions
diff --git a/addons/kate/katesql/dataoutputmodel.cpp b/addons/kate/katesql/dataoutputmodel.cpp
index 0dc9697..8d3cace 100644
--- a/addons/kate/katesql/dataoutputmodel.cpp
+++ b/addons/kate/katesql/dataoutputmodel.cpp
@@ -24,6 +24,9 @@
#include <kconfiggroup.h>
#include <KSharedConfig>
+#include <QFontDatabase>
+#include <QLocale>
+
inline bool isNumeric(const QVariant::Type type)
{
return (type > 1 && type < 7);
@@ -78,9 +81,9 @@ void DataOutputModel::readConfig()
s->foreground = scheme.foreground();
s->background = scheme.background();
- s->font = KGlobalSettings::generalFont();
+ s->font = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
- QFont dummy = g.readEntry("font", KGlobalSettings::generalFont());
+ QFont dummy = g.readEntry("font", QFontDatabase::systemFont(QFontDatabase::GeneralFont));
s->font.setBold(dummy.bold());
s->font.setItalic(dummy.italic());
@@ -153,7 +156,7 @@ QVariant DataOutputModel::data(const QModelIndex &index, int role) const
if (role == Qt::DisplayRole || role == Qt::UserRole)
{
if (useSystemLocale())
- return QVariant(KGlobal::locale()->formatNumber(value.toString(), false));
+ return QVariant(value.toString()); //FIXME KF5 KGlobal::locale()->formatNumber(value.toString(), false));
else
return QVariant(value.toString());
}
@@ -168,7 +171,7 @@ QVariant DataOutputModel::data(const QModelIndex &index, int role) const
if (role == Qt::BackgroundRole)
return QVariant(m_styles.value(QLatin1String ("bool"))->background);
if (role == Qt::DisplayRole)
- return QVariant(value.toBool() ? "True" : "False");
+ return QVariant(value.toBool() ? QLatin1String ("True") : QLatin1String ("False"));
}
if (type == QVariant::Date ||
@@ -186,11 +189,11 @@ QVariant DataOutputModel::data(const QModelIndex &index, int role) const
if (useSystemLocale())
{
if (type == QVariant::Date)
- return QVariant(KGlobal::locale()->formatDate(value.toDate(), KLocale::ShortDate));
+ return QVariant(QLocale().toString(value.toDate(), QLocale::ShortFormat));
if (type == QVariant::Time)
- return QVariant(KGlobal::locale()->formatTime(value.toTime(), true));
+ return QVariant(QLocale().toString(value.toTime()));
if (type == QVariant::DateTime)
- return QVariant(KGlobal::locale()->formatDateTime(value.toDateTime(), KLocale::ShortDate, true));
+ return QVariant(QLocale().toString(value.toDateTime(), QLocale::ShortFormat));
}
else // return sql server format
return QVariant(value.toString());
diff --git a/addons/kate/katesql/dataoutputwidget.cpp b/addons/kate/katesql/dataoutputwidget.cpp
index a8b8951..608249b 100644
--- a/addons/kate/katesql/dataoutputwidget.cpp
+++ b/addons/kate/katesql/dataoutputwidget.cpp
@@ -21,17 +21,15 @@
#include "dataoutputview.h"
#include "exportwizard.h"
-#include <kate/application.h>
-#include <kate/mainwindow.h>
-#include <kate/documentmanager.h>
+#include <ktexteditor/editor.h>
+#include <ktexteditor/application.h>
+#include <ktexteditor/mainwindow.h>
#include <ktexteditor/document.h>
#include <ktexteditor/view.h>
-#include <kfiledialog.h>
-#include <kapplication.h>
+
#include <ktoolbar.h>
#include <ktoggleaction.h>
#include <QAction>
-#include <kicon.h>
#include <klocalizedstring.h>
#include <kmessagebox.h>
@@ -44,6 +42,9 @@
#include <qtextstream.h>
#include <qfile.h>
#include <qtimer.h>
+#include <QApplication>
+#include <QClipboard>
+#include <QTime>
DataOutputWidget::DataOutputWidget(QWidget *parent)
: QWidget(parent)
@@ -63,33 +64,33 @@ DataOutputWidget::DataOutputWidget(QWidget *parent)
/// TODO: disable actions if no results are displayed or selected
- KAction *action;
+ QAction *action;
- action = new KAction( KIcon("distribute-horizontal-x"), i18nc("@action:intoolbar", "Resize columns to contents"), this);
+ action = new QAction( QIcon::fromTheme(QLatin1String("distribute-horizontal-x")), i18nc("@action:intoolbar", "Resize columns to contents"), this);
toolbar->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(resizeColumnsToContents()));
- action = new KAction( KIcon("distribute-vertical-y"), i18nc("@action:intoolbar", "Resize rows to contents"), this);
+ action = new QAction( QIcon::fromTheme(QLatin1String("distribute-vertical-y")), i18nc("@action:intoolbar", "Resize rows to contents"), this);
toolbar->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(resizeRowsToContents()));
- action = new KAction( KIcon("edit-copy"), i18nc("@action:intoolbar", "Copy"), this);
+ action = new QAction( QIcon::fromTheme(QLatin1String("edit-copy")), i18nc("@action:intoolbar", "Copy"), this);
toolbar->addAction(action);
m_view->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(slotCopySelected()));
- action = new KAction( KIcon("document-export-table"), i18nc("@action:intoolbar", "Export..."), this);
+ action = new QAction( QIcon::fromTheme(QLatin1String("document-export-table")), i18nc("@action:intoolbar", "Export..."), this);
toolbar->addAction(action);
m_view->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(slotExport()));
- action = new KAction( KIcon("edit-clear"), i18nc("@action:intoolbar", "Clear"), this);
+ action = new QAction( QIcon::fromTheme(QLatin1String("edit-clear")), i18nc("@action:intoolbar", "Clear"), this);
toolbar->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(clearResults()));
toolbar->addSeparator();
- KToggleAction *toggleAction = new KToggleAction( KIcon("applications-education-language"), i18nc("@action:intoolbar", "Use system locale"), this);
+ KToggleAction *toggleAction = new KToggleAction( QIcon::fromTheme(QLatin1String("applications-education-language")), i18nc("@action:intoolbar", "Use system locale"), this);
toolbar->addAction(toggleAction);
connect(toggleAction, SIGNAL(triggered()), this, SLOT(slotToggleLocale()));
@@ -193,7 +194,7 @@ void DataOutputWidget::slotCopySelected()
exportData(stream);
if (!text.isEmpty())
- kapp->clipboard()->setText(text);
+ QApplication::clipboard()->setText(text);
}
@@ -213,12 +214,12 @@ void DataOutputWidget::slotExport()
if (wizard.exec() != QDialog::Accepted)
return;
- bool outputInDocument = wizard.field("outDocument").toBool();
- bool outputInClipboard = wizard.field("outClipboard").toBool();
- bool outputInFile = wizard.field("outFile").toBool();
+ bool outputInDocument = wizard.field(QLatin1String("outDocument")).toBool();
+ bool outputInClipboard = wizard.field(QLatin1String("outClipboard")).toBool();
+ bool outputInFile = wizard.field(QLatin1String("outFile")).toBool();
- bool exportColumnNames = wizard.field("exportColumnNames").toBool();
- bool exportLineNumbers = wizard.field("exportLineNumbers").toBool();
+ bool exportColumnNames = wizard.field(QLatin1String("exportColumnNames")).toBool();
+ bool exportLineNumbers = wizard.field(QLatin1String("exportLineNumbers")).toBool();
Options opt = NoOptions;
@@ -227,17 +228,17 @@ void DataOutputWidget::slotExport()
if (exportLineNumbers)
opt |= ExportLineNumbers;
- bool quoteStrings = wizard.field("checkQuoteStrings").toBool();
- bool quoteNumbers = wizard.field("checkQuoteNumbers").toBool();
+ bool quoteStrings = wizard.field(QLatin1String("checkQuoteStrings")).toBool();
+ bool quoteNumbers = wizard.field(QLatin1String("checkQuoteNumbers")).toBool();
- QChar stringsQuoteChar = (quoteStrings) ? wizard.field("quoteStringsChar").toString().at(0) : '\0';
- QChar numbersQuoteChar = (quoteNumbers) ? wizard.field("quoteNumbersChar").toString().at(0) : '\0';
+ QChar stringsQuoteChar = (quoteStrings) ? wizard.field(QLatin1String("quoteStringsChar")).toString().at(0) : QLatin1Char('\0');
+ QChar numbersQuoteChar = (quoteNumbers) ? wizard.field(QLatin1String("quoteNumbersChar")).toString().at(0) : QLatin1Char('\0');
- QString fieldDelimiter = wizard.field("fieldDelimiter").toString();
+ QString fieldDelimiter = wizard.field(QLatin1String("fieldDelimiter")).toString();
if (outputInDocument)
{
- Kate::MainWindow *mw = Kate::application()->activeMainWindow();
+ KTextEditor::MainWindow *mw = KTextEditor::Editor::instance()->application()->activeMainWindow();
KTextEditor::View *kv = mw->activeView();
if (!kv)
@@ -258,11 +259,11 @@ void DataOutputWidget::slotExport()
exportData(stream, stringsQuoteChar, numbersQuoteChar, fieldDelimiter, opt);
- kapp->clipboard()->setText(text);
+ QApplication::clipboard()->setText(text);
}
else if (outputInFile)
{
- QString url = wizard.field("outFileUrl").toString();
+ QString url = wizard.field(QLatin1String ("outFileUrl")).toString();
QFile data(url);
if (data.open(QFile::WriteOnly | QFile::Truncate))
{
@@ -294,9 +295,9 @@ void DataOutputWidget::exportData(QTextStream &stream,
QString fixedFieldDelimiter = fieldDelimiter;
/// FIXME: ugly workaround...
- fixedFieldDelimiter = fixedFieldDelimiter.replace("\\t", "\t");
- fixedFieldDelimiter = fixedFieldDelimiter.replace("\\r", "\r");
- fixedFieldDelimiter = fixedFieldDelimiter.replace("\\n", "\n");
+ fixedFieldDelimiter = fixedFieldDelimiter.replace(QLatin1String ("\\t"), QLatin1String ("\t"));
+ fixedFieldDelimiter = fixedFieldDelimiter.replace(QLatin1String ("\\r"), QLatin1String ("\r"));
+ fixedFieldDelimiter = fixedFieldDelimiter.replace(QLatin1String ("\\n"), QLatin1String ("\n"));
QTime t;
t.start();
@@ -323,14 +324,14 @@ void DataOutputWidget::exportData(QTextStream &stream,
if (data.type() < 7) // is numeric or boolean
{
- if (numbersQuoteChar != '\0')
+ if (numbersQuoteChar != QLatin1Char ('\0'))
snapshot[qMakePair(row,col)] = numbersQuoteChar + data.toString() + numbersQuoteChar;
else
snapshot[qMakePair(row,col)] = data.toString();
}
else
{
- if (stringsQuoteChar != '\0')
+ if (stringsQuoteChar != QLatin1Char ('\0'))
snapshot[qMakePair(row,col)] = stringsQuoteChar + data.toString() + stringsQuoteChar;
else
snapshot[qMakePair(row,col)] = data.toString();
@@ -347,7 +348,7 @@ void DataOutputWidget::exportData(QTextStream &stream,
{
const QVariant data = m_model->headerData(j.next(), Qt::Horizontal);
- if (stringsQuoteChar != '\0')
+ if (stringsQuoteChar != QLatin1Char ('\0'))
stream << stringsQuoteChar + data.toString() + stringsQuoteChar;
else
stream << data.toString();
diff --git a/addons/kate/katesql/outputstylewidget.cpp b/addons/kate/katesql/outputstylewidget.cpp
index a7e764c..321da17 100644
--- a/addons/kate/katesql/outputstylewidget.cpp
+++ b/addons/kate/katesql/outputstylewidget.cpp
@@ -120,7 +120,7 @@ void OutputStyleWidget::readConfig(QTreeWidgetItem *item)
KColorButton *foregroundColorButton = static_cast<KColorButton*>(itemWidget(item, 5));
KColorButton *backgroundColorButton = static_cast<KColorButton*>(itemWidget(item, 6));
- const QFont font = g.readEntry("font", KGlobalSettings::generalFont());
+ const QFont font = g.readEntry("font", QFontDatabase::systemFont(QFontDatabase::GeneralFont));
boldCheckBox->setChecked(font.bold());
italicCheckBox->setChecked(font.italic());
@@ -145,7 +145,7 @@ void OutputStyleWidget::writeConfig(QTreeWidgetItem *item)
KColorButton *foregroundColorButton = static_cast<KColorButton*>(itemWidget(item, 5));
KColorButton *backgroundColorButton = static_cast<KColorButton*>(itemWidget(item, 6));
- QFont f(KGlobalSettings::generalFont());
+ QFont f(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
f.setBold(boldCheckBox->isChecked());
f.setItalic(italicCheckBox->isChecked());
@@ -194,7 +194,7 @@ void OutputStyleWidget::updatePreviews()
const KColorButton *foregroundColorButton = static_cast<KColorButton*>(itemWidget(item, 5));
const KColorButton *backgroundColorButton = static_cast<KColorButton*>(itemWidget(item, 6));
- QFont f(KGlobalSettings::generalFont());
+ QFont f(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
f.setBold(boldCheckBox->isChecked());
f.setItalic(italicCheckBox->isChecked());