From 17e8387d9df3291172d561e31cb1fa064f908b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Thu, 28 Jan 2016 08:25:58 +0000 Subject: [PATCH] QPIConfig includes improvements git-svn-id: svn://db.shs.com.ru/libs@77 a8b55f48-bf90-11e4-a774-851b48703e85 --- kx_tools/CMakeLists.txt | 4 ++-- piqt_tools/CMakeLists.txt | 4 ++-- piqt_tools/piqt_highlighter.cpp | 9 +++++++++ piqt_tools/piqt_highlighter.h | 2 +- qad_utils/qpiconfig.cpp | 21 ++++++++++++++------- qad_utils/qpiconfig.h | 2 +- 6 files changed, 29 insertions(+), 13 deletions(-) diff --git a/kx_tools/CMakeLists.txt b/kx_tools/CMakeLists.txt index f0a9aa8..7658183 100644 --- a/kx_tools/CMakeLists.txt +++ b/kx_tools/CMakeLists.txt @@ -21,7 +21,7 @@ endif () target_link_libraries(kx_utils ${PIP_LIBRARY}) if (NOT DEFINED ENV{QNX_HOST}) - if (${KX_PULT}) + if (KX_PULT) find_package(Qt4 REQUIRED) include_directories(${QT_INCLUDES}) set(CPPS "kx_pult.cpp" "kx_pult.h" "kx_pult.ui" "main_kx_pult.cpp") @@ -56,7 +56,7 @@ else () endif () if (NOT DEFINED ENV{QNX_HOST}) - if (${KX_PULT}) + if (KX_PULT) install(TARGETS kx_pult DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) endif () endif () diff --git a/piqt_tools/CMakeLists.txt b/piqt_tools/CMakeLists.txt index 3122932..df81ba1 100644 --- a/piqt_tools/CMakeLists.txt +++ b/piqt_tools/CMakeLists.txt @@ -1,6 +1,6 @@ project(piqt_tools) cmake_minimum_required(VERSION 2.6) -if (NOT LIBPROJECT) +if (NOT ${LIBPROJECT}) find_package(PIP REQUIRED) endif () find_package(Qt4 REQUIRED) @@ -39,7 +39,7 @@ if (NOT DEFINED ENV{QNX_HOST}) endif () if (DEFINED LIB) - set(LIB 1) + set(LIB true) if (${WIN32}) find_package(MinGW REQUIRED) set(CMAKE_INSTALL_PREFIX ${MINGW_DIR}) diff --git a/piqt_tools/piqt_highlighter.cpp b/piqt_tools/piqt_highlighter.cpp index 636fce4..8e6ae64 100644 --- a/piqt_tools/piqt_highlighter.cpp +++ b/piqt_tools/piqt_highlighter.cpp @@ -26,6 +26,15 @@ ConfigHighlighter::ConfigHighlighter(QTextDocument * parent): QSyntaxHighlighter rule.format = sectionFormat; highlightingRules.append(rule); + //substFormat.setFontWeight(QFont::Bold); + substFormat.setForeground(QColor(192, 0, 192)); + rule.pattern = QRegExp("\\$\\{.*\\}+"); + rule.pattern.setMinimal(true); + rule.format = substFormat; + highlightingRules.append(rule); + rule.pattern = QRegExp("\\$\\{[^\\{]*\\}+"); + highlightingRules.append(rule); + singleLineCommentFormat.setFontItalic(true); singleLineCommentFormat.setForeground(QColor(128, 128, 128)); rule.pattern = QRegExp("#[^\n]*"); diff --git a/piqt_tools/piqt_highlighter.h b/piqt_tools/piqt_highlighter.h index 91037ee..1d481bb 100644 --- a/piqt_tools/piqt_highlighter.h +++ b/piqt_tools/piqt_highlighter.h @@ -25,7 +25,7 @@ private: QVector highlightingRules; QRegExp commentStartExpression, commentEndExpression; - QTextCharFormat singleLineCommentFormat, valueNameFormat, valueFormat, equalFormat, sectionFormat, spaceFormat; + QTextCharFormat singleLineCommentFormat, valueNameFormat, valueFormat, equalFormat, sectionFormat, spaceFormat, substFormat; }; #endif // CONF_HIGHTLIGHTER_H diff --git a/qad_utils/qpiconfig.cpp b/qad_utils/qpiconfig.cpp index 4bfadc1..bbd1cd2 100644 --- a/qad_utils/qpiconfig.cpp +++ b/qad_utils/qpiconfig.cpp @@ -688,7 +688,7 @@ void QPIConfig::updateIncludes() { } -QString QPIConfig::entryValue(QString v) { +QString QPIConfig::parseLine(QString v) { int i = -1, l = 0; while (1) { i = v.indexOf("${"); @@ -696,11 +696,18 @@ QString QPIConfig::entryValue(QString v) { l = v.indexOf("}", i + 1); QString w = v.mid(i + 2, l - i - 2), r; l = w.length() + 3; + w = parseLine(w); w = w.trimmed(); - foreach (QPIConfig::Entry * e, all_includes) { - if (e->_full_name == w) { - r = e->_value; - break; + bool ex = false; + QPIConfig::Entry & me = getValue(w, "", &ex); + if (ex) { + r = me._value; + } else { + foreach (QPIConfig::Entry * e, all_includes) { + if (e->_full_name == w) { + r = e->_value; + break; + } } } v.replace(i, l, r); @@ -735,7 +742,7 @@ void QPIConfig::parse(QString content) { lines = centry = 0; while (!stream.atEnd()) { other.push_back(QString()); - src = str = stream.readLine(); + src = str = parseLine(stream.readLine()); tprefix = getPrefixFromLine(src, &isPrefix); if (isPrefix) { prefix = tprefix; @@ -799,7 +806,7 @@ void QPIConfig::parse(QString content) { ce->delim = delim; ce->_tab = tab; ce->_name = name; - ce->_value = entryValue(str.right(str.length() - ind - 1).trimmed()); + ce->_value = str.right(str.length() - ind - 1).trimmed(); ce->_type = type; ce->_comment = comm; ce->_line = lines; diff --git a/qad_utils/qpiconfig.h b/qad_utils/qpiconfig.h index 4098f3f..32ac2eb 100644 --- a/qad_utils/qpiconfig.h +++ b/qad_utils/qpiconfig.h @@ -260,7 +260,7 @@ private: void deleteEntry(Entry * e) {foreach (Entry * i, e->_children) deleteEntry(i); delete e;} QString getPrefixFromLine(QString line, bool * exists); void updateIncludes(); - QString entryValue(QString v); + QString parseLine(QString v); void parse(QString content = QString()); int centry;