Bug 119373

Summary: CSS class autocompletion does not ignore selectors
Product: quanta Reporter: Rolf Eike Beer <kde>
Component: generalAssignee: András Manţia <amantia>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: description.rc

Description Rolf Eike Beer 2006-01-02 11:04:21 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    SuSE RPMs

If you type 'class' for one element the autocompletion shows up. If there are CSS classes defined with :selector quanta does not ignore them. You can test by adding this to the header of a new HTML document:

<style type="text/css">
li.special:before {}
li.special:after {}
li.foo :before {}
li.foo :after {}
</style>

If you add a new <li> there should only be two valid classes to select: "special" and "foo". Instead there are "special:before", "special:after", "foo", "foo:before" and "foo:after" but no "special".
Comment 1 Rolf Eike Beer 2006-01-04 14:01:35 UTC
As I was told the second example is wrong, there must not be whitespace before the colon. Nevertheless the bug still is there.
Comment 2 András Manţia 2006-01-10 15:31:21 UTC
I have a question (I am not a web developer...). In case of 
<style type="text/css">
  li.special:before {}
  li.special:after {}
  li.foo:before {}
  li.foo:after {}
 A:link    { color: red }
 A:active  { color: blue; font-size: 125% }
 A:visited { color: green; font-size: 85% }
</style>

<li class="">
<a class=""></a>


What *exactly* should appear for the li class and for the a class?
Comment 3 Rolf Eike Beer 2006-01-10 15:34:02 UTC
For <li> there should be the choices "special" and "foo", for <a> none.
Comment 4 András Manţia 2006-01-10 15:50:27 UTC
Ok, then modify the $KDEDIR/share/apps/quanta/dtep/cdd/description.rc 
file so under [StructGroup_1] you replace the DefinitionRx line with 
this:

DefinitionRx = \s([\d\S\w]+):.*\b

Please report if you find some problem with this version related CSS 
selectors/class autocompletion.
Comment 5 Rolf Eike Beer 2006-01-11 09:36:10 UTC
Now I don't get any autocompletion at all.

It's not .../dtep/cdd/... but .../dtep/css/..., isn't it?
Comment 6 András Manţia 2006-01-11 10:22:05 UTC
On Wednesday 11 January 2006 10:36, Rolf Eike Beer wrote:
> Now I don't get any autocompletion at all.


That's strange, as for the example I pasted, I get foo and special for 
<li> and nothing for <a>.
Did you put in the global KDE folder (on 
suse /opt/kde3/share/apps/quanta/dtep/css)? I also have suse, although 
I'm using a self compiled KDE.

Anyway, i attach the version I have to test.

> It's not .../dtep/cdd/... but .../dtep/css/..., isn't it?



Yes, of course, I misstyped it.

Andras


Created an attachment (id=14207)
description.rc
Comment 7 Rolf Eike Beer 2006-01-11 10:26:59 UTC
Ah, I found the problem. I used a different example. Now autocompletion does not show up if the defined CSS does _not_ use selectors.
Comment 8 András Manţia 2006-01-11 11:08:26 UTC
SVN commit 496777 by amantia:

Don't show CSS pseudo-classes/elements in autocompletion for the class attribute.

BUG: 119373

 M  +2 -1      ChangeLog  
 M  +8 -2      src/dcopquanta.cpp  


--- branches/KDE/3.5/kdewebdev/quanta/ChangeLog #496776:496777
@@ -1,6 +1,6 @@
 This files contains the changes since Quanta 2.0 until the current 3.5.x series.
 
-Version 3.5.1 (Release date: 29-11-2005; Started 04-03-2004):
+Version 3.5.1 (Release date: xx-01-2006; Started 30-29-2005):
  - bugfixes:
         - better handling of quotation marks when editing tags inside a script area [#118693]
         - don't show the file changed dialog after using save as and save again
@@ -10,6 +10,7 @@
         - don't show the Pages tab in DTEP editing dialog more than once [#118840]
         - set the DTEP of the document to the one selected in the Quick Start dialog [#118814]
         - don't have two Close actions [#118448]
+        - don't show CSS pseudo-classes in autocompletion for the class attribute [#119373]
 
  - improvements:
         - add XHTML 1.1 and XHTML 1.0 Basic to the quickstart dialog [#118813]
--- branches/KDE/3.5/kdewebdev/quanta/src/dcopquanta.cpp #496776:496777
@@ -31,6 +31,7 @@
 
 QStringList DCOPQuanta::selectors(const QString& tag)
 {
+  const QRegExp rx("\\.|\\#|\\:");
   QStringList selectorList;
   GroupElementMapList::Iterator it;
   for ( it = globalGroupMap.begin(); it != globalGroupMap.end(); ++it )
@@ -39,8 +40,11 @@
     if (key.startsWith("Selectors|"))
     {
       QString selectorName = key.mid(10);
+      int index = selectorName.find(':');
+      if (index != -1)
+        selectorName = selectorName.mid(0, index);
       QString tmpStr;
-      int index = selectorName.find(QRegExp("\\.|\\#|\\:"));
+      index = selectorName.find(rx);
       if (index != -1)
       {
         tmpStr = selectorName.left(index).lower();
@@ -50,7 +54,9 @@
       }
       if (tmpStr.isEmpty() || tag.lower() == tmpStr || tmpStr == "*")
       {
-        selectorList << selectorName.mid(index + 1).replace('.',' ');
+        tmpStr = selectorName.mid(index + 1).replace('.',' ');
+        if (!tmpStr.isEmpty() && !selectorList.contains(tmpStr))
+          selectorList << tmpStr;
       }
      }
   }
Comment 9 András Manţia 2006-01-11 11:12:52 UTC
Unfortunately it seems the problem cannot be solved in a good way with 
the regular expression only, so I needed some code change as well. The 
fix will be in 3.5.1, if you want it sooner, see my commit message 
(soon it will be forwarded to the bug as well).
Comment 10 Rolf Eike Beer 2006-01-11 11:15:21 UTC
Thx