Commit e07e9145 authored by con's avatar con
Browse files

External tools need a uid, e.g. for keyboard shortcuts.

parent 51ae5f63
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
** **
**************************************************************************/ **************************************************************************/
--> -->
<externaltool> <externaltool id="lrelease">
<description>Creates qm translation files that can be used by an application from the translator's ts files</description> <description>Creates qm translation files that can be used by an application from the translator's ts files</description>
<description xml:lang="de">Erstellt die von Anwendungen nutzbaren qm-Dateien aus ts-Dateien von Übersetzern</description> <description xml:lang="de">Erstellt die von Anwendungen nutzbaren qm-Dateien aus ts-Dateien von Übersetzern</description>
<displayname>Release translations (lrelease)</displayname> <displayname>Release translations (lrelease)</displayname>
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
** **
**************************************************************************/ **************************************************************************/
--> -->
<externaltool> <externaltool id="lupdate">
<description>Synchronizes translator's ts files with the program code</description> <description>Synchronizes translator's ts files with the program code</description>
<description xml:lang="de">Synchronisiert die ts-Übersetzungsdateien mit dem Programmcode</description> <description xml:lang="de">Synchronisiert die ts-Übersetzungsdateien mit dem Programmcode</description>
<displayname>Update translations (lupdate)</displayname> <displayname>Update translations (lupdate)</displayname>
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
** **
**************************************************************************/ **************************************************************************/
--> -->
<externaltool> <externaltool id="sort">
<description>Sorts the selected text</description> <description>Sorts the selected text</description>
<description xml:lang="de">Sortiert den ausgewählten Text</description> <description xml:lang="de">Sortiert den ausgewählten Text</description>
<displayname>Sort</displayname> <displayname>Sort</displayname>
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
** **
**************************************************************************/ **************************************************************************/
--> -->
<externaltool> <externaltool id="vi">
<description>Opens the current file in vi</description> <description>Opens the current file in vi</description>
<description xml:lang="de">Öffnet die aktuelle Datei in vi</description> <description xml:lang="de">Öffnet die aktuelle Datei in vi</description>
<displayname>Edit with vi</displayname> <displayname>Edit with vi</displayname>
......
...@@ -59,6 +59,11 @@ ExternalTool::ExternalTool() : ...@@ -59,6 +59,11 @@ ExternalTool::ExternalTool() :
{ {
} }
QString ExternalTool::id() const
{
return m_id;
}
QString ExternalTool::description() const QString ExternalTool::description() const
{ {
return m_description; return m_description;
...@@ -153,6 +158,9 @@ ExternalTool * ExternalTool::createFromXml(const QString &xml, QString *errorMes ...@@ -153,6 +158,9 @@ ExternalTool * ExternalTool::createFromXml(const QString &xml, QString *errorMes
if (!reader.readNextStartElement() || reader.name() != QLatin1String(kExternalTool)) if (!reader.readNextStartElement() || reader.name() != QLatin1String(kExternalTool))
reader.raiseError(QLatin1String("Missing start element <externaltool>")); reader.raiseError(QLatin1String("Missing start element <externaltool>"));
tool->m_id = reader.attributes().value(QLatin1String("id")).toString();
if (tool->m_id.isEmpty())
reader.raiseError(QLatin1String("Missing or empty id attribute for <externaltool>"));
while (reader.readNextStartElement()) { while (reader.readNextStartElement()) {
if (reader.name() == QLatin1String(kDescription)) { if (reader.name() == QLatin1String(kDescription)) {
localizedText(locales, &reader, &descriptionLocale, &tool->m_description); localizedText(locales, &reader, &descriptionLocale, &tool->m_description);
......
...@@ -47,6 +47,7 @@ public: ...@@ -47,6 +47,7 @@ public:
ExternalTool(); ExternalTool();
QString id() const;
QString description() const; QString description() const;
QString displayName() const; QString displayName() const;
QString displayCategory() const; QString displayCategory() const;
...@@ -60,6 +61,7 @@ public: ...@@ -60,6 +61,7 @@ public:
static ExternalTool *createFromXml(const QString &xml, QString *errorMessage = 0, const QString &locale = QString()); static ExternalTool *createFromXml(const QString &xml, QString *errorMessage = 0, const QString &locale = QString());
private: private:
QString m_id;
QString m_description; QString m_description;
QString m_displayName; QString m_displayName;
QString m_displayCategory; QString m_displayCategory;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
using namespace Core::Internal; using namespace Core::Internal;
static const char * const TEST_XML1 = static const char * const TEST_XML1 =
"<externaltool>" "<externaltool id=\"lupdate\">"
" <description>Synchronizes translator's ts files with the program code</description>" " <description>Synchronizes translator's ts files with the program code</description>"
" <description xml:lang=\"de\">Synchronisiert die ts-Übersetzungsdateien mit dem Programmcode</description>" " <description xml:lang=\"de\">Synchronisiert die ts-Übersetzungsdateien mit dem Programmcode</description>"
" <displayname>Update translations (lupdate)</displayname>" " <displayname>Update translations (lupdate)</displayname>"
...@@ -24,7 +24,7 @@ static const char * const TEST_XML1 = ...@@ -24,7 +24,7 @@ static const char * const TEST_XML1 =
; ;
static const char * const TEST_XML2 = static const char * const TEST_XML2 =
"<externaltool>" "<externaltool id=\"sort\">"
" <description>Sorts the selected text</description>" " <description>Sorts the selected text</description>"
" <description xml:lang=\"de\">Sortiert den ausgewählten Text</description>" " <description xml:lang=\"de\">Sortiert den ausgewählten Text</description>"
" <displayname>Sort</displayname>" " <displayname>Sort</displayname>"
...@@ -39,7 +39,7 @@ static const char * const TEST_XML2 = ...@@ -39,7 +39,7 @@ static const char * const TEST_XML2 =
"</externaltool>"; "</externaltool>";
static const char * const TEST_XML3 = static const char * const TEST_XML3 =
"<externaltool>" "<externaltool id=\"vi\">"
" <description>Opens the current file in vi</description>" " <description>Opens the current file in vi</description>"
" <description xml:lang=\"de\">Öffnet die aktuelle Datei in vi</description>" " <description xml:lang=\"de\">Öffnet die aktuelle Datei in vi</description>"
" <displayname>Edit with vi</displayname>" " <displayname>Edit with vi</displayname>"
...@@ -54,7 +54,7 @@ static const char * const TEST_XML3 = ...@@ -54,7 +54,7 @@ static const char * const TEST_XML3 =
"</externaltool>"; "</externaltool>";
static const char * const TEST_XML_LANG = static const char * const TEST_XML_LANG =
"<externaltool>" "<externaltool id=\"temp\">"
" <description>Hi</description>" " <description>Hi</description>"
" <description xml:lang=\"de\">Hallo</description>" " <description xml:lang=\"de\">Hallo</description>"
" <description xml:lang=\"de_CH\">Grüezi</description>" " <description xml:lang=\"de_CH\">Grüezi</description>"
...@@ -86,6 +86,7 @@ void ExternaltoolTest::testRead1() ...@@ -86,6 +86,7 @@ void ExternaltoolTest::testRead1()
ExternalTool *tool = ExternalTool::createFromXml(QLatin1String(TEST_XML1), &error); ExternalTool *tool = ExternalTool::createFromXml(QLatin1String(TEST_XML1), &error);
QVERIFY(tool != 0); QVERIFY(tool != 0);
QVERIFY(error.isEmpty()); QVERIFY(error.isEmpty());
QCOMPARE(tool->id(), QString::fromLatin1("lupdate"));
QVERIFY(tool->description().startsWith(QLatin1String("Synchronizes tran"))); QVERIFY(tool->description().startsWith(QLatin1String("Synchronizes tran")));
QCOMPARE(tool->displayName(), QString::fromLatin1("Update translations (lupdate)")); QCOMPARE(tool->displayName(), QString::fromLatin1("Update translations (lupdate)"));
QCOMPARE(tool->displayCategory(), QString::fromLatin1("Linguist")); QCOMPARE(tool->displayCategory(), QString::fromLatin1("Linguist"));
...@@ -105,6 +106,7 @@ void ExternaltoolTest::testRead2() ...@@ -105,6 +106,7 @@ void ExternaltoolTest::testRead2()
ExternalTool *tool = ExternalTool::createFromXml(QLatin1String(TEST_XML2), &error); ExternalTool *tool = ExternalTool::createFromXml(QLatin1String(TEST_XML2), &error);
QVERIFY(tool != 0); QVERIFY(tool != 0);
QVERIFY(error.isEmpty()); QVERIFY(error.isEmpty());
QCOMPARE(tool->id(), QString::fromLatin1("sort"));
QVERIFY(tool->description().startsWith(QLatin1String("Sorts the"))); QVERIFY(tool->description().startsWith(QLatin1String("Sorts the")));
QCOMPARE(tool->displayName(), QString::fromLatin1("Sort")); QCOMPARE(tool->displayName(), QString::fromLatin1("Sort"));
QCOMPARE(tool->displayCategory(), QString::fromLatin1("Text")); QCOMPARE(tool->displayCategory(), QString::fromLatin1("Text"));
...@@ -123,6 +125,7 @@ void ExternaltoolTest::testRead3() ...@@ -123,6 +125,7 @@ void ExternaltoolTest::testRead3()
ExternalTool *tool = ExternalTool::createFromXml(QLatin1String(TEST_XML3), &error); ExternalTool *tool = ExternalTool::createFromXml(QLatin1String(TEST_XML3), &error);
QVERIFY(tool != 0); QVERIFY(tool != 0);
QVERIFY(error.isEmpty()); QVERIFY(error.isEmpty());
QCOMPARE(tool->id(), QString::fromLatin1("vi"));
QVERIFY(tool->description().startsWith(QLatin1String("Opens the"))); QVERIFY(tool->description().startsWith(QLatin1String("Opens the")));
QCOMPARE(tool->displayName(), QString::fromLatin1("Edit with vi")); QCOMPARE(tool->displayName(), QString::fromLatin1("Edit with vi"));
QCOMPARE(tool->displayCategory(), QString::fromLatin1("Text")); QCOMPARE(tool->displayCategory(), QString::fromLatin1("Text"));
......
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