[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdewebdev/quanta
From:       Andras Mantia <amantia () kde ! org>
Date:       2008-04-18 15:18:30
Message-ID: 1208531910.439265.14682.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 798551 by amantia:

Add some functionality to the structure tree:
- click : go to the tag
- double click (activate): select the active tag area

Parser: <!DOCTYPE> tag should not have children. Maybe this needs to be handled in \
the parser, not the builder though,

 M  +15 -0     lib/dommodel.cpp  
 M  +1 -0      lib/dommodel.h  
 M  +6 -1      lib/editorsource.cpp  
 M  +10 -0     lib/editorsource.h  
 M  +3 -0      plugins/structuretree/structuretreepart.cpp  
 M  +46 -0     plugins/structuretree/structuretreeview.cpp  
 M  +14 -2     plugins/structuretree/structuretreeview.h  
 M  +19 -19    quanta.kdevelop  
 M  +2 -30     quanta.kdevelop.filelist  
 M  +8 -3      quantacore/parsers/dombuilder.cpp  
 M  +12 -0     quantacore/quantacorepart.cpp  
 M  +8 -1      quantacore/quantacorepart.h  


--- trunk/KDE/kdewebdev/quanta/lib/dommodel.cpp #798550:798551
@@ -13,6 +13,7 @@
 
 //own includes
 #include "dommodel.h"
+#include "areastruct.h"
 
 //qt includes
 #include <QVariant>
@@ -61,6 +62,20 @@
 
 QVariant DomModelItem::data(int column, int role) const
 {  
+  if (role == Qt::UserRole)
+  {
+    switch (column)
+    {
+      case 0: 
+      {
+        AreaStruct *area = new AreaStruct(m_range->start().line(), \
m_range->start().column(), m_range->end().line(), m_range->end().column()); +        \
return qVariantFromValue((void*)area); +      }     
+      default:
+        return QVariant();      
+    }
+  }
+      
   if (role != Qt::DisplayRole)
     return QVariant();
 
--- trunk/KDE/kdewebdev/quanta/lib/dommodel.h #798550:798551
@@ -33,6 +33,7 @@
       TagEnd,
       Text,
       Comment,
+      DocType,
       Empty
     };
     
--- trunk/KDE/kdewebdev/quanta/lib/editorsource.cpp #798550:798551
@@ -178,10 +178,15 @@
 
 void EditorSource::selectArea(const AreaStruct &area)
 {
-  m_view->setSelection(KTextEditor::Range(area.bLine(), area.bCol(), area.eLine(), \
area.eCol() + 1));  m_view->setFocus();
+  m_view->setSelection(KTextEditor::Range(area.bLine(), area.bCol(), area.eLine(), \
area.eCol()));  }
 
+void EditorSource::selectRange(const KTextEditor::Range &range)
+{
+  m_view->setFocus();
+  m_view->setSelection(range);
+}
 
 void EditorSource::setCursorPosition(int line, int col)
 {
--- trunk/KDE/kdewebdev/quanta/lib/editorsource.h #798550:798551
@@ -25,6 +25,10 @@
  class IDocument; 
 }
 
+namespace KTextEditor {
+  class Range;
+}
+
 /**
 This class can be used to access the editor functionality in an abstracted way.
 
@@ -109,6 +113,12 @@
    */
   void selectArea(const AreaStruct &area);
 
+  /**set the selection to the area and get the focus
+   *
+   * @param area
+   */
+  void selectRange(const KTextEditor::Range &range);
+  
   /** move the cursor to a new position and get the focus
    *
    * @param line
--- trunk/KDE/kdewebdev/quanta/plugins/structuretree/structuretreepart.cpp \
#798550:798551 @@ -82,6 +82,9 @@
       QObject::connect(corePlugin, SIGNAL(finishedParsing(const ParseResult *)), \
documentTree, SLOT(newDataArrived(const ParseResult *)));  
       QObject::connect(corePlugin, SIGNAL(newCursorPosition(const QPoint &)), \
documentTree, SLOT(slotNewCursorPosition(const QPoint &))); +      
+      QObject::connect(documentTree, SIGNAL(selectRange(const KTextEditor::Range \
&)), corePlugin ,SLOT(selectRange(const KTextEditor::Range &))); +      \
QObject::connect(documentTree, SIGNAL(setCursorPosition(const KTextEditor::Cursor \
&)), corePlugin ,SLOT(setCursorPosition(const KTextEditor::Cursor &)));  
       QTreeView *groupsTree = new QTreeView(widget);
 #if 0
--- trunk/KDE/kdewebdev/quanta/plugins/structuretree/structuretreeview.cpp \
#798550:798551 @@ -17,10 +17,18 @@
 #include "parseresult.h"
 #include "dommodel.h"
 
+#include <ktexteditor/range.h>
+
+#include <QHeaderView>
+#include <QModelIndex>
+
 StructureTreeView::StructureTreeView(QWidget *parent)
  : QTreeView(parent)
 {
   m_parseResult = 0L;
+  connect(this, SIGNAL(activated(const QModelIndex &)), this, \
SLOT(modelIndexActivated(const QModelIndex &))); +  connect(this, \
SIGNAL(clicked(const QModelIndex &)), this, SLOT(modelIndexClicked(const QModelIndex \
&))); +  header()->hide();
 }
 
 
@@ -32,7 +40,45 @@
 {
   m_parseResult = data;
   if (data)
+  {
     setModel(m_parseResult->model);
+    expandToDepth(2);
+  }
   else
     setModel(0L);
 }
+
+void StructureTreeView::modelIndexActivated(const QModelIndex &index)
+{
+  DomModelItem *item = static_cast<DomModelItem*>(index.internalPointer());
+  if (!item)
+    return;
+  
+  KTextEditor::Range range(*(item->range()));
+  if (item->type() == DomModelItem::TagStart && item->parent())
+  {
+    int row = item->row();
+    DomModelItem *closingItem = item->parent()->child(row + 1);
+    if (closingItem)
+    {
+      range.end() = closingItem->range()->end();
+    }
+  } 
+  
+  emit selectRange(range);
+}
+
+void StructureTreeView::modelIndexClicked(const QModelIndex &index)
+{
+  DomModelItem *item = static_cast<DomModelItem*>(index.internalPointer());
+  if (!item)
+    return;
+  
+  KTextEditor::Cursor cursor(item->range()->start());
+  if (item->type() == DomModelItem::TagStart || item->type() == \
DomModelItem::TagEnd) +  {
+    cursor.setColumn(cursor.column() + 1);
+  } 
+  
+  emit setCursorPosition(cursor);
+}
--- trunk/KDE/kdewebdev/quanta/plugins/structuretree/structuretreeview.h \
#798550:798551 @@ -19,6 +19,10 @@
 #include <QTreeView>
 
 class ParseResult;
+namespace KTextEditor {
+  class Cursor;
+  class Range;
+}
 
 /**
 	@author Andras Mantia <amantia@kde.org>
@@ -35,8 +39,16 @@
   
   void newDataArrived(const ParseResult *data);
 
-  private:
-    const ParseResult *m_parseResult;
+Q_SIGNALS:
+  void selectRange(const KTextEditor::Range &range);
+  void setCursorPosition(const KTextEditor::Cursor &cursor);
+    
+private Q_SLOTS:    
+  void modelIndexActivated(const QModelIndex &index);
+  void modelIndexClicked(const QModelIndex &index);
+  
+private:
+  const ParseResult *m_parseResult;
 };
 
 #endif
--- trunk/KDE/kdewebdev/quanta/quanta.kdevelop #798550:798551
@@ -14,8 +14,8 @@
     <secondaryLanguages>
       <language>C</language>
     </secondaryLanguages>
-    <description></description>
-    <defaultencoding></defaultencoding>
+    <description/>
+    <defaultencoding/>
     <versioncontrol/>
     <projectname>quanta</projectname>
   </general>
@@ -38,7 +38,7 @@
         <envvar value="/opt/qt4" name="QTDIR" />
         <envvar value="/opt/kde4/share:$XDG_DATA_DIRS" name="XDG_DATA_DIRS" />
       </envvars>
-      <globaldebugarguments></globaldebugarguments>
+      <globaldebugarguments/>
       <globalcwd>/data/development/build/kde-trunk/kdewebdev</globalcwd>
       <useglobalprogram>false</useglobalprogram>
       <autoinstall>false</autoinstall>
@@ -52,7 +52,7 @@
       <abortonerror>true</abortonerror>
       <numberofjobs>2</numberofjobs>
       <dontact>false</dontact>
-      <makebin></makebin>
+      <makebin/>
       <selectedenvironment>default</selectedenvironment>
       <environments>
         <default>
@@ -64,8 +64,8 @@
         </default>
       </environments>
       <prio>0</prio>
-      <defaulttarget></defaulttarget>
-      <makeoptions></makeoptions>
+      <defaulttarget/>
+      <makeoptions/>
     </make>
     <general>
       <projectmanagement>KDevCustomProject</projectmanagement>
@@ -92,9 +92,9 @@
     <blacklist/>
     <other>
       <prio>0</prio>
-      <otherbin></otherbin>
-      <defaulttarget></defaulttarget>
-      <otheroptions></otheroptions>
+      <otherbin/>
+      <defaulttarget/>
+      <otheroptions/>
       <selectedenvironment>default</selectedenvironment>
       <environments>
         <default/>
@@ -103,16 +103,16 @@
   </kdevcustomproject>
   <kdevfilecreate>
     <filetypes>
-      <type icon="source_cpp" ext="cpp" name="C++ Source" create="template" >
+      <type icon="source_cpp" ext="cpp" create="template" name="C++ Source" >
         <descr>A new empty C++ file.</descr>
       </type>
-      <type icon="source_h" ext="h" name="C/C++ Header" create="template" >
+      <type icon="source_h" ext="h" create="template" name="C/C++ Header" >
         <descr>A new empty header file for C or C++.</descr>
       </type>
-      <type icon="source_cpp" ext="cpp" name="C++ Source" create="template" >
+      <type icon="source_cpp" ext="cpp" create="template" name="C++ Source" >
         <descr>A new empty C++ file.</descr>
       </type>
-      <type icon="source_f" ext="for" name="Preprocessed Fortran" create="template" \
> +      <type icon="source_f" ext="for" create="template" name="Preprocessed \
> Fortran" >
         <descr>A new empty preprocessed Fortran file.</descr>
       </type>
     </filetypes>
@@ -184,7 +184,7 @@
       </designerpluginpaths>
     </qt>
     <creategettersetter>
-      <prefixGet></prefixGet>
+      <prefixGet/>
       <prefixSet>set</prefixSet>
       <prefixVariable>m_,_</prefixVariable>
       <parameterName>theValue</parameterName>
@@ -217,11 +217,11 @@
       <projectdirectory>/data/development/sources/kde-trunk/kdewebdev</projectdirectory>
  <absoluteprojectpath>true</absoluteprojectpath>
       <programargs/>
-      <gdbpath></gdbpath>
-      <dbgshell></dbgshell>
-      <configGdbScript></configGdbScript>
-      <runShellScript></runShellScript>
-      <runGdbScript></runGdbScript>
+      <gdbpath/>
+      <dbgshell/>
+      <configGdbScript/>
+      <runShellScript/>
+      <runGdbScript/>
       <breakonloadinglibs>true</breakonloadinglibs>
       <separatetty>false</separatetty>
       <floatingtoolbar>false</floatingtoolbar>
--- trunk/KDE/kdewebdev/quanta/quanta.kdevelop.filelist #798550:798551
@@ -541,8 +541,6 @@
 quanta/lib/helper.h
 quanta/lib/myprocess.cpp
 quanta/lib/myprocess.h
-quanta/lib/node.cpp
-quanta/lib/node.h
 quanta/lib/parseresult.h
 quanta/lib/qtag.cpp
 quanta/lib/qtag.h
@@ -559,18 +557,10 @@
 quanta/lib/settings.cpp
 quanta/lib/settings.h
 quanta/lib/settingsbase.kcfgc
-quanta/lib/structuretreeview.cpp
-quanta/lib/structuretreeview.h
-quanta/lib/tag.cpp
-quanta/lib/tag.h
-quanta/lib/tagattr.cpp
-quanta/lib/tagattr.h
 quanta/lib/tagdialogsif.cpp
 quanta/lib/tagdialogsif.h
 quanta/lib/tagpair.cpp
 quanta/lib/tagpair.h
-quanta/lib/treelement.cpp
-quanta/lib/treelement.h
 quanta/lib/useraction.cpp
 quanta/lib/useraction.h
 quanta/plugins
@@ -656,14 +646,6 @@
 quanta/plugins/project/quantaproject/quantaprojectprojectconfigbase.ui
 quanta/plugins/structuretree
 quanta/plugins/structuretree/CMakeLists.txt
-quanta/plugins/structuretree/groupstreeitem.cpp
-quanta/plugins/structuretree/groupstreeitem.h
-quanta/plugins/structuretree/groupswidget.cpp
-quanta/plugins/structuretree/groupswidget.h
-quanta/plugins/structuretree/structtreebranch.cpp
-quanta/plugins/structuretree/structtreebranch.h
-quanta/plugins/structuretree/structtreeitem.cpp
-quanta/plugins/structuretree/structtreeitem.h
 quanta/plugins/structuretree/structuretreeglobalconfig.cpp
 quanta/plugins/structuretree/structuretreeglobalconfig.h
 quanta/plugins/structuretree/structuretreeglobalconfigbase.ui
@@ -672,8 +654,8 @@
 quanta/plugins/structuretree/structuretreeprojectconfig.cpp
 quanta/plugins/structuretree/structuretreeprojectconfig.h
 quanta/plugins/structuretree/structuretreeprojectconfigbase.ui
-quanta/plugins/structuretree/structuretreewidget.cpp
-quanta/plugins/structuretree/structuretreewidget.h
+quanta/plugins/structuretree/structuretreeview.cpp
+quanta/plugins/structuretree/structuretreeview.h
 quanta/plugins/tagdialogs
 quanta/plugins/tagdialogs/CMakeLists.txt
 quanta/plugins/tagdialogs/attributes.cpp
@@ -810,16 +792,10 @@
 quanta/quantacore/parsers/comparator.h
 quanta/quantacore/parsers/dombuilder.cpp
 quanta/quantacore/parsers/dombuilder.h
-quanta/quantacore/parsers/dommodel.cpp
-quanta/quantacore/parsers/dommodel.h
 quanta/quantacore/parsers/dtd
 quanta/quantacore/parsers/dtd/dtdparser.cpp
 quanta/quantacore/parsers/dtd/dtdparser.h
 quanta/quantacore/parsers/dtd/dtepcreationdlg.ui
-quanta/quantacore/parsers/parser.cpp
-quanta/quantacore/parsers/parser.h
-quanta/quantacore/parsers/parsercommon.cpp
-quanta/quantacore/parsers/parsercommon.h
 quanta/quantacore/parsers/parsermanager.cpp
 quanta/quantacore/parsers/parsermanager.h
 quanta/quantacore/parsers/parserstatus.cpp
@@ -827,10 +803,6 @@
 quanta/quantacore/parsers/quantahandler.h
 quanta/quantacore/parsers/quantaxmlinputsource.cpp
 quanta/quantacore/parsers/quantaxmlinputsource.h
-quanta/quantacore/parsers/sagroupparser.cpp
-quanta/quantacore/parsers/sagroupparser.h
-quanta/quantacore/parsers/saparser.cpp
-quanta/quantacore/parsers/saparser.h
 quanta/quantacore/parsers/stateactions.cpp
 quanta/quantacore/parsers/stateactions.h
 quanta/quantacore/parsers/statemachine.cpp
--- trunk/KDE/kdewebdev/quanta/quantacore/parsers/dombuilder.cpp #798550:798551
@@ -123,7 +123,7 @@
   
   if (emptyElement)
   {
-    emptyElement->setName("endElement");
+    emptyElement->setName("Empty area before endElement");
     emptyElement->setRange(new KTextEditor::Range(m_lastInserted->range()->end(), \
m_elementRange.start()));  }
   
@@ -187,7 +187,7 @@
   {
     DomModelItem *el = new DomModelItem(m_currentElement);
     el->setRange(new KTextEditor::Range(m_lastInserted->range()->end(), \
                m_elementRange.start()));
-    el->setName("startElement");
+    el->setName("Empty area before startElement");
   }
   
   m_lastInserted = new DomModelItem(m_currentElement);
@@ -210,7 +210,11 @@
   
   m_lastInserted->setRange(new KTextEditor::Range(m_elementRange));
   m_lastInserted->setAttributeRanges(m_attrRanges);
-  m_currentElement = m_lastInserted;
+  if (localName.startsWith("DOCTYPE "))
+  {
+    m_lastInserted->setType(DomModelItem::DocType);
+  } else
+    m_currentElement = m_lastInserted;
   return true;
 }
 
@@ -238,6 +242,7 @@
       el = new DomModelItem(m_currentElement->parent());
     }
     el->setRange(new KTextEditor::Range(m_lastInserted->range()->end(), \
m_elementRange.start())); +    el->setName("Empty area before comment");
   }
   
   if (m_currentElement->type() != DomModelItem::Comment)
--- trunk/KDE/kdewebdev/quanta/quantacore/quantacorepart.cpp #798550:798551
@@ -59,6 +59,8 @@
 #include <iuicontroller.h>
 
 #include <ktexteditor/document.h>
+#include <ktexteditor/range.h>
+#include <ktexteditor/cursor.h>
 
 typedef KGenericFactory<QuantaCorePart> QuantaCoreFactory;
 K_EXPORT_COMPONENT_FACTORY(libkdevquantacore, QuantaCoreFactory("kdevquantacore"))
@@ -508,4 +510,14 @@
   return DTDs::ref()->getDTDNickNameFromName(name.toLower());
 }
 
+void QuantaCorePart::selectRange(const KTextEditor::Range &range)
+{
+  m_activeQuantaDoc->selectRange(range);
+}
+
+void QuantaCorePart::setCursorPosition(const KTextEditor::Cursor &cursor)
+{
+  m_activeQuantaDoc->setCursorPosition(cursor.line(), cursor.column());
+}
+
 #include "quantacorepart.moc"
--- trunk/KDE/kdewebdev/quanta/quantacore/quantacorepart.h #798550:798551
@@ -37,6 +37,11 @@
   class IDocument; 
 }
 
+namespace KTextEditor {
+  class Cursor;
+  class Range;
+}
+
 /**
 @author Andras Mantia
 */
@@ -108,7 +113,9 @@
    * @param dirInfo optional information for pre and post text
    */
   void slotInsertTag(const KUrl& url, Helper::DirInfo * dirInfo = 0);
-
+  
+  void selectRange(const KTextEditor::Range& area);
+  void setCursorPosition(const KTextEditor::Cursor &cursor);
 private slots:
 
   void init();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic