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

List:       kde-commits
Subject:    branches/KDE/3.5/kdewebdev/quanta
From:       Andras Mantia <amantia () kde ! org>
Date:       2006-09-09 10:21:44
Message-ID: 1157797304.893130.31777.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 582414 by amantia:

Make CSS completion work inside style attributes.

BUG: 80605

 M  +3 -0      ChangeLog  
 M  +2 -2      quanta.kdevelop  
 M  +47 -10    src/document.cpp  


--- branches/KDE/3.5/kdewebdev/quanta/ChangeLog #582413:582414
@@ -20,7 +20,10 @@
       - fix automatic updating of closing tags [#132357]
       - accept float numbers for length values [#130295]
 
+ - improvements:
+      - make CSS completion work inside style attributes [#80605]
 
+
 Version 3.5.4 (Release date: 02-08-2006; Started 24-06-2005):
  - bugfixes:
       - make Open File in context menu work for remote projects as well
--- branches/KDE/3.5/kdewebdev/quanta/quanta.kdevelop #582413:582414
@@ -245,10 +245,10 @@
   </kdevcvs>
   <kdevfilecreate>
     <filetypes>
-      <type icon="" ext="h" create="template" name="C++ header" >
+      <type icon="" ext="h" name="C++ header" create="template" >
         <descr>Quanta speicfic header</descr>
       </type>
-      <type icon="source_cpp" ext="cpp" create="template" name="C++ source" >
+      <type icon="source_cpp" ext="cpp" name="C++ source" create="template" >
         <descr>A new empty C++ file.</descr>
       </type>
     </filetypes>
--- branches/KDE/3.5/kdewebdev/quanta/src/document.cpp #582413:582414
@@ -1050,17 +1050,46 @@
          }
     else if ( string[0] == qConfig.attrValueQuotation )
           {
-          //we need to find the attribute name
-          QString textLine = editIf->textLine(line).left(column-1);
-          QString attribute = textLine.mid(textLine.findRev(' ')+1);
-          showCodeCompletions( getAttributeValueCompletions(tagName, attribute) );
-          handled = true;
+            //we need to find the attribute name
+            QString textLine = editIf->textLine(line).left(column-1);
+            QString attribute = textLine.mid(textLine.findRev(' ')+1);
+            if (attribute == "style" && completionDTD->insideDTDs.contains("css"))
+            {
+              completionDTD = DTDs::ref()->find("text/css");
+              completionRequested = true;
+              return scriptAutoCompletion(line, column + 1, string);
+            }
+            showCodeCompletions( getAttributeValueCompletions(tagName, attribute) );
+            handled = true;
           }
   } // else - we are inside of a tag
   if (!handled)
   {
+    //check if we are inside a style attribute, and use css autocompletion if we are
+    QString textLine = editIf->textLine(line);
+    textLine = textLine.left(column);
+    int pos = textLine.findRev('"');
+    if (pos != -1)
+    {
+      pos = textLine.findRev(' ', pos);
+      if (pos != -1)
+      {
+        textLine = textLine.mid(pos + 1);
+        pos = textLine.find('=');
+        if (pos != -1)
+        {
+          QString attribute = textLine.left(pos);
+          if (attribute == "style" && completionDTD->insideDTDs.contains("css"))
+          {
+            completionDTD = DTDs::ref()->find("text/css");
+            completionRequested = true;
+            return scriptAutoCompletion(line, column + 1, string);
+          }
+        }
+      }
+    }
     QString s = editIf->textLine(line).left(column + 1);
-    int pos = s.findRev('&');
+    pos = s.findRev('&');
     if (pos != -1)
     {
       //complete character codes
@@ -2064,10 +2093,18 @@
       index = tag->valueIndexAtPos(line,col);
       if (index != -1)      //inside a value
       {
-        tag->attributeValuePos(index, bLine, bCol);
-        s = tag->attributeValue(index).left(col - bCol);
-        showCodeCompletions( getAttributeValueCompletions(tagName, tag->attribute(index), s) );
-        handled = true;
+        s = tag->attribute(index);
+        if (s == "style" && completionDTD->insideDTDs.contains("css"))
+        {
+          completionDTD = DTDs::ref()->find("text/css");
+          return scriptAutoCompletion(line, col, "");
+        } else
+        {
+          tag->attributeValuePos(index, bLine, bCol);
+          s = tag->attributeValue(index).left(col - bCol);
+          showCodeCompletions( getAttributeValueCompletions(tagName, tag->attribute(index), s) );
+          handled = true;
+        }
       } else
       {
         index = tag->attributeIndexAtPos(line,col);
[prev in list] [next in list] [prev in thread] [next in thread] 

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