summaryrefslogtreecommitdiffstats
path: root/part/kxechardatadialog.cpp
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2016-03-26 13:50:43 +0100
committerSlávek Banko <slavek.banko@axis.cz>2016-03-26 13:50:43 +0100
commitd62c8c002c51fb7c36487839eeeb4ac89f044dee (patch)
treebb4d1f5c631ab1f22a3018ba39e6a806035f80fd /part/kxechardatadialog.cpp
downloadkxmleditor-d62c8c002c51fb7c36487839eeeb4ac89f044dee.tar.gz
kxmleditor-d62c8c002c51fb7c36487839eeeb4ac89f044dee.zip
Initial import of kxmleditor 1.1.4
Diffstat (limited to 'part/kxechardatadialog.cpp')
-rw-r--r--part/kxechardatadialog.cpp119
1 files changed, 119 insertions, 0 deletions
diff --git a/part/kxechardatadialog.cpp b/part/kxechardatadialog.cpp
new file mode 100644
index 0000000..fb74ad4
--- /dev/null
+++ b/part/kxechardatadialog.cpp
@@ -0,0 +1,119 @@
+/***************************************************************************
+ kxechardatadialog.cpp - description
+ ---------------------
+ begin : Don Apr 25 2002
+ copyright : (C) 2002, 2003 by The KXMLEditor Team
+ email : lvanek@users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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 <qlabel.h>
+#include <qcombobox.h>
+#include <qpushbutton.h>
+#include <qtextedit.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+
+KXECharDataDialog::KXECharDataDialog( QWidget * 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()
+{
+ QString 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
+QString KXECharDataDialog::checkContents(const QString strData)
+{
+ if(strData.length() == 0)
+ return "";
+
+ // Forbidden characters
+ /*QString strForbiddenChars("<>");
+ for(unsigned int i = 0; i < strForbiddenChars.length(); i++)
+ {
+ QChar ch = strForbiddenChars[i];
+
+ if(strData.find(ch) >= 0)
+ return i18n("Contents cannot contain character: %1 !").arg(ch);
+ }
+
+ L.V. Removed this check, bacause QDomCharacterData.setData() escapec special
+ charactesr and data() unescapes it back to original string
+
+ */
+
+ return "";
+}
+
+