summaryrefslogtreecommitdiffstats
path: root/quanta/components/csseditor/csseditor.h
blob: 6994a686dae29d143f17e6713d8d2ada58e9a1f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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