summaryrefslogtreecommitdiffstats
path: root/quanta/components/csseditor
diff options
context:
space:
mode:
Diffstat (limited to 'quanta/components/csseditor')
-rw-r--r--quanta/components/csseditor/Makefile.am18
-rw-r--r--quanta/components/csseditor/colorrequester.cpp129
-rw-r--r--quanta/components/csseditor/colorrequester.h50
-rw-r--r--quanta/components/csseditor/colorslider.cpp85
-rw-r--r--quanta/components/csseditor/colorslider.h69
-rw-r--r--quanta/components/csseditor/csseditor.cpp697
-rw-r--r--quanta/components/csseditor/csseditor.h117
-rw-r--r--quanta/components/csseditor/csseditor_globals.cpp50
-rw-r--r--quanta/components/csseditor/csseditor_globals.h63
-rw-r--r--quanta/components/csseditor/csseditors.ui411
-rw-r--r--quanta/components/csseditor/cssselector.cpp395
-rw-r--r--quanta/components/csseditor/cssselector.h74
-rw-r--r--quanta/components/csseditor/cssselectors.ui985
-rw-r--r--quanta/components/csseditor/cssshpropertyparser.cpp127
-rw-r--r--quanta/components/csseditor/cssshpropertyparser.h46
-rw-r--r--quanta/components/csseditor/data/Makefile.am3
-rw-r--r--quanta/components/csseditor/data/atrules.xml7
-rw-r--r--quanta/components/csseditor/data/config.xml609
-rw-r--r--quanta/components/csseditor/data/dtdTags.xml19
-rw-r--r--quanta/components/csseditor/data/pseudo.xml14
-rw-r--r--quanta/components/csseditor/doubleeditors.cpp120
-rw-r--r--quanta/components/csseditor/doubleeditors.h86
-rw-r--r--quanta/components/csseditor/encodingselector.cpp47
-rw-r--r--quanta/components/csseditor/encodingselector.h40
-rw-r--r--quanta/components/csseditor/encodingselectors.ui115
-rw-r--r--quanta/components/csseditor/fontfamilychooser.cpp175
-rw-r--r--quanta/components/csseditor/fontfamilychooser.h52
-rw-r--r--quanta/components/csseditor/fontfamilychoosers.ui441
-rw-r--r--quanta/components/csseditor/minieditor.h37
-rw-r--r--quanta/components/csseditor/percentageeditor.cpp38
-rw-r--r--quanta/components/csseditor/percentageeditor.h52
-rw-r--r--quanta/components/csseditor/propertysetter.cpp129
-rw-r--r--quanta/components/csseditor/propertysetter.h64
-rw-r--r--quanta/components/csseditor/qmyhighlighter.cpp65
-rw-r--r--quanta/components/csseditor/qmyhighlighter.h36
-rw-r--r--quanta/components/csseditor/shorthandformer.cpp781
-rw-r--r--quanta/components/csseditor/shorthandformer.h117
-rw-r--r--quanta/components/csseditor/specialsb.cpp127
-rw-r--r--quanta/components/csseditor/specialsb.h79
-rw-r--r--quanta/components/csseditor/styleeditor.cpp109
-rw-r--r--quanta/components/csseditor/styleeditor.h42
-rw-r--r--quanta/components/csseditor/stylesheetparser.cpp245
-rw-r--r--quanta/components/csseditor/stylesheetparser.h58
-rw-r--r--quanta/components/csseditor/tlpeditors.cpp174
-rw-r--r--quanta/components/csseditor/tlpeditors.h94
45 files changed, 7291 insertions, 0 deletions
diff --git a/quanta/components/csseditor/Makefile.am b/quanta/components/csseditor/Makefile.am
new file mode 100644
index 00000000..3b888e32
--- /dev/null
+++ b/quanta/components/csseditor/Makefile.am
@@ -0,0 +1,18 @@
+SUBDIRS = data
+
+noinst_LTLIBRARIES = libcsseditor.la
+
+libcsseditor_la_SOURCES = fontfamilychoosers.ui cssselectors.ui csseditors.ui \
+ fontfamilychooser.cpp cssselector.cpp csseditor.cpp specialsb.cpp doubleeditors.cpp \
+ qmyhighlighter.cpp colorrequester.cpp propertysetter.cpp shorthandformer.cpp colorslider.cpp \
+ csseditor_globals.cpp tlpeditors.cpp styleeditor.cpp stylesheetparser.cpp cssshpropertyparser.cpp percentageeditor.cpp
+
+libcsseditor_la_METASOURCES = AUTO
+
+AM_CPPFLAGS = -I$(top_srcdir)/quanta/src \
+ -I$(top_srcdir)/quanta/utility \
+ -I$(top_srcdir)/quanta/parsers \
+ -I$(top_srcdir)/quanta/project \
+ -I$(top_srcdir)/lib \
+ $(KMDI_INCLUDES) $(all_includes)
+noinst_HEADERS = styleeditor.h
diff --git a/quanta/components/csseditor/colorrequester.cpp b/quanta/components/csseditor/colorrequester.cpp
new file mode 100644
index 00000000..1333a48e
--- /dev/null
+++ b/quanta/components/csseditor/colorrequester.cpp
@@ -0,0 +1,129 @@
+/***************************************************************************
+ colorrequester.cpp - description
+ -------------------
+ copyright : (C) 2004 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "colorrequester.h"
+#include <klineedit.h>
+#include <kcombobox.h>
+#include <kcolordialog.h>
+#include <qtooltip.h>
+#include <qiconset.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kaccel.h>
+
+#include "propertysetter.h"
+
+class colorRequester::colorRequesterPrivate{
+ public:
+ KLineEdit *edit;
+ colorRequesterPrivate() { edit = 0L; }
+ void setText( const QString& text ) { edit->setText( text ); }
+ void connectSignals( QObject *receiver ) { connect( edit, SIGNAL( textChanged( const QString& )),receiver, SIGNAL( textChanged( const QString& ))); }
+};
+
+colorRequester::colorRequester(QWidget *parent, const char* name) : miniEditor(parent,name){
+ d = new colorRequesterPrivate;
+ init();
+}
+
+colorRequester::~colorRequester(){
+ delete myColorDialog;
+ delete d;
+}
+
+void colorRequester::connectToPropertySetter(propertySetter* p){
+ connect( this, SIGNAL(textChanged(const QString&)), p, SIGNAL(valueChanged(const QString&)));
+}
+
+void colorRequester::init()
+{
+ myColorDialog = 0L;
+
+ if ( !d->edit )
+ d->edit = new KLineEdit( this, "line edit" );
+
+ myButton = new KPushButton( this, "kfile button");
+ QIconSet iconSet = SmallIconSet(QString::fromLatin1("colorize"));
+ QPixmap pixMap = iconSet.pixmap( QIconSet::Small, QIconSet::Normal );
+ myButton->setIconSet( iconSet );
+ myButton->setFixedSize( pixMap.width()+8, pixMap.height()+8 );
+ QToolTip::add(myButton, i18n("Open color dialog"));
+
+ setSpacing( KDialog::spacingHint() );
+
+ QWidget *widget = (QWidget*) d->edit;
+ setFocusProxy( widget );
+
+ d->connectSignals( this );
+ connect( myButton, SIGNAL( clicked() ), this, SLOT( openColorDialog() ));
+ connect( d->edit, SIGNAL( textChanged ( const QString & ) ), this, SLOT( setInitialValue(/*const QString&*/ ) ));
+
+ KAccel *accel = new KAccel( this );
+ accel->insert( KStdAccel::Open, this, SLOT( openColorDialog() ));
+ accel->readSettings();
+ }
+
+void colorRequester::openColorDialog(){
+ KColorDialog dlg(this,"dlg",true);
+ dlg.setColor(QColor(m_initialValue));
+ if(dlg.exec()){
+ QColor myColor(dlg.color());
+ d->edit->setText(myColor.name());
+ emit textChanged(myColor.name());
+ }
+}
+
+KLineEdit * colorRequester::lineEdit() const{
+ return d->edit;
+}
+#include <kdebug.h>
+void colorRequester::setInitialValue(/*const QString& s*/){
+ QString temp = d->edit->text();
+ temp.remove(" ");
+ if( temp.contains("#") != 0){
+ temp.remove("#");
+ if(temp.length() == 3) {
+ QString temp2;
+ temp2.append(temp[0]);
+ temp2.append(temp[0]);
+ temp2.append(temp[1]);
+ temp2.append(temp[1]);
+ temp2.append(temp[2]);
+ temp2.append(temp[2]);
+ temp = temp2;
+ }
+ bool ok;
+ int r = temp.left(2).toInt( &ok, 16 );
+ int g = temp.mid(2,2).toInt( &ok, 16 );
+ int b = temp.right(2).toInt( &ok, 16 );
+ m_initialValue.setRgb(r,g,b);
+ }
+ else
+
+ if( temp.contains("rgb(") != 0){
+ temp.remove("rgb(").remove(")");
+ QStringList rgbValues = QStringList::split(",",temp);
+// bool ok;
+ int r = rgbValues[0].toInt();
+ int g = rgbValues[1].toInt();
+ int b = rgbValues[2].toInt();
+ m_initialValue.setRgb(r,g,b);
+ }
+ else
+ m_initialValue.setNamedColor(d->edit->text());
+}
+
+#include "colorrequester.moc"
diff --git a/quanta/components/csseditor/colorrequester.h b/quanta/components/csseditor/colorrequester.h
new file mode 100644
index 00000000..e0b4be4f
--- /dev/null
+++ b/quanta/components/csseditor/colorrequester.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ colorrequester.h - description
+ -------------------
+ copyright : (C) 2004 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef COLORREQUESTER_H
+#define COLORREQUESTER_H
+
+#include <kpushbutton.h>
+#include <qcolor.h>
+
+#include "minieditor.h"
+
+class KLineEdit;
+class KColorDialog;
+class colorRequester : public miniEditor{
+ Q_OBJECT
+ public:
+ colorRequester(QWidget *parent, const char* name=0);
+ ~colorRequester();
+ KLineEdit * lineEdit() const;
+ KPushButton * button() const { return myButton; }
+ virtual void connectToPropertySetter(propertySetter* p);
+ //void setInitialValue(const QString&);
+ public slots:
+ void openColorDialog();
+ void setInitialValue(/*const QString&*/);
+ protected:
+ void init();
+ signals:
+ void selectedColor(QColor);
+ void textChanged(const QString&);
+ private:
+ mutable KColorDialog * myColorDialog;
+ KPushButton *myButton;
+ class colorRequesterPrivate;
+ colorRequesterPrivate *d;
+ QColor m_initialValue;
+};
+#endif
diff --git a/quanta/components/csseditor/colorslider.cpp b/quanta/components/csseditor/colorslider.cpp
new file mode 100644
index 00000000..436c7e21
--- /dev/null
+++ b/quanta/components/csseditor/colorslider.cpp
@@ -0,0 +1,85 @@
+/***************************************************************************
+ colorslider.cpp - description
+ -------------------
+ begin : lun ago 9 2004
+ copyright : (C) 2004 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qvbox.h>
+#include <qlabel.h>
+
+#include <klocale.h>
+
+#include "colorslider.h"
+#include "propertysetter.h"
+
+/**
+ *@author gulmini luciano
+ */
+
+
+
+colorSlider::colorSlider(const QString& fn,const QString& l,const QString& c,const QString& r,QWidget *parent, const char *name) : miniEditor(parent,name) {
+ m_functionName = fn;
+ QVBox *leftBox = new QVBox(this);
+ QVBox *centerBox = new QVBox(this);
+ QVBox *rightBox = new QVBox(this);
+ QLabel *leftLabel = new QLabel("<b>" + l +"</b>",leftBox);
+ QLabel *centerLabel = new QLabel(("<b>" + c +"</b>"),centerBox);
+ QLabel *rightLabel = new QLabel(("<b>" + r +"</b>"),rightBox);
+ leftLabel->setAlignment(Qt::AlignHCenter);
+ centerLabel->setAlignment(Qt::AlignHCenter);
+ rightLabel->setAlignment(Qt::AlignHCenter);
+ leftLabel->setTextFormat (Qt::RichText ) ;
+ centerLabel->setTextFormat ( Qt::RichText ) ;
+ rightLabel->setTextFormat (Qt::RichText ) ;
+ m_leftValue = new QSlider ( 0, 255, 1, 0, Qt::Horizontal , leftBox);
+ m_centerValue = new QSlider ( 0, 255, 1, 0, Qt::Horizontal , centerBox);
+ m_rightValue = new QSlider ( 0, 255, 1, 0, Qt::Horizontal , rightBox);
+ setSpacing(10);
+ connect(m_leftValue, SIGNAL(valueChanged ( int)), this, SLOT(convertLeftValue(int)));
+ connect(m_centerValue, SIGNAL(valueChanged ( int)), this, SLOT(convertCenterValue(int)));
+ connect(m_rightValue, SIGNAL(valueChanged ( int)), this, SLOT(convertRightValue(int)));
+}
+
+colorSlider::~colorSlider(){
+ //delete m_redValue;
+ //delete m_greenValue;
+ //delete m_blueValue;
+}
+
+void colorSlider::connectToPropertySetter(propertySetter* p){
+ connect( this, SIGNAL(valueChanged(const QString&)), p, SIGNAL(valueChanged(const QString&)));
+}
+
+void colorSlider::convertLeftValue(int i){
+ emit valueChanged(m_functionName + "(" + QString::number(i,10) + "," + QString::number(m_centerValue->value(),10) + "," +QString::number(m_rightValue->value(),10) +")");
+}
+
+void colorSlider::convertCenterValue(int i){
+ emit valueChanged(m_functionName + "(" + QString::number(m_leftValue->value(),10) + "," + QString::number(i,10) + "," + QString::number(m_rightValue->value(),10) +")");
+}
+
+void colorSlider::convertRightValue(int i){
+ emit valueChanged(m_functionName + "(" + QString::number(m_leftValue->value(),10) + "," + QString::number(m_centerValue->value(),10) + "," + QString::number(i,10) +")");
+}
+
+RGBcolorSlider::RGBcolorSlider(QWidget *parent, const char *name) : colorSlider("rgb",i18n("Red"),i18n("Green"),i18n("Blue"),parent,name){
+}
+
+//FOR CSS3
+/*HSLcolorSlider::HSLcolorSlider(QWidget *parent, const char *name) : colorSlider("hsl",i18n("Hue"),i18n("Saturation"),i18n("Lightness"),parent,name){
+}
+*/
+
+#include "colorslider.moc"
diff --git a/quanta/components/csseditor/colorslider.h b/quanta/components/csseditor/colorslider.h
new file mode 100644
index 00000000..41a78fa9
--- /dev/null
+++ b/quanta/components/csseditor/colorslider.h
@@ -0,0 +1,69 @@
+/***************************************************************************
+ colorslider.h - description
+ -------------------
+ begin : lun ago 9 2004
+ copyright : (C) 2004 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef COLORSLIDER_H
+#define COLORSLIDER_H
+
+#include <qslider.h>
+
+#include "minieditor.h"
+
+
+
+/**
+ *@author gulmini luciano
+ */
+
+class colorSlider : public miniEditor {
+ Q_OBJECT
+ private :
+ QString m_functionName;
+ protected:
+ QSlider *m_leftValue,
+ *m_centerValue,
+ *m_rightValue;
+ public:
+ colorSlider(const QString& functionName,const QString& l=QString::null,const QString& c=QString::null,const QString& r=QString::null,QWidget *parent=0, const char *name=0);
+ virtual ~colorSlider();
+ virtual void connectToPropertySetter(propertySetter* p);
+
+ private slots:
+ void convertLeftValue(int i);
+ void convertCenterValue(int i);
+ void convertRightValue(int i);
+
+ signals:
+ void valueChanged(const QString&);
+};
+
+class RGBcolorSlider : public colorSlider {
+ Q_OBJECT
+ public:
+ RGBcolorSlider(QWidget *parent=0, const char *name=0);
+ ~RGBcolorSlider(){}
+};
+
+//FOR CSS3
+/*class HSLcolorSlider : public colorSlider {
+ Q_OBJECT
+ public:
+ HSLcolorSlider(QWidget *parent=0, const char *name=0);
+ ~HSLcolorSlider();
+};*/
+
+
+#endif
diff --git a/quanta/components/csseditor/csseditor.cpp b/quanta/components/csseditor/csseditor.cpp
new file mode 100644
index 00000000..692a8edf
--- /dev/null
+++ b/quanta/components/csseditor/csseditor.cpp
@@ -0,0 +1,697 @@
+/***************************************************************************
+ csseditor.cpp - description
+ -------------------
+ begin : mer lug 23 11:20:17 CEST 2003
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "csseditor.h"
+#include <qlayout.h>
+#include <qtabwidget.h>
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+#include <qtextedit.h>
+#include <qtextstream.h>
+#include <qfileinfo.h>
+
+#include <kapplication.h>
+#include <klocale.h>
+#include <khtml_part.h>
+#include <khtmlview.h>
+#include <kstandarddirs.h>
+#include <klineedit.h>
+#include <kdebug.h>
+#include <kconfig.h>
+#include <kparts/browserextension.h>
+
+#include "propertysetter.h"
+#include "qmyhighlighter.h"
+#include "cssshpropertyparser.h"
+#include "shorthandformer.h"
+#include "percentageeditor.h"
+#include "colorslider.h"
+#include "tlpeditors.h"
+#include "doubleeditors.h"
+#include "specialsb.h"
+#include "colorrequester.h"
+
+
+
+myCheckListItem::myCheckListItem(QListView * parent, const QString & text):QCheckListItem(parent, text, QCheckListItem::CheckBox),m_checkedChildren(0){
+ m_sig = new QSignal;
+}
+
+myCheckListItem::myCheckListItem(QCheckListItem * parent, const QString & text):QCheckListItem(parent, text, QCheckListItem::CheckBox),m_checkedChildren(0){
+ m_sig = new QSignal;
+}
+
+myCheckListItem::~myCheckListItem(){
+ delete m_sig;
+}
+
+void myCheckListItem::connect( QObject *receiver, const char *member ){
+ m_sig->connect( receiver, member );
+}
+
+void myCheckListItem::activate(){
+ if(isOn()) QCheckListItem::activate();
+}
+
+void myCheckListItem::addCheckedChild() {
+ m_checkedChildren++;
+}
+
+void myCheckListItem::stateChange (bool b){
+
+ if(!b) {
+ if(childCount()) {
+ QListViewItem * child = firstChild();
+ while( child ) {
+ m_sig->setValue(QVariant(child->text(0)));
+ m_sig->activate();
+ static_cast<myCheckListItem*>(child)->setOn(false);
+ child = child->nextSibling();
+ }
+ m_checkedChildren = 0;
+ }
+ else {
+ if(parent()){
+ myCheckListItem *p = static_cast<myCheckListItem*>(parent());
+ while( p ) {
+ if( p->m_checkedChildren != 1) {
+ p->m_checkedChildren--;
+ m_sig->setValue(QVariant(text(0)));
+ m_sig->activate();
+ break;
+ }
+ else {
+ m_sig->setValue(QVariant(text(0)));
+ m_sig->activate();
+ p->setOn(false);
+ }
+ p = static_cast<myCheckListItem*>(p->parent());
+ }
+ }
+ else {
+ m_sig->setValue(QVariant(text(0)));
+ m_sig->activate();
+ }
+ }
+ }
+ else {
+ if(parent()) static_cast<myCheckListItem*>(parent())->addCheckedChild();
+ }
+}
+
+void CSSEditor::appendSub(QDomNodeList l, myCheckListItem *cli){
+ unsigned int i;
+ for(i=0;i<l.length();i++) {
+ myCheckListItem *item = new myCheckListItem(cli,l.item(i).toElement().tagName());
+ item->connect(this,SLOT(removeProperty(const QVariant&)));
+ if(l.item(i).toElement().attribute("hasSub") == "yes")
+ appendSub(l.item(i).childNodes(),item);
+ }
+}
+
+void CSSEditor::buildListView(QDomNodeList l, QListView *lv){
+ unsigned int i;
+ for(i=0;i<l.length();i++) {
+ myCheckListItem *item = new myCheckListItem(lv,l.item(i).toElement().tagName());
+ item->connect(this,SLOT(removeProperty(const QVariant&)));
+ if(l.item(i).toElement().attribute("hasSub") == "yes") {
+ QDomNodeList listSub = l.item(i).childNodes();
+ appendSub(listSub,item);
+ }
+ }
+}
+
+void CSSEditor::setCurrentPropOn(const QString& s){
+ if( (m_currentProp = static_cast<myCheckListItem*>(lvVisual->findItem( s,0 )) ))
+ m_currentProp->setOn(true);
+ else
+ if( (m_currentProp = static_cast<myCheckListItem*>(lvAll->findItem( s,0 )) ))
+ m_currentProp->setOn(true);
+ else
+ if( (m_currentProp = static_cast<myCheckListItem*>(lvAural->findItem( s,0 )) ))
+ m_currentProp->setOn(true);
+ else
+ if( (m_currentProp = static_cast<myCheckListItem*>(lvInteractive->findItem( s,0 )) ))
+ m_currentProp->setOn(true);
+ else
+ if( (m_currentProp = static_cast<myCheckListItem*>(lvPaged->findItem( s,0 )) ))
+ m_currentProp->setOn(true);
+
+ if( m_currentProp && m_currentProp->depth() ) {
+ myCheckListItem *p = static_cast<myCheckListItem*>(m_currentProp->parent());
+ while(p) {
+ p->setOn(true);
+ p=static_cast<myCheckListItem*>(p->parent());
+ }
+ }
+}
+
+
+ void CSSEditor::addAndSetPropertyOn(const QString& property, const QString& value){
+ addProperty(property,value);
+ setCurrentPropOn(property);
+ }
+
+ void CSSEditor::setSidesOfPropertyBorderOn(const QString& s){
+ static_cast<myCheckListItem*>(lvVisual->findItem( "border-top",0 ))->setOn(true);
+ static_cast<myCheckListItem*>(lvVisual->findItem( "border-right",0 ))->setOn(true);
+ static_cast<myCheckListItem*>(lvVisual->findItem( "border-bottom",0 ))->setOn(true);
+ static_cast<myCheckListItem*>(lvVisual->findItem( "border-left",0 ))->setOn(true);
+ static_cast<myCheckListItem*>(lvVisual->findItem( "border-top-"+s,0 ))->setOn(true);
+ static_cast<myCheckListItem*>(lvVisual->findItem( "border-right-"+s,0 ))->setOn(true);
+ static_cast<myCheckListItem*>(lvVisual->findItem( "border-bottom-"+s,0 ))->setOn(true);
+ static_cast<myCheckListItem*>(lvVisual->findItem( "border-left-"+s,0 ))->setOn(true);
+ }
+
+void CSSEditor::hidePreviewer(){
+ fPreview->hide();
+ }
+
+void CSSEditor::initialize(){
+
+ m_config = kapp->config();
+ connect(pbOk, SIGNAL(clicked()), this, SLOT(toggleShortendForm()));
+ m_config->setGroup("CSSEditor Options");
+ SHckb->setChecked(m_config->readBoolEntry("Shorthand form enabled",false));
+
+ QString configFile = locate("appdata", "csseditor/config.xml");
+
+ m_myhi = new QMyHighlighter(display);
+
+ QBoxLayout *fPreviewLayout = new QBoxLayout(fPreview,QBoxLayout::LeftToRight);
+ m_previewer=new KHTMLPart(fPreview);
+
+ fPreviewLayout->addWidget(m_previewer->view());
+
+ QFile file( configFile );
+ if ( !file.open( IO_ReadOnly ) ) {
+ return;
+ }
+ if ( !m_doc.setContent( &file ) ) {
+ file.close();
+ return;
+ }
+ file.close();
+
+ QDomElement docElem = m_doc.documentElement();
+
+ QDomNode n = docElem.firstChild();
+ while( !n.isNull() ) {
+ QDomElement e = n.toElement();
+ if( !e.isNull() ) {
+ if( e.attribute("type") == "visual") {
+ lvVisual->setRootIsDecorated(true);
+ buildListView(e.childNodes(), lvVisual);
+ }
+ if( e.attribute("type") == "paged") {
+ lvPaged->setRootIsDecorated(true);
+ buildListView(e.childNodes(), lvPaged);
+ }
+ if( e.attribute("type") == "interactive") {
+ lvInteractive->setRootIsDecorated(true);
+ buildListView(e.childNodes(), lvInteractive);
+ }
+ if( e.attribute("type") == "aural") {
+ lvAural->setRootIsDecorated(true);
+ buildListView(e.childNodes(), lvAural);
+ }
+ if( e.attribute("type") == "all"){
+ lvAll->setRootIsDecorated(true);
+ buildListView(e.childNodes(), lvAll);
+ }
+ }
+ n = n.nextSibling();
+ } // end while
+
+ Connect();
+
+ QBoxLayout *fEditingLayout = new QBoxLayout(fEditing,QBoxLayout::LeftToRight);
+
+ m_ps = new propertySetter(fEditing);
+ fEditingLayout->addWidget(m_ps);
+ connect(m_ps, SIGNAL(valueChanged(const QString&)), this, SLOT(checkProperty(const QString&)));
+
+ QStringList props;
+ QString temp;
+ bool normalMode = true;
+
+ if( !m_selectorName.isEmpty() ){ //the cssselector has been called
+ m_initialProperties = m_initialProperties.stripWhiteSpace();
+ props=QStringList::split(";",m_initialProperties);
+ temp= m_selectorName + " {\n\t" ;
+ }
+
+ else {
+ m_InlineStyleContent = m_InlineStyleContent.stripWhiteSpace();
+ normalMode = false;
+ props=QStringList::split(";",m_InlineStyleContent);
+ temp="\n\t";
+ }
+
+ for ( QStringList::Iterator it = props.begin(); it != props.end(); ++it ) {
+ const QString propertyName((*it).section(":",0,0).stripWhiteSpace());
+ const QString propertyValue((*it).section(":",1));
+
+ if( ShorthandFormer::SHFormList().contains(propertyName)==0 ) {
+ temp+= propertyName + " : " + propertyValue +";\n\t";
+ addAndSetPropertyOn(propertyName,propertyValue);
+ }
+ else{
+ ShorthandFormer decompressor;
+ QMap<QString,QString> expandedProperties = decompressor.expand(propertyName, propertyValue );
+ QMap<QString,QString>::Iterator it;
+
+ for ( it = expandedProperties.begin(); it != expandedProperties.end(); ++it ) {
+ addAndSetPropertyOn( it.key(), it.data() );
+ temp += ( it.key() + " : " + it.data() + ";\n\t");
+ }
+ }
+ }
+ temp.truncate(temp.length()-1);
+ //temp.chop(1);
+ if(normalMode)//normal mode editing
+ temp+="}";
+ display->setText(temp);
+ activatePreview();
+}
+
+void CSSEditor::toggleShortendForm()
+{
+ m_config->setGroup("CSSEditor Options");
+ m_config->writeEntry("Shorthand form enabled", SHckb->isChecked());
+ m_config->sync();
+}
+
+CSSEditor::CSSEditor(QListViewItem *i, QWidget *parent, const char *name) : CSSEditorS(parent, name){
+ m_selectorName = i->text(0);
+ m_initialProperties = i->text(1);
+}
+
+CSSEditor::~CSSEditor() {
+ delete m_myhi;
+ delete m_ps;
+ delete m_previewer;
+}
+
+void CSSEditor::setMiniEditors(QListViewItem* i){
+
+ m_ps->reset();
+
+ if(i->childCount()==0) {
+ m_currentProp = static_cast<myCheckListItem*>(i);
+ QDomNodeList valueTypes = m_doc.elementsByTagName(i->text(0)).item(0).childNodes();
+ unsigned int i;
+ for(i=0; i<valueTypes.length(); i++) {
+ QDomElement curr =valueTypes.item(i).toElement();
+ QString valueTypeName(curr.tagName());
+
+ if(valueTypeName =="list") {
+ m_ps->setComboBox();
+ QStringList values = QStringList::split(",",curr.attribute("value"));
+ m_ps->ComboBox()->insertStringList(values);
+ if(m_properties.contains(m_currentProp->text(0)) !=0 )
+ if( values.contains(m_currentProp->text(0)))
+ m_ps->ComboBox()->setCurrentText(m_properties[m_currentProp->text(0)]);
+ if(curr.attribute("editable") == "yes"){
+ m_ps->ComboBox()->setEditable(true);
+ /*if(m_properties.contains(m_currentProp->text(0)) !=0 )
+ m_ps->ComboBox()->setEditText(m_properties[m_currentProp->text(0)]); */
+ }
+ }
+ else
+
+ /*if( typeName == "spinbox") {
+ m_ps->setSpinBox("0", values.item(k).toElement().attribute("minValue"),
+ values.item(k).toElement().attribute("maxValue"),
+ values.item(k).toElement().attribute("suffix"));
+ }
+
+ else*/
+ if( valueTypeName == "number") m_ps->setLineEdit();
+ else
+ if( valueTypeName == "integer") {
+ if(m_properties.contains(m_currentProp->text(0)) !=0 ) {
+ if(!curr.attribute("minValue").isNull())
+ m_ps->setSpinBox(m_properties[m_currentProp->text(0)],curr.attribute("minValue"));
+ else
+ m_ps->setSpinBox(m_properties[m_currentProp->text(0)]);
+ }
+ else
+ if(!curr.attribute("minValue").isNull())
+ m_ps->setSpinBox("0",curr.attribute("minValue"));
+ else
+ m_ps->setSpinBox();
+ }
+ else
+ if( valueTypeName == "length") {
+ lengthEditor *editor = new lengthEditor(m_ps);
+ if(m_properties.contains(m_currentProp->text(0)) !=0 )
+ editor->setInitialValue(m_properties[m_currentProp->text(0)]);
+ else
+ editor->setInitialValue(QString::null);
+ m_ps->installMiniEditor(editor);
+ }
+ else
+ if( valueTypeName == "percentage") {
+ if(m_properties.contains(m_currentProp->text(0)) !=0 ){
+ percentageEditor *editor = new percentageEditor(m_properties[m_currentProp->text(0)],m_ps);
+ m_ps->installMiniEditor(editor);
+ }
+ else {
+ percentageEditor *editor = new percentageEditor("0",m_ps);
+ m_ps->installMiniEditor(editor);
+ }
+ }
+ else
+ if( valueTypeName == "doubleLength") {
+ doubleLengthEditor *editor = new doubleLengthEditor(m_ps);
+
+ if(m_properties.contains(m_currentProp->text(0)) !=0 ){
+ QString temp(m_properties[m_currentProp->text(0)].simplifyWhiteSpace()),
+ sx(temp.section(" ",0,0)),
+ dx(temp.section(" ",1,1));
+
+ editor->setInitialValue(sx,dx);
+ }
+ else editor->setInitialValue(QString::null,QString::null);
+ m_ps->installMiniEditor(editor);
+ }
+ else
+ if( valueTypeName == "doublePercentage") {
+ doublePercentageEditor *editor = new doublePercentageEditor(m_ps);
+
+ if(m_properties.contains(m_currentProp->text(0)) !=0 ){
+ QString temp(m_properties[m_currentProp->text(0)].simplifyWhiteSpace()),
+ sx(temp.section(" ",0,0)),
+ dx(temp.section(" ",1,1));
+
+ editor->setInitialValue(sx,dx);
+ }
+ else editor->setInitialValue(QString::null,QString::null);
+ m_ps->installMiniEditor(editor);
+ }
+ else
+ if( valueTypeName == "frequency") {
+ frequencyEditor *editor = new frequencyEditor(m_ps);
+ if(m_properties.contains(m_currentProp->text(0)) !=0 )
+ editor->setInitialValue(m_properties[m_currentProp->text(0)]);
+ else
+ editor->setInitialValue(QString::null);
+ m_ps->installMiniEditor(editor);
+ }
+ else
+ if( valueTypeName == "time") {
+ timeEditor *editor = new timeEditor(m_ps);
+ if(m_properties.contains(m_currentProp->text(0)) !=0 )
+ editor->setInitialValue(m_properties[m_currentProp->text(0)]);
+ else
+ editor->setInitialValue(QString::null);
+ m_ps->installMiniEditor(editor);
+ }
+ else
+ if( valueTypeName == "angle") {
+ angleEditor *editor = new angleEditor(m_ps);
+ if(m_properties.contains(m_currentProp->text(0)) !=0 )
+ editor->setInitialValue(m_properties[m_currentProp->text(0)]);
+ else
+ editor->setInitialValue(QString::null);
+ m_ps->installMiniEditor(editor);
+ }
+ else
+ if( valueTypeName == "freeedit") {
+ m_ps->setLineEdit();
+ }
+ else
+ if( valueTypeName == "uri") {
+ URIEditor *editor = new URIEditor(m_ps);
+
+ if(curr.attribute("mode") == "multi") editor->setMode(URIEditor::Multi);
+ else editor->setMode(URIEditor::Single);
+
+ if( curr.attribute("resourceType") == "audio") editor->setResourceType(URIEditor::audio);
+ else
+ if( curr.attribute("resourceType") == "image") editor->setResourceType(URIEditor::image);
+ else
+ if( curr.attribute("resourceType") == "mousePointer") editor->setResourceType(URIEditor::mousePointer);
+
+ m_ps->installMiniEditor(editor);
+ }
+ else
+ if( valueTypeName == "colors") {
+ RGBcolorSlider *RGBeditor = new RGBcolorSlider(m_ps);
+ colorRequester *CReditor = new colorRequester(m_ps);
+ if(m_properties.contains(m_currentProp->text(0)) !=0 ){
+ CReditor->lineEdit()->setText(m_properties[m_currentProp->text(0)]);
+ CReditor->setInitialValue();
+
+ }
+
+ m_ps->installMiniEditor(CReditor);
+ m_ps->setPredefinedColorListEditor();
+ m_ps->installMiniEditor(RGBeditor);
+ }
+ else
+ if( valueTypeName =="doubleList") {
+ doubleComboBoxEditor *editor = new doubleComboBoxEditor(m_ps);
+ editor->cbSx()->insertStringList(QStringList::split(",",curr.firstChild().toElement().attribute("value")));
+ editor->cbDx()->insertStringList(QStringList::split(",",curr.lastChild().toElement().attribute("value")));
+ m_ps->installMiniEditor(editor);
+ }
+ else
+ if( valueTypeName == "fontDialog" ){
+ fontEditor *editor = new fontEditor(m_ps);
+ if(m_properties.contains(m_currentProp->text(0)) !=0 ){
+ editor->setInitialValue(m_properties[m_currentProp->text(0)]);
+ }
+ else editor->setInitialValue(QString::null);
+ m_ps->installMiniEditor(editor);
+ }
+ }
+ m_ps->addButton();
+ m_ps->Show();
+ }
+}
+
+void CSSEditor::checkProperty(const QString& v){
+ if(!m_currentProp->isOn())
+ m_currentProp->setOn(true);
+
+ if( m_currentProp->depth() ){
+ myCheckListItem *p = static_cast<myCheckListItem*>(m_currentProp->parent());
+ while(p){
+ p->setOn(true);
+ p=static_cast<myCheckListItem*>(p->parent());
+ }
+ }
+
+ if(m_currentProp->text(0) =="border-style" ){
+ setSidesOfPropertyBorderOn("style");
+ QStringList values = QStringList::split(" ",v.stripWhiteSpace());
+ addProperty("border-top-style",values[0]);
+ switch(values.count()) {
+ case 1:
+ addProperty("border-right-style",values[0]);
+ addProperty("border-bottom-style",values[0]);
+ addProperty("border-left-style",values[0]);
+ break;
+
+ case 2:
+ addProperty("border-right-style",values[1]);
+ addProperty("border-bottom-style",values[0]);
+ addProperty("border-left-style",values[1]);
+ break;
+
+ case 3:
+ addProperty("border-right-style",values[1]);
+ addProperty("border-bottom-style",values[2]);
+ addProperty("border-left-style",values[1]);
+ break;
+
+ case 4:
+ addProperty("border-right-style",values[1]);
+ addProperty("border-bottom-style",values[2]);
+ addProperty("border-left-style",values[3]);break;
+ }
+ }
+ else
+ if(m_currentProp->text(0) =="border-width" ){
+ setSidesOfPropertyBorderOn("width");
+ QStringList values = QStringList::split(" ",v.stripWhiteSpace());
+ addProperty("border-top-width",values[0]);
+ switch(values.count()) {
+ case 1:
+ addProperty("border-right-width",values[0]);
+ addProperty("border-bottom-width",values[0]);
+ addProperty("border-left-width",values[0]);
+ break;
+
+ case 2:
+ addProperty("border-right-width",values[1]);
+ addProperty("border-bottom-width",values[0]);
+ addProperty("border-left-width",values[1]);
+ break;
+
+ case 3:
+ addProperty("border-right-width",values[1]);
+ addProperty("border-bottom-width",values[2]);
+ addProperty("border-left-width",values[1]);
+ break;
+
+ case 4:
+ addProperty("border-right-width",values[1]);
+ addProperty("border-bottom-width",values[2]);
+ addProperty("border-left-width",values[3]);break;
+ }
+ }
+ else
+ if(m_currentProp->text(0) =="border-color" ){
+ setSidesOfPropertyBorderOn("color");
+ QStringList values = QStringList::split(" ",v.stripWhiteSpace());
+ addProperty("border-top-color",values[0]);
+ switch(values.count()) {
+ case 1:
+ addProperty("border-right-color",values[0]);
+ addProperty("border-bottom-color",values[0]);
+ addProperty("border-left-color",values[0]);
+ break;
+
+ case 2:
+ addProperty("border-right-color",values[1]);
+ addProperty("border-bottom-color",values[0]);
+ addProperty("border-left-color",values[1]);
+ break;
+
+ case 3:
+ addProperty("border-right-color",values[1]);
+ addProperty("border-bottom-color",values[2]);
+ addProperty("border-left-color",values[1]);
+ break;
+
+ case 4:
+ addProperty("border-right-style",values[1]);
+ addProperty("border-bottom-style",values[2]);
+ addProperty("border-left-style",values[3]);break;
+ }
+ }
+ else addProperty(m_currentProp->text(0),v);
+ emit signalUpdatePreview();
+}
+
+void CSSEditor::Connect(){
+ connect(this, SIGNAL(signalUpdatePreview()), this, SLOT(updatePreview()));
+ connect(lvVisual,SIGNAL(selectionChanged ( QListViewItem * )),this,SLOT(setMiniEditors ( QListViewItem * )));
+ connect(lvAll,SIGNAL( selectionChanged( QListViewItem * )),this,SLOT(setMiniEditors ( QListViewItem * )));
+ connect(lvAural,SIGNAL( selectionChanged( QListViewItem * )),this,SLOT(setMiniEditors ( QListViewItem * )));
+ connect(lvInteractive,SIGNAL( selectionChanged( QListViewItem * )),this,SLOT(setMiniEditors ( QListViewItem * )));
+ connect(lvPaged,SIGNAL( selectionChanged( QListViewItem * )),this,SLOT(setMiniEditors ( QListViewItem * )));
+}
+
+void CSSEditor::removeProperty(const QVariant& v){
+ m_properties.remove(v.toString());
+ updatePreview();
+}
+
+QString CSSEditor::generateProperties(){
+ QString props;
+ QMap<QString,QString>::Iterator it;
+ if(!SHckb->isChecked()) {
+ for ( it = m_properties.begin(); it != m_properties.end(); ++it )
+ props+= it.key() + " : " + it.data().stripWhiteSpace() + "; " ;
+ props.truncate(props.length()-1);//the last white space creates some problems: better remove it
+ //props.chop(1);
+ return props;
+ }
+ else {
+ ShorthandFormer sf(m_properties);
+ return sf.compress();
+ }
+}
+
+void CSSEditor::updatePreview(){
+ updateDisplay();
+ activatePreview();
+}
+
+void CSSEditor::activatePreview() {
+ if(!m_isFileToPreviewExternal){
+ QString testHeader,
+ testFooter,
+ testBody;
+
+ if(!m_selectorName.isEmpty()) {
+ testHeader += m_selectorName + " { \n ";
+ testFooter = "\n}" + m_Selectors;
+ }
+ else {
+ testHeader += " style=\"" ;
+ testFooter = "\"" ;
+ }
+
+ QMap<QString,QString>::Iterator it;
+ for ( it = m_properties.begin(); it != m_properties.end(); ++it )
+ testBody+= it.key() + " : " + it.data() + ";";
+
+ m_previewer->begin( KURL(m_fileToPreview) );
+ m_previewer->write( m_Header + testHeader + testBody+ testFooter+ m_Footer);
+ m_previewer->end();
+
+
+ }
+ else {
+ QString tmp("{");
+ QFile file(m_fileToPreview);
+ if ( file.open( IO_ReadOnly ) ) {
+ QMap<QString,QString>::Iterator it;
+ for ( it = m_properties.begin(); it != m_properties.end(); ++it )
+ tmp+= it.key() + " : " + it.data() + ";";
+
+
+ QFileInfo fi(m_fileToPreview);
+ KParts::URLArgs a;
+ if(fi.extension().lower() == "xml" || fi.extension().lower() == "xhtml")
+ a.serviceType="text/xml";
+ if(fi.extension().lower() == "html" || fi.extension().lower() == "html")
+ a.serviceType="text/xml";
+ m_previewer->browserExtension()->setURLArgs(a);
+ QTextStream stream( &file );
+
+ m_previewer->begin(KURL(m_fileToPreview));
+ m_previewer->write(stream.read());
+ m_previewer->end();
+ m_previewer->setUserStyleSheet(m_externalStyleSheetDefinition + " " + m_selectorName+" "+ tmp +"}");
+ file.close();
+ }
+ //else KMessageBox::sorry(this,i18n("The css file you want to edit can't be opened"));
+ }
+}
+
+void CSSEditor::updateDisplay(){
+ QString toDisplay;
+ QMap<QString,QString>::Iterator it;
+ for ( it = m_properties.begin(); it != m_properties.end(); ++it )
+ toDisplay += it.key() + " : " + it.data() + ";\n\t";
+
+ if(!m_selectorName.isEmpty()){// we're working on <style></style> block
+ toDisplay.prepend(m_selectorName +" {\n\t");
+ toDisplay+="}";
+ }
+ else toDisplay.prepend("\n\t");
+
+ display->setText(toDisplay);
+}
+
+#include "csseditor.moc"
diff --git a/quanta/components/csseditor/csseditor.h b/quanta/components/csseditor/csseditor.h
new file mode 100644
index 00000000..6994a686
--- /dev/null
+++ b/quanta/components/csseditor/csseditor.h
@@ -0,0 +1,117 @@
+/***************************************************************************
+ csseditor.h - description
+ -------------------
+ begin : mer lug 23 11:20:17 CEST 2003
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef CSSEDITOR_H
+#define CSSEDITOR_H
+
+#include <qwidget.h>
+#include "csseditors.h"
+#include <qdom.h>
+#include <qmap.h>
+#include <qlistview.h>
+#include <qsignal.h>
+
+class propertySetter;
+class KConfig;
+class KHTMLPart;
+class QListViewItem;
+class QDomNodeList;
+class QVariant;
+class QMyHighlighter;
+
+
+class myCheckListItem : public QCheckListItem
+{
+ private:
+ QSignal *m_sig;
+ unsigned int m_checkedChildren;
+
+ public :
+ myCheckListItem(QCheckListItem * parent, const QString & text);
+ myCheckListItem(QListView * parent, const QString & text);
+ ~myCheckListItem();
+ void connect( QObject *receiver, const char *member );
+ void addCheckedChild();
+
+ protected :
+ virtual void activate();
+ virtual void stateChange (bool);
+};
+
+/** CSSEditor is the base class of the project */
+class CSSEditor : public CSSEditorS
+{
+ Q_OBJECT
+ private:
+ QMyHighlighter *m_myhi;
+ propertySetter *m_ps;
+ myCheckListItem *m_currentProp;
+ KHTMLPart *m_previewer;
+ QDomDocument m_doc;
+ QMap<QString,QString> m_properties;
+ QString m_selectorName,
+ m_initialProperties,
+ m_Selectors,
+ m_Header,
+ m_Footer,
+
+ m_InlineStyleContent,
+ m_externalStyleSheetDefinition,
+ m_fileToPreview;
+
+ bool m_isFileToPreviewExternal;
+ KConfig *m_config;
+
+ //sourceFileName;
+
+ void Connect();
+ void appendSub(QDomNodeList, myCheckListItem *);
+ void buildListView(QDomNodeList, QListView *);
+ void updateDisplay();
+ void activatePreview();
+ void setCurrentPropOn(const QString& s);
+ void addProperty(const QString& property, const QString& value) { m_properties[property] = value; }
+ void addAndSetPropertyOn(const QString& property, const QString& value);
+ void setSidesOfPropertyBorderOn(const QString& s);
+
+ private slots:
+ void checkProperty(const QString&);
+ void removeProperty(const QVariant&);
+ void updatePreview();
+ void setMiniEditors(QListViewItem*);
+ void toggleShortendForm();
+
+ public:
+
+ CSSEditor(QWidget* parent=0, const char *name=0): CSSEditorS(parent, name), m_config(0L){}
+ CSSEditor( QListViewItem * i, QWidget* parent=0, const char *name=0);
+ ~CSSEditor();
+ void initialize();
+ void setSelectors( const QString& s) { m_Selectors = s; }
+ void setHeader( const QString& s) { m_Header = s; }
+ void setFooter( const QString& s) { m_Footer = s;}
+ void setInlineStyleContent( const QString& s){ m_InlineStyleContent = s; }
+ QString generateProperties();
+ void hidePreviewer();
+ void setFileToPreview(const QString& s,bool b) { m_fileToPreview = s; m_isFileToPreviewExternal = b;}
+ void setExternalStyleSheetDefinition(const QString& s) { m_externalStyleSheetDefinition = s;}
+
+ signals:
+ void signalUpdatePreview();
+};
+
+#endif
diff --git a/quanta/components/csseditor/csseditor_globals.cpp b/quanta/components/csseditor/csseditor_globals.cpp
new file mode 100644
index 00000000..a73cb876
--- /dev/null
+++ b/quanta/components/csseditor/csseditor_globals.cpp
@@ -0,0 +1,50 @@
+/***************************************************************************
+ csseditor_globals.cpp - description
+ -------------------
+ begin : dom ago 3 2003
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qlineedit.h>
+#include "csseditor_globals.h"
+
+mySpinBox::mySpinBox(QWidget * parent , const char * name ) : QSpinBox (parent, name){
+ connect( editor(), SIGNAL(textChanged(const QString&)), this, SLOT(checkSuffix( const QString & )));
+ connect( editor(), SIGNAL(textChanged(const QString&)), this, SIGNAL(valueChanged( const QString & )));
+}
+
+mySpinBox::mySpinBox( int minValue, int maxValue, int step, QWidget * parent, const char * name ) : QSpinBox( minValue, maxValue, step, parent,name ){
+ connect( editor(), SIGNAL(textChanged(const QString&)), this, SLOT(checkSuffix( const QString & )));
+ connect( editor(), SIGNAL(textChanged(const QString&)), this, SIGNAL(valueChanged( const QString & )));
+}
+
+mySpinBox::~mySpinBox(){}
+
+void mySpinBox::checkSuffix(const QString&){// check if the suffix is present and how many times : it normalizes these times to one
+ if(!suffix().isEmpty()){
+ const QString suf(suffix());
+ QString t(editor()->text());
+ if( t.contains(suf) ==0 ) {
+ editor()->setText( t + suf);
+ editor()->setCursorPosition(editor()->cursorPosition() - 1);
+ }
+ else
+ if( t.contains(suf) >1 ) {
+ editor()->setText( t.remove(suf) + suf);
+ editor()->setCursorPosition(editor()->cursorPosition() - 1);
+ }
+ }
+}
+
+
+#include "csseditor_globals.moc"
diff --git a/quanta/components/csseditor/csseditor_globals.h b/quanta/components/csseditor/csseditor_globals.h
new file mode 100644
index 00000000..fefae7c8
--- /dev/null
+++ b/quanta/components/csseditor/csseditor_globals.h
@@ -0,0 +1,63 @@
+/***************************************************************************
+ csseditor_globals.h - description
+ -------------------
+ begin : dom ago 3 2003
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef CSSEDITOR_GLOBALS_H
+#define CSSEDITOR_GLOBALS_H
+#include <qspinbox.h>
+#include <qregexp.h>
+#include <qstringlist.h>
+
+namespace CSSEditorGlobals {
+const QStringList HTMLColors(QStringList::split(",",QString("aliceblue,antiquewhite,aqua,aquamarine,azure,beige,bisque,black,blanchedalmond,"
+ "blue,blueviolet,brown,burlywood,cadetblue,chartreuse,chocolate,coral,cornflowerblue,"
+ "cornsilk,crimson,cyan,darkblue,darkcyan,darkgoldenrod,darkgray,darkgreen,"
+ "darkkhaki,darkmagenta,darkolivegreen,darkorange,darkorchid,darkred,darksalmon,"
+ "darkseagreen,darkslateblue,darkslategray,darkturquoise,darkviolet,deeppink,"
+ "deepskyblue,dimgray,dodgerblue,firebrick,floralwhite,forestgreen,fuchsia,gainsboro,"
+ "ghostwhite,gold,goldenrod,gray,green,greenyellow,honeydew,hotpink,indianred,"
+ "indigo,ivory,khaki,lavender,lavenderblush,lawngreen,lemonchiffon,lightblue,lightcoral,"
+ "lightcyan,lightgoldenrodyellow,lightgreen,lightgrey,lightpink,lightsalmon,lightseagreen,"
+ "lightskyblue,lightslategray,lightsteelblue,lightyellow,lime,limegreen,linen,magenta,"
+ "maroon,mediumaquamarine,mediumblue,mediumorchid,mediumpurple,mediumseagreen,"
+ "mediumslateblue,mediumspringgreen,mediumturquoise,mediumvioletred,midnightblue,"
+ "mintcream,mistyrose,moccasin,navajowhite,navy,oldlace,olive,olivedrab,orange,"
+ "orangered,orchid,palegoldenrod,palegreen,paleturquoise,palevioletred,papayawhip,"
+ "peachpuff,peru,pink,plum,powderblue,purple,red,rosybrown,royalblue,saddlebrown,"
+ "salmon,sandybrown,seagreen,seashell,sienna,silver,skyblue,slateblue,slategray,snow,"
+ "springgreen,steelblue,tan,teal,thistle,tomato,turquoise,violet,wheat,white,whitesmoke,"
+ "yellow,yellowgreen")));
+
+
+ const QStringList lengthUnits(QStringList::split(",",QString("cm,em,ex,in,mm,pc,pt,px")));
+ const QStringList frequencyUnits(QStringList::split(",",QString("Hz,kHz")));
+ const QStringList angleUnits(QStringList::split(",",QString("deg,rad,grad")));
+ const QStringList timeUnits(QStringList::split(",",QString("s,ms")));
+}
+
+
+class mySpinBox : public QSpinBox{
+ Q_OBJECT
+ public:
+ mySpinBox(QWidget * parent = 0, const char * name = 0 );
+ mySpinBox( int minValue, int maxValue, int step = 1, QWidget * parent = 0, const char * name = 0 );
+ ~mySpinBox();
+ public slots:
+ void checkSuffix(const QString&);
+};
+
+
+#endif
diff --git a/quanta/components/csseditor/csseditors.ui b/quanta/components/csseditor/csseditors.ui
new file mode 100644
index 00000000..de99118f
--- /dev/null
+++ b/quanta/components/csseditor/csseditors.ui
@@ -0,0 +1,411 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>CSSEditorS</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>CSSEditorS</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>631</width>
+ <height>490</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>CSS Editor</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="2" column="1">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>280</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget" row="2" column="2">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pbOk</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pbCancel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>SHckb</cstring>
+ </property>
+ <property name="text">
+ <string>Use shorthand form</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QSplitter" row="0" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>splitter3</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <widget class="QTabWidget">
+ <property name="name">
+ <cstring>twMediaGroup</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>33</width>
+ <height>7</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>290</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Visual</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Properties</string>
+ </property>
+ <property name="clickable">
+ <bool>false</bool>
+ </property>
+ <property name="resizable">
+ <bool>false</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>lvVisual</cstring>
+ </property>
+ <property name="cursor">
+ <cursor>13</cursor>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Paged</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Properties</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>lvPaged</cstring>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Interactive</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Properties</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>lvInteractive</cstring>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Aural</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Properties</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>lvAural</cstring>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>All</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Properties</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>lvAll</cstring>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ <widget class="QSplitter">
+ <property name="name">
+ <cstring>splitter3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <widget class="QFrame">
+ <property name="name">
+ <cstring>fEditing</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Raised</enum>
+ </property>
+ </widget>
+ <widget class="QFrame">
+ <property name="name">
+ <cstring>fPreview</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>200</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Raised</enum>
+ </property>
+ </widget>
+ <widget class="QTextEdit">
+ <property name="name">
+ <cstring>display</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32766</width>
+ <height>32766</height>
+ </size>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ <widget class="KPushButton" row="2" column="0">
+ <property name="name">
+ <cstring>pbHelp</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Help</string>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>pbCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>CSSEditorS</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>pbOk</sender>
+ <signal>clicked()</signal>
+ <receiver>CSSEditorS</receiver>
+ <slot>accept()</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/quanta/components/csseditor/cssselector.cpp b/quanta/components/csseditor/cssselector.cpp
new file mode 100644
index 00000000..1425102f
--- /dev/null
+++ b/quanta/components/csseditor/cssselector.cpp
@@ -0,0 +1,395 @@
+/***************************************************************************
+ cssselector.cpp - description
+ -------------------
+ begin : mer ago 6 2003
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "cssselector.h"
+#include "csseditor.h"
+
+#include <qlineedit.h>
+#include <qcombobox.h>
+#include <qpushbutton.h>
+#include <qtextstream.h>
+#include <qtabwidget.h>
+#include <qobjectlist.h>
+#include <qfileinfo.h>
+#include <qlabel.h>
+#include <qregexp.h>
+#include <qwhatsthis.h>
+
+#include <kstandarddirs.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include <kmessagebox.h>
+#include <kurlrequester.h>
+#include <kfiledialog.h>
+#include "project.h"
+#include "stylesheetparser.h"
+
+
+CSSSelector::CSSSelector(QWidget *parent, const char* name) : CSSSelectorS (parent,name),m_orderNumber(0),m_stopProcessingStylesheet(false) {
+
+ m_currentItem = 0L;
+
+ Connect();
+
+ kurApplyToFile->fileDialog()->setURL(Project::ref()->projectBaseURL().url());
+ kurApplyToFile->fileDialog()->setFilter( "*.html *.htm |" + i18n("HTML Files") +" (*.html *.htm)\n*.xhtml |" + i18n("XHTML Files")+" (*.xhtml)\n*.xml |" + i18n("XML Files")+" (*.xml)\n*.*|" + i18n("All Files")+" (*.*)" );
+ QWhatsThis::add((QLineEdit*)(kurApplyToFile->lineEdit()),"With this line edit you can insert the URL of the file you want to use to preview the style sheet you are editing");
+
+ /*QString configDir = locate("appdata", "csseditor/config.xml");
+ configDir = QFileInfo(configDir).dirPath() + "/";*/
+
+ QString configDir = QFileInfo( locate("appdata", "csseditor/config.xml") ).dirPath() + "/";
+
+ QDomDocument doc;
+ QFile file( configDir+"pseudo.xml" );
+ if ( !file.open( IO_ReadOnly ) )
+ return;
+ if ( !doc.setContent( &file ) ) {
+ file.close();
+ return;
+ }
+ file.close();
+
+ QDomElement docElem = doc.documentElement();
+
+ QDomNode n = docElem.firstChild();
+ while( !n.isNull() ) {
+ QDomElement e = n.toElement();
+ if( !e.isNull() ) {
+ cbPseudo->insertItem(e.attribute("name"));
+ }
+ n = n.nextSibling();
+ }
+
+ file.setName( configDir+"dtdTags.xml" );
+ if ( !file.open( IO_ReadOnly ) )
+ return;
+ if ( !doc.setContent( &file ) ) {
+ file.close();
+ return;
+ }
+ file.close();
+
+ QStringList dtdNames,
+ dtdNickNames;
+ docElem = doc.documentElement();
+ n = docElem.firstChild();
+ while( !n.isNull() ) {
+ QDomElement e = n.toElement();
+ if( !e.isNull() ) {
+ dtdNames.append(e.attribute("name"));
+ dtdNickNames.append(e.attribute("nickName"));
+ if(e.attribute("default") == "yes") {
+ QStringList tagList = QStringList::split( ',',e.text() );
+ tagList.sort();
+ cbTag->insertStringList( tagList );
+ cbTag->setAutoCompletion(true);
+ }
+ }
+ n = n.nextSibling();
+ }
+ cbDTD->insertStringList( dtdNickNames );
+}
+
+CSSSelector::~CSSSelector(){
+}
+
+void CSSSelector::Connect(){
+
+ connect(cbDTD,SIGNAL(activated(const QString&)),this,SLOT(setDTDTags(const QString&)));
+
+ connect(pbAddTag,SIGNAL(clicked()), this ,SLOT(addTag()));
+ connect(pbAddClass,SIGNAL(clicked()), this ,SLOT(addClass()));
+ connect(pbAddID,SIGNAL(clicked()), this ,SLOT(addID()));
+ connect(pbAddPseudo,SIGNAL(clicked()), this ,SLOT(addPseudo()));
+
+ connect(lvTags, SIGNAL(doubleClicked( QListViewItem * )), this, SLOT(openCSSEditor(QListViewItem *)));
+ connect(lvClasses, SIGNAL(doubleClicked( QListViewItem * )), this, SLOT(openCSSEditor(QListViewItem *)));
+ connect(lvIDs, SIGNAL(doubleClicked( QListViewItem * )), this, SLOT(openCSSEditor(QListViewItem *)));
+ connect(lvPseudo, SIGNAL(doubleClicked( QListViewItem * )), this, SLOT(openCSSEditor(QListViewItem *)));
+
+ connect(lvTags, SIGNAL(selectionChanged( QListViewItem * )), this, SLOT(setCurrentItem(QListViewItem *)));
+ connect(lvClasses, SIGNAL(selectionChanged( QListViewItem * )), this, SLOT(setCurrentItem(QListViewItem *)));
+ connect(lvIDs, SIGNAL(selectionChanged( QListViewItem * )), this, SLOT(setCurrentItem(QListViewItem *)));
+ connect(lvPseudo, SIGNAL( selectionChanged( QListViewItem * )), this, SLOT(setCurrentItem(QListViewItem *)));
+
+ connect(pbRemoveSelectedTag,SIGNAL(clicked()), this ,SLOT(removeSelected()));
+ connect(pbRemoveSelectedClass,SIGNAL(clicked()), this ,SLOT(removeSelected()));
+ connect(pbRemoveSelectedID,SIGNAL(clicked()), this ,SLOT(removeSelected()));
+ connect(pbRemoveSelectedPseudo,SIGNAL(clicked()), this ,SLOT(removeSelected()));
+
+ connect(twSelectors,SIGNAL(currentChanged ( QWidget * )), this ,SLOT(setCurrentListView( QWidget * )));
+
+ connect(pbRemoveAllTags,SIGNAL(clicked()), this ,SLOT(removeAll()));
+ connect(pbRemoveAllClasses,SIGNAL(clicked()), this ,SLOT(removeAll()));
+ connect(pbRemoveAllIDs,SIGNAL(clicked()), this ,SLOT(removeAll()));
+ connect(pbRemoveAllPseudo,SIGNAL(clicked()), this ,SLOT(removeAll()));
+}
+
+void CSSSelector::setDTDTags(const QString& s){
+
+ QString configDir = QFileInfo( locate("appdata", "csseditor/config.xml") ).dirPath() + "/";
+
+ QDomDocument doc;
+
+ QFile file( configDir+"dtdTags.xml" );
+ if ( !file.open( IO_ReadOnly ) )
+ return;
+ if ( !doc.setContent( &file ) ) {
+ file.close();
+ return;
+ }
+ file.close();
+
+ QStringList dtdNames;
+ QDomElement docElem = doc.documentElement();
+ QDomNode n = docElem.firstChild();
+ while( !n.isNull() ) {
+ if( n.toElement().attribute("nickName") == s )
+ break;
+ n = n.nextSibling();
+ }
+ QStringList tagList = QStringList::split( ',',n.toElement().text() );
+ tagList.sort();
+ cbTag->clear();
+ cbTag->insertStringList( tagList );
+ cbTag->setAutoCompletion(true);
+}
+
+void CSSSelector::addTag(){
+ QListViewItem *item = new QListViewItem(lvTags);
+ if(!cbTag->currentText().isEmpty()){
+ item->setText(0,cbTag->currentText());
+ QPair<QString, unsigned int> tmp(QString::null,++m_orderNumber);
+ m_currentStylesheetStructure[item->text(0)]=tmp;
+ }
+}
+
+void CSSSelector::addClass(){
+ QListViewItem *item = new QListViewItem(lvClasses);
+ if(!leClass->text().isEmpty()){
+ item->setText(0,leClass->text());
+ QPair<QString, unsigned int> tmp(QString::null,++m_orderNumber);
+ m_currentStylesheetStructure[item->text(0)]=tmp;
+ }
+}
+
+void CSSSelector::addID(){
+ QListViewItem *item = new QListViewItem(lvIDs);
+ if(!leID->text().isEmpty()){
+ item->setText(0,leID->text());
+ QPair<QString, unsigned int> tmp(QString::null,++m_orderNumber);
+ m_currentStylesheetStructure[item->text(0)]=tmp;
+ }
+}
+
+void CSSSelector::addPseudo(){
+ QListViewItem *item = new QListViewItem(lvPseudo);
+ item->setText(0,(lePseudoSelector->text()+":"+cbPseudo->currentText()).stripWhiteSpace());
+ QPair<QString, unsigned int> tmp(QString::null,++m_orderNumber);
+ m_currentStylesheetStructure[item->text(0)]=tmp;
+}
+
+void CSSSelector::openCSSEditor(QListViewItem * i){
+ if(!m_stopProcessingStylesheet){
+ QListView *lv = i->listView();
+ QListViewItem *temp;
+ QString s;
+ QObjectList *l = queryList( "QListView" );
+ QObjectListIt it( *l ); // iterate over the listviews
+ QObject *obj;
+
+ while ( (obj = it.current()) != 0 ) {
+ QListView *lvTemp = (QListView*)obj;
+ if( lv != lvTemp){
+ temp = lvTemp->firstChild();
+ while(temp){
+ s+=(temp->text(0)+" { "+temp->text(1)+" } ");
+ temp = temp->nextSibling();
+ }
+ }
+ ++it;
+ }
+ delete l; // delete the list, not the objects
+
+ temp = lv->firstChild();
+
+ while(temp){
+ if(temp != i) s+=(temp->text(0)+" { "+temp->text(1)+" } ");
+ temp = temp->nextSibling();
+ }
+
+ CSSEditor dlg(i);
+ if(m_callingFrom == "XHTML"){
+ dlg.setHeader(m_header);
+ dlg.setSelectors(s);
+ dlg.setFooter(m_footer);
+ dlg.setFileToPreview(m_fileToPreview,false);
+ }
+ else if(m_callingFrom == "CSS"){
+ if(kurApplyToFile->url().isEmpty())
+ dlg.hidePreviewer();
+ else {
+ dlg.setFileToPreview(kurApplyToFile->url(),true);
+
+ QString tmp;
+ QListViewItem *item = lvTags->firstChild();
+ while( item ) {
+ if(i->text(0).stripWhiteSpace() != item->text(0).stripWhiteSpace())
+ tmp += item->text(0) + " {" + item->text(1) + "}";
+ item = item->nextSibling();
+ }
+
+ item = lvClasses->firstChild();
+ while( item ) {
+ if(i->text(0).stripWhiteSpace() != item->text(0).stripWhiteSpace())
+ tmp += item->text(0) + " {" + item->text(1) + "}";
+ item = item->nextSibling();
+ }
+
+ item = lvIDs->firstChild();
+ while( item ) {
+ if(i->text(0).stripWhiteSpace() != item->text(0).stripWhiteSpace())
+ tmp += item->text(0) + " {" + item->text(1) + "}";
+ item = item->nextSibling();
+ }
+
+ item = lvPseudo->firstChild();
+ while( item ) {
+ if(i->text(0).stripWhiteSpace() != item->text(0).stripWhiteSpace())
+ tmp += item->text(0) + " {" + item->text(1) + "}";
+ item = item->nextSibling();
+ }
+
+ dlg.setExternalStyleSheetDefinition(tmp);
+ }
+ }
+
+ dlg.initialize();
+
+ if(dlg.exec()) {
+ i->setText(1,dlg.generateProperties());
+ QPair<QString, unsigned int> tmp(m_currentStylesheetStructure[i->text(0)]);
+ tmp.first = dlg.generateProperties();
+ m_currentStylesheetStructure[i->text(0)] = tmp;
+ }
+ }
+}
+
+void CSSSelector::setCurrentListView(QWidget* w){
+ QObjectList *l = w->queryList( "QListView" );
+ m_currentListView = static_cast<QListView*>(l->first());
+}
+
+void CSSSelector::removeAll(){
+ QListViewItemIterator it( m_currentListView );
+ while ( it.current() ) {
+ QListViewItem *item = it.current();
+ m_currentStylesheetStructure.remove(item->text(0));
+ ++it;
+ }
+ m_currentListView->clear();
+}
+
+void CSSSelector::removeSelected(){
+ if( m_currentItem ) {
+ m_currentStylesheetStructure.remove(m_currentItem->text(0));
+ delete m_currentItem;
+ m_currentItem = 0L;
+ }
+}
+
+void CSSSelector::loadCSSContent(const QString& s){
+ stylesheetParser p(s);
+ connect(&p,SIGNAL(errorOccurred(const QString&)), this, SLOT(setStylesheetProcessing(const QString&)));
+ p.parse();
+ m_orderNumber = p.orderNumber();
+
+ QMap<QString, QPair<QString,unsigned int> >::Iterator it;
+ m_currentStylesheetStructure = p.stylesheetStructure();
+ for ( it = m_currentStylesheetStructure.begin(); it != m_currentStylesheetStructure.end(); ++it ) {
+ if(!it.key().startsWith("@rule") && !it.key().startsWith("/*")){
+ QListViewItem *item;
+ if(it.key().contains(":")){
+ item = new QListViewItem(lvPseudo);
+ }
+ else
+ if(it.key().contains("#")){
+ item = new QListViewItem(lvIDs);
+ }
+ else
+ if(it.key().contains(".")){
+ item = new QListViewItem(lvClasses);
+ }
+ else {
+ item = new QListViewItem(lvTags);
+ }
+
+ item->setText(0,it.key());
+ item->setText(1,it.data().first);
+
+ }
+ }
+}
+
+QString CSSSelector::generateFormattedStyleSection(){
+ QMap< QString,QPair<QString,unsigned int> >::Iterator it;
+ QString styleSection,tmpStr;
+ unsigned int indentWidth,
+ indentDisplacement = 2;
+ for ( unsigned int i=0;i<=m_orderNumber;i++ ) {
+ for ( it = m_currentStylesheetStructure.begin(); it != m_currentStylesheetStructure.end(); ++it ) {
+ QString key = it.key();
+ if(it.data().second == i){
+ if(key.startsWith("@rule"))
+ styleSection += it.data().first;
+ else if(key.startsWith("/*"))
+ styleSection += it.data().first;
+ else {
+ key.remove(QRegExp("-v[\\d]+$"));
+ styleSection += "\n" + key + " {\n";
+ indentWidth = indentDisplacement + 2;
+ QStringList props = QStringList::split(";",it.data().first.simplifyWhiteSpace());
+ QString indentStr;
+ indentStr.fill(' ',indentWidth);
+ for ( QStringList::Iterator it = props.begin(); it != props.end(); ++it ) {
+ if((*it).startsWith(" "))
+ tmpStr += indentStr + (*it).remove(0,1) + ";\n";
+ else
+ tmpStr += indentStr + (*it) + ";\n";
+ }
+ indentStr.fill(' ', indentDisplacement);
+ styleSection += tmpStr + indentStr + "}\n\n";
+ tmpStr = QString::null;
+ }
+ }
+ }
+ }
+ return "\n"+styleSection;
+}
+
+void CSSSelector::enableApplyToFile(){
+ tlApplyToFile->setEnabled(true);
+ kurApplyToFile->setEnabled(true);
+}
+
+void CSSSelector::setStylesheetProcessing(const QString& msg) {
+ m_stopProcessingStylesheet=true;
+ KMessageBox::error (0L, msg );
+}
+
+#include "cssselector.moc"
diff --git a/quanta/components/csseditor/cssselector.h b/quanta/components/csseditor/cssselector.h
new file mode 100644
index 00000000..f4d42e89
--- /dev/null
+++ b/quanta/components/csseditor/cssselector.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ cssselector.h - description
+ -------------------
+ begin : mer ago 6 2003
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef CSSSELECTOR_H
+#define CSSSELECTOR_H
+
+#include <qmap.h>
+#include <qpair.h>
+#include "cssselectors.h"
+
+class QListViewItem;
+class QStringList;
+/**
+ *@author gulmini luciano
+ */
+
+class CSSSelector : public CSSSelectorS {
+ Q_OBJECT
+
+ private:
+ QListViewItem *m_currentItem;
+ QListView *m_currentListView;
+ QString m_header,
+ m_footer,
+ m_callingFrom,
+ m_fileToPreview;
+ QMap<QString, QPair<QString,unsigned int> > m_currentStylesheetStructure;
+ unsigned int m_orderNumber;
+ bool m_stopProcessingStylesheet;
+
+ void Connect();
+
+ public:
+ CSSSelector(QWidget *parent=0, const char* name=0);
+ ~CSSSelector();
+ void loadCSSContent(const QString& s);
+ void setHeader(const QString& h) { m_header = h; }
+ void setFooter(const QString& f) { m_footer = f; }
+ void enableApplyToFile();
+ void setCallingFrom(const QString& cf){ m_callingFrom = cf ;}
+ void setFileToPreview(const QString& s){ m_fileToPreview=s;}
+ bool errorOnProcessingStylesheet() const { return m_stopProcessingStylesheet; }
+ QString generateFormattedStyleSection();
+
+ private slots:
+ void openCSSEditor(QListViewItem *);
+ void addTag();
+ void addClass();
+ void addID();
+ void addPseudo();
+ void removeAll();
+ void removeSelected();
+ void setCurrentItem(QListViewItem* i) { m_currentItem = i; }
+ void setCurrentListView(QWidget*);
+ void setDTDTags(const QString&);
+ void setStylesheetProcessing(const QString&);
+};
+
+#endif
+
diff --git a/quanta/components/csseditor/cssselectors.ui b/quanta/components/csseditor/cssselectors.ui
new file mode 100644
index 00000000..1119ccdb
--- /dev/null
+++ b/quanta/components/csseditor/cssselectors.ui
@@ -0,0 +1,985 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>CSSSelectorS</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>CSSSelectorS</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>621</width>
+ <height>496</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>CSS Selector Dialog</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>layout11</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>tlApplyToFile</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Apply to file:</string>
+ </property>
+ </widget>
+ <widget class="KURLRequester">
+ <property name="name">
+ <cstring>kurApplyToFile</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer row="2" column="1">
+ <property name="name">
+ <cstring>spacer19_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget" row="3" column="2">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pbOk</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pbCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QTabWidget" row="0" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>twSelectors</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Tags</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="2">
+ <property name="name">
+ <cstring>layout13</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Remove Selector</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pbRemoveSelectedTag</cstring>
+ </property>
+ <property name="font">
+ <font>
+ </font>
+ </property>
+ <property name="text">
+ <string>Selected</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>pbRemoveAllTags</cstring>
+ </property>
+ <property name="text">
+ <string>All</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>DTD Selection</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QComboBox" row="0" column="0">
+ <property name="name">
+ <cstring>cbDTD</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer7_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox3</cstring>
+ </property>
+ <property name="title">
+ <string>Add Selector</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QComboBox" row="0" column="0">
+ <property name="name">
+ <cstring>cbTag</cstring>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>pbAddTag</cstring>
+ </property>
+ <property name="text">
+ <string>Add</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer6_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Selector</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Properties</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>lvTags</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="showSortIndicator">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ </widget>
+ <spacer row="0" column="1">
+ <property name="name">
+ <cstring>spacer15</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Minimum</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>IDs</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Selector</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Properties</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>lvIDs</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="showSortIndicator">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ </widget>
+ <spacer row="0" column="1">
+ <property name="name">
+ <cstring>spacer18</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget" row="0" column="2">
+ <property name="name">
+ <cstring>layout14</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer12</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox4_2</cstring>
+ </property>
+ <property name="title">
+ <string>Remove Selector</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pbRemoveSelectedID</cstring>
+ </property>
+ <property name="font">
+ <font>
+ </font>
+ </property>
+ <property name="text">
+ <string>Selected</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>pbRemoveAllIDs</cstring>
+ </property>
+ <property name="text">
+ <string>All</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer13</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox7_2</cstring>
+ </property>
+ <property name="title">
+ <string>Add Selector</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLineEdit" row="0" column="0">
+ <property name="name">
+ <cstring>leID</cstring>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>pbAddID</cstring>
+ </property>
+ <property name="text">
+ <string>Add</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer14</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Classes</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Selector</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Properties</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>lvClasses</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="showSortIndicator">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ </widget>
+ <spacer row="0" column="1">
+ <property name="name">
+ <cstring>spacer19</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget" row="0" column="2">
+ <property name="name">
+ <cstring>layout13</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer9</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox4_3</cstring>
+ </property>
+ <property name="title">
+ <string>Remove Selector</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pbRemoveSelectedClass</cstring>
+ </property>
+ <property name="font">
+ <font>
+ </font>
+ </property>
+ <property name="text">
+ <string>Selected</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>pbRemoveAllClasses</cstring>
+ </property>
+ <property name="text">
+ <string>All</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer11</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox7</cstring>
+ </property>
+ <property name="title">
+ <string>Add Selector</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLineEdit" row="0" column="0">
+ <property name="name">
+ <cstring>leClass</cstring>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>pbAddClass</cstring>
+ </property>
+ <property name="text">
+ <string>Add</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer10</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Pseudo</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Selector</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Properties</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>lvPseudo</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="showSortIndicator">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ </widget>
+ <spacer row="0" column="1">
+ <property name="name">
+ <cstring>spacer7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget" row="0" column="2">
+ <property name="name">
+ <cstring>layout17</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer15_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox4</cstring>
+ </property>
+ <property name="title">
+ <string>Remove Selector</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>pbRemoveAllPseudo</cstring>
+ </property>
+ <property name="text">
+ <string>All</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pbRemoveSelectedPseudo</cstring>
+ </property>
+ <property name="font">
+ <font>
+ </font>
+ </property>
+ <property name="text">
+ <string>Selected</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer16</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox7_3</cstring>
+ </property>
+ <property name="title">
+ <string>Add Selector</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLineEdit" row="0" column="0">
+ <property name="name">
+ <cstring>lePseudoSelector</cstring>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="1" column="0">
+ <property name="name">
+ <cstring>cbPseudo</cstring>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="2" column="0">
+ <property name="name">
+ <cstring>pbAddPseudo</cstring>
+ </property>
+ <property name="text">
+ <string>Add</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer17</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ <spacer row="3" column="1">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>380</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton" row="3" column="0">
+ <property name="name">
+ <cstring>pbHelp</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Help</string>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>pbOk</sender>
+ <signal>clicked()</signal>
+ <receiver>CSSSelectorS</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>pbCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>CSSSelectorS</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/quanta/components/csseditor/cssshpropertyparser.cpp b/quanta/components/csseditor/cssshpropertyparser.cpp
new file mode 100644
index 00000000..d02c39a5
--- /dev/null
+++ b/quanta/components/csseditor/cssshpropertyparser.cpp
@@ -0,0 +1,127 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Gulmini Luciano *
+ * gulmini.luciano@student.unife.it *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#include "cssshpropertyparser.h"
+#include <qregexp.h>
+//#include <kdebug.h>
+
+CSSSHPropertyParser::CSSSHPropertyParser(const QString& s){
+ QStringList l1,
+ l2=QStringList::split(",",s);
+
+ for ( QStringList::Iterator it = l2.begin(); it != l2.end(); ++it ) {
+ QString temp;
+ temp=removeBeginningWhiteSpaces((*it));
+ temp=removeEndingWhiteSpaces(temp);
+ l1.append(temp);
+ }
+
+ m_propertyToParse = l1.join(",");// we eliminte blanks before after a comma in things like "something" , something , serif
+}
+
+CSSSHPropertyParser::~CSSSHPropertyParser(){}
+
+QString CSSSHPropertyParser::removeEndingWhiteSpaces(const QString& s){
+ int index = s.length()-1;
+ while(s[index] == ' ' ) index--;
+ return s.left(index+1);
+}
+
+QString CSSSHPropertyParser::removeBeginningWhiteSpaces(const QString& s){
+ int index = 0;
+ while(s[index] == ' ' ) index++;
+ return s.right(s.length()-index);
+}
+
+QString CSSSHPropertyParser::extractFunctionList(){
+ QRegExp functionListPattern("\\s*([a-zA-Z0-9_]*\\([\\W\\w]*\\))\\s*");
+ functionListPattern.search(m_propertyToParse);
+ return functionListPattern.cap(1);
+}
+
+QString CSSSHPropertyParser::extractQuotedStringList(){
+ QString temp;
+ bool stop = false;
+ unsigned int i=0;
+ while(!stop && i<m_propertyToParse.length() ){
+ if( m_propertyToParse[i] == ' ' ){
+ if( ( temp.contains("\"") + temp.contains("\'") )%2 == 0 ) stop = true;
+ else temp += m_propertyToParse[i];
+ }
+ else temp += m_propertyToParse[i];
+ i++;
+ }
+ return temp;
+}
+
+QString CSSSHPropertyParser::extractURIList(){//extract things like url('...') or url("..") or url("..."), url(.....
+ //kdDebug(24000) << "\n\n\nextractURIList()\n\n\n";
+ QRegExp URIListPattern("\\s*(url\\([\\W\\w]*\\))\\s*");
+ URIListPattern.search(m_propertyToParse);
+ return URIListPattern.cap(1);
+}
+
+QStringList CSSSHPropertyParser::parse(){
+ QStringList tokenList;
+ bool stop = false;
+ m_propertyToParse = removeBeginningWhiteSpaces(m_propertyToParse);
+
+ while(!stop){
+ QString temp;
+ for(unsigned int i=0;i<m_propertyToParse.length() ;i++){
+ if(m_propertyToParse[i] == ' ') break;// tokens are delimited by a blank
+ temp+=m_propertyToParse[i];
+ }
+
+ if(temp.contains("url(") !=0 ){
+ QString foundURIList = extractURIList();
+ m_propertyToParse = removeBeginningWhiteSpaces(m_propertyToParse.remove(foundURIList));
+ tokenList.append(foundURIList);
+ }
+ else
+ if(temp.contains("(")!=0){
+ QString foundFunctionList = extractFunctionList();
+ m_propertyToParse = removeBeginningWhiteSpaces(m_propertyToParse.remove(foundFunctionList));
+ tokenList.append(foundFunctionList);
+ }
+ else
+ if(temp.contains("'")!=0 || temp.contains("\"")!=0 || temp.contains(",")!=0){
+ QString foundQuotedStringList = extractQuotedStringList();
+ m_propertyToParse = removeBeginningWhiteSpaces(m_propertyToParse.remove(foundQuotedStringList));
+ tokenList.append(foundQuotedStringList);
+ }
+ else
+ if(temp.contains("/")!=0){ //treat the presence of line-height in font shorthand form
+ m_propertyToParse = removeBeginningWhiteSpaces(m_propertyToParse.remove(temp));
+ tokenList.append(temp.section("/",0,0));
+ tokenList.append("/"+temp.section("/",1,1));
+ }
+ else {
+ tokenList.append(temp);
+ int tempPos = m_propertyToParse.find(temp);
+ m_propertyToParse = removeBeginningWhiteSpaces(m_propertyToParse.remove(tempPos,temp.length()));
+ }
+ if( m_propertyToParse.isEmpty() ) stop = true;
+ }
+ return tokenList;
+}
+
+
+
+
diff --git a/quanta/components/csseditor/cssshpropertyparser.h b/quanta/components/csseditor/cssshpropertyparser.h
new file mode 100644
index 00000000..dd95eb39
--- /dev/null
+++ b/quanta/components/csseditor/cssshpropertyparser.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Gulmini Luciano *
+ * gulmini.luciano@student.unife.it *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef CSSSHPROPERTYPARSER_H
+#define CSSSHPROPERTYPARSER_H
+
+/**
+@author Gulmini Luciano
+*/
+#include <qstringlist.h>
+
+class CSSSHPropertyParser{
+
+ public:
+ CSSSHPropertyParser(const QString& s);
+ ~CSSSHPropertyParser();
+ QStringList parse();
+
+ private:
+ QString m_propertyToParse;
+
+ private:
+ QString extractURIList();
+ QString extractFunctionList();
+ QString extractQuotedStringList();
+ QString removeBeginningWhiteSpaces(const QString& s);
+ QString removeEndingWhiteSpaces(const QString& s);
+};
+
+#endif
diff --git a/quanta/components/csseditor/data/Makefile.am b/quanta/components/csseditor/data/Makefile.am
new file mode 100644
index 00000000..01ddeee5
--- /dev/null
+++ b/quanta/components/csseditor/data/Makefile.am
@@ -0,0 +1,3 @@
+cssxmldir= ${quanta_datadir}/csseditor
+cssxml_DATA = config.xml pseudo.xml atrules.xml dtdTags.xml
+
diff --git a/quanta/components/csseditor/data/atrules.xml b/quanta/components/csseditor/data/atrules.xml
new file mode 100644
index 00000000..4d9f0d38
--- /dev/null
+++ b/quanta/components/csseditor/data/atrules.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="iso-8859-1" ?>
+<rules version="2.1">
+ <rule name="charset"/>
+ <rule name="import"/>
+ <rule name="media"/>
+ <rule name="page"/>
+</rules>
diff --git a/quanta/components/csseditor/data/config.xml b/quanta/components/csseditor/data/config.xml
new file mode 100644
index 00000000..15fd659f
--- /dev/null
+++ b/quanta/components/csseditor/data/config.xml
@@ -0,0 +1,609 @@
+<?xml version="1.0" encoding="iso-8859-1" ?>
+<css version="2.1">
+<mediagroup type="aural">
+
+ <azimuth>
+ <list value="leftwards,rightwards,inherit"/>
+ <doubleList>
+ <leftList value="left-side,far-left,left,center-left,center,center-right,right,far-right,right-side"/>
+ <rightList value="behind"/>
+ </doubleList>
+ <angle/>
+ </azimuth>
+
+ <cue hasSub="yes">
+ <cue-after>
+ <uri mode="single" resourceType="audio"/>
+ <list value="none,inherit"/>
+ </cue-after>
+ <cue-before>
+ <uri mode="single" resourceType="audio"/>
+ <list value="none,inherit"/>
+ </cue-before>
+ </cue>
+
+ <elevation>
+ <list value="below,level,above,higher,lower,inherit"/>
+ <angle/>
+ <freeedit/>
+ </elevation>
+
+ <pitch>
+ <list value="inherit,x-low,medium,high,x-high,low"/>
+ <frequency/>
+ <freeedit/>
+ </pitch>
+
+ <pitch-range>
+ <number/>
+ <list value="inherit"/>
+ </pitch-range>
+
+ <play-during>
+ <list value="inherit,none,auto"/>
+ <uri mode="single" resourceType="audio"/>
+ </play-during>
+
+ <pause hasSub="yes">
+ <pause-after>
+ <time/>
+ <percentage/>
+ <list value="inherit"/>
+ <freeedit/>
+ </pause-after>
+ <pause-before>
+ <time/>
+ <percentage/>
+ <list value="inherit"/>
+ <freeedit/>
+ </pause-before>
+ </pause>
+
+ <richness>
+ <number/>
+ <list value="inherit"/>
+ </richness>
+
+ <speach-rate>
+ <list value="inherit,x-slow,medium,slow,fast,x-fast,faster,slower"/>
+ <number/>
+ </speach-rate>
+
+ <speak>
+ <list value="normal,none,spell-out,inherit"/>
+ </speak>
+
+ <speak-punctuation>
+ <list value="code,none,inherit"/>
+ </speak-punctuation>
+
+ <speak-header>
+ <list value="once,always,inherit"/>
+ </speak-header>
+
+ <speak-numeral>
+ <list value="digits,continuous,inherit"/>
+ </speak-numeral>
+
+ <stress>
+ <number/>
+ <list value="inherit"/>
+ </stress>
+
+ <voice-family>
+ <freeedit/>
+ <list value="inherit"/>
+ </voice-family>
+
+ <volume>
+ <list value="silent,x-soft,soft,medium,loud,x-loud,inherit"/>
+ <number/>
+ <percentage/>
+ </volume>
+
+</mediagroup>
+
+<mediagroup type="visual">
+
+ <background hasSub="yes">
+ <background-attachment>
+ <list value="scroll,fixed,inherit"/>
+ </background-attachment>
+ <background-color>
+ <colors/>
+ <list value="transparent,inherit"/>
+ </background-color>
+ <background-image>
+ <uri mode="single" resourceType="image"/>
+ <list value="none,inherit"/>
+ </background-image>
+ <background-position>
+ <doubleList>
+ <leftList value="top,center,bottom"/>
+ <rightList value="left,center,right"/>
+ </doubleList>
+ <freeedit/>
+ <doubleLength/>
+ <doublePercentage/>
+ <list value="inherit" editable="yes"/>
+ </background-position>
+ <background-repeat>
+ <list value="repeat,repeat-x,repeat-y,no-repeat,inherit"/>
+ </background-repeat>
+ </background>
+
+ <border hasSub="yes">
+ <border-collapse>
+ <list value="collapse,separate,inherit"/>
+ </border-collapse>
+ <border-color>
+ <colors/>
+ <list value="transparent,inherit" editable="yes"/>
+ </border-color>
+ <border-spacing>
+ <freeedit/>
+ <doubleLength/>
+ <list value="inherit" editable="yes"/>
+ </border-spacing>
+ <border-style>
+ <list value="none,hidden,dotted,dashed,solid,double,groove,ridge,inset,outset,inherit" editable="yes"/>
+ </border-style>
+ <border-top hasSub="yes">
+ <border-top-color>
+ <colors/>
+ <list value="transparent,inherit"/>
+ </border-top-color>
+ <border-top-style>
+ <list value="none,hidden,dotted,dashed,solid,double,groove,ridge,inset,outset,inherit"/>
+ </border-top-style>
+ <border-top-width>
+ <length/>
+ <list value="thin,medium,thick,inherit"/>
+ <freeedit/>
+ </border-top-width>
+ </border-top>
+
+ <border-left hasSub="yes">
+
+ <border-left-color>
+ <colors/>
+ <list value="transparent,inherit"/>
+ </border-left-color>
+
+ <border-left-style>
+ <list value="none,hidden,dotted,dashed,solid,double,groove,ridge,inset,outset,inherit"/>
+ </border-left-style>
+
+ <border-left-width>
+ <length/>
+ <list value="thin,medium,thick,inherit"/>
+ <freeedit/>
+ </border-left-width>
+
+ </border-left>
+
+ <border-right hasSub="yes">
+
+ <border-right-color>
+ <colors/>
+ <list value="transparent,inherit"/>
+ </border-right-color>
+
+ <border-right-style>
+ <list value="none,hidden,dotted,dashed,solid,double,groove,ridge,inset,outset,inherit"/>
+ </border-right-style>
+
+ <border-right-width>
+ <length/>
+ <list value="thin,medium,thick,inherit"/>
+ <freeedit/>
+ </border-right-width>
+
+ </border-right>
+
+ <border-bottom hasSub="yes">
+
+ <border-bottom-color>
+ <colors/>
+ <list value="transparent,inherit"/>
+ </border-bottom-color>
+
+ <border-bottom-style>
+ <list value="none,hidden,dotted,dashed,solid,double,groove,ridge,inset,outset,inherit"/>
+ </border-bottom-style>
+
+ <border-bottom-width>
+ <length/>
+ <list value="thin,medium,thick,inherit"/>
+ <freeedit/>
+ </border-bottom-width>
+
+ </border-bottom>
+
+ <border-width>
+ <edit/>
+ <list value="inherit" editable="yes"/>
+ </border-width>
+
+ </border>
+
+ <bottom>
+ <length/>
+ <percentage/>
+ <list value="auto,inherit"/>
+ <freeedit/>
+ </bottom>
+
+ <caption-side>
+ <list value="top,bottom,inherit"/>
+ </caption-side>
+
+ <clear>
+ <list value="none,left,right,both,inherit"/>
+ </clear>
+
+ <clip>
+ <list value="auto,inherit" editable="yes"/>
+ </clip>
+
+ <color>
+ <colors/>
+ <list value="inherit"/>
+ </color>
+
+ <cursor>
+ <list value="inherit,auto,crosshair,default,pointer,move,e-resize,ne-resize,nw-resize,n-resize,se-resize,sw-resize,s-resize,w-resize,text,wait,help,progress"/>
+ <uri mode="multi" resourceType="mousePointer"/>
+ </cursor>
+
+ <direction>
+ <list value="ltr,rtl,inherit"/>
+ </direction>
+
+ <empty-cells>
+ <list value="show,hide,inherit"/>
+ </empty-cells>
+
+ <float>
+ <list value="left,right,none,inherit"/>
+ </float>
+
+ <font>
+ <list value="caption,icon,menu,message-box,small-caption,status-bar"/>
+ </font>
+
+ <font hasSub="yes">
+
+ <font-family>
+ <fontDialog/>
+ </font-family>
+
+ <font-size>
+ <length/>
+ <percentage/>
+ <list value="xx-small,x-small,small,medium,large,x-large,xx-large,larger,smaller,inherit"/>
+ <freeedit/>
+ </font-size>
+
+ <font-style>
+ <list value="normal,italic,oblique,inherit"/>
+ </font-style>
+
+ <font-variant>
+ <list value="normal,small-caps,inherit"/>
+ </font-variant>
+
+ <font-weight>
+ <list value="normal,bold,bolder,lighter,100,200,300,400,500,600,700,800,900,inherit"/>
+ </font-weight>
+
+ </font>
+
+ <height>
+ <length/>
+ <percentage/>
+ <list value="auto,inherit"/>
+ <freeedit/>
+ </height>
+
+ <left>
+ <length/>
+ <percentage/>
+ <list value="auto,inherit"/>
+ <freeedit/>
+ </left>
+
+ <letter-spacing>
+ <length/>
+ <list value="normal,inherit"/>
+ <freeedit/>
+ </letter-spacing>
+
+ <line-height>
+ <length/>
+ <percentage/>
+ <number/>
+ <list value="normal,inherit"/>
+ <freeedit/>
+ </line-height>
+
+ <list-style hasSub="yes">
+ <list-style-image>
+ <uri mode="single" resourceType="image"/>
+ <list value="none,inherit"/>
+ </list-style-image>
+ <list-style-position>
+ <list value="inside,outside,inherit"/>
+ </list-style-position>
+ <list-style-type>
+ <list value="disc,circle,square,decimal,decimal-leading-zero,lower-roman,upper-roman,lower-greek,lower-alpha,lower-latin,upper-alpha,upper-latin,hebrew,armenian,georgian,cjk-ideographic,hiragana,katakana,hiragana-iroha,katakana-iroha,none,inherit"/>
+ </list-style-type>
+ </list-style>
+
+ <margin hasSub="yes">
+ <margin-left>
+ <length/>
+ <percentage/>
+ <list value="auto"/>
+ <freeedit/>
+ </margin-left>
+ <margin-bottom>
+ <length/>
+ <percentage/>
+ <list value="auto"/>
+ <freeedit/>
+ </margin-bottom>
+ <margin-right>
+ <length/>
+ <percentage/>
+ <list value="auto"/>
+ <freeedit/>
+ </margin-right>
+ <margin-top>
+ <length/>
+ <percentage/>
+ <list value="auto"/>
+ <freeedit/>
+ </margin-top>
+ </margin>
+
+ <max-height>
+ <length/>
+ <percentage/>
+ <list value="none,inherit"/>
+ <freeedit/>
+ </max-height>
+
+ <max-width>
+ <length/>
+ <percentage/>
+ <list value="none,inherit"/>
+ <freeedit/>
+ </max-width>
+
+ <min-height>
+ <length/>
+ <percentage/>
+ <list value="none,inherit"/>
+ <freeedit/>
+ </min-height>
+
+ <min-width>
+ <length/>
+ <percentage/>
+ <list value="none,inherit"/>
+ <freeedit/>
+ </min-width>
+
+ <outline hasSub="yes">
+ <outline-color>
+ <colors/>
+ <list value="invert,inherit"/>
+ </outline-color>
+ <outline-style>
+ <list value="none,hidden,dotted,dashed,solid,double,groove,ridge,inset,outset,inherit"/>
+ </outline-style>
+ <outline-width>
+ <length/>
+ <list value="thin,medium,thick,inherit"/>
+ <freeedit/>
+ </outline-width>
+ </outline>
+
+ <overflow>
+ <list value="visible,hidden,scroll,auto,inherit"/>
+ </overflow>
+
+ <padding hasSub="yes">
+ <padding-top>
+ <length/>
+ <list value="thin,medium,thick,inherit"/>
+ <freeedit/>
+ </padding-top>
+ <padding-right>
+ <length/>
+ <list value="thin,medium,thick,inherit"/>
+ <freeedit/>
+ </padding-right>
+ <padding-bottom>
+ <length/>
+ <list value="thin,medium,thick,inherit"/>
+ <freeedit/>
+ </padding-bottom>
+ <padding-left>
+ <length/>
+ <list value="thin,medium,thick,inherit"/>
+ <freeedit/>
+ </padding-left>
+ </padding>
+
+ <page>
+ <freeedit/>
+ <list value="auto"/>
+ </page>
+
+ <page-break-after>
+ <list value="auto,always,avoid,left,right,inherit"/>
+ </page-break-after>
+
+ <page-break-before>
+ <list value="auto,always,avoid,left,right,inherit"/>
+ </page-break-before>
+
+ <page-break-inside>
+ <list value="avoid,auto,inherit"/>
+ </page-break-inside>
+
+ <position>
+ <list value="static,relative,absolute,fixed,inherit"/>
+ </position>
+
+ <quotes>
+ <list value="none,inherit" editable="yes"/>
+ </quotes>
+
+ <right>
+ <length/>
+ <percentage/>
+ <list value="auto,inherit"/>
+ <freeedit/>
+ </right>
+
+ <table-layout>
+ <list value="auto,fixed,inherit"/>
+ </table-layout>
+
+ <text-align>
+ <list value="center,justify,right,left,inherit"/>
+ </text-align>
+
+ <text-decoration>
+ <list value="none,underline,overline,line-through,blink,inherit"/>
+ <doubleList>
+ <leftList value="none,underline,overline,line-through,blink,inherit"/>
+ <rightList value="none,underline,overline,line-through,blink,inherit"/>
+ </doubleList>
+ </text-decoration>
+
+ <text-indent>
+ <length/>
+ <percentage/>
+ <list value="inherit"/>
+ <freeedit/>
+ </text-indent>
+
+ <text-transform>
+ <list value="capitalize,uppercase,lowercase,none,inherit"/>
+ </text-transform>
+
+ <top>
+ <length/>
+ <percentage/>
+ <list value="auto,inherit"/>
+ <freeedit/>
+ </top>
+
+ <unicode-bidi>
+ <list value="normal,embed,bidi-override,inherit"/>
+ </unicode-bidi>
+
+ <vertical-align>
+ <list value="baseline,inherit,sub,super,top,text-top,middle,bottom,text-bottom"/>
+ <length/>
+ <percentage/>
+ <freeedit/>
+ </vertical-align>
+
+ <visibility>
+ <list value="visible,hidden,collapse,inherit"/>
+ </visibility>
+
+ <white-space>
+ <list value="normal,pre,pre-wrap,pre-line,nowrap,inherit"/>
+ </white-space>
+
+ <width>
+ <length/>
+ <percentage/>
+ <list value="auto,inherit"/>
+ <freeedit/>
+ </width>
+
+ <word-spacing>
+ <length/>
+ <list value="auto,inherit"/>
+ <freeedit/>
+ </word-spacing>
+
+ <z-index>
+ <integer minValue="-9999"/>
+ <list value="inherit,auto"/>
+ </z-index>
+
+</mediagroup>
+
+<mediagroup type="paged">
+
+ <page>
+ <list value="auto"/>
+ <freeedit/>
+ </page>
+
+ <page-break-after>
+ <list value="auto,always,avoid,left,right,inherit"/>
+ </page-break-after>
+
+ <page-break-before>
+ <list value="auto,always,avoid,left,right,inherit"/>
+ </page-break-before>
+
+ <page-break-inside>
+ <list value=",avoid,auto,inherit"/>
+ </page-break-inside>
+
+</mediagroup>
+
+<mediagroup type="interactive">
+
+ <cursor>
+ <list value="inherit,auto,crosshair,default,pointer,move,e-resize,ne-resize,nw-resize,n-resize,se-resize,sw-resize,s-resize,w-resize,text,wait,help,progress"/>
+ <uri mode="multi" resourceType="mousePointer"/>
+ </cursor>
+
+ <outline hasSub="yes">
+ <outline-color>
+ <colors/>
+ <list value="invert,inherit"/>
+ </outline-color>
+ <outline-style>
+ <list value="none,hidden,dotted,dashed,solid,double,groove,ridge,inset,outset,inherit"/>
+ </outline-style>
+ <outline-width>
+ <length/>
+ <list value="thin,medium,thick,inherit"/>
+ <freeedit/>
+ </outline-width>
+ </outline>
+
+</mediagroup>
+
+<mediagroup type="all">
+
+ <content>
+ <list value="open-quote,close-quote,no-open-quote,no-close-quote,inherit" editable="yes"/>
+ </content>
+
+ <counter-increment>
+ <list value="none,inherit" editable="yes"/>
+ </counter-increment>
+
+ <counter-reset>
+ <list value="none,inherit" editable="yes"/>
+ </counter-reset>
+
+ <display>
+ <list value="inline,inline-block,block,list-item,run-in,table,inline-table,table-row-group,table-header-group,table-footer-group,table-row,table-column-group,table-column,table-cell,table-caption,none,inherit"/>
+ </display>
+
+ </mediagroup>
+</css>
diff --git a/quanta/components/csseditor/data/dtdTags.xml b/quanta/components/csseditor/data/dtdTags.xml
new file mode 100644
index 00000000..1ce44d82
--- /dev/null
+++ b/quanta/components/csseditor/data/dtdTags.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="iso-8859-1" ?>
+<dtds>
+ <dtd default="yes" name="" nickName="HTML strict">style,link,h1,h2,h3,h4,h5,h6,ul,pre,tt,i,b,big,em,strong,dfn,code,samp,kbd,var,cite,abbr,acronym,img,br,script,map,span,bdo,select,textarea,label,button,p,dl,div,noscript,blockquote,hr,table,fieldset,body,address,a,area,object,param,small,sub,sup,q,dt,dd,ol,li,form,text,password,checkbox,radio,submit,reset,file,hidden,input,optgroup,option,legend,caption,thead,tfoot,tbody,colgroup,col,tr,th,td,head,title,base,meta,html</dtd>
+ <dtd name="-//w3c//dtd html 4.01 transitional//en" nickName="HTML transitional">a,abbr,acronym,address,applet,area,b,base,basefont,bdo,big,blockquote,body,br,button,caption,center,cite,code,col,colgroup,div,dfn,del,dl,dt,dd,dir,em,fieldset,frameset,frame,font,form,kbd,head,html,hr,h1,h2,h3,h4,h5,h6,i,iframe,img,input,ins,isindex,label,legend,li,link,map,menu,meta,noframes,noscript,object,ol,optgroup,option,p,param,pre,q,s,samp,script,select,small,span,strike,strong,style,sub,sup,table,textarea,tt,thead,tfoot,tbody,tr,th,td,title,u,ul,usemap,var</dtd>
+ <dtd name="-//W3C//DTD MathML 2.0//EN" nickName="MathML">mi,mn,mo,mtext,mspace,ms,mglyph,mrow,mfrac,msrqt,mroot,mstyle,merror,mpadded,mphantom,mfenced,menclose,msub,msup,msubsup,munder,mover,munderover,nmultiscripts,mtable,mtr,mlabeldtr,mtd,maction</dtd>
+</dtds>
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/quanta/components/csseditor/data/pseudo.xml b/quanta/components/csseditor/data/pseudo.xml
new file mode 100644
index 00000000..354544ff
--- /dev/null
+++ b/quanta/components/csseditor/data/pseudo.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="iso-8859-1" ?>
+<pseudo>
+ <element name="after"/>
+ <element name="before"/>
+ <element name="first-child"/>
+ <element name="first-letter"/>
+ <element name="first-line" appliesTo="p"/>
+ <class name="active"/>
+ <class name="focus"/>
+ <class name="hover"/>
+ <class name="lang"/>
+ <class name="link"/>
+ <class name="visited"/>
+</pseudo> \ No newline at end of file
diff --git a/quanta/components/csseditor/doubleeditors.cpp b/quanta/components/csseditor/doubleeditors.cpp
new file mode 100644
index 00000000..6fab0547
--- /dev/null
+++ b/quanta/components/csseditor/doubleeditors.cpp
@@ -0,0 +1,120 @@
+/***************************************************************************
+ doubleeditors.cpp - description
+ -------------------
+ begin : dom ago 3 2003
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+ #include "doubleeditors.h"
+ #include "specialsb.h"
+ #include <qcombobox.h>
+ #include "csseditor_globals.h"
+ #include "propertysetter.h"
+ #include <qregexp.h>
+
+
+
+doubleEditorBase::doubleEditorBase(QWidget *parent, const char *name) : miniEditor(parent,name){
+}
+
+void doubleEditorBase::sxValueSlot(const QString& v){
+ m_sxValue=v;
+ emit valueChanged( m_sxValue +" " + m_dxValue);
+}
+
+void doubleEditorBase::dxValueSlot(const QString& v){
+ m_dxValue=v;
+ emit valueChanged( m_sxValue +" " + m_dxValue);
+}
+
+ doubleLengthEditor::doubleLengthEditor(QWidget *parent, const char *name) : doubleEditorBase(parent,name){
+
+ m_ssbSx = new specialSB(this);
+ m_ssbSx->insertItem("cm");
+ m_ssbSx->insertItem("em");
+ m_ssbSx->insertItem("ex");
+ m_ssbSx->insertItem("in");
+ m_ssbSx->insertItem("mm");
+ m_ssbSx->insertItem("pc");
+ m_ssbSx->insertItem("pt");
+ m_ssbSx->insertItem("px");
+
+ m_ssbDx = new specialSB(this);
+ m_ssbDx->insertItem("cm");
+ m_ssbDx->insertItem("em");
+ m_ssbDx->insertItem("ex");
+ m_ssbDx->insertItem("in");
+ m_ssbDx->insertItem("mm");
+ m_ssbDx->insertItem("pc");
+ m_ssbDx->insertItem("pt");
+ m_ssbDx->insertItem("px");
+
+ connect(m_ssbSx, SIGNAL(valueChanged(const QString&)), this, SLOT(sxValueSlot(const QString&)));
+ connect(m_ssbDx, SIGNAL(valueChanged(const QString&)), this, SLOT(dxValueSlot(const QString&)));
+}
+
+doubleLengthEditor::~doubleLengthEditor(){
+ delete m_ssbSx;
+ delete m_ssbDx;
+}
+
+void doubleLengthEditor::connectToPropertySetter(propertySetter* p){
+ connect(this, SIGNAL(valueChanged(const QString&)), p ,SIGNAL(valueChanged(const QString&)));
+}
+
+void doubleLengthEditor::setInitialValue(const QString& sx, const QString& dx){
+ m_ssbSx->setInitialValue(sx);
+ m_ssbDx->setInitialValue(dx);
+}
+
+doubleComboBoxEditor::doubleComboBoxEditor(QWidget *parent, const char *name) : doubleEditorBase(parent,name){
+ m_cbSx = new QComboBox(this);
+ m_cbDx = new QComboBox(this);
+ connect(m_cbSx, SIGNAL(activated ( const QString & )), this, SLOT(sxValueSlot(const QString&)));
+ connect(m_cbDx, SIGNAL(activated ( const QString & )), this, SLOT(dxValueSlot(const QString&)));
+}
+
+doubleComboBoxEditor::~doubleComboBoxEditor(){
+ delete m_cbSx;
+ delete m_cbDx;
+}
+
+void doubleComboBoxEditor::connectToPropertySetter(propertySetter* p){
+ connect(this, SIGNAL(valueChanged(const QString&)), p ,SIGNAL(valueChanged(const QString&)));
+}
+
+doublePercentageEditor::doublePercentageEditor(QWidget *parent, const char *name) : doubleEditorBase(parent,name){
+ m_sbSx = new mySpinBox(this);
+ m_sbDx = new mySpinBox(this);
+ m_sbSx->setSuffix("%");
+ m_sbDx->setSuffix("%");
+ connect(m_sbSx,SIGNAL(valueChanged(const QString&)),this,SLOT(sxValueSlot(const QString&)));
+ connect(m_sbDx,SIGNAL(valueChanged(const QString&)),this,SLOT(dxValueSlot(const QString&)));
+}
+
+doublePercentageEditor::~doublePercentageEditor(){
+ delete m_sbSx;
+ delete m_sbDx;
+}
+
+void doublePercentageEditor::connectToPropertySetter(propertySetter* p){
+ connect(this, SIGNAL(valueChanged(const QString&)), p ,SIGNAL(valueChanged(const QString&)));
+}
+
+void doublePercentageEditor::setInitialValue(const QString& a_sx, const QString& a_dx){
+ QString sx = a_sx;
+ QString dx = a_dx;
+ m_sbSx->setValue(sx.remove("%").toInt());
+ m_sbDx->setValue(dx.remove("%").toInt());
+}
+
+#include "doubleeditors.moc"
diff --git a/quanta/components/csseditor/doubleeditors.h b/quanta/components/csseditor/doubleeditors.h
new file mode 100644
index 00000000..6496a6fa
--- /dev/null
+++ b/quanta/components/csseditor/doubleeditors.h
@@ -0,0 +1,86 @@
+/***************************************************************************
+ doubleeditors.h - description
+ -------------------
+ begin : dom ago 3 2003
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+ #ifndef DOUBLEEDITORS_H
+ #define DOUBLEEDITORS_H
+ #include "minieditor.h"
+
+ class mySpinBox;
+ class specialSB;
+ class QSpinBox;
+ class QComboBox;
+
+class doubleEditorBase : public miniEditor {
+ Q_OBJECT
+ protected:
+ QString m_sxValue,
+ m_dxValue;
+
+ public:
+ doubleEditorBase(QWidget *parent=0, const char *name=0);
+ virtual ~doubleEditorBase(){}
+ virtual void setInitialValue(){}
+ virtual void connectToPropertySetter(propertySetter* /*p*/){}
+
+ public slots:
+ void sxValueSlot(const QString&);
+ void dxValueSlot(const QString&);
+
+ signals:
+ void valueChanged(const QString&);
+};
+
+class doublePercentageEditor : public doubleEditorBase {
+ Q_OBJECT
+ private:
+ mySpinBox *m_sbSx,
+ *m_sbDx;
+
+ public:
+ doublePercentageEditor(QWidget *parent=0, const char *name=0);
+ virtual ~doublePercentageEditor();
+ virtual void setInitialValue(const QString& sx, const QString& dx);
+ virtual void connectToPropertySetter(propertySetter* p);
+};
+
+class doubleComboBoxEditor : public doubleEditorBase {
+ Q_OBJECT
+ private:
+ QComboBox *m_cbSx,
+ *m_cbDx;
+
+ public:
+ doubleComboBoxEditor(QWidget *parent=0, const char *name=0);
+ virtual ~doubleComboBoxEditor();
+ QComboBox* cbSx() const { return m_cbSx;}
+ QComboBox* cbDx() const { return m_cbDx;}
+ virtual void connectToPropertySetter(propertySetter* p);
+};
+
+class doubleLengthEditor : public doubleEditorBase {
+ Q_OBJECT
+ private:
+ specialSB *m_ssbSx,
+ *m_ssbDx;
+
+ public:
+ doubleLengthEditor(QWidget *parent=0, const char *name=0);
+ virtual ~doubleLengthEditor();
+ virtual void setInitialValue(const QString& sx, const QString& dx);
+ virtual void connectToPropertySetter(propertySetter* p);
+};
+
+#endif
diff --git a/quanta/components/csseditor/encodingselector.cpp b/quanta/components/csseditor/encodingselector.cpp
new file mode 100644
index 00000000..3eeb593b
--- /dev/null
+++ b/quanta/components/csseditor/encodingselector.cpp
@@ -0,0 +1,47 @@
+/***************************************************************************
+ encodingselector.cpp - description
+ -------------------
+ begin : mer ago 6 2003
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+
+#include "encodingselector.h"
+#include <kglobal.h>
+#include <kcharsets.h>
+#include <qtextcodec.h>
+
+/**
+ *@author gulmini luciano
+ */
+
+encodingSelector::encodingSelector(QWidget *parent, const char* name) : encodingSelectorS(parent,name){
+ QStringList encodings (KGlobal::charsets()->availableEncodingNames());
+ int insert = 0;
+ for (uint i=0; i < encodings.count(); i++) {
+ bool found = false;
+ QTextCodec *codecForEnc = KGlobal::charsets()->codecForName(encodings[i], found);
+
+ if (found){
+ cbEncoding->insertItem (encodings[i]);
+ insert++;
+ }
+ }
+}
+
+encodingSelector::~encodingSelector(){}
+
+
+
+#include "encodingselector.moc"
diff --git a/quanta/components/csseditor/encodingselector.h b/quanta/components/csseditor/encodingselector.h
new file mode 100644
index 00000000..3b10fa23
--- /dev/null
+++ b/quanta/components/csseditor/encodingselector.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+ encodingselector.h - description
+ -------------------
+ begin : mer ago 6 2003
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef ENCODINGSELECTOR_H
+#define ENCODINGSELECTOR_H
+
+
+#include "encodingselectors.h"
+#include <qcombobox.h>
+
+/**
+ *@author gulmini luciano
+ */
+
+class encodingSelector : public encodingSelectorS {
+ Q_OBJECT
+
+ public:
+ encodingSelector(QWidget *parent=0, const char* name=0);
+ ~encodingSelector();
+ QString encodingSet() const { return cbEncoding->currentText();}
+
+ };
+
+#endif
+
diff --git a/quanta/components/csseditor/encodingselectors.ui b/quanta/components/csseditor/encodingselectors.ui
new file mode 100644
index 00000000..45d269de
--- /dev/null
+++ b/quanta/components/csseditor/encodingselectors.ui
@@ -0,0 +1,115 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>encodingSelectorS</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>encodingSelectorS</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>228</width>
+ <height>109</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Encoding Selector</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Select encoding:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>cbEncoding</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pbOk</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pbCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pbOk</sender>
+ <signal>clicked()</signal>
+ <receiver>encodingSelectorS</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>pbCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>encodingSelectorS</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/quanta/components/csseditor/fontfamilychooser.cpp b/quanta/components/csseditor/fontfamilychooser.cpp
new file mode 100644
index 00000000..d42139f8
--- /dev/null
+++ b/quanta/components/csseditor/fontfamilychooser.cpp
@@ -0,0 +1,175 @@
+/***************************************************************************
+ fontfamilychooser.cpp - description
+ -------------------
+ begin : mer lug 23 11:20:17 CEST 2003
+ copyright : (C) |YEAR| by si2003 email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "fontfamilychooser.h"
+
+#include <qfontdatabase.h>
+#include <qstringlist.h>
+#include <qlistbox.h>
+#include <qfont.h>
+#include <klocale.h>
+#include <qiconset.h>
+#include <qpixmap.h>
+#include <kiconloader.h>
+#include <kpushbutton.h>
+#include <kglobalsettings.h>
+#include <qregexp.h>
+#include <qlineedit.h>
+#include <qwhatsthis.h>
+
+#include<kdebug.h>
+
+fontFamilyChooser::fontFamilyChooser(QWidget* parent, const char *name) : fontFamilyChooserS(parent,name){
+
+ QFont tmpFont( KGlobalSettings::generalFont().family(), 64, QFont::Black );
+ lePreview->setMinimumHeight( lePreview->fontMetrics().lineSpacing() );
+ lePreview->setAlignment(Qt::AlignCenter);
+ QFont font;
+ font.setPointSize(20);
+ lePreview->setFont(font);
+ lePreview->setText(i18n("The Quick Brown Fox Jumps Over The Lazy Dog"));
+
+ QFontDatabase fdb;
+ QStringList families = fdb.families();
+ for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) {
+ if( (*it).contains('[') !=0 )
+ it = families.remove(it);
+ }
+
+ if( families.count() != 0 ) lbAvailable->insertStringList(families);
+
+
+ QIconSet iconSet = SmallIconSet(QString::fromLatin1("forward"));
+ QPixmap pixMap = iconSet.pixmap( QIconSet::Small, QIconSet::Normal );
+ pbAdd->setIconSet(iconSet);
+ pbAdd->setFixedSize( pixMap.width()+8, pixMap.height()+8 );
+
+ iconSet = SmallIconSet(QString::fromLatin1("back"));
+ pbRemove->setIconSet(iconSet);
+ pbRemove->setFixedSize( pixMap.width()+8, pixMap.height()+8 );
+
+ iconSet = SmallIconSet(QString::fromLatin1("up"));
+ pbMoveUp->setIconSet(iconSet);
+ pbMoveUp->setFixedSize( pixMap.width()+8, pixMap.height()+8 );
+
+ iconSet = SmallIconSet(QString::fromLatin1("down"));
+ pbMoveDown->setIconSet(iconSet);
+ pbMoveDown->setFixedSize( pixMap.width()+8, pixMap.height()+8 );
+
+ connect(pbAdd, SIGNAL(clicked()), this ,SLOT( addFont() ));
+ connect( lbAvailable, SIGNAL( highlighted( const QString& ) ), this, SLOT( updatePreview( const QString&) ) );
+ connect( lbAvailable, SIGNAL( highlighted( const QString& ) ), this, SLOT( setCurrentSelectedAvailableFamilyFont( const QString&) ) );
+ connect( lbGeneric, SIGNAL( highlighted( const QString& ) ), this, SLOT( updatePreview( const QString&) ) );
+ connect( lbGeneric, SIGNAL( highlighted( const QString& ) ), this, SLOT( setCurrentSelectedGenericFamilyFont( const QString&) ) );
+ connect( lbSelected, SIGNAL( highlighted( const QString& ) ), this, SLOT( updatePreview( const QString&) ) );
+ connect( lbSelected, SIGNAL( highlighted( int ) ), this, SLOT( setCurrentSelectedFont( int ) ) );
+ connect( lbSelected, SIGNAL( highlighted( const QString& ) ), this, SLOT( setCurrentSelectedFont( const QString&) ) );
+ connect( pbRemove, SIGNAL( clicked() ), this, SLOT( removeFont() ) );
+ connect( pbMoveUp, SIGNAL( clicked() ), this, SLOT( moveFontUp() ) );
+ connect( pbMoveDown, SIGNAL( clicked() ), this, SLOT( moveFontDown() ) );
+
+ QWhatsThis::add(lbAvailable,i18n("These are the names of the available fonts on your system"));
+ QWhatsThis::add(lbGeneric,i18n("These are the names of the generic fonts "));
+ QWhatsThis::add(lbSelected,i18n("These are the names of the generic fonts you have selected "));
+ QWhatsThis::add(pbAdd,i18n("Click this to add a font to your style sheet"));
+ QWhatsThis::add(pbRemove,i18n("Click this to remove a font from your style sheet"));
+ QWhatsThis::add(pbMoveUp,i18n("Click this to make the font more preferable than the preceeding one"));
+ QWhatsThis::add(pbMoveDown,i18n("Click this to make the font less preferable than the following one"));
+
+}
+
+fontFamilyChooser::~fontFamilyChooser(){}
+
+void fontFamilyChooser::updatePreview(const QString& s){
+ lePreview->setFont(QFont(s,20));
+}
+
+void fontFamilyChooser::addFont(){
+ lbSelected->insertItem( m_currentSelectedFont );
+ switch(m_fontOrigin) {
+ case available: lbAvailable->removeItem(lbAvailable->index(lbAvailable->findItem(m_currentSelectedFont)));
+ break;
+ case generic : lbGeneric->removeItem(lbGeneric->index(lbGeneric->findItem(m_currentSelectedFont)));
+ break;
+ }
+}
+
+void fontFamilyChooser::setCurrentSelectedAvailableFamilyFont(const QString& f){
+ m_fontOrigin = available;
+ m_currentSelectedFont = f;
+ m_selectedFontMap[f] = available;
+}
+
+void fontFamilyChooser::setCurrentSelectedGenericFamilyFont(const QString& f){
+ m_fontOrigin = generic;
+ m_currentSelectedFont =f;
+ m_selectedFontMap[f] = generic;
+}
+
+void fontFamilyChooser::moveFontUp(){
+ if(m_currentSelectedFontIndex == 0) return;
+ int dummyIndex = m_currentSelectedFontIndex;
+ lbSelected->insertItem( lbSelected->text(m_currentSelectedFontIndex ), dummyIndex -1);
+ lbSelected->removeItem(dummyIndex + 1);
+ lbSelected->setSelected( dummyIndex -1, true);
+}
+
+void fontFamilyChooser::moveFontDown(){
+ if((unsigned int)m_currentSelectedFontIndex == lbSelected->count()) return;
+ int dummyIndex = m_currentSelectedFontIndex;
+ lbSelected->insertItem( lbSelected->text(m_currentSelectedFontIndex ), dummyIndex + 2);
+ lbSelected->removeItem(dummyIndex);
+ lbSelected->setSelected(dummyIndex +1, true);
+}
+
+void fontFamilyChooser::removeFont(){
+ QString dummyFont(m_currentSelectedFont);// since removeItem emits highlighted signal, after
+ // removeItem call the value of m_currentSelectedFont
+ // is actually the font after m_currentSelectedFont and so
+ // we must save m_currentSelectedFont value in dummyFont
+ lbSelected->removeItem( m_currentSelectedFontIndex );
+ switch(m_selectedFontMap[dummyFont]) {
+ case available: lbAvailable->insertItem(dummyFont);
+ lbAvailable->sort();
+ break;
+ case generic : lbGeneric->insertItem(dummyFont);
+ lbGeneric->sort();
+ break;
+ }
+
+}
+
+QStringList fontFamilyChooser::fontList(){
+ QStringList list;
+ QListBoxItem *item = lbSelected->firstItem();
+ while( item != 0 ){
+ if( item->text().contains( QRegExp("\\W") ) ) list.append( "'" + item->text() + "'" );
+ else list.append( item->text() );
+ item = item->next();
+ }
+ return list;
+}
+
+void fontFamilyChooser::setInitialValue(const QString& s){
+ QStringList familyList = QStringList::split(",",s);
+ for ( QStringList::Iterator it = familyList.begin(); it != familyList.end(); ++it ) {
+ (*it).remove("'");
+ (*it).remove("\"");
+ lbSelected->insertItem((*it).stripWhiteSpace());
+ }
+}
+
+#include "fontfamilychooser.moc"
diff --git a/quanta/components/csseditor/fontfamilychooser.h b/quanta/components/csseditor/fontfamilychooser.h
new file mode 100644
index 00000000..c812e774
--- /dev/null
+++ b/quanta/components/csseditor/fontfamilychooser.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ fontfamilychooser.h - description
+ -------------------
+ begin : mer lug 23 11:20:17 CEST 2003
+ copyright : (C) |YEAR| by si2003 email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef FONTFAMILYCHOOSER_H
+#define FONTFAMILYCHOOSER_H
+
+#include "fontfamilychoosers.h"
+#include <qmap.h>
+class QStringList;
+
+class fontFamilyChooser : public fontFamilyChooserS
+{
+ Q_OBJECT
+ private:
+ enum FontOrigin { available, generic };
+ QString m_currentSelectedFont;
+ FontOrigin m_fontOrigin;
+ int m_currentSelectedFontIndex;
+ QMap<QString,FontOrigin> m_selectedFontMap;
+
+ private slots:
+ void updatePreview(const QString &);
+ void setCurrentSelectedAvailableFamilyFont(const QString&);
+ void setCurrentSelectedGenericFamilyFont(const QString&);
+ void setCurrentSelectedFont( int i) { m_currentSelectedFontIndex = i; }
+ void setCurrentSelectedFont( const QString& f ) { m_currentSelectedFont = f; }
+ void addFont();
+ void removeFont();
+ void moveFontUp();
+ void moveFontDown();
+
+ public:
+ fontFamilyChooser(QWidget* parent, const char *name=0);
+ ~fontFamilyChooser();
+ QStringList fontList();
+ void setInitialValue(const QString& s);
+};
+
+#endif
diff --git a/quanta/components/csseditor/fontfamilychoosers.ui b/quanta/components/csseditor/fontfamilychoosers.ui
new file mode 100644
index 00000000..1b846446
--- /dev/null
+++ b/quanta/components/csseditor/fontfamilychoosers.ui
@@ -0,0 +1,441 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>fontFamilyChooserS</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>fontFamilyChooserS</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>487</width>
+ <height>399</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>Font Family Chooser</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout42</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout40</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout39</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout36</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout20</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Available system font families:</string>
+ </property>
+ </widget>
+ <widget class="QListBox">
+ <property name="name">
+ <cstring>lbAvailable</cstring>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout15</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Generic family:</string>
+ </property>
+ </widget>
+ <widget class="QListBox">
+ <item>
+ <property name="text">
+ <string>cursive</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>fantasy</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>monospace</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>sans-serif</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>serif</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>lbGeneric</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout38</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer20</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>buttonGroup1</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="lineWidth">
+ <number>2</number>
+ </property>
+ <property name="midLineWidth">
+ <number>0</number>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ <property name="radioButtonExclusive">
+ <bool>false</bool>
+ </property>
+ <property name="selectedId" stdset="0">
+ <number>-1</number>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="KPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>pbMoveUp</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="1" column="2">
+ <property name="name">
+ <cstring>pbAdd</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>pbRemove</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="2" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>pbMoveDown</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer21</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Selected font families:</string>
+ </property>
+ </widget>
+ <widget class="QListBox">
+ <property name="name">
+ <cstring>lbSelected</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>lePreview</cstring>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout41</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>313</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout9</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>pbOK</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>pbCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>pbCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>fontFamilyChooserS</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>pbOK</sender>
+ <signal>clicked()</signal>
+ <receiver>fontFamilyChooserS</receiver>
+ <slot>accept()</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/quanta/components/csseditor/minieditor.h b/quanta/components/csseditor/minieditor.h
new file mode 100644
index 00000000..773ed285
--- /dev/null
+++ b/quanta/components/csseditor/minieditor.h
@@ -0,0 +1,37 @@
+/***************************************************************************
+ minieditor.h - description
+ -------------------
+ begin : lun ago 9 2004
+ copyright : (C) 2004 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef MINIEDITOR_H
+#define MINIEDITOR_H
+
+#include <qhbox.h>
+
+/**
+ *@author gulmini luciano
+ */
+
+class propertySetter;
+
+class miniEditor : public QHBox{
+ public:
+ miniEditor(QWidget *parent=0, const char *name=0):QHBox(parent,name){}
+ ~miniEditor(){}
+ virtual void connectToPropertySetter(propertySetter* p)=0;
+};
+
+
+#endif
diff --git a/quanta/components/csseditor/percentageeditor.cpp b/quanta/components/csseditor/percentageeditor.cpp
new file mode 100644
index 00000000..0c8a9d6c
--- /dev/null
+++ b/quanta/components/csseditor/percentageeditor.cpp
@@ -0,0 +1,38 @@
+/***************************************************************************
+ percentageeditor.cpp - description
+ -------------------
+ begin : lun ago 9 2004
+ copyright : (C) 2004 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include "percentageeditor.h"
+#include "propertysetter.h"
+
+percentageEditor::percentageEditor(const QString& initialValue, QWidget *parent, const char *name) : miniEditor(parent,name)
+{
+ QString temp(initialValue);
+ m_sb = new mySpinBox(0,9999,1,this);
+ m_sb->setValue(temp.remove("%").toInt());
+ m_sb->setSuffix("%");
+ connect(m_sb, SIGNAL(valueChanged ( const QString & )), this, SIGNAL(valueChanged(const QString&)));
+}
+
+percentageEditor::~percentageEditor()
+{
+ delete m_sb;
+}
+
+void percentageEditor::connectToPropertySetter(propertySetter* p){
+ connect( this, SIGNAL(valueChanged(const QString&)), p, SIGNAL(valueChanged(const QString&)));
+}
+
+#include "percentageeditor.moc"
diff --git a/quanta/components/csseditor/percentageeditor.h b/quanta/components/csseditor/percentageeditor.h
new file mode 100644
index 00000000..d6931aec
--- /dev/null
+++ b/quanta/components/csseditor/percentageeditor.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ percentageeeditor.h - description
+ -------------------
+ begin : lun ago 9 2004
+ copyright : (C) 2004 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef PERCENTAGEEDITOR_H
+#define PERCENTAGEEDITOR_H
+
+#include <qhbox.h>
+#include <qptrlist.h>
+#include "doubleeditors.h"
+#include <qcombobox.h>
+#include <qslider.h>
+
+#include "csseditor_globals.h"
+#include "minieditor.h"
+
+class KPushButton;
+
+
+/**
+ *@author gulmini luciano
+ */
+
+class propertySetter;
+
+class percentageEditor : public miniEditor {
+ Q_OBJECT
+ private:
+ mySpinBox *m_sb;
+ public:
+ percentageEditor(const QString& initialValue="0",QWidget *parent=0, const char *name=0);
+ ~percentageEditor();
+ virtual void connectToPropertySetter(propertySetter* p);
+ signals:
+ void valueChanged(const QString&);
+};
+
+
+#endif
diff --git a/quanta/components/csseditor/propertysetter.cpp b/quanta/components/csseditor/propertysetter.cpp
new file mode 100644
index 00000000..683320ae
--- /dev/null
+++ b/quanta/components/csseditor/propertysetter.cpp
@@ -0,0 +1,129 @@
+/***************************************************************************
+ propertysetter.cpp - description
+ -------------------
+ begin : gio lug 24 2003
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "propertysetter.h"
+
+#include <qlineedit.h>
+#include <qcombobox.h>
+#include <qspinbox.h>
+#include <qlabel.h>
+#include <qtooltip.h>
+#include <qregexp.h>
+#include <qvbox.h>
+
+#include <kpushbutton.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <klineedit.h>
+
+
+#include "csseditor_globals.h"
+#include "minieditor.h"
+
+propertySetter::propertySetter(QWidget *parent, const char *name ) : QHBox(parent,name) {
+ m_ind = 0;
+ m_cb = 0L;
+ m_list.setAutoDelete(true);
+ m_pb = 0L;
+ setSpacing( KDialog::spacingHint() );
+}
+
+propertySetter::~propertySetter(){
+ reset();
+}
+
+void propertySetter::reset(){
+ if(!m_list.isEmpty()) m_list.clear();
+ if(m_pb) {
+ delete m_pb;
+ m_pb=0L;
+ }
+ m_ind=0;
+}
+
+void propertySetter::setComboBox()
+{
+ m_cb = new QComboBox(this);
+ connect(m_cb, SIGNAL(activated(const QString&)), this, SIGNAL(valueChanged(const QString&)));
+ connect(m_cb, SIGNAL(textChanged(const QString&)), this, SIGNAL(valueChanged(const QString&)));
+ m_list.append(m_cb);
+}
+
+void propertySetter::setSpinBox(const QString& initialValue, const QString& min, const QString& max, const QString& s)
+{
+ mySpinBox *editor = new mySpinBox(min.toInt(), max.toInt(), 1, this);
+ editor->setSuffix(s);
+ editor->setValue(initialValue.toInt());
+ connect(editor, SIGNAL(valueChanged(const QString&)), this ,SIGNAL(valueChanged(const QString&)));
+ m_list.append(editor);
+}
+
+void propertySetter::setLineEdit()
+{
+ QLineEdit *editor = new QLineEdit(this);
+ connect(editor,SIGNAL(textChanged ( const QString & )), this, SIGNAL(valueChanged ( const QString & )));
+ m_list.append(editor);
+}
+
+void propertySetter::setPredefinedColorListEditor()
+{
+ QComboBox *editor = new QComboBox(this);
+ editor->insertStringList(CSSEditorGlobals::HTMLColors);
+ connect(editor, SIGNAL(activated(const QString&)), this, SIGNAL(valueChanged(const QString&)));
+ m_list.append(editor);
+}
+
+void propertySetter::Show(){
+ QWidget *w;
+ for ( w = m_list.first(); w; w = m_list.next() )
+ w->hide();
+
+ m_list.at(m_ind)->show();
+
+ if(m_list.count() == 1) {
+ if(m_pb)
+ m_pb->hide();
+ }
+ else
+ if(m_ind<(m_list.count()-1)) {
+ m_ind++;
+ m_pb->show();
+ }
+ else
+ m_ind=0;
+}
+
+void propertySetter::addButton(){
+
+ m_pb = new KPushButton(this);
+ QToolTip::add(m_pb, i18n( "More..." ));
+ QIconSet iconSet = SmallIconSet(QString::fromLatin1("2rightarrow"));
+ QPixmap pixMap = iconSet.pixmap( QIconSet::Small, QIconSet::Normal );
+ m_pb->setIconSet(iconSet);
+ m_pb->setFixedSize( pixMap.width()+8, pixMap.height()+8 );
+ m_pb->hide();
+ connect(m_pb, SIGNAL(clicked()), this ,SLOT(Show()));
+}
+
+void propertySetter::installMiniEditor(miniEditor *m){
+ m->connectToPropertySetter(this);
+ m_list.append(m);
+}
+
+#include "propertysetter.moc"
diff --git a/quanta/components/csseditor/propertysetter.h b/quanta/components/csseditor/propertysetter.h
new file mode 100644
index 00000000..3f13b8ba
--- /dev/null
+++ b/quanta/components/csseditor/propertysetter.h
@@ -0,0 +1,64 @@
+/***************************************************************************
+ propertysetter.h - description
+ -------------------
+ begin : gio lug 24 2003
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef PROPERTYSETTER_H
+#define PROPERTYSETTER_H
+
+#include <qhbox.h>
+#include <qptrlist.h>
+#include <qcombobox.h>
+
+
+class miniEditor;
+class KPushButton;
+
+
+/**
+ *@author gulmini luciano
+ */
+
+class propertySetter : public QHBox {
+ Q_OBJECT
+
+ private:
+ unsigned int m_ind;
+ QPtrList<QWidget> m_list;
+ QComboBox *m_cb;
+ KPushButton *m_pb;
+
+ public:
+ propertySetter(QWidget *parent=0, const char *name=0);
+ ~propertySetter();
+
+ void installMiniEditor(miniEditor *m);
+
+ void setComboBox();
+ void setSpinBox(const QString& initialValue="0", const QString& min="0", const QString& max="9999", const QString& s=QString::null);
+ void setLineEdit();
+ void setPredefinedColorListEditor();
+ void reset();
+ void addButton();
+ QComboBox* ComboBox() const { return m_cb; }
+
+ public slots:
+ void Show();
+
+ signals:
+ void valueChanged(const QString&);
+};
+
+#endif
diff --git a/quanta/components/csseditor/qmyhighlighter.cpp b/quanta/components/csseditor/qmyhighlighter.cpp
new file mode 100644
index 00000000..431bf6a5
--- /dev/null
+++ b/quanta/components/csseditor/qmyhighlighter.cpp
@@ -0,0 +1,65 @@
+/***************************************************************************
+ bashhighlighter.cpp - description
+ -------------------
+ begin : dom mar 16 2003
+ copyright : (C) 2003 by Emiliano Gulmini
+ email : emi_barbarossa@yahoo.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "qmyhighlighter.h"
+#include <qregexp.h>
+QMyHighlighter::QMyHighlighter(QTextEdit* Qtxt):QSyntaxHighlighter(Qtxt){
+}
+/*****************************************************************************/
+QMyHighlighter::~QMyHighlighter(){
+}
+
+/*****************************************************************************/
+int QMyHighlighter::highlightParagraph( const QString & text, int /*endStateOfLastPara*/ )
+{
+ //QRegExp pattern("\\s*\\{([\\w\\s\\d:;-\"]*)\\}\\s*");
+ QRegExp pattern("([#:\\.\\w]*)\\s*\\{");
+ int pos=pattern.search(text,0);
+ int l=int(pattern.cap(1).length());
+
+ setFormat(pos,l,QColor("red"));
+
+ if( pos== -1)
+ pos = 0;
+
+ const int npos = pos+l;
+
+ pattern.setPattern("\\s*([\\s\\w\\d-]*)\\s*:");
+ pos=npos;
+ while ( pos >= 0 ) {
+ pos = pattern.search( text, pos );
+ if ( pos > -1 ) {
+ l = pattern.matchedLength();
+
+ setFormat(pos,l,QColor("mediumvioletred"));
+ pos += pattern.matchedLength();
+ }
+ }
+ pattern.setPattern(":\\s*([\\.\\#\\w\\s\\d-\\(\\)\",%/]*)\\s*;");
+ pattern.setPattern(":\\s*([\\W\\w]*)\\s*;");
+ pos=npos;
+ while ( pos >= 0 ) {
+ pos = pattern.search( text, pos );
+ if ( pos > -1 ) {
+ l = pattern.cap(1).length();
+ setFormat(pos + 2 ,l,QColor("steelblue"));
+ pos += pattern.matchedLength();
+ }
+ }
+ return 0;
+}
+
diff --git a/quanta/components/csseditor/qmyhighlighter.h b/quanta/components/csseditor/qmyhighlighter.h
new file mode 100644
index 00000000..a75d6d00
--- /dev/null
+++ b/quanta/components/csseditor/qmyhighlighter.h
@@ -0,0 +1,36 @@
+/***************************************************************************
+ bashhighlighter.h - description
+ -------------------
+ begin : dom mar 16 2003
+ copyright : (C) 2003 by Emiliano Gulmini
+ email : emi_barbarossa@yahoo.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef QMYHIGHLIGHTER_H
+#define QMYHIGHLIGHTER_H
+
+#include <qsyntaxhighlighter.h>
+
+/**
+ *@author Emiliano Gulmini
+ */
+
+class QMyHighlighter : public QSyntaxHighlighter {
+public:
+ QMyHighlighter(QTextEdit* Qtxt);
+
+ ~QMyHighlighter();
+ int highlightParagraph ( const QString & text, int endStateOfLastPara );
+
+};
+
+#endif
diff --git a/quanta/components/csseditor/shorthandformer.cpp b/quanta/components/csseditor/shorthandformer.cpp
new file mode 100644
index 00000000..e8b7a837
--- /dev/null
+++ b/quanta/components/csseditor/shorthandformer.cpp
@@ -0,0 +1,781 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Gulmini Luciano *
+ * gulmini.luciano@student.unife.it *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#include "shorthandformer.h"
+#include <qstringlist.h>
+#include "cssshpropertyparser.h"
+#include <kdebug.h>
+#include "csseditor_globals.h"
+
+QRegExp globalPercentagePattern("\\d%"),
+ globalLengthPattern("\\d(ex|em|px|cm|pt|pc|in|mm)"),
+ globalColorPattern("#[\\w\\d]*"),
+ globalNumberPattern("\\d*");
+
+static const QString borderStyleValueString("none,hidden,dotted,dashed,solid,double,groove,ridge,inset,outset,inherit");
+static const QString widthValueString("thin,medium,thick,inherit");
+static const QString listTypeValueString("disc,circle,square,decimal,decimal-leading-zero,lower-roman,upper-roman,lower-greek,lower-alpha,lower-latin,upper-alpha,upper-latin,hebrew,armenian,georgian,cjk-ideographic,hiragana,katakana,hiragana-iroha,katakana-iroha,none,inherit");
+static const QString fontSizeValueString("smaller,larger,xx-large,x-large,large,medium,small,x-small,xx-small,inherit");
+static const QString fontWeightValueString("900,800,700,600,500,400,300,200,100,lighter,bolder,normal,bold,inherit");
+static const QString fontVariantValueString("normal,small-caps,inherit");
+static const QString fontStyleValueString("oblique,italic,normal,inherit");
+static const QString backgroundRepeatValueString("repeat,repeat-x,repeat-y,no-repeat,inherit");
+
+
+static const QStringList borderStyleValueList = QStringList::split(",",borderStyleValueString);
+static const QStringList widthValueList = QStringList::split(",",widthValueString);
+static const QStringList listTypeValueList = QStringList::split(",",listTypeValueString);
+static const QStringList fontSizeValueList = QStringList::split(",",fontSizeValueString);
+static const QStringList fontWeightValueList = QStringList::split(",",fontWeightValueString);
+static const QStringList fontStyleValueList = QStringList::split(",",fontStyleValueString);
+static const QStringList fontVariantValueList = QStringList::split(",",fontVariantValueString);
+static const QStringList backgroundRepeatValueList = QStringList::split(",",backgroundRepeatValueString);
+
+
+
+ShorthandFormer::ShorthandFormer( QMap<QString,QString> m){
+
+ m_properties = m;
+ if(m_properties.contains("cue-after")){
+ cue_after= m_properties["cue-after"];
+ m_properties.remove("cue-after");
+ }
+ if(m_properties.contains("cue-before")){
+ cue_before = m_properties["cue-before"];
+ m_properties.remove("cue-before");
+ }
+ if(m_properties.contains("pause-before")){
+ pause_before= m_properties["pause-before"];
+ m_properties.remove("pause-before");
+ }
+ if(m_properties.contains("pause-after")){
+ pause_after = m_properties["pause-after"];
+ m_properties.remove("pause-after");
+ }
+ if(m_properties.contains("background-color")){
+ background_color = m_properties["background-color"];
+ m_properties.remove("background-color");
+ }
+ if(m_properties.contains("background-image")){
+ background_image = m_properties["background-image"];
+ m_properties.remove("background-image");
+ }
+ if(m_properties.contains("background-repeat")){
+ background_repeat = m_properties["background-repeat"];
+ m_properties.remove("background-repeat");
+ }
+ if(m_properties.contains("background-attachment")){
+ background_attachment = m_properties["background-attachment"];
+ m_properties.remove("background-attachment");
+ }
+ if(m_properties.contains("background-position")){
+ background_position = m_properties["background-position"];
+ m_properties.remove("background-position");
+ }
+ if(m_properties.contains("border-top-style")){
+ border_top_style = m_properties["border-top-style"];
+ m_properties.remove("border-top-style");
+ }
+ if(m_properties.contains("border-top-color")){
+ border_top_color = m_properties["border-top-color"];
+ m_properties.remove("border-top-color");
+ }
+ if(m_properties.contains("border-top-width")){
+ border_top_width = m_properties["border-top-width"];
+ m_properties.remove("border-top-width");
+ }
+ if(m_properties.contains("border-left-style")){
+ border_left_style = m_properties["border-left-style"];
+ m_properties.remove("border-left-style");
+ }
+ if(m_properties.contains("border-left-color")){
+ border_left_color = m_properties["border-left-color"];
+ m_properties.remove("border-left-color");
+ }
+ if(m_properties.contains("border-left-width")){
+ border_left_width = m_properties["border-left-width"];
+ m_properties.remove("border-left-width");
+ }
+ if(m_properties.contains("border-right-style")){
+ border_right_style = m_properties["border-right-style"];
+ m_properties.remove("border-right-style");
+ }
+ if(m_properties.contains("border-right-color")){
+ border_right_color = m_properties["border-right-color"];
+ m_properties.remove("border-right-color");
+ }
+ if(m_properties.contains("border-right-width")){
+ border_right_width= m_properties["border-right-width"];
+ m_properties.remove("border-right-width");
+ }
+ if(m_properties.contains("border-bottom-style")){
+ border_bottom_style = m_properties["border-bottom-style"];
+ m_properties.remove("border-bottom-style");
+ }
+ if(m_properties.contains("border-bottom-color")){
+ border_bottom_color = m_properties["border-bottom-color"];
+ m_properties.remove("border-bottom-color");
+ }
+ if(m_properties.contains("border-bottom-width")){
+ border_bottom_width = m_properties["border-bottom-width"];
+ m_properties.remove("border-bottom-width");
+ }
+ if(m_properties.contains("outline-style")){
+ outline_style = m_properties["outline-style"];
+ m_properties.remove("outline-style");
+ }
+ if(m_properties.contains("outline-color")){
+ outline_color = m_properties["outline-color"];
+ m_properties.remove("outline-color");
+ }
+ if(m_properties.contains("outline-width")){
+ outline_width = m_properties["outline-width"];
+ m_properties.remove("outline-width");
+ }
+ if(m_properties.contains("list-style-type")){
+ list_style_type= m_properties["list-style-type"];
+ m_properties.remove("list-style-type");
+ }
+ if(m_properties.contains("list-style-image")){
+ list_style_image = m_properties["list-style-image"];
+ m_properties.remove("list-style-image");
+ }
+ if(m_properties.contains("list-style-position")){
+ list_style_position = m_properties["list-style-position"];
+ m_properties.remove("list-style-position");
+ }
+ if(m_properties.contains("font-style")){
+ font_style = m_properties["font-style"];
+ m_properties.remove("font-style");
+ }
+ if(m_properties.contains("font-variant")){
+ font_variant = m_properties["font-variant"];
+ m_properties.remove("font-variant");
+ }
+ if(m_properties.contains("font-weight")){
+ font_weight = m_properties["font-weight"];
+ m_properties.remove("font-weight");
+ }
+ if(m_properties.contains("font-size")){
+ font_size = m_properties["font-size"];
+ m_properties.remove("font-size");
+ }
+ if(m_properties.contains("line-height")){
+ line_height= m_properties["line-height"];
+ m_properties.remove("line-height");
+ }
+ if(m_properties.contains("font-family")){
+ font_family = m_properties["font-family"];
+ m_properties.remove("font-family");
+ }
+ if(m_properties.contains("margin-top")){
+ margin_top = m_properties["margin-top"];
+ m_properties.remove("margin-top");
+ }
+ if(m_properties.contains("margin-bottom")){
+ margin_bottom = m_properties["margin-bottom"];
+ m_properties.remove("margin-bottom");
+ }
+ if(m_properties.contains("margin-left")){
+ margin_left = m_properties["margin-left"];
+ m_properties.remove("margin-left");
+ }
+ if(m_properties.contains("margin-right")){
+ margin_right = m_properties["margin-right"];
+ m_properties.remove("margin-right");
+ }
+ if(m_properties.contains("padding-top")){
+ padding_top = m_properties["padding-top"];
+ m_properties.remove("padding-top");
+ }
+ if(m_properties.contains("padding-bottom")){
+ padding_bottom = m_properties["padding-bottom"];
+ m_properties.remove("padding-bottom");
+ }
+ if(m_properties.contains("padding-left")){
+ padding_left = m_properties["padding-left"];
+ m_properties.remove("padding-left");
+ }
+ if(m_properties.contains("padding-right")){
+ padding_right = m_properties["padding-right"];
+ m_properties.remove("padding-right");
+ }
+}
+
+QString ShorthandFormer::compress(){
+ QString props;
+
+ props += compressCueProp();
+ props += compressPauseProp();
+ props += compressBackgroundProp();
+ props += compressFontProp();
+ props += compressPaddingProp();
+ props += compressMarginProp();
+ props += compressOutlineProp();
+ props += compressListStyleProp();
+ props += compressBorderProp();
+
+ QMap<QString,QString>::Iterator it;
+ for ( it = m_properties.begin(); it != m_properties.end(); ++it )
+ props += it.key() + " : " + it.data().stripWhiteSpace() + "; " ;
+
+ props.truncate(props.length()-1);//the last white space creates some problem: better remove it
+ //props.chop(1);
+ return props;
+}
+
+QString ShorthandFormer::compressBorderProp(){
+ QString props;
+
+ bool allColorSidesSet = false,
+ allStyleSidesSet = false,
+ allWidthSidesSet = false;
+
+ if(!border_left_color.isEmpty())
+ if( ( border_left_color == border_top_color ) && ( border_top_color == border_right_color ) && ( border_right_color == border_bottom_color ) )
+ allColorSidesSet = true;
+
+ if(!border_left_style.isEmpty())
+ if( ( border_left_style == border_top_style ) && ( border_top_style == border_right_style ) && ( border_right_style == border_bottom_style ) )
+ allStyleSidesSet = true;
+
+ if(!border_left_width.isEmpty())
+ if( ( border_left_width == border_top_width ) && ( border_top_width == border_right_width ) && ( border_right_width == border_bottom_width ) )
+ allWidthSidesSet = true;
+
+ if ( allColorSidesSet ) {
+ if ( allStyleSidesSet ) {
+ if ( allWidthSidesSet ) {
+ props += "border : " + border_left_color + " " + border_left_style + " " + border_left_width +"; ";
+
+ }
+ else {
+ props += "border : " + border_left_color + " " + border_left_style +"; ";
+ props += compressBorderWidthProp();
+ }
+ }
+ else {
+ if ( allWidthSidesSet ) {
+ props += "border : " + border_left_color + " " + border_left_width +"; ";
+ props += compressBorderStyleProp();
+ }
+ else {
+ props += "border : " + border_left_color +"; ";
+ props += compressBorderWidthProp();
+ props += compressBorderStyleProp();
+ }
+
+ }
+ }
+ else { // allColorSidesSet is false
+ if ( allStyleSidesSet ) {
+ if ( allWidthSidesSet ) {
+ props += "border : " + border_left_style + " " + border_left_width +"; ";
+ props += compressBorderColorProp();
+ }
+ else {
+ props += compressBorderStyleProp();
+ props += compressBorderWidthProp();
+ props += compressBorderColorProp();
+ }
+ }
+ else {
+
+ props += compressBorderStyleProp();
+ props += compressBorderWidthProp();
+ props += compressBorderColorProp();
+ }
+ }
+
+ return props;
+}
+
+QString ShorthandFormer::compressBorderStyleProp(){
+ return compressImplementation( "border-style" ,border_top_style, border_bottom_style, border_right_style, border_left_style, "none");
+}
+
+QString ShorthandFormer::compressBorderWidthProp(){
+ return compressImplementation( "border-width" ,border_top_width, border_bottom_width, border_right_width, border_left_width, "medium");
+}
+
+QString ShorthandFormer::compressBorderColorProp(){
+//because the default value of color property is browser dependant, this method doesn't compress the color value
+ QString props;
+ if( !border_top_color.isEmpty() )
+ props += "border-top-color : " + border_top_color +"; ";
+ if( !border_right_color.isEmpty() )
+ props += "border-right-color : " + border_right_color +"; ";
+ if( !border_bottom_color.isEmpty() )
+ props += "border-bottom-color : " + border_bottom_color +"; ";
+ if( !border_left_color.isEmpty() )
+ props += "border-left-color : " + border_left_color +"; ";
+ return props;
+}
+
+QString ShorthandFormer::compressFontProp(){
+ QString fontProp,
+ props;
+ //bool appendLineHeight = false;
+
+ if( font_style.isEmpty() && font_variant.isEmpty() && font_weight.isEmpty() && font_size.isEmpty() && font_family.isEmpty() ) {
+ if( !line_height.isEmpty() )
+ props += "line-height : " + line_height + "; ";
+ }
+ else {
+ if( !font_style.isEmpty() )
+ fontProp += " " + font_style;
+ if( !font_variant.isEmpty() )
+ fontProp += " " + font_variant;
+ if( !font_weight.isEmpty() )
+ fontProp += " " + font_weight;
+ if( !font_size.isEmpty() ){
+ fontProp += " " + font_size;
+ if( !line_height.isEmpty() )
+ fontProp += "/" + line_height.stripWhiteSpace() ;
+ }
+ else {
+ fontProp += ( " medium");
+ /*if( !line_height.isEmpty() )
+ appendLineHeight = true; */
+ if( !line_height.isEmpty() )
+ fontProp += ( "/" + line_height.stripWhiteSpace() );
+ }
+
+ if( !font_family.isEmpty() )
+ fontProp += ( " " + font_family);
+ else fontProp += " serif";
+ if( !fontProp.isEmpty() )
+ props += ( "font :" + fontProp + "; ");
+ /* if(appendLineHeight)
+ props += ( "line-height : " + line_height + "; ");*/
+ }
+ return props;
+}
+
+QString ShorthandFormer::compressCueProp(){
+ return compressImplementation2( "cue", cue_after, cue_before, "none");
+}
+
+QString ShorthandFormer::compressPauseProp(){
+ return compressImplementation2( "pause", pause_after, pause_before, "0");
+}
+
+QString ShorthandFormer::compressBackgroundProp(){
+ QString backgroundProp;
+ if( !background_color.isEmpty() ) backgroundProp += (" " + background_color );
+ if( !background_image.isEmpty() ) backgroundProp += (" " + background_image );
+ if( !background_repeat.isEmpty() ) backgroundProp += (" " + background_repeat );
+ if( !background_attachment.isEmpty() ) backgroundProp += (" " + background_attachment );
+ if( !background_position.isEmpty() ) backgroundProp += (" " + background_position );
+ if( !backgroundProp.isEmpty() ) return ( "background :" + backgroundProp + "; ");
+ return QString::null;
+}
+
+QString ShorthandFormer::compressPaddingProp(){
+ return compressImplementation( "padding" ,padding_top, padding_bottom, padding_right, padding_left, "0");
+}
+
+QString ShorthandFormer::compressMarginProp(){
+ return compressImplementation( "margin" ,margin_top, margin_bottom, margin_right, margin_left, "0");
+}
+
+QString ShorthandFormer::compressOutlineProp(){
+ return compressImplementation3("outline", outline_color, outline_style, outline_width);
+}
+QString ShorthandFormer::compressListStyleProp(){
+ return compressImplementation3("list-style", list_style_type, list_style_image, list_style_position);
+}
+
+QString ShorthandFormer::compressImplementation3( const QString& prop, const QString& p1, const QString& p2, const QString& p3){
+ QString props;
+ if( !p1.isEmpty() ) props += (" " + p1 );
+ if( !p2.isEmpty() ) props += (" " + p2 );
+ if( !p3.isEmpty() ) props += (" " + p3 );
+ if( !props.isEmpty() ) return ( prop + " :" + props + "; ");
+ return QString::null;
+}
+
+QString ShorthandFormer::compressImplementation2( const QString& prop, const QString& after, const QString& before, const QString& defValue){
+ QString props;
+ if(after == before){
+ if(!after.isEmpty()) props+=( prop + " : " + after + "; ");
+ }
+ else {
+ if(before.isEmpty()) props+=( prop + " : " + defValue + " " + after + "; ");
+ else
+ if(after.isEmpty()) props+=( prop + " : " + before + " " + defValue + "; ");
+ else props+=( prop + " : " + before + " " + after + "; ");
+ }
+ return props;
+}
+
+QString ShorthandFormer::compressImplementation( const QString& prop, const QString& t, const QString& b, const QString& r, const QString& l, const QString& defValue){
+
+ QString props,
+ top(t.stripWhiteSpace()),
+ bottom(b.stripWhiteSpace()),
+ left(l.stripWhiteSpace()),
+ right(r.stripWhiteSpace());
+
+ if( top.isEmpty() ) top = defValue;
+ if( bottom.isEmpty() ) bottom = defValue;
+ if( left.isEmpty() ) left = defValue;
+ if( right.isEmpty() ) right = defValue;
+
+
+ if( top == defValue && bottom == defValue && right == defValue && left == defValue)
+ return QString::null;
+
+ if( top == bottom && bottom == right && right == left )
+ return ( prop +" : " + top + "; ");
+
+ if( right == left ) {
+ if( top == bottom ) return ( prop +" : " + top + " " + right + "; ");
+ else return ( prop +" : " + top + " " + right + " " + bottom + "; ");
+ }
+ else return (prop +" : " + top + " " + right + " " + bottom + " " + left + "; ");
+}
+
+
+//+++++++++++++++++++++EXPANDING METHODS+++++++++++++++++++++++++++++++++++
+
+
+QMap<QString,QString> ShorthandFormer::expand( const QString& propertyName, const QString& propertyValue ){
+ CSSSHPropertyParser parser(propertyValue);
+ QStringList foundValues = parser.parse();
+
+ if( propertyName == "cue" ) return expandCueProp(foundValues);
+ if( propertyName == "pause") return expandPauseProp(foundValues);
+ if( propertyName == "background") return expandBackgroundProp(foundValues);
+ if( propertyName == "border-color") return expandBox("color", foundValues);
+ if( propertyName == "border-style") return expandBox("style", foundValues);
+ if( propertyName == "border-width") return expandBox("width", foundValues);
+ if( propertyName == "font") return expandFontProp(foundValues);
+ if( propertyName == "outline") return expandOutlineProp(foundValues);
+ if( propertyName == "list-style") return expandListstyleProp(foundValues);
+ if( propertyName == "border-bottom") return expandBoxSide("bottom",foundValues);
+ if( propertyName == "border-top") return expandBoxSide("top",foundValues);
+ if( propertyName == "border-left") return expandBoxSide("left",foundValues);
+ if( propertyName == "border-right") return expandBoxSide("right",foundValues);
+ if( propertyName == "border") return expandBorderProp(foundValues);
+ if( propertyName == "padding") return expandPaddingProp(foundValues);
+ if( propertyName == "margin") return expandMarginProp(foundValues);
+ return QMap<QString,QString>();//dummy instruction avoiding a pedantic warning; can never be reached
+}
+
+QMap<QString,QString> ShorthandFormer::expandCueProp(const QStringList& l){
+ return expandImplementation("cue",l);
+}
+
+QMap<QString,QString> ShorthandFormer::expandPauseProp(const QStringList& l){
+ return expandImplementation("pause",l);
+}
+
+QMap<QString,QString> ShorthandFormer::expandImplementation(const QString& propertyName, const QStringList& l){
+ QMap<QString,QString> expandedProps;
+ if( l.count()==1) {
+ expandedProps[propertyName + "-before"] = l[0] ;
+ expandedProps[propertyName + "-after"] = l[0] ;
+ return expandedProps;
+ }
+ else
+ {
+ expandedProps[propertyName + "-before"] = l[0] ;
+ expandedProps[propertyName + "-after"] = l[1] ;
+ return expandedProps;
+ }
+}
+
+QMap<QString,QString> ShorthandFormer::expandBackgroundProp(const QStringList& l){
+ QMap<QString,QString> expandedProps;
+ if(l.count()==1 && l[0] == "inherit"){ // it works also as protection against wrong single value inserted
+ expandedProps["background-color"] = l[0];
+ expandedProps["background-image"] = l[0];
+ expandedProps["background-repeat"] = l[0];
+ expandedProps["background-attachment"] =l[0];
+ expandedProps["background-position"] = l[0];
+ }
+ else {
+
+ QStringList::ConstIterator it = l.begin();
+
+ while ( it != l.end() ) {
+ QString temp((*it).stripWhiteSpace());
+ if( (*it).contains("url(") || temp == "none" || temp == "inherit" ){
+ expandedProps["background-image"] = (*it);
+ }
+ else
+ if( backgroundRepeatValueList.contains(temp)!=0 ) {
+ expandedProps["background-repeat"] = (*it);
+ }
+ else
+ if( temp == "scroll" || temp == "fixed" || temp == "inherit"){
+ expandedProps["background-attachment"] = (*it);
+ }
+ else
+ if( (*it).contains("rgb(") || (*it).contains(globalColorPattern) || CSSEditorGlobals::HTMLColors.contains((*it))!=0 || temp == "transparent" || temp == "inherit" ){
+ expandedProps["background-color"] = (*it);
+ }
+ else
+ if( temp == "top" || temp == "center" || temp == "bottom" || temp == "left" || temp == "right" || (*it).contains(globalPercentagePattern) || (*it).contains(globalLengthPattern) || temp == "inherit"){
+ if( expandedProps.contains("background-position") )
+ expandedProps["background-position"] = ( expandedProps["background-position"] + " " + (*it) );
+ else
+ expandedProps["background-position"] = (*it);
+ }
+
+ ++it;
+ }
+ }
+ return expandedProps;
+}
+
+QMap<QString,QString> ShorthandFormer::expandBox(const QString& subPropName, const QStringList& l){
+
+ QMap<QString,QString> expandedProps;
+ expandedProps["border-top-" + subPropName] = l[0];
+ switch(l.count()){
+ case 1 :
+ expandedProps["border-right-" + subPropName] = l[0];
+ expandedProps["border-bottom-" + subPropName] = l[0];
+ expandedProps["border-left-" + subPropName] = l[0];
+ break;
+ case 2 :
+ expandedProps["border-right-" + subPropName] = l[1];
+ expandedProps["border-bottom-" + subPropName] = l[0];
+ expandedProps["border-left-" + subPropName] = l[1];
+ break;
+ case 3 :
+ expandedProps["border-right-" + subPropName] = l[1];
+ expandedProps["border-bottom-" + subPropName] = l[2];
+ expandedProps["border-left-" + subPropName] = l[1];
+ break;
+ case 4 :
+ expandedProps["border-right-" + subPropName] = l[1];
+ expandedProps["border-bottom-" + subPropName] = l[2];
+ expandedProps["border-left-" + subPropName] = l[3];
+ break;
+ default:break;
+ }
+ return expandedProps;
+}
+
+QMap<QString,QString> ShorthandFormer::expandFontProp(const QStringList& l){
+ QMap<QString,QString> expandedProps;
+
+ QRegExp percentagePattern("/"+globalPercentagePattern.pattern()),
+ lengthPattern("/"+globalLengthPattern.pattern()),
+ numberPattern("/"+globalNumberPattern.pattern());
+
+ QStringList fontPseudoSHFormValues;
+ fontPseudoSHFormValues.append("caption");
+ fontPseudoSHFormValues.append("icon");
+ fontPseudoSHFormValues.append("menu");
+ fontPseudoSHFormValues.append("message-box");
+ fontPseudoSHFormValues.append("small-caption");
+ fontPseudoSHFormValues.append("status-bar");
+ if( l.count()==1 && fontPseudoSHFormValues.contains(l[0]) != 0) {
+ expandedProps["font"] = l[0];
+ return expandedProps;
+ }
+ else {
+ QStringList::ConstIterator it = l.begin();
+ while ( it != l.end() ) {
+ QString currentIt = (*it);
+ QString temp(currentIt.stripWhiteSpace());
+ if( fontStyleValueList.contains(temp)!=0 ) expandedProps["font-style"] = (*it);
+ else
+ if( fontVariantValueList.contains(temp)!=0 ) expandedProps["font-variant"] = currentIt ;
+ else
+ if( fontWeightValueList.contains(temp)!=0) expandedProps["font-weight"] = currentIt;
+ else
+ if( (fontSizeValueList.contains(temp)!=0 || currentIt.contains(globalPercentagePattern)!=0 || currentIt.contains(globalLengthPattern)!=0) && expandedProps["font-size"].isEmpty() )
+ {
+ expandedProps["font-size"] = currentIt;
+ }
+ else
+ if( currentIt.contains(percentagePattern)!=0 || currentIt.contains(numberPattern)!=0 || currentIt.contains(lengthPattern)!=0 || temp == "/normal" || temp == "/inherit" )
+ {
+ expandedProps["line-height"] = (currentIt.remove('/'));
+ }
+ else expandedProps["font-family"] = currentIt;
+ ++it;
+ }
+ return expandedProps;
+ }
+}
+
+QMap<QString,QString> ShorthandFormer::expandListstyleProp( const QStringList& l){
+ QMap<QString,QString> expandedProps;
+ if( (l.count() == 1) && (l[0] == "inherit")){
+ expandedProps["list-style-image"] ="inherit";
+ expandedProps["list-style-type"] ="inherit";
+ expandedProps["list-style-position"] ="inherit";
+ return expandedProps;
+ }
+
+ if( (l.count() == 1) && (l[0] == "none")){
+ expandedProps["list-style-image"] ="none";
+ expandedProps["list-style-type"] ="none";
+ return expandedProps;
+ }
+
+
+ QStringList::ConstIterator it = l.begin();
+ while ( it != l.end() ) {
+ QString temp((*it).stripWhiteSpace());
+ if( listTypeValueList.contains(temp)!=0) {
+ expandedProps["list-style-type"] = (*it) ;
+ }
+ else
+ if( temp == "inside" || temp == "outside" || temp == "inherit") {
+ expandedProps["list-style-position"] = (*it);
+ }
+ else
+ if( (*it).contains("url(") || temp == "none" || temp == "inherit" )
+ expandedProps["list-style-image"] = (*it);
+
+ ++it;
+ }
+ return expandedProps;
+}
+
+QMap<QString,QString> ShorthandFormer::expandOutlineProp( const QStringList& l){
+ QMap<QString,QString> expandedProps;
+ QStringList::ConstIterator it = l.begin();
+ while ( it != l.end() ) {
+ QString temp((*it).stripWhiteSpace());
+ if( borderStyleValueList.contains(temp)!=0 ) expandedProps["outline-style"] = (*it);
+ else
+ if( (*it).contains(globalColorPattern) || CSSEditorGlobals::HTMLColors.contains((*it))!=0 || temp == "invert" || temp == "inherit")
+ expandedProps["outline-color"] = (*it) ;
+ else
+ if( (*it).contains(globalLengthPattern) || widthValueList.contains(temp)!=0)
+ expandedProps["outline-width"] = (*it);
+ ++it;
+ }
+ return expandedProps;
+}
+
+QMap<QString,QString> ShorthandFormer::expandBoxSide(const QString& subPropName, const QStringList& l){
+ QMap<QString,QString> expandedProps;
+
+ QStringList::ConstIterator it = l.begin();
+ while ( it != l.end() ) {
+ QString temp((*it).stripWhiteSpace());
+ if( borderStyleValueList.contains(temp)!=0 ) expandedProps[subPropName + "-style"] = (*it);
+ else
+ if( (*it).contains(globalColorPattern) || CSSEditorGlobals::HTMLColors.contains((*it))!=0 || temp == "transparent" || temp == "inherit")
+ expandedProps[subPropName + "-color"] = (*it) ;
+ else
+ if( (*it).contains(globalLengthPattern) || widthValueList.contains(temp)!=0)
+ expandedProps[subPropName + "-width"] = (*it);
+ ++it;
+ }
+ return expandedProps;
+}
+
+QMap<QString,QString> ShorthandFormer::expandBorderProp(const QStringList& l){
+ QMap<QString,QString> expandedProps;
+ QStringList::ConstIterator it = l.begin();
+ while ( it != l.end() ) {
+ QString temp((*it).stripWhiteSpace());
+ if( borderStyleValueList.contains(temp)!=0 ){
+ expandedProps["border-top-style"] = (*it);
+ expandedProps["border-left-style"] = (*it);
+ expandedProps["border-right-style"] = (*it);
+ expandedProps["border-bottom-style"] = (*it);
+ }
+ else
+ if( (*it).contains(globalColorPattern) || CSSEditorGlobals::HTMLColors.contains((*it))!=0 || temp == "transparent" || temp == "inherit"){
+ expandedProps["border-top-color"] = (*it);
+ expandedProps["border-left-color"] = (*it);
+ expandedProps["border-right-color"] = (*it);
+ expandedProps["border-bottom-color"] = (*it);
+ }
+ else
+ if( (*it).contains(globalLengthPattern) || widthValueList.contains(temp)!=0){
+ expandedProps["border-top-width"] = (*it);
+ expandedProps["border-left-width"] = (*it);
+ expandedProps["border-right-width"] = (*it);
+ expandedProps["border-bottom-width"] = (*it);
+ }
+ ++it;
+ }
+ return expandedProps;
+}
+
+QMap<QString,QString> ShorthandFormer::expandImplementation2(const QString& propertyName, const QStringList& l){
+ QMap<QString,QString> expandedProps;
+ expandedProps[ propertyName + "-top" ] = l[0];
+ switch(l.count()){
+ case 1 :
+ expandedProps[ propertyName + "-right" ] = l[0];
+ expandedProps[ propertyName + "-bottom" ] = l[0];
+ expandedProps[ propertyName + "-left" ] = l[0];
+ break;
+ case 2 :
+ expandedProps[ propertyName + "-right" ] = l[1];
+ expandedProps[ propertyName + "-bottom" ] = l[0];
+ expandedProps[ propertyName + "-left" ] = l[1];
+ break;
+ case 3 :
+ expandedProps[ propertyName + "-right" ] = l[1];
+ expandedProps[ propertyName + "-bottom" ] = l[2];
+ expandedProps[ propertyName + "-left" ] = l[1];
+ break;
+ case 4 :
+ expandedProps[ propertyName + "-right" ] = l[1];
+ expandedProps[ propertyName + "-bottom" ] = l[2];
+ expandedProps[ propertyName + "-left" ] = l[3];
+ break;
+ default:break;
+ }
+ return expandedProps;
+ }
+
+ QMap<QString,QString> ShorthandFormer::expandPaddingProp(const QStringList& l){
+ return expandImplementation2("padding", l);
+}
+
+ QMap<QString,QString> ShorthandFormer::expandMarginProp(const QStringList& l){
+ return expandImplementation2("margin", l);
+ }
+
+QStringList ShorthandFormer::SHFormList() {
+ QStringList l;
+ l.append("cue");
+ l.append("pause");
+ l.append("font");
+ l.append("background");
+ l.append("border");
+ l.append("border-top");
+ l.append("border-bottom");
+ l.append("border-left");
+ l.append("border-right");
+ l.append("border-color");
+ l.append("border-style");
+ l.append("border-width");
+ l.append("outline");
+ l.append("list-style");
+ l.append("padding");
+ l.append("margin");
+ return l;
+}
+
diff --git a/quanta/components/csseditor/shorthandformer.h b/quanta/components/csseditor/shorthandformer.h
new file mode 100644
index 00000000..f5b0f291
--- /dev/null
+++ b/quanta/components/csseditor/shorthandformer.h
@@ -0,0 +1,117 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Gulmini Luciano *
+ * gulmini.luciano@student.unife.it *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef SHORTHANDFORMER_H
+#define SHORTHANDFORMER_H
+
+/**
+@author Gulmini Luciano
+*/
+#include <qmap.h>
+class QString;
+class QStringList;
+
+class ShorthandFormer{
+public:
+ ShorthandFormer(){}
+ ShorthandFormer( QMap<QString,QString> m );
+ ~ShorthandFormer(){}
+ QString compress();
+ QMap<QString,QString> expand(const QString& propertyName, const QString& propertyValue);
+ static QStringList SHFormList();
+
+private:
+ QMap<QString,QString> m_properties;
+ QString cue_after,
+ cue_before,
+ pause_before,
+ pause_after,
+ background_color,
+ background_image,
+ background_repeat,
+ background_attachment,
+ background_position,
+ border_top_style,
+ border_top_color,
+ border_top_width,
+ border_left_style,
+ border_left_color,
+ border_left_width,
+ border_right_style,
+ border_right_color,
+ border_right_width,
+ border_bottom_style,
+ border_bottom_color,
+ border_bottom_width,
+ outline_style,
+ outline_color,
+ outline_width,
+ list_style_type,
+ list_style_image,
+ list_style_position,
+ font_style,
+ font_variant,
+ font_weight,
+ font_size,
+ line_height,
+ font_family,
+ margin_top,
+ margin_bottom,
+ margin_left,
+ margin_right,
+ padding_top,
+ padding_bottom,
+ padding_left,
+ padding_right;
+
+private:
+ QString compressCueProp();
+ QString compressPauseProp();
+ QString compressPaddingProp();
+ QString compressMarginProp();
+ QString compressFontProp();
+ QString compressBackgroundProp();
+ QString compressOutlineProp();
+ QString compressListStyleProp();
+ QString compressBorderStyleProp();
+ QString compressBorderWidthProp();
+ QString compressBorderColorProp();
+ QString compressBorderProp();
+
+ QString compressImplementation( const QString& prop, const QString& t, const QString& b, const QString& r, const QString& l, const QString& defValue);
+ QString compressImplementation2( const QString& prop, const QString& after, const QString& before, const QString& defValue);
+ QString compressImplementation3( const QString& prop, const QString& p1, const QString& p2, const QString& p3);
+
+ QMap<QString,QString> expandCueProp(const QStringList& l);
+ QMap<QString,QString> expandPauseProp(const QStringList& l);
+ QMap<QString,QString> expandBackgroundProp(const QStringList& l);
+ QMap<QString,QString> expandFontProp(const QStringList& l);
+ QMap<QString,QString> expandOutlineProp(const QStringList& l);
+ QMap<QString,QString> expandListstyleProp(const QStringList& l);
+ QMap<QString,QString> expandBoxSide(const QString& subPropName, const QStringList& l);
+ QMap<QString,QString> expandBorderProp(const QStringList& l);
+ QMap<QString,QString> expandBox(const QString& subPropName, const QStringList& l);
+ QMap<QString,QString> expandPaddingProp(const QStringList& l);
+ QMap<QString,QString> expandMarginProp(const QStringList& l);
+
+ QMap<QString,QString> expandImplementation(const QString& propertyName, const QStringList& l);
+ QMap<QString,QString> expandImplementation2(const QString& propertyName, const QStringList& l);
+ };
+
+#endif
diff --git a/quanta/components/csseditor/specialsb.cpp b/quanta/components/csseditor/specialsb.cpp
new file mode 100644
index 00000000..eb26e05f
--- /dev/null
+++ b/quanta/components/csseditor/specialsb.cpp
@@ -0,0 +1,127 @@
+/***************************************************************************
+ specialsb.cpp - description
+ -------------------
+ begin : dom ago 3 2003
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "specialsb.h"
+#include "propertysetter.h"
+#include "csseditor_globals.h"
+
+#include <klineedit.h>
+
+specialSB::specialSB(QWidget *parent, const char *name, bool useLineEdit ) : miniEditor(parent,name) {
+ if (useLineEdit)
+ {
+ m_lineEdit = new KLineEdit(this);
+ m_sb = 0L;
+ connect(m_lineEdit, SIGNAL(textChanged ( const QString & )), this, SLOT(lineEditValueSlot ( const QString & )));
+ }
+ else
+ {
+ m_sb=new mySpinBox(this);
+ connect(m_sb, SIGNAL(valueChanged ( const QString & )), this, SLOT(sbValueSlot(const QString&)));
+ m_lineEdit = 0L;
+ }
+ m_cb = new QComboBox(this);
+ connect(m_cb, SIGNAL(activated ( const QString & )), this, SLOT(cbValueSlot(const QString&)));
+}
+
+specialSB::~specialSB(){
+ delete m_cb;
+ delete m_sb;
+ delete m_lineEdit;
+}
+
+void specialSB::connectToPropertySetter(propertySetter* p){
+ connect(this, SIGNAL(valueChanged(const QString&)), p,SIGNAL(valueChanged(const QString&)));
+}
+
+
+void specialSB::cbValueSlot(const QString& s){
+ if (m_sb)
+ emit valueChanged( m_sb->text() +s );
+ else
+ emit valueChanged( m_lineEdit->text() +s );
+}
+
+void specialSB::sbValueSlot(const QString& s){
+ emit valueChanged( s + m_cb->currentText());
+}
+
+void specialSB::lineEditValueSlot(const QString& s){
+ emit valueChanged( s + m_cb->currentText());
+}
+
+void specialSB::setInitialValue(const QString& s){
+
+ QRegExp pattern("\\d("+ cbValueList().join("|")+")");
+
+ if (pattern.search(s) != -1) {
+ QString temp(s.stripWhiteSpace());
+ QString cbValue = pattern.cap(1);
+
+ if (m_sb)
+ m_sb->setValue(temp.remove(cbValue).toInt());
+ else
+ m_lineEdit->setText(temp.remove(cbValue));
+ m_cb->setCurrentText(cbValue);
+ }
+ else return;
+}
+
+QStringList specialSB::cbValueList(){
+ QStringList l;
+ for(int i=0; i<m_cb->count();i++) l.append(m_cb->text(i));
+ return l;
+}
+
+frequencyEditor::frequencyEditor(QWidget *parent, const char *name ) : specialSB(parent,name) {
+ m_cb->insertItem("Hz");
+ m_cb->insertItem("kHz");
+ m_sb->setMaxValue(9999);
+}
+
+angleEditor::angleEditor(QWidget *parent, const char *name) : specialSB(parent,name){
+ m_cb->insertItem("deg");
+ m_cb->insertItem("grad");
+ m_cb->insertItem("rad");
+ m_sb->setMaxValue(-400);
+ m_sb->setMaxValue(400);
+}
+
+timeEditor::timeEditor(QWidget *parent, const char *name ) : specialSB(parent,name) {
+ m_cb->insertItem("ms");
+ m_cb->insertItem("s");
+ m_sb->setMaxValue(99999);
+}
+
+lengthEditor::lengthEditor(QWidget *parent, const char *name ) : specialSB(parent,name, true) {
+ m_cb->insertItem("px");
+ m_cb->insertItem("em");
+ m_cb->insertItem("ex");
+ m_cb->insertItem("in");
+ m_cb->insertItem("cm");
+ m_cb->insertItem("mm");
+ m_cb->insertItem("pt");
+ m_cb->insertItem("pc");
+ if (m_sb)
+ m_sb->setMaxValue(99999);
+}
+
+
+
+
+
+#include "specialsb.moc"
diff --git a/quanta/components/csseditor/specialsb.h b/quanta/components/csseditor/specialsb.h
new file mode 100644
index 00000000..43d6273e
--- /dev/null
+++ b/quanta/components/csseditor/specialsb.h
@@ -0,0 +1,79 @@
+/***************************************************************************
+ specialsb.h - description
+ -------------------
+ begin : dom ago 3 2003
+ copyright : (C) 2003 by Gulmini Luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SPECIALSB_H
+#define SPECIALSB_H
+
+#include "minieditor.h"
+#include <qcombobox.h>
+class mySpinBox;
+class KLineEdit;
+
+/**
+ *@author gulmini luciano
+ */
+
+class specialSB : public miniEditor {
+ Q_OBJECT
+ protected:
+ QComboBox *m_cb;
+ mySpinBox *m_sb;
+ KLineEdit *m_lineEdit;
+
+ public:
+ specialSB(QWidget *parent=0, const char *name=0, bool useLineEdit = false);
+ ~specialSB();
+ void insertItem(const QString& s){ m_cb->insertItem(s); }
+ void setInitialValue(const QString& s);
+ QStringList cbValueList();
+ virtual void connectToPropertySetter(propertySetter* p);
+
+ public slots:
+ void cbValueSlot(const QString&);
+ void sbValueSlot(const QString&);
+ void lineEditValueSlot(const QString&);
+
+ signals:
+ void valueChanged(const QString&);
+
+};
+
+class angleEditor : public specialSB {
+ Q_OBJECT
+ public:
+ angleEditor(QWidget *parent=0, const char *name=0);
+};
+
+class frequencyEditor : public specialSB {
+ Q_OBJECT
+ public:
+ frequencyEditor(QWidget *parent=0, const char *name=0);
+};
+
+class timeEditor : public specialSB {
+ Q_OBJECT
+ public:
+ timeEditor(QWidget *parent=0, const char *name=0);
+};
+
+class lengthEditor : public specialSB {
+ Q_OBJECT
+ public:
+ lengthEditor(QWidget *parent=0, const char *name=0);
+};
+
+#endif
diff --git a/quanta/components/csseditor/styleeditor.cpp b/quanta/components/csseditor/styleeditor.cpp
new file mode 100644
index 00000000..63d4af79
--- /dev/null
+++ b/quanta/components/csseditor/styleeditor.cpp
@@ -0,0 +1,109 @@
+/***************************************************************************
+ styleeditor - implementation
+ begin : Wed Apr 7 2004
+ copyright : (C) 2004 by Luciano Gulmini <gulmini.luciano@student.unife.it>
+ ***************************************************************************/
+
+/***************************************************************************
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ ***************************************************************************/
+
+//qt includes
+#include <qlineedit.h>
+#include <qtooltip.h>
+#include <qiconset.h>
+#include <qlabel.h>
+#include <qfileinfo.h>
+
+//kde includes
+#include <kdialog.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kpushbutton.h>
+#include <kurl.h>
+#include <ktexteditor/editinterface.h>
+#include <ktexteditor/viewcursorinterface.h>
+
+//app includes
+#include "parser.h"
+#include "tag.h"
+#include "node.h"
+#include "project.h"
+#include "resource.h"
+#include "document.h"
+#include "styleeditor.h"
+#include "viewmanager.h"
+#include "csseditor.h"
+
+StyleEditor::StyleEditor(QWidget *parent, const char* name) : TLPEditor(parent,name){
+ connect(m_pb, SIGNAL(clicked()), this, SLOT(openCSSEditor()));
+ setToolTip(i18n("Open css dialog"));
+ QIconSet iconSet = SmallIconSet(QString::fromLatin1("stylesheet"));
+ QPixmap pixMap = iconSet.pixmap( QIconSet::Small, QIconSet::Normal );
+ m_pb->setIconSet(iconSet);
+ m_iconWidth = pixMap.width();
+ m_iconHeight = pixMap.height();
+ m_pb->setFixedSize( m_iconWidth+8, m_iconHeight+8 );
+ m_label->hide();
+}
+
+void StyleEditor::setButtonIcon(int width, int height){
+ m_pb->setFixedSize( m_iconWidth+width, m_iconHeight+height );
+}
+
+void StyleEditor::openCSSEditor(){
+ Document *w = ViewManager::ref()->activeDocument();
+ if (!w) return;
+ uint line, col;
+ int bLine, bCol, eLine, eCol;
+ bLine = bCol = eLine = eCol = 0;
+ w->viewCursorIf->cursorPositionReal(&line, &col);
+ if (line == 0 && col == 0)
+ col++;
+ //parser->rebuild(w);
+ Node *node = parser->nodeAt(line, col, false);
+ unsigned int lastLine = w->editIf->numLines() - 1;
+ unsigned int lastCol = w->editIf->lineLength(lastLine);
+ Node *styleNode = node;
+
+ if (styleNode->tag->type == Tag::XmlTagEnd && styleNode->prev)
+ styleNode = styleNode->prev;
+
+ QString fullDocument = w->editIf->text().stripWhiteSpace();
+
+ if (styleNode && (styleNode->tag->type == Tag::XmlTag || styleNode->tag->type == Tag::Empty) ) {
+ CSSEditor *dlg = new CSSEditor(this);
+ QFileInfo fi(ViewManager::ref()->currentURL());
+ dlg->setFileToPreview(Project::ref()->projectBaseURL().path() + fi.baseName(),false);
+
+ styleNode->tag->beginPos(bLine, bCol);
+ styleNode->tag->endPos(eLine, eCol);
+ dlg->setFooter(">" + w->text(eLine, eCol + 1, lastLine, lastCol));
+
+ QString temp;
+ if (styleNode->tag->hasAttribute("style")) {
+ dlg->setInlineStyleContent(styleNode->tag->attributeValue("style"));
+ Tag tempTag(*(styleNode->tag));
+ tempTag.deleteAttribute("style");
+ temp = tempTag.toString();
+ }
+ else {
+ dlg->setInlineStyleContent(QString::null);
+ temp = styleNode->tag->toString();
+ }
+
+ temp = temp.left(temp.length()-1);//remove >
+ temp = temp.right(temp.length()-1);//remove <
+ dlg->setHeader(w->text(0, 0, bLine, bCol) + temp);
+
+ dlg->initialize();
+ if( dlg->exec() ) m_le->setText(dlg->generateProperties());
+ delete dlg;
+ }
+}
+
+#include "styleeditor.moc"
diff --git a/quanta/components/csseditor/styleeditor.h b/quanta/components/csseditor/styleeditor.h
new file mode 100644
index 00000000..582ac848
--- /dev/null
+++ b/quanta/components/csseditor/styleeditor.h
@@ -0,0 +1,42 @@
+/***************************************************************************
+ styleeditor - description
+ begin : Wed Apr 7 2004
+ copyright : (C) 2004 by Luciano Gulmini <gulmini.luciano@student.unife.it>
+ ***************************************************************************/
+
+/***************************************************************************
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ ***************************************************************************/
+
+#ifndef STYLEEDITOR_H
+#define STYLEEDITOR_H
+
+//qt includes
+#include "tlpeditors.h"
+//kde includes
+
+//app includes
+
+//forward declarations
+class propertySetter;
+class StyleEditor : public TLPEditor{
+ Q_OBJECT
+ private:
+ int m_iconWidth,
+ m_iconHeight;
+public:
+ StyleEditor(QWidget *parent=0, const char* name=0);
+ virtual void setButtonIcon(int width, int height);
+
+public slots:
+ void openCSSEditor();
+ virtual void connectToPropertySetter(propertySetter* /*p*/){}
+ virtual void setInitialValue(const QString& /*s*/){}
+};
+
+
+#endif //STYLEEDITOR_H
diff --git a/quanta/components/csseditor/stylesheetparser.cpp b/quanta/components/csseditor/stylesheetparser.cpp
new file mode 100644
index 00000000..b8cbf306
--- /dev/null
+++ b/quanta/components/csseditor/stylesheetparser.cpp
@@ -0,0 +1,245 @@
+/***************************************************************************
+ stylesheetparser.cpp - description
+ -------------------
+ begin : gio ago 19 2004
+ copyright : (C) 2004 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "stylesheetparser.h"
+#include <klocale.h>
+#include <kdebug.h>
+
+static const QString msg1(i18n("has not been closed")),
+ msg2(i18n("needs an opening parenthesis "));
+
+stylesheetParser::stylesheetParser(const QString& s){
+ m_styleSheet = s;
+ m_styleSheet=m_styleSheet.right(m_styleSheet.length()-whiteSpaces(0));
+ m_stopProcessing = false;
+ m_orderNumber = 0;
+}
+
+int stylesheetParser::whiteSpaces(int d){
+ int ws=0;
+ for( unsigned int i=d;i<m_styleSheet.length();i++){
+ QString temp;
+ if(m_styleSheet[i] == ' ' || m_styleSheet[i] == '\n' || m_styleSheet[i] == '\t' )
+ ws++;
+ else break;
+ }
+ return ws;
+}
+
+void stylesheetParser::parse(){
+ if(!m_stopProcessing){
+ if(!m_styleSheet.isEmpty()){
+ if(m_styleSheet.startsWith("/*"))
+ parseComment();
+ else if(m_styleSheet.startsWith("@page"))
+ parseAtRules1();
+ else if(m_styleSheet.startsWith("@media"))
+ parseAtRules1();
+ else if(m_styleSheet.startsWith("@import"))
+ parseAtRules2();
+ else if(m_styleSheet.startsWith("@charset"))
+ parseAtRules2();
+ else parseSelector();
+ }
+ else return;
+ }
+}
+
+void stylesheetParser::parseComment(){
+ bool stopProcessingComment=false;
+ unsigned int k;
+ for(k=2;k<m_styleSheet.length()-1;k++){
+ QString temp;
+ temp.append(m_styleSheet[k]).append(m_styleSheet[k+1]);
+ if(temp=="*/") {
+ k+=2;
+ stopProcessingComment=true;
+ break;
+ }
+ }
+
+ if(stopProcessingComment){
+ int ws=whiteSpaces(k);
+ QPair<QString,unsigned int> tmp(m_styleSheet.left(k+ws),++m_orderNumber);
+ m_stylesheetStructure["/*"+QString::number(m_orderNumber,10)]=tmp;
+ m_styleSheet=m_styleSheet.right(m_styleSheet.length()-k-ws);
+ parse();
+ }
+
+ else {
+ m_stopProcessing = true;
+ emit errorOccurred(i18n("The comment") + " :\n" +m_styleSheet.mid(0,20) + "...\n "+ msg1);
+ return;
+ }
+}
+
+unsigned int stylesheetParser::numberOfParenthesisInAParenthesisBlock(parenthesisKind p, const QString& b){
+ QChar searchFor = '{';
+ if (p == closed)
+ searchFor = '}';
+ int num = 0;
+ int len = b.length();
+ bool ignore = false;
+ for (int i = 0; i < len; i++)
+ {
+ if (b[i] == '/' && (i + 1 < len) && b[i + 1] == '*')
+ ignore = true;
+ if (b[i] == '*' && (i + 1 < len) && b[i + 1] == '/')
+ ignore = false;
+ if (!ignore && b[i] == searchFor)
+ num++;
+ }
+ return num;
+}
+
+int findParanthesis(const QString& string, const QChar &ch, int startPos = 0)
+{
+ int pos = -1;
+ int len = string.length();
+ bool ignore = false;
+ for (int i = startPos; i < len; i++)
+ {
+ if (string[i] == '/' && (i + 1 < len) && string[i + 1] == '*')
+ ignore = true;
+ if (string[i] == '*' && (i + 1 < len) && string[i + 1] == '/')
+ ignore = false;
+ if (!ignore && string[i] == ch)
+ {
+ pos = i;
+ break;
+ }
+ }
+ return pos;
+}
+
+void stylesheetParser::parseSelector(){
+ int closingParenthesisPos = findParanthesis(m_styleSheet, '}');
+ if(closingParenthesisPos==-1) {
+ m_stopProcessing = true;
+ emit errorOccurred(i18n("The selector") + " :\n" +m_styleSheet.mid(0,20) + "...\n "+ msg1);
+ return;
+ }
+
+ QString temp(m_styleSheet.left(closingParenthesisPos+1));
+
+ if(numberOfParenthesisInAParenthesisBlock(closed,temp) < numberOfParenthesisInAParenthesisBlock(opened,temp)){
+ m_stopProcessing = true;
+ emit errorOccurred(i18n("The selector") + " :\n" +m_styleSheet.mid(0,20) + "...\n "+ msg1);
+ return;
+ }
+
+ if(numberOfParenthesisInAParenthesisBlock(closed,temp) > numberOfParenthesisInAParenthesisBlock(opened,temp)){
+ m_stopProcessing = true;
+ emit errorOccurred(i18n("The selector") + " :\n" +m_styleSheet.mid(0,20) + "...\n "+ msg2);
+ return;
+ }
+
+ int closingParentheses = 1,
+ openingParentheses = 0;
+ while(true){
+ openingParentheses = numberOfParenthesisInAParenthesisBlock(closed,m_styleSheet.left(closingParenthesisPos+1)); //m_styleSheet.left(closingParenthesisPos+1).contains("{");
+
+ if(openingParentheses==closingParentheses){
+ QString selectorName=m_styleSheet.left(findParanthesis(m_styleSheet, '{')/*m_styleSheet.find("{")*/).stripWhiteSpace(),
+ selectorValue=m_styleSheet.mid(findParanthesis(m_styleSheet, '{')/*m_styleSheet.find("{")*/+1, closingParenthesisPos - m_styleSheet.find("{") -1);
+
+ selectorName.remove("\n").remove("\t");
+ selectorValue.remove("\n").remove("\t");
+ QPair<QString,unsigned int> tmp(selectorValue,++m_orderNumber);
+
+ if (m_stylesheetStructure.contains(selectorName))
+ {
+ uint i = 2;
+ QString s = selectorName + QString("-v%1").arg(i);
+ while (m_stylesheetStructure.contains(s))
+ {
+ i++;
+ s = selectorName + QString("-v%1").arg(i);
+ }
+ selectorName = s;
+ }
+ m_stylesheetStructure[selectorName]=tmp;
+ break;
+ }
+ else {
+ closingParenthesisPos = findParanthesis(m_styleSheet, '{',closingParenthesisPos+1)/*m_styleSheet.find("}",closingParenthesisPos+1)*/;
+ closingParentheses++;
+ }
+ }
+
+ int ws=whiteSpaces(closingParenthesisPos+1);
+ m_styleSheet=m_styleSheet.right(m_styleSheet.length()-closingParenthesisPos-1-ws);
+ parse();
+}
+
+void stylesheetParser::parseAtRules1(){
+//TODO this needs to be fixed : in case the at rule is not properly closed the parser hangs
+ if(m_styleSheet.find("{") == -1) {
+ m_stopProcessing = true;
+ emit errorOccurred(m_styleSheet.mid(0,20) + "...\n " + msg2);
+ return;
+ }
+
+ int closingParenthesisPos = m_styleSheet.find("}"),
+ closingParentheses = 0;
+
+ if(closingParenthesisPos==-1) return;
+ else closingParentheses = 1;
+
+ int openingParentheses=0;
+ while(true){
+ openingParentheses = m_styleSheet.left(closingParenthesisPos+1).contains("{");
+
+ if(openingParentheses==closingParentheses)
+ break;
+ else {
+ closingParenthesisPos = m_styleSheet.find("}",closingParenthesisPos+1);
+ if( closingParenthesisPos!= -1 )
+ closingParentheses++;
+ else {
+ m_stopProcessing = true;
+ emit errorOccurred(m_styleSheet.mid(0,20) + "...\n " + msg1);
+ return;
+ }
+ }
+ }
+
+ int ws=whiteSpaces(closingParenthesisPos+1);
+ QPair<QString,unsigned int> tmp(m_styleSheet.left(closingParenthesisPos+1+ws),++m_orderNumber);
+ m_stylesheetStructure["@rule"+QString::number(m_orderNumber,10)]=tmp;
+ m_styleSheet=m_styleSheet.right(m_styleSheet.length()-closingParenthesisPos-1-ws);
+ parse();
+}
+
+void stylesheetParser::parseAtRules2(){
+//TODO this needs to be fixed : in case the at rule is not properly closed the parser hangs
+ int semicolonPos = m_styleSheet.find(";");
+
+ if(semicolonPos==-1) {
+ m_stopProcessing = true;
+ emit errorOccurred(m_styleSheet.mid(0,20) + "...\n " + msg1);
+ return;
+ }
+
+ int ws=whiteSpaces(semicolonPos+1);
+ QPair<QString,unsigned int> tmp(m_styleSheet.left(semicolonPos+1+ws),++m_orderNumber);
+ m_stylesheetStructure["@rule"+QString::number(m_orderNumber,10)]=tmp;
+ m_styleSheet=m_styleSheet.right(m_styleSheet.length()-semicolonPos-1-ws);
+ parse();
+}
+
+#include "stylesheetparser.moc"
diff --git a/quanta/components/csseditor/stylesheetparser.h b/quanta/components/csseditor/stylesheetparser.h
new file mode 100644
index 00000000..26d5fa3e
--- /dev/null
+++ b/quanta/components/csseditor/stylesheetparser.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ stylesheetparser.h - description
+ -------------------
+ begin : gio ago 19 2004
+ copyright : (C) 2004 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef STYLESHEETPARSER_H
+#define STYLESHEETPARSER_H
+
+#include <qmap.h>
+#include <qpair.h>
+#include <qobject.h>
+
+/**
+ *@author gulmini luciano
+ */
+
+class stylesheetParser : public QObject{
+ Q_OBJECT
+ private:
+
+ enum parenthesisKind { opened, closed };
+ QString m_styleSheet;
+ bool m_stopProcessing;
+ unsigned int m_orderNumber;
+ QMap<QString, QPair<QString,unsigned int> > m_stylesheetStructure;
+ void parseComment();
+ void parseSelector();
+ void parseAtRules1();
+ void parseAtRules2();
+ int whiteSpaces(int);
+ unsigned int numberOfParenthesisInAParenthesisBlock(parenthesisKind p, const QString& b);
+
+ 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&);
+};
+
+#endif
+
diff --git a/quanta/components/csseditor/tlpeditors.cpp b/quanta/components/csseditor/tlpeditors.cpp
new file mode 100644
index 00000000..706ac518
--- /dev/null
+++ b/quanta/components/csseditor/tlpeditors.cpp
@@ -0,0 +1,174 @@
+/***************************************************************************
+ tlpeditors.cpp - description
+ -------------------
+ begin : gio apr 1 2004
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qlineedit.h>
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+#include <kpushbutton.h>
+#include <kurl.h>
+#include <kdialog.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kfiledialog.h>
+#include <kimagefilepreview.h>
+
+#include "qextfileinfo.h"
+#include "tlpeditors.h"
+#include "fontfamilychooser.h"
+#include "project.h"
+
+TLPEditor::TLPEditor(QWidget *parent, const char* name) : miniEditor(parent,name){
+ m_label = new QLabel(this);
+ m_le = new QLineEdit(this);
+ m_pb = new KPushButton(this);
+ setSpacing( KDialog::spacingHint() );
+}
+
+TLPEditor::~TLPEditor(){
+ delete m_label;
+ delete m_le;
+ delete m_pb;
+}
+
+void TLPEditor::setButtonIcon(QString s){
+ QIconSet iconSet = SmallIconSet(QString::fromLatin1(s));
+ QPixmap pixMap = iconSet.pixmap( QIconSet::Small, QIconSet::Normal );
+ m_pb->setIconSet(iconSet);
+ m_pb->setFixedSize( pixMap.width()+8, pixMap.height()+8 );
+}
+
+void TLPEditor::setLabelText(QString s){
+ m_label->setText(s);
+}
+
+void TLPEditor::setToolTip(QString s){
+ QToolTip::add(m_pb, s);
+}
+
+void TLPEditor::setWhatsThis(QString s){
+ QWhatsThis::add(m_le,s);
+}
+
+URIEditor::URIEditor(QWidget *parent, const char* name) : TLPEditor(parent,name){
+ QString whatsthis =i18n("With this line edit you can insert the URI of the resource you want to reach");
+ setWhatsThis(whatsthis);
+ setLabelText(" Uri :");
+ setButtonIcon("fileopen");
+ setToolTip(i18n("Open the URI selector"));
+
+ connect(m_pb, SIGNAL(clicked()), this, SLOT(openFileDialog()));
+}
+
+void URIEditor::connectToPropertySetter(propertySetter* p){
+ connect(this,SIGNAL(valueChanged(const QString&)), p ,SIGNAL(valueChanged(const QString&)));
+}
+
+void URIEditor::setMode(const mode& m) {
+ m_Mode = m ;
+ if( m_Mode == Single )
+ connect(m_le, SIGNAL(textChanged ( const QString & )), this, SLOT(selectedURI(const QString&)));
+ else{
+ connect(m_le, SIGNAL(textChanged ( const QString & )), this, SLOT(selectedURIs(const QStringList&)));
+ }
+}
+
+void URIEditor::selectedURI(const QString & s){
+ KURL u;
+ u.setPath(s);
+ emit valueChanged("url(\'" + QExtFileInfo::toRelative(u, Project::ref()->projectBaseURL()).path() + "\')");
+}
+
+void URIEditor::selectedURIs(const QStringList& s){
+ KURL u;
+ QStringList selectedFiles = s,
+ selectedFilesWithURLFormat;
+ for ( QStringList::Iterator it = selectedFiles.begin(); it != selectedFiles.end(); ++it ){
+ u.setPath(*it);
+ selectedFilesWithURLFormat.append( "url(\'" + QExtFileInfo::toRelative(u, Project::ref()->projectBaseURL()).path() + "\')");
+ }
+ emit valueChanged(selectedFilesWithURLFormat.join(","));
+}
+
+void URIEditor::openFileDialog(){
+
+ KFileDialog fd( Project::ref()->projectBaseURL().url(), "*.*", this, "file dialog", true );
+ switch(m_resourceType) {
+ case image : {
+ fd.setFilter( "*.png *.gif *.jpg *.mng|" + i18n("Image Files") +" (*.png *.gif *.jpg *.mng)\n*.*|" + i18n("All Files")+(" (*.*)") );
+ KImageFilePreview *ip = new KImageFilePreview( &fd );
+ fd.setPreviewWidget( ip );
+ }
+ break;
+ case audio : {
+ fd.setFilter( "*.au *.aiff *.wav|" + i18n("Audio Files")+" (*.au *.aiff *.wav)\n*.*|" + i18n("All Files")+(" (*.*)") );
+
+
+ }
+ break;
+ //case mousePointer : fd.setFilter( "*.|" + i18n("Mouse Pointers (*.)")+"\n*.*|" + i18n("All Files (*.*)") );break;
+ case mousePointer : fd.setFilter( "*.*|" + i18n("All Files")+(" (*.*)") );break;
+
+ default:;
+ }
+
+ if( m_Mode == Single)
+ fd.setMode(KFile::File);
+ else
+ fd.setMode(KFile::Files);
+
+
+ if( fd.exec() ){
+ if( fd.mode() == KFile::File )
+ selectedURI( fd.selectedFile() );
+ else {
+ selectedURIs( fd.selectedFiles() );
+ /*QStringList selectedFiles = fd.selectedFiles();
+ KURL u;
+ for ( QStringList::Iterator it = selectedFiles.begin(); it != selectedFiles.end(); ++it ){
+ u.setPath(*it);
+ m_sFiles.append( "url(\'" + QExtFileInfo::toRelative(u, Project::ref()->projectBaseURL()).path() + "\')");
+ }
+ emit valueChanged(m_sFiles.join(","));*/
+ }
+ }
+}
+
+fontEditor::fontEditor(QWidget *parent, const char* name) : TLPEditor(parent,name), m_initialValue(QString::null){
+ QString whatsthis =i18n("With this line edit you can insert the name of the font you want to use");
+ setWhatsThis(whatsthis);
+ setLabelText(i18n("Font family:"));
+ setButtonIcon("fonts");
+ setToolTip(i18n("Open font family chooser"));
+ connect(m_pb, SIGNAL(clicked()), this, SLOT(openFontChooser()));
+ connect(m_le, SIGNAL(textChanged ( const QString & )), this, SIGNAL( valueChanged( const QString& ) ) );
+}
+
+void fontEditor::connectToPropertySetter(propertySetter* p){
+ connect(this, SIGNAL(valueChanged(const QString&)), p, SIGNAL(valueChanged(const QString&)));
+}
+
+void fontEditor::openFontChooser(){
+ fontFamilyChooser dlg( this );
+ dlg.setInitialValue(m_initialValue);
+ if( dlg.exec() )
+ emit valueChanged( dlg.fontList().join(", "));
+}
+
+#include "tlpeditors.moc"
diff --git a/quanta/components/csseditor/tlpeditors.h b/quanta/components/csseditor/tlpeditors.h
new file mode 100644
index 00000000..d0e52d37
--- /dev/null
+++ b/quanta/components/csseditor/tlpeditors.h
@@ -0,0 +1,94 @@
+/***************************************************************************
+ tlpeditors.h - description
+ -------------------
+ begin : gio apr 1 2004
+ copyright : (C) 2003 by gulmini luciano
+ email : gulmini.luciano@student.unife.it
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef TLPEDITORS_H
+#define TLPEDITORS_H
+
+#include "minieditor.h"
+#include "propertysetter.h"
+
+class KPushButton;
+class QLineEdit;
+class QLabel;
+/**
+ *@author gulmini luciano
+ */
+
+
+class TLPEditor : public miniEditor { //editor with a line text and a button calling a dialog
+ Q_OBJECT
+
+ protected:
+ QLineEdit *m_le;
+ QLabel *m_label;
+ KPushButton *m_pb;
+
+ public:
+ TLPEditor(QWidget *parent, const char* name=0);
+ virtual ~TLPEditor();
+ virtual void setButtonIcon(QString);
+ void setToolTip(QString);
+ void setLabelText(QString);
+ void setWhatsThis(QString);
+ QLineEdit* lineEdit() const { return m_le; }
+ KPushButton* button() const { return m_pb; }
+ virtual void setInitialValue(const QString& s)=0;
+ virtual void connectToPropertySetter(propertySetter* p)=0;
+
+ signals:
+ void valueChanged(const QString&);
+};
+
+class fontEditor : public TLPEditor{
+ Q_OBJECT
+ private:
+ QString m_initialValue;
+
+ public:
+ fontEditor(QWidget *parent, const char* name=0);
+ virtual void setInitialValue(const QString& s) { m_initialValue = s; }
+ virtual void connectToPropertySetter(propertySetter* p);
+
+ public slots:
+ void openFontChooser();
+};
+
+class URIEditor : public TLPEditor {
+ Q_OBJECT
+ public:
+ enum mode{ Multi, Single };
+ enum URIResourceType{ audio, image, mousePointer };
+
+ private:
+ mode m_Mode;
+ URIResourceType m_resourceType;
+
+ public:
+ URIEditor(QWidget *parent, const char* name=0);
+ void setMode(const mode& m);
+ void setResourceType(const URIResourceType& r) { m_resourceType = r ; }
+ virtual void setInitialValue(const QString& /*s*/){}
+ virtual void connectToPropertySetter(propertySetter* p);
+
+ public slots:
+ void selectedURI(const QString&);
+ void selectedURIs(const QStringList&);
+ void openFileDialog();
+};
+
+
+#endif