summaryrefslogtreecommitdiffstats
path: root/quanta/dialogs/tagdialogs/tagattr.h
blob: 30b5220dfb74bfbd3db3092d98526a0ea3a42a6e (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/***************************************************************************
                          tagxml.h  -  description
                             -------------------
    begin                : ����25 14:34:07 EEST 2000
    copyright            : (C) 2000 by Dmitry Poplavsky & Alexander Yakovlev <pdima@users.sourceforge.net,yshurik@linuxfan.com>
                           (C) 2004 Andras Mantia <amantia@kde.org>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 TAGATTR_H
#define TAGATTR_H

//qt includes
#include <qstring.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qdom.h>

//kde includes
#include <klineedit.h>
#include <kurl.h>

//app includes
#include "colorcombo.h"
#include "filecombo.h"

class QDomElement;
class QWidget;
class QTag;


QDomNode findChild( QDomNode &parent, const QString &name );


class Attr
{
  public:
    Attr( QDomElement const& el, QWidget *, QTag *dtdTag )
    : domEl(el), name(domEl.attribute("name","")), m_dtdTag(dtdTag) {}
    //{ domEl = el; name = domEl->attribute("name",""); m_dtdTag = dtdTag;}
    virtual ~Attr(){}

    virtual QString value()=0;
    virtual void setValue(const QString &value)=0;

    QString attrName() const;
    QDomElement const& domElement() const { return domEl; }

  protected:
     QDomElement domEl;
     QString name;
     QTag *m_dtdTag;
};


class Attr_line : public Attr
{
  protected:
    QLineEdit *line;

  public:
    Attr_line( QDomElement const& el, QWidget *w, QTag *dtdTag ) : Attr(el, w, dtdTag)
        {  line = (QLineEdit *)w; }
    virtual ~Attr_line(){};

    virtual QString value() { return line->text(); }
    virtual void setValue(const QString &value) { line->setText(value); }
};


class Attr_color : public Attr
{
  protected:
    ColorCombo *color;

  public:
    Attr_color( QDomElement const& el, QWidget *w, QTag *dtdTag ) : Attr(el, w, dtdTag)
        { color = (ColorCombo *)w; }
    virtual ~Attr_color(){};

    virtual QString value() {  return color->colorName(); }
    virtual void setValue(const QString &value) { color->setColorName(value); }
};

class Attr_file : public Attr
{
  protected:
    FileCombo *file;

  public:
    Attr_file( QDomElement const& el, QWidget *w , QTag * dtdTag ) : Attr(el, w, dtdTag)
        { file = (FileCombo *)w; }
    virtual ~Attr_file(){};

    virtual QString value() {  return file->text(); }
    virtual void setValue(const QString &value) { file->setText(value); }
};

class Attr_list : public Attr
{
  protected:
    QComboBox *combo;

  public:
    Attr_list( QDomElement const& el, QWidget *w, QTag *dtdTag );
    virtual ~Attr_list(){};

    virtual QString value() { return combo->currentText(); }
    virtual void setValue(const QString &value);
};


class Attr_check : public Attr
{
  protected:
    QCheckBox *check;

  public:
    Attr_check( QDomElement const& el, QWidget *w, QTag *dtdTag ) : Attr(el, w, dtdTag)
        { check = (QCheckBox *)w; }
    virtual ~Attr_check(){};

    virtual QString value() { return check->isChecked() ? "checked" : "unchecked" ; }
    virtual void setValue(const QString &value) { check->setChecked( !value.isEmpty() ); }
};



#endif