~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to lib/kotext/KoCustomVariablesDia.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
 
3
 
 
4
   This library is free software; you can redistribute it and/or
 
5
   modify it under the terms of the GNU Library General Public
 
6
   License as published by the Free Software Foundation; either
 
7
   version 2 of the License, or (at your option) any later version.
 
8
 
 
9
   This library is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
   Library General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU Library General Public License
 
15
   along with this library; see the file COPYING.LIB.  If not, write to
 
16
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
 * Boston, MA 02110-1301, USA.
 
18
*/
 
19
 
 
20
#ifndef KOVARIABLEDLGS_H
 
21
#define KOVARIABLEDLGS_H
 
22
 
 
23
#include "KoVariable.h"
 
24
 
 
25
#include <kdialogbase.h>
 
26
#include <qptrlist.h>
 
27
#include <qstring.h>
 
28
#include <klistview.h>
 
29
#include <koffice_export.h>
 
30
class QComboBox;
 
31
class QVBox;
 
32
class QResizeEvent;
 
33
class KLineEdit;
 
34
class QCloseEvent;
 
35
 
 
36
/******************************************************************
 
37
 *
 
38
 * Class: KoVariableNameDia
 
39
 *
 
40
 ******************************************************************/
 
41
 
 
42
class KoVariableNameDia : public KDialogBase
 
43
{
 
44
    Q_OBJECT
 
45
 
 
46
public:
 
47
    // For KWMailMergeVariableInsertDia
 
48
    KoVariableNameDia( QWidget *parent );
 
49
    // For kwview
 
50
    KoVariableNameDia( QWidget *parent, const QPtrList<KoVariable> &vars );
 
51
    QString getName() const;
 
52
 
 
53
protected slots:
 
54
    void textChanged ( const QString &_text );
 
55
protected:
 
56
    void init();
 
57
 
 
58
    QComboBox *names;
 
59
    QVBox *back;
 
60
};
 
61
 
 
62
/**
 
63
 * Class: KoCustomVariablesListItem
 
64
 * Used by KoCustomVariablesDia
 
65
 * Represents an item in the listview, holding a lineedit to edit the value of the variable.
 
66
 */
 
67
class KoCustomVariablesListItem : public QListViewItem
 
68
{
 
69
public:
 
70
    KoCustomVariablesListItem( QListView *parent );
 
71
 
 
72
    void setVariable( KoCustomVariable *v );
 
73
    KoCustomVariable *getVariable() const;
 
74
 
 
75
    virtual void setup();
 
76
    virtual int width ( const QFontMetrics & fm, const QListView * lv, int c ) const;
 
77
    void update();
 
78
 
 
79
    // Gets the value from the lineedit and sets it into the variable
 
80
    void applyValue();
 
81
 
 
82
protected:
 
83
    KoCustomVariable *var;
 
84
    KLineEdit *editWidget;
 
85
};
 
86
 
 
87
/**
 
88
 * Class: KoCustomVariablesList
 
89
 * The listview.
 
90
 * Used by KoCustomVariablesDia
 
91
 */
 
92
class KoCustomVariablesList : public KListView
 
93
{
 
94
    Q_OBJECT
 
95
 
 
96
public:
 
97
    KoCustomVariablesList( QWidget *parent );
 
98
 
 
99
    void setValues();
 
100
    void updateItems();
 
101
 
 
102
protected slots:
 
103
    void columnSizeChange( int c, int os, int ns );
 
104
    void sectionClicked( int c );
 
105
 
 
106
private:
 
107
    class Private;
 
108
    Private* d; // currently unused
 
109
};
 
110
 
 
111
/**
 
112
 * Class: KoCustomVariablesDia
 
113
 * This dialog allows to set the value of the custom variables.
 
114
 */
 
115
class KOTEXT_EXPORT KoCustomVariablesDia : public KDialogBase
 
116
{
 
117
    Q_OBJECT
 
118
 
 
119
public:
 
120
    KoCustomVariablesDia( QWidget *parent, const QPtrList<KoVariable> &variables );
 
121
protected slots:
 
122
    void slotOk();
 
123
 
 
124
protected:
 
125
    QVBox *back;
 
126
    KoCustomVariablesList *list;
 
127
 
 
128
};
 
129
 
 
130
/**
 
131
 * Class: KoCustomVarDialog
 
132
 * This dialog allows to add a new custom variable or
 
133
 * to edit an existing one.
 
134
 */
 
135
class KOTEXT_EXPORT KoCustomVarDialog : public KDialogBase
 
136
{
 
137
    Q_OBJECT
 
138
 
 
139
public:
 
140
    /**
 
141
     * Add new variable
 
142
     */
 
143
    KoCustomVarDialog( QWidget *parent );
 
144
    /**
 
145
     * Edit existing variable @p var
 
146
     */
 
147
    KoCustomVarDialog( QWidget *parent, KoCustomVariable *var );
 
148
 
 
149
    virtual QString name();
 
150
    virtual QString value();
 
151
 
 
152
protected slots:
 
153
    void slotAddOk();
 
154
    void slotEditOk();
 
155
    void slotTextChanged(const QString&);
 
156
 
 
157
protected:
 
158
    QVBox *back;
 
159
    KLineEdit *m_name;
 
160
    KLineEdit *m_value;
 
161
 
 
162
private:
 
163
    void init();
 
164
    KoCustomVariable *m_var;
 
165
};
 
166
 
 
167
#endif