[prev in list] [next in list] [prev in thread] [next in thread]
List: quanta-devel
Subject: Re: [quanta-devel] Style edtition
From: Luciano Gulmini <gulmini.luciano () student ! unife ! it>
Date: 2005-04-21 19:22:11
Message-ID: 4268196A.8010108 () student ! unife ! it
[Download RAW message or body]
Paulo Moura Guedes ha scritto:
>Hi,
>
>Similar to the Attribute Editor with could have a Style Editor, that would
>manipulate CSS properties of a tag. It could be separated in meaning tabs,
>like layout, font, background, etc, with the most important properties.
>At first, this edition would only be applied in an external CSS file. I
>remember Andras saying we would need a CSS parser but, in this cenario, I see
>that CSS editor does everything we would need.
>Can you advise me on this, as I don't know the Quanta CSS code?
>
>
Hi everybody,
it's been a long time I'm not on this list ( still 3 months before my
enlistment would terminate ) : hope everything's OK with all you guys.
It's the first time I open my e-mail browser since my enlistment ( about
7 months ) so I don't exactly know what's the subject of this thread but
I see you need information on some of the internals of the CSS editor :
hope what I'm going to write is what you need.
The CSS editor uses a very simple parser that extracts information from
data passed as text .It simply splits that text into the various
elements putting them in a
QMap<QString, QPair<QString,unsigned int> >
that reflects the original disposition of the various elements in their
original CSS style sheet, for example, suppose you have this css file :
/*this is a css file */
div {background:teal;}
span {color:blue}
/*this is another comment
continuing comment*/
The parser will split this in :
/*this is a css file*/
div {background:teal;border:none}
span {color:blue}
/*this is another comment continuing comment*/
mantaining information of this disposition.
The QPair<QString,unsigned int> used in the map holds the value of an
element ( for example background:teal;border:none) and an order position
( in this case 2) while the QString index in the QMap holds the name of
the elements ( in this case div; for a comment the name is /* followed
by the order position, for an at rule is a @rule followed by the order
position)
There's only one other thing : the parser can be stopped if the data are
not correct emitting
the signal
errorOccurred(const QString&)
It's emitted when selectors,comments, @rules are not properly closed
(with some problems in the case of @rules as the code is still buggy)
The code is made of a single class
class stylesheetParser : public QObject{
Q_OBJECT
private:
enum parenthesisKind { opened, closed };
QString m_styleSheet;//the text containing the data
bool m_stopProcessing;//flag telling the parser to stop
unsigned int m_orderNumber;
QMap<QString, QPair<QString,unsigned int> > m_stylesheetStructure;
void parseComment();
void parseSelector();
void parseAtRules1();//parses block terminated @rules
void parseAtRules2();//parses ; terminated @rules
int whiteSpaces(int);//facility method for counting whitespaces
unsigned int numberOfParenthesisInAParenthesisBlock(parenthesisKind
p, const QString& b);//obvious
public:
stylesheetParser(const QString& s);
~stylesheetParser(){}
void parse();
QMap<QString, QPair<QString,unsigned int> > stylesheetStructure() {
return m_stylesheetStructure; }
unsigned int orderNumber() const {return m_orderNumber; }
signals:
void errorOccurred(const QString&);
};
All the code is in stylesheetparser.h/cpp
This is all.
Luciano
_______________________________________________
quanta-devel mailing list
quanta-devel@kde.org
https://mail.kde.org/mailman/listinfo/quanta-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic