forked from qt-creator/qt-creator
Beautifier: Fix Qt4 compile.
Change-Id: Ifbd01628b28abe6879d30d43f8bd1f389988086f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
@@ -65,7 +65,11 @@ QStringList AbstractSettings::completerWords()
|
||||
QStringList AbstractSettings::styles() const
|
||||
{
|
||||
QStringList list = m_styles.keys();
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
list.sort(Qt::CaseInsensitive);
|
||||
#else //QT_VERSION_CHECK(5, 0, 0)
|
||||
list.sort();
|
||||
#endif // QT_VERSION_CHECK(5, 0, 0)
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QProcess>
|
||||
#include <QTextDocument> // Qt::escape() in Qt 4
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
namespace Beautifier {
|
||||
@@ -164,7 +165,7 @@ void ArtisticStyleSettings::createDocumentationFile() const
|
||||
const QString text = QLatin1String("<p><span class=\"option\">")
|
||||
+ keys.filter(QRegExp(QLatin1String("^\\-"))).join(QLatin1String(", "))
|
||||
+ QLatin1String("</span></p><p>")
|
||||
+ Qt::escape(docu.join(QLatin1Char(' ')))
|
||||
+ Qt::escape(docu.join(QLatin1String(" ")))
|
||||
+ QLatin1String("</p>");
|
||||
stream.writeTextElement(QLatin1String(Constants::DOCUMENTATION_XMLDOC), text);
|
||||
stream.writeEndElement();
|
||||
|
||||
@@ -135,14 +135,15 @@ QString BeautifierPlugin::format(const QString &text, QStringList command, const
|
||||
// Format temporary file
|
||||
QProcess process;
|
||||
command.replaceInStrings(QLatin1String("%file"), sourceFile.fileName());
|
||||
process.start(command.takeFirst(), command);
|
||||
const QString processProgram = command.takeFirst();
|
||||
process.start(processProgram, command);
|
||||
if (!process.waitForFinished()) {
|
||||
showError(tr("Failed to call %1 or an error occurred.").arg(process.program()));
|
||||
showError(tr("Failed to call %1 or an error occurred.").arg(processProgram));
|
||||
return QString();
|
||||
}
|
||||
const QByteArray output = process.readAllStandardError();
|
||||
if (!output.isEmpty())
|
||||
showError(process.program() + QLatin1String(": ") + QString::fromLocal8Bit(output));
|
||||
showError(processProgram + QLatin1String(": ") + QString::fromLocal8Bit(output));
|
||||
|
||||
// Read text back
|
||||
Utils::FileReader reader;
|
||||
|
||||
@@ -80,7 +80,9 @@ QString ClangFormatOptionsPageWidget::searchKeywords() const
|
||||
void ClangFormatOptionsPageWidget::restore()
|
||||
{
|
||||
ui->command->setPath(m_settings->command());
|
||||
ui->predefinedStyle->setCurrentText(m_settings->predefinedStyle());
|
||||
int textIndex = ui->predefinedStyle->findText(m_settings->predefinedStyle());
|
||||
if (textIndex != -1)
|
||||
ui->predefinedStyle->setCurrentIndex(textIndex);
|
||||
ui->formatEntireFileFallback->setChecked(m_settings->formatEntireFileFallback());
|
||||
ui->configurations->setSettings(m_settings);
|
||||
ui->configurations->setCurrentConfiguration(m_settings->customStyle());
|
||||
|
||||
@@ -63,7 +63,7 @@ void ConfigurationSyntaxHighlighter::setKeywords(const QStringList &keywords)
|
||||
for (int i = 0, total = keywords.count(); i < total; ++i)
|
||||
pattern << QRegExp::escape(keywords.at(i));
|
||||
|
||||
m_expressionKeyword.setPattern(QLatin1String("(?:\\s|^)(") + pattern.join(QLatin1Char('|'))
|
||||
m_expressionKeyword.setPattern(QLatin1String("(?:\\s|^)(") + pattern.join(QLatin1String("|"))
|
||||
+ QLatin1String(")(?=\\s|\\:|\\=|\\,|$)"));
|
||||
}
|
||||
|
||||
@@ -120,7 +120,11 @@ void ConfigurationEditor::setSettings(AbstractSettings *settings)
|
||||
QStringList keywords = m_settings->options();
|
||||
m_highlighter->setKeywords(keywords);
|
||||
keywords << m_settings->completerWords();
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
keywords.sort(Qt::CaseInsensitive);
|
||||
#else //QT_VERSION_CHECK(5, 0, 0)
|
||||
keywords.sort();
|
||||
#endif //QT_VERSION_CHECK(5, 0, 0)
|
||||
m_model->setStringList(keywords);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,9 @@ void ConfigurationPanel::setSettings(AbstractSettings *settings)
|
||||
|
||||
void ConfigurationPanel::setCurrentConfiguration(const QString &text)
|
||||
{
|
||||
ui->configurations->setCurrentText(text);
|
||||
int textIndex = ui->configurations->findText(text);
|
||||
if (textIndex != -1)
|
||||
ui->configurations->setCurrentIndex(textIndex);
|
||||
}
|
||||
|
||||
QString ConfigurationPanel::currentConfiguration() const
|
||||
@@ -113,7 +115,9 @@ void ConfigurationPanel::populateConfigurations(const QString &key)
|
||||
const QString currentText = (!key.isEmpty()) ? key : ui->configurations->currentText();
|
||||
ui->configurations->clear();
|
||||
ui->configurations->addItems(m_settings->styles());
|
||||
ui->configurations->setCurrentText(currentText);
|
||||
int textIndex = ui->configurations->findText(currentText);
|
||||
if (textIndex != -1)
|
||||
ui->configurations->setCurrentIndex(textIndex);
|
||||
updateButtons();
|
||||
ui->configurations->blockSignals(false);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QProcess>
|
||||
#include <QTextDocument> // Qt::escape() in Qt 4
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
namespace Beautifier {
|
||||
@@ -150,7 +151,8 @@ void UncrustifySettings::createDocumentationFile() const
|
||||
//TODO As soon as Qt 4 support is dropped, use toHtmlEscaped().
|
||||
const QString text = QLatin1String("<p><span class=\"option\">") + keyword
|
||||
+ QLatin1String("</span> <span class=\"param\">") + options
|
||||
+ QLatin1String("</span></p><p>") + Qt::escape(docu.join(QLatin1Char(' ')))
|
||||
+ QLatin1String("</span></p><p>")
|
||||
+ Qt::escape(docu.join(QLatin1String(" ")))
|
||||
+ QLatin1String("</p>");
|
||||
stream.writeStartElement(QLatin1String(Constants::DOCUMENTATION_XMLENTRY));
|
||||
stream.writeTextElement(QLatin1String(Constants::DOCUMENTATION_XMLKEY), keyword);
|
||||
|
||||
Reference in New Issue
Block a user