summaryrefslogtreecommitdiffstats
path: root/part/kxespecprocinstrdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'part/kxespecprocinstrdialog.cpp')
-rw-r--r--part/kxespecprocinstrdialog.cpp135
1 files changed, 135 insertions, 0 deletions
diff --git a/part/kxespecprocinstrdialog.cpp b/part/kxespecprocinstrdialog.cpp
new file mode 100644
index 0000000..09f1224
--- /dev/null
+++ b/part/kxespecprocinstrdialog.cpp
@@ -0,0 +1,135 @@
+/***************************************************************************
+ kxespecprocinstrdialog.cpp - description
+ --------------------------
+ begin : Ne ?ec 6 2003
+ copyright : (C) 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 "kxespecprocinstrdialog.h"
+
+#include "kxmleditorfactory.h"
+#include "kxeconfiguration.h"
+#include "kxenewfilesettings.h"
+
+#include <qstring.h>
+#include <qcombobox.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qregexp.h>
+#include <qframe.h>
+#include <qcheckbox.h>
+
+#include <kdebug.h>
+
+KXESpecProcInstrDialog::KXESpecProcInstrDialog(QWidget *parent, const char *name )
+ : KXESpecProcInstrDialogBase(parent,name)
+{
+ m_pComboBoxEncoding->insertStringList( KXMLEditorFactory::configuration()->newfile()->encodings() );
+
+ m_pLineEditVersion->setText("1.0");
+
+ m_pHLine->hide();
+ m_pDontShowAgain->hide();
+
+ // signals and slots connections
+ connect( m_pBtnOK, SIGNAL( clicked() ), this, SLOT( slotAccept() ) );
+}
+
+KXESpecProcInstrDialog::~KXESpecProcInstrDialog()
+{
+}
+
+void KXESpecProcInstrDialog::fillDialog( const QString strData )
+{
+ QString strVersion;
+ QString strEncoding;
+
+ int iStart, iEnd;
+
+ // find version info
+ if((iStart = strData.find("version", 0)) >= 0)
+ {
+ // info about encoding found;
+ iStart += 7; // skip version
+
+ // search " or ' after encoding
+ if((iStart = strData.find(QRegExp("[\"']"), iStart)) > 0)
+ {
+ QChar ch = strData[iStart];
+ iStart++; // skip ch
+ if((iEnd = strData.find(ch, iStart)) > 0)
+ strVersion = strData.mid(iStart, iEnd - iStart);
+ }
+ }
+ else
+ strVersion = "1.0";
+
+ // find encoding info
+ if((iStart = strData.find("encoding", 0)) >= 0)
+ {
+ // info about encoding found;
+ iStart += 8; // skip encoding
+
+ // search " or ' after encoding
+ if((iStart = strData.find(QRegExp("[\"']"), iStart)) > 0)
+ {
+ QChar ch = strData[iStart];
+ iStart++; // skip ch
+ if((iEnd = strData.find(ch, iStart)) > 0)
+ strEncoding = strData.mid(iStart, iEnd - iStart);
+ }
+ }
+ else
+ strEncoding = "UTF-8";
+
+
+ m_pLineEditVersion->setText(strVersion);
+ m_pComboBoxEncoding->setCurrentText(strEncoding);
+}
+
+int KXESpecProcInstrDialog::exec()
+{
+ m_pBtnOK->setDefault(true);
+
+ return KXESpecProcInstrDialogBase::exec();
+}
+
+
+/** Called when user press OK button */
+void KXESpecProcInstrDialog::slotAccept()
+{
+ accept();
+}
+
+
+/*!
+ Initializes content of dialog controls with specified values.
+ @param version XML file version
+ @param encoding encoding type for the XML file
+ */
+void KXESpecProcInstrDialog::fillDialog(const QString& version, const QString& encoding)
+{
+
+ m_pLineEditVersion->setText(version);
+ m_pComboBoxEncoding->setCurrentText(encoding);
+}
+
+
+/*!
+ Returns content of the dialog as an string of format: '"version = '...' encoding = '...' ".
+ */
+QString KXESpecProcInstrDialog::getData()
+{
+ return QString("version = '")+m_pLineEditVersion->text()+
+ "' encoding = '"+m_pComboBoxEncoding->currentText()+"' ";
+}