From d62c8c002c51fb7c36487839eeeb4ac89f044dee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Sat, 26 Mar 2016 13:50:43 +0100 Subject: Initial import of kxmleditor 1.1.4 --- part/kxechardatadialog.cpp | 119 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 part/kxechardatadialog.cpp (limited to 'part/kxechardatadialog.cpp') 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 +#include +#include +#include + +#include +#include + +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 ""; +} + + -- cgit v1.2.1