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
|
/***************************************************************************
kxechardatadialog.cpp - description
---------------------
begin : Don Apr 25 2002
copyright : (C) 2002, 2003 by The KXMLEditor Team
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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 "kxechardatadialog.h"
#include <tqlabel.h>
#include <tqcombobox.h>
#include <tqpushbutton.h>
#include <tqtextedit.h>
#include <kdebug.h>
#include <tdelocale.h>
KXECharDataDialog::KXECharDataDialog( TQWidget * pParent, const char * pszName, bool fModal, WFlags fl )
: KXECharDataDialogBase( pParent, pszName, fModal, fl )
{
connect( m_pEditData, SIGNAL(textChanged()), this, SLOT(slotDataChanged()) );
}
void KXECharDataDialog::clearDialog()
{
m_pEditData->clear();
}
int KXECharDataDialog::exec( bool bEditExisting )
{
if(bEditExisting)
{
m_pComboInsert->hide();
m_pComboInsert->setDisabled(true);
m_pLblInsert->hide();
m_pLblInsert->setDisabled(true);
// m_pComboType->setDisabled(true);
m_pEditData->setText( m_strContents );
// m_pComboType->setCurrentItem(m_eCharDataKind);
}
else
{
// m_pComboType->setEnabled(true);
clearDialog();
}
int iReturn = exec();
if ( iReturn == Accepted )
{
m_strContents = m_pEditData->text();
m_bAtTop = ( m_pComboInsert->currentItem() == 0 );
// m_eCharDataKind = (CharDataKind) m_pComboType->currentItem();
}
return iReturn;
}
int KXECharDataDialog::exec()
{
if ( m_pEditData->text().isEmpty() )
m_pBtnOK->setEnabled(false);
else
m_pBtnOK->setEnabled(true);
m_pEditData->setFocus();
m_pBtnOK->setDefault(true);
return KXECharDataDialogBase::exec();
}
void KXECharDataDialog::slotDataChanged()
{
TQString strMessage = checkContents(m_pEditData->text());
m_pTextLabelMessage->setText(strMessage);
if ( m_pEditData->text().isEmpty() || (strMessage.length() > 0))
m_pBtnOK->setEnabled(false);
else
m_pBtnOK->setEnabled(true);
}
// Check, if XML chardata contents is OK
TQString KXECharDataDialog::checkContents(const TQString strData)
{
if(strData.length() == 0)
return "";
// Forbidden characters
/*TQString strForbiddenChars("<>");
for(unsigned int i = 0; i < strForbiddenChars.length(); i++)
{
TQChar ch = strForbiddenChars[i];
if(strData.find(ch) >= 0)
return i18n("Contents cannot contain character: %1 !").arg(ch);
}
L.V. Removed this check, bacause TQDomCharacterData.setData() escapec special
charactesr and data() unescapes it back to original string
*/
return "";
}
#include "kxechardatadialog.moc"
|