Commit cb009830 authored by hjk's avatar hjk Committed by David Schulz
Browse files

TextEditor: Move HighlightDefinition constants to where they are used



Change-Id: Ibdd3147cc2a64407802fa237b7943d2e96c90030
Reviewed-by: default avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent d8eb5ddb
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "highlightdefinitionmetadata.h"
using namespace TextEditor;
using namespace Internal;
const QLatin1String HighlightDefinitionMetaData::kPriority("priority");
const QLatin1String HighlightDefinitionMetaData::kName("name");
const QLatin1String HighlightDefinitionMetaData::kExtensions("extensions");
const QLatin1String HighlightDefinitionMetaData::kMimeType("mimetype");
const QLatin1String HighlightDefinitionMetaData::kVersion("version");
const QLatin1String HighlightDefinitionMetaData::kUrl("url");
HighlightDefinitionMetaData::HighlightDefinitionMetaData() : priority(0)
{}
......@@ -30,7 +30,6 @@
#ifndef HIGHLIGHTDEFINITIONMETADATA_H
#define HIGHLIGHTDEFINITIONMETADATA_H
#include <QString>
#include <QStringList>
#include <QUrl>
......@@ -40,14 +39,7 @@ namespace Internal {
class HighlightDefinitionMetaData
{
public:
HighlightDefinitionMetaData();
static const QLatin1String kPriority;
static const QLatin1String kName;
static const QLatin1String kExtensions;
static const QLatin1String kMimeType;
static const QLatin1String kVersion;
static const QLatin1String kUrl;
HighlightDefinitionMetaData() : priority(0) {}
public:
int priority;
......
......@@ -67,6 +67,13 @@
using namespace TextEditor;
using namespace Internal;
const char kPriority[] = "priority";
const char kName[] = "name";
const char kExtensions[] = "extensions";
const char kMimeType[] = "mimetype";
const char kVersion[] = "version";
const char kUrl[] = "url";
Manager::Manager() :
m_isDownloadingDefinitionsSpec(false),
m_hasQueuedRegistration(false)
......@@ -360,14 +367,13 @@ QSharedPointer<HighlightDefinitionMetaData> Manager::parseMetadata(const QFileIn
metaData->fileName = fileInfo.fileName();
metaData->id = fileInfo.absoluteFilePath();
metaData->name = atts.value(HighlightDefinitionMetaData::kName).toString();
metaData->version = atts.value(HighlightDefinitionMetaData::kVersion).toString();
metaData->priority = atts.value(HighlightDefinitionMetaData::kPriority).toString()
.toInt();
metaData->patterns = atts.value(HighlightDefinitionMetaData::kExtensions)
metaData->name = atts.value(QLatin1String(kName)).toString();
metaData->version = atts.value(QLatin1String(kVersion)).toString();
metaData->priority = atts.value(QLatin1String(kPriority)).toString().toInt();
metaData->patterns = atts.value(QLatin1String(kExtensions))
.toString().split(kSemiColon, QString::SkipEmptyParts);
QStringList mimeTypes = atts.value(HighlightDefinitionMetaData::kMimeType).
QStringList mimeTypes = atts.value(QLatin1String(kMimeType)).
toString().split(kSemiColon, QString::SkipEmptyParts);
if (mimeTypes.isEmpty()) {
// There are definitions which do not specify a MIME type, but specify file
......@@ -400,9 +406,9 @@ QList<HighlightDefinitionMetaData> Manager::parseAvailableDefinitionsList(QIODev
const QXmlStreamAttributes &atts = reader.attributes();
HighlightDefinitionMetaData metaData;
metaData.name = atts.value(HighlightDefinitionMetaData::kName).toString();
metaData.version = atts.value(HighlightDefinitionMetaData::kVersion).toString();
QString url(atts.value(HighlightDefinitionMetaData::kUrl).toString());
metaData.name = atts.value(QLatin1String(kName)).toString();
metaData.version = atts.value(QLatin1String(kVersion)).toString();
QString url = atts.value(QLatin1String(kUrl)).toString();
metaData.url = QUrl(url);
const int slash = url.lastIndexOf(kSlash);
if (slash != -1)
......
......@@ -56,7 +56,6 @@ SOURCES += texteditorplugin.cpp \
generichighlighter/highlightersettingspage.cpp \
generichighlighter/highlightersettings.cpp \
generichighlighter/managedefinitionsdialog.cpp \
generichighlighter/highlightdefinitionmetadata.cpp \
generichighlighter/definitiondownloader.cpp \
refactoringchanges.cpp \
refactoroverlay.cpp \
......
......@@ -212,7 +212,6 @@ QtcPlugin {
"highlightdefinition.h",
"highlightdefinitionhandler.cpp",
"highlightdefinitionhandler.h",
"highlightdefinitionmetadata.cpp",
"highlightdefinitionmetadata.h",
"highlighter.cpp",
"highlighter.h",
......
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