~ubuntu-branches/ubuntu/vivid/kate/vivid-updates

« back to all changes in this revision

Viewing changes to addons/kate/symbolviewer/xslt_parser.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2014-12-04 16:49:41 UTC
  • mfrom: (1.6.6)
  • Revision ID: package-import@ubuntu.com-20141204164941-l3qbvsly83hhlw2v
Tags: 4:14.11.97-0ubuntu1
* New upstream release
* Update build-deps and use pkg-kde v3 for Qt 5 build
* kate-data now kate5-data for co-installability

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
                          xslt_parser.cpp  -  description
3
 
                             -------------------
4
 
    begin                : Mar 28 2007
5
 
    author               : 2007 jiri Tyr
6
 
    email                : jiri.tyr@vslib.cz
7
 
 ***************************************************************************/
8
 
 /***************************************************************************
9
 
 *                                                                         *
10
 
 *   This program is free software; you can redistribute it and/or modify  *
11
 
 *   it under the terms of the GNU General Public License as published by  *
12
 
 *   the Free Software Foundation; either version 2 of the License, or     *
13
 
 *   (at your option) any later version.                                   *
14
 
 *                                                                         *
15
 
 ***************************************************************************/
16
 
 
17
 
#include "plugin_katesymbolviewer.h"
18
 
 
19
 
void KatePluginSymbolViewerView::parseXsltSymbols(void)
20
 
{
21
 
  if (!mainWindow()->activeView())
22
 
   return;
23
 
 
24
 
 m_macro->setText(i18n("Show Params"));
25
 
 m_struct->setText(i18n("Show Variables"));
26
 
 m_func->setText(i18n("Show Templates"));
27
 
 
28
 
 QString cl; // Current Line
29
 
 QString stripped;
30
 
 
31
 
 char comment = 0;
32
 
 char templ = 0;
33
 
 int i;
34
 
 
35
 
 QPixmap cls( ( const char** ) class_xpm );
36
 
 QPixmap sct( ( const char** ) struct_xpm );
37
 
 QPixmap mcr( ( const char** ) macro_xpm );
38
 
 QPixmap cls_int( ( const char** ) class_int_xpm );
39
 
 
40
 
 QTreeWidgetItem *node = NULL;
41
 
 QTreeWidgetItem *mcrNode = NULL, *sctNode = NULL, *clsNode = NULL;
42
 
 QTreeWidgetItem *lastMcrNode = NULL, *lastSctNode = NULL, *lastClsNode = NULL;
43
 
 
44
 
 KTextEditor::Document *kv = mainWindow()->activeView()->document();
45
 
 //kdDebug(13000)<<"Lines counted :"<<kv->numLines()<<endl;
46
 
 
47
 
 
48
 
 if(m_plugin->treeOn)
49
 
   {
50
 
    mcrNode = new QTreeWidgetItem(m_symbols, QStringList( i18n("Params") ) );
51
 
    sctNode = new QTreeWidgetItem(m_symbols, QStringList( i18n("Variables") ) );
52
 
    clsNode = new QTreeWidgetItem(m_symbols, QStringList( i18n("Templates") ) );
53
 
    mcrNode->setIcon(0, QIcon(mcr));
54
 
    sctNode->setIcon(0, QIcon(sct));
55
 
    clsNode->setIcon(0, QIcon(cls));
56
 
 
57
 
    if (m_plugin->expandedOn) 
58
 
      {
59
 
       m_symbols->expandItem(mcrNode);
60
 
       m_symbols->expandItem(sctNode);
61
 
       m_symbols->expandItem(clsNode);
62
 
      }
63
 
 
64
 
    lastMcrNode = mcrNode;
65
 
    lastSctNode = sctNode;
66
 
    lastClsNode = clsNode;
67
 
 
68
 
    m_symbols->setRootIsDecorated(1);
69
 
   }
70
 
 else
71
 
   {
72
 
    m_symbols->setRootIsDecorated(0);
73
 
   }
74
 
 
75
 
 for (i=0; i<kv->lines(); i++)
76
 
    {
77
 
     cl = kv->line(i);
78
 
     cl = cl.trimmed();
79
 
 
80
 
     if(cl.indexOf(QRegExp("<!--")) >= 0) { comment = 1; }
81
 
     if(cl.indexOf(QRegExp("-->")) >= 0) { comment = 0; continue; }
82
 
 
83
 
     if(cl.indexOf(QRegExp("^</xsl:template>")) >= 0) { templ = 0; continue; }
84
 
 
85
 
     if (comment==1) { continue; }
86
 
     if (templ==1) { continue; }
87
 
 
88
 
     if(cl.indexOf(QRegExp("^<xsl:param ")) == 0 && macro_on)
89
 
       {
90
 
        QString stripped = cl.remove(QRegExp("^<xsl:param +name=\""));
91
 
        stripped = stripped.remove(QRegExp("\".*"));
92
 
 
93
 
        if (m_plugin->treeOn)
94
 
          {
95
 
           node = new QTreeWidgetItem(mcrNode, lastMcrNode);
96
 
           lastMcrNode = node;
97
 
          }
98
 
        else node = new QTreeWidgetItem(m_symbols);
99
 
        node->setText(0, stripped);
100
 
        node->setIcon(0, QIcon(mcr));
101
 
        node->setText(1, QString::number( i, 10));
102
 
       }
103
 
 
104
 
     if(cl.indexOf(QRegExp("^<xsl:variable ")) == 0 && struct_on)
105
 
       {
106
 
        QString stripped = cl.remove(QRegExp("^<xsl:variable +name=\""));
107
 
        stripped = stripped.remove(QRegExp("\".*"));
108
 
 
109
 
        if (m_plugin->treeOn)
110
 
          {
111
 
           node = new QTreeWidgetItem(sctNode, lastSctNode);
112
 
           lastSctNode = node;
113
 
          }
114
 
        else node = new QTreeWidgetItem(m_symbols);
115
 
        node->setText(0, stripped);
116
 
        node->setIcon(0, QIcon(sct));
117
 
        node->setText(1, QString::number( i, 10));
118
 
       }
119
 
 
120
 
     if(cl.indexOf(QRegExp("^<xsl:template +match=")) == 0 && func_on)
121
 
       {
122
 
        QString stripped = cl.remove(QRegExp("^<xsl:template +match=\""));
123
 
        stripped = stripped.remove(QRegExp("\".*"));
124
 
 
125
 
        if (m_plugin->treeOn)
126
 
          {
127
 
           node = new QTreeWidgetItem(clsNode, lastClsNode);
128
 
           lastClsNode = node;
129
 
          }
130
 
        else node = new QTreeWidgetItem(m_symbols);
131
 
        node->setText(0, stripped);
132
 
        node->setIcon(0, QIcon(cls_int));
133
 
        node->setText(1, QString::number( i, 10));
134
 
       }
135
 
 
136
 
     if(cl.indexOf(QRegExp("^<xsl:template +name=")) == 0 && func_on)
137
 
       {
138
 
        QString stripped = cl.remove(QRegExp("^<xsl:template +name=\""));
139
 
        stripped = stripped.remove(QRegExp("\".*"));
140
 
 
141
 
        if (m_plugin->treeOn)
142
 
          {
143
 
           node = new QTreeWidgetItem(clsNode, lastClsNode);
144
 
           lastClsNode = node;
145
 
          }
146
 
        else node = new QTreeWidgetItem(m_symbols);
147
 
        node->setText(0, stripped);
148
 
        node->setIcon(0, QIcon(cls));
149
 
        node->setText(1, QString::number( i, 10));
150
 
 
151
 
       }
152
 
 
153
 
     if(cl.indexOf(QRegExp("<xsl:template")) >= 0) 
154
 
       {
155
 
        templ = 1;
156
 
       }
157
 
    }
158
 
}