Commit 0f727b16 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix warning found by clazy

parent 6e478690
......@@ -45,7 +45,7 @@ void PythonServer::login()
Py_InspectFlag = 1;
Py_Initialize();
m_pModule = PyImport_AddModule("__main__");
filePath = QLatin1String("python_cantor_worksheet");
filePath = QStringLiteral("python_cantor_worksheet");
}
void PythonServer::runPythonCommand(const QString& command) const
......
......@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
return 1;
}
const QString& serviceName = QString::fromLatin1("org.kde.Cantor.Python2-%1").arg(app.applicationPid());
const QString& serviceName = QStringLiteral("org.kde.Cantor.Python2-%1").arg(app.applicationPid());
if (!QDBusConnection::sessionBus().registerService(serviceName))
{
......@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
}
PythonServer server;
QDBusConnection::sessionBus().registerObject(QString::fromLatin1("/"), &server, QDBusConnection::ExportAllSlots);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/"), &server, QDBusConnection::ExportAllSlots);
QTextStream(stdout) << "ready" << endl;
......
......@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
return 1;
}
const QString& serviceName = QString::fromLatin1("org.kde.Cantor.Python3-%1").arg(app.applicationPid());
const QString& serviceName = QStringLiteral("org.kde.Cantor.Python3-%1").arg(app.applicationPid());
if (!QDBusConnection::sessionBus().registerService(serviceName))
{
......@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
}
PythonServer server;
QDBusConnection::sessionBus().registerObject(QString::fromLatin1("/"), &server, QDBusConnection::ExportAllSlots);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/"), &server, QDBusConnection::ExportAllSlots);
QTextStream(stdout) << "ready" << endl;
......
......@@ -56,7 +56,7 @@ AnimationResult::~AnimationResult()
QString AnimationResult::toHtml()
{
return QString::fromLatin1("<img src=\"%1\" alt=\"%2\"/>").arg(d->url.toLocalFile(), d->alt);
return QStringLiteral("<img src=\"%1\" alt=\"%2\"/>").arg(d->url.toLocalFile(), d->alt);
}
QVariant AnimationResult::data()
......@@ -85,9 +85,9 @@ QString AnimationResult::mimeType()
QDomElement AnimationResult::toXml(QDomDocument& doc)
{
qDebug()<<"saving imageresult "<<toHtml();
QDomElement e=doc.createElement(QLatin1String("Result"));
e.setAttribute(QLatin1String("type"), QLatin1String("animation"));
e.setAttribute(QLatin1String("filename"), d->url.fileName());
QDomElement e=doc.createElement(QStringLiteral("Result"));
e.setAttribute(QStringLiteral("type"), QStringLiteral("animation"));
e.setAttribute(QStringLiteral("filename"), d->url.fileName());
qDebug()<<"done";
return e;
......
......@@ -46,11 +46,11 @@ void Assistant::setBackend(Cantor::Backend* backend)
d->backend=backend;
}
void Assistant::setPluginInfo(KPluginMetaData info)
void Assistant::setPluginInfo(const KPluginMetaData &info)
{
d->name=info.name();
d->icon=info.iconName();
d->requiredExtensions=info.value(QLatin1String("RequiredExtensions")).split(QLatin1Char(','));
d->requiredExtensions=info.value(QStringLiteral("RequiredExtensions")).split(QLatin1Char(','));
}
......
......@@ -62,7 +62,7 @@ class CANTOR_EXPORT Assistant : public QObject, public KXMLGUIClient
* according to KPluginMetaData
* @param info KPluginMetaData
*/
void setPluginInfo(KPluginMetaData info);
void setPluginInfo(const KPluginMetaData &info);
/**
* Returns a list of all extensions, the current backend
......
......@@ -100,7 +100,7 @@ void CompletionObject::setLine(const QString& line, int index)
d->command=line.mid(cmd_index, index-cmd_index);
//start a delayed fetch
QTimer::singleShot(0, this, SLOT(fetchCompletions()));
QTimer::singleShot(0, this, &CompletionObject::fetchCompletions);
}
void CompletionObject::updateLine(const QString& line, int index)
......@@ -115,7 +115,7 @@ void CompletionObject::updateLine(const QString& line, int index)
// start a delayed fetch
// For some backends this is a lot of unnecessary work...
QTimer::singleShot(0, this, SLOT(fetchCompletions()));
QTimer::singleShot(0, this, &CompletionObject::fetchCompletions);
}
void CompletionObject::completeLine(const QString& comp, CompletionObject::LineCompletionMode mode)
......@@ -127,7 +127,7 @@ void CompletionObject::completeLine(const QString& comp, CompletionObject::LineC
} else if (mode == PreliminaryCompletion) {
completeUnknownLine();
} else /* mode == FinalCompletion */ {
QTimer::singleShot(0, this, SLOT(fetchIdentifierType()));
QTimer::singleShot(0, this, &CompletionObject::fetchIdentifierType);
}
}
......
......@@ -215,7 +215,7 @@ class CANTOR_EXPORT CompletionObject : public KCompletion
* @param line the new line
* @param index the new cursor index
*/
void lineDone(QString line, int index);
void lineDone(const QString &line, int index);
private:
CompletionObjectPrivate* d;
};
......
......@@ -94,8 +94,8 @@ DefaultHighlighter::DefaultHighlighter(QObject* parent)
addPair(QLatin1Char('{'), QLatin1Char('}'));
updateFormats();
connect(qApp, SIGNAL(paletteChanged(QPalette)),
this, SLOT(updateFormats()));
connect(qApp, &QGuiApplication::paletteChanged,
this, &DefaultHighlighter::updateFormats);
}
DefaultHighlighter::~DefaultHighlighter()
......@@ -215,7 +215,7 @@ void DefaultHighlighter::highlightWords(const QString& text)
{
//qDebug() << "j: " << j << "w: " << words[j];
const QString& w = words[j];
const QString exp = QString::fromLatin1("(%1)*$").arg(nonSeparatingCharacters());
const QString exp = QStringLiteral("(%1)*$").arg(nonSeparatingCharacters());
//qDebug() << "exp: " << exp;
int idx = w.indexOf(QRegExp(exp));
const QString& s = w.mid(idx);
......
......@@ -43,7 +43,7 @@ d_ptr(new DefaultVariableModelPrivate)
d->session = session;
if (session)
{
d->extension = dynamic_cast<Cantor::VariableManagementExtension*>(session->backend()->extension(QLatin1String("VariableManagementExtension")));
d->extension = dynamic_cast<Cantor::VariableManagementExtension*>(session->backend()->extension(QStringLiteral("VariableManagementExtension")));
}
qDebug() << d->session << d->extension;
}
......
......@@ -48,12 +48,12 @@ EpsResult::~EpsResult()
QString EpsResult::toHtml()
{
return QString::fromLatin1("<img src=\"%1\" />").arg(d->url.url());
return QStringLiteral("<img src=\"%1\" />").arg(d->url.url());
}
QString EpsResult::toLatex()
{
return QString::fromLatin1(" \\begin{center} \n \\includegraphics[width=12cm]{%1}\n \\end{center}").arg(d->url.fileName());
return QStringLiteral(" \\begin{center} \n \\includegraphics[width=12cm]{%1}\n \\end{center}").arg(d->url.fileName());
}
QVariant EpsResult::data()
......@@ -73,15 +73,15 @@ int EpsResult::type()
QString EpsResult::mimeType()
{
return QLatin1String("image/x-eps");
return QStringLiteral("image/x-eps");
}
QDomElement EpsResult::toXml(QDomDocument& doc)
{
qDebug()<<"saving imageresult "<<toHtml();
QDomElement e=doc.createElement(QLatin1String("Result"));
e.setAttribute(QLatin1String("type"), QLatin1String("image"));
e.setAttribute(QLatin1String("filename"), d->url.fileName());
QDomElement e=doc.createElement(QStringLiteral("Result"));
e.setAttribute(QStringLiteral("type"), QStringLiteral("image"));
e.setAttribute(QStringLiteral("filename"), d->url.fileName());
qDebug()<<"done";
return e;
......
......@@ -45,13 +45,13 @@ EXTENSION_CONSTRUCTORS(PackagingExtension)
//implement this here, as it's ";" most of the time
QString ScriptExtension::commandSeparator()
{
return QLatin1String(";\n");
return QStringLiteral(";\n");
}
//implement this here, as it's "#" most of the time
QString ScriptExtension::commentStartingSequence()
{
return QLatin1String("#");
return QStringLiteral("#");
}
//implement this here, as it's "" most of the time
......@@ -68,7 +68,7 @@ QString LinearAlgebraExtension::nullVector(int size, VectorType type)
{
QStringList values;
for (int i=0;i<size;i++)
values<<QLatin1String("0");
values<<QStringLiteral("0");
return createVector(values, type);
}
......@@ -79,7 +79,7 @@ QString LinearAlgebraExtension::identityMatrix(int size)
{
QStringList column;
for(int j=0;j<size;j++)
column<<((i==j) ? QLatin1String("1"): QLatin1String("0"));
column<<((i==j) ? QStringLiteral("1"): QStringLiteral("0"));
m<<column;
}
......@@ -94,7 +94,7 @@ QString LinearAlgebraExtension::nullMatrix(int rows, int columns)
{
QStringList column;
for(int j=0;j<columns;j++)
column<<QLatin1String("0");
column<<QStringLiteral("0");
m<<column;
}
......@@ -127,7 +127,7 @@ QString AdvancedPlotExtension::dispatchDirective(const PlotDirective& directive)
QString AdvancedPlotExtension::separatorSymbol() const
{
return QLatin1String(",");
return QStringLiteral(",");
}
QWidget* AdvancedPlotExtension::PlotDirective::widget(QWidget* parent)
......
......@@ -53,8 +53,8 @@ int HelpResult::type()
QDomElement HelpResult::toXml(QDomDocument& doc)
{
//No need to save results of a help request
QDomElement e=doc.createElement(QLatin1String("Result"));
e.setAttribute(QLatin1String("type"), QLatin1String("help"));
QDomElement e=doc.createElement(QStringLiteral("Result"));
e.setAttribute(QStringLiteral("type"), QStringLiteral("help"));
return e;
}
......@@ -70,7 +70,7 @@ QVariant HelpResult::data()
QString HelpResult::mimeType()
{
return QLatin1String("text/html");
return QStringLiteral("text/html");
}
void HelpResult::save(const QString& filename)
......
......@@ -49,12 +49,12 @@ ImageResult::~ImageResult()
QString ImageResult::toHtml()
{
return QString::fromLatin1("<img src=\"%1\" alt=\"%2\"/>").arg(d->url.toLocalFile(), d->alt);
return QStringLiteral("<img src=\"%1\" alt=\"%2\"/>").arg(d->url.toLocalFile(), d->alt);
}
QString ImageResult::toLatex()
{
return QString::fromLatin1(" \\begin{center} \n \\includegraphics[width=12cm]{%1} \n \\end{center}").arg(d->url.fileName());
return QStringLiteral(" \\begin{center} \n \\includegraphics[width=12cm]{%1} \n \\end{center}").arg(d->url.fileName());
}
QVariant ImageResult::data()
......@@ -91,9 +91,9 @@ QString ImageResult::mimeType()
QDomElement ImageResult::toXml(QDomDocument& doc)
{
qDebug()<<"saving imageresult "<<toHtml();
QDomElement e=doc.createElement(QLatin1String("Result"));
e.setAttribute(QLatin1String("type"), QLatin1String("image"));
e.setAttribute(QLatin1String("filename"), d->url.fileName());
QDomElement e=doc.createElement(QStringLiteral("Result"));
e.setAttribute(QStringLiteral("type"), QStringLiteral("image"));
e.setAttribute(QStringLiteral("filename"), d->url.fileName());
qDebug()<<"done";
return e;
......
......@@ -167,8 +167,8 @@ void LatexRenderer::render()
void LatexRenderer::renderBlocking()
{
QEventLoop event;
connect(this, SIGNAL(done()), &event, SLOT(quit()));
connect(this, SIGNAL(error()), &event, SLOT(quit()));
connect(this, &LatexRenderer::done, &event, &QEventLoop::quit);
connect(this, &LatexRenderer::error, &event, &QEventLoop::quit);
render();
event.exec();
......@@ -210,7 +210,7 @@ void LatexRenderer::renderWithLatex()
KProcess *p=new KProcess( this );
p->setWorkingDirectory(dir);
(*p)<<Settings::self()->latexCommand()<<QLatin1String("-interaction=batchmode")<<QLatin1String("-halt-on-error")<<fileName;
(*p)<<Settings::self()->latexCommand()<<QStringLiteral("-interaction=batchmode")<<QStringLiteral("-halt-on-error")<<fileName;
connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(convertToPs()) );
p->start();
......@@ -222,7 +222,7 @@ void LatexRenderer::convertToPs()
dviFile.replace(QLatin1String(".eps"), QLatin1String(".dvi"));
KProcess *p=new KProcess( this );
qDebug()<<"converting to eps: "<<Settings::self()->dvipsCommand()<<"-E"<<"-o"<<d->latexFilename<<dviFile;
(*p)<<Settings::self()->dvipsCommand()<<QLatin1String("-E")<<QLatin1String("-o")<<d->latexFilename<<dviFile;
(*p)<<Settings::self()->dvipsCommand()<<QStringLiteral("-E")<<QStringLiteral("-o")<<d->latexFilename<<dviFile;
connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(convertingDone()) );
p->start();
......@@ -245,7 +245,7 @@ void LatexRenderer::convertingDone()
}else
{
d->success=false;
setErrorMessage(QLatin1String("failed to create the latex preview image"));
setErrorMessage(QStringLiteral("failed to create the latex preview image"));
emit error();
}
}
......
......@@ -58,7 +58,7 @@ int LatexResult::type()
QString LatexResult::mimeType()
{
if(isCodeShown())
return QLatin1String("text/plain");
return QStringLiteral("text/plain");
else
return EpsResult::mimeType();
}
......@@ -117,10 +117,10 @@ QString LatexResult::toLatex()
QDomElement LatexResult::toXml(QDomDocument& doc)
{
qDebug()<<"saving textresult "<<toHtml();
QDomElement e=doc.createElement(QLatin1String("Result"));
e.setAttribute(QLatin1String("type"), QLatin1String("application/x-latex"));
QDomElement e=doc.createElement(QStringLiteral("Result"));
e.setAttribute(QStringLiteral("type"), QStringLiteral("application/x-latex"));
QUrl url= EpsResult::data().toUrl();
e.setAttribute(QLatin1String("filename"), url.fileName());
e.setAttribute(QStringLiteral("filename"), url.fileName());
QDomText txt=doc.createTextNode(code());
e.appendChild(txt);
......
......@@ -57,7 +57,7 @@ QWidget* PanelPlugin::parentWidget()
void PanelPlugin::setPluginInfo(const KPluginMetaData& info)
{
d->name=info.name();
d->requiredExtensions=info.value(QLatin1String("RequiredExtensions")).split(QLatin1Char(','));
d->requiredExtensions=info.value(QStringLiteral("RequiredExtensions")).split(QLatin1Char(','));
}
QStringList PanelPlugin::requiredExtensions()
......
......@@ -41,7 +41,7 @@ class Cantor::PanelPluginHandlerPrivate
PanelPluginHandler::PanelPluginHandler( QObject* parent ) : QObject(parent) ,
d(new PanelPluginHandlerPrivate)
{
setObjectName(QLatin1String("PanelPluginHandler"));
setObjectName(QStringLiteral("PanelPluginHandler"));
d->session=nullptr;
}
......
......@@ -50,10 +50,10 @@ QString Result::toLatex()
{
QString html=toHtml();
//replace linebreaks
html.replace(QRegExp(QLatin1String("<br/>[\n]")), QLatin1String("\n"));
html.replace(QRegExp(QLatin1String("<br/>[\n]")), QStringLiteral("\n"));
//remove all the unknown tags
html.remove( QRegExp( QLatin1String("<[a-zA-Z\\/][^>]*>") ) );
return QString::fromLatin1("\\begin{verbatim} %1 \\end{verbatim}").arg(html);
return QStringLiteral("\\begin{verbatim} %1 \\end{verbatim}").arg(html);
}
void Result::saveAdditionalData(KZip* archive)
......
......@@ -47,7 +47,7 @@ SyntaxHelpObject::~SyntaxHelpObject()
void SyntaxHelpObject::fetchSyntaxHelp()
{
//Start a delayed fetch
QTimer::singleShot(0, this, SLOT(fetchInformation()));
QTimer::singleShot(0, this, &SyntaxHelpObject::fetchInformation);
}
......
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