summaryrefslogtreecommitdiffstats
path: root/part/commands_file.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/commands_file.cpp
downloadkxmleditor-d62c8c002c51fb7c36487839eeeb4ac89f044dee.tar.gz
kxmleditor-d62c8c002c51fb7c36487839eeeb4ac89f044dee.zip
Initial import of kxmleditor 1.1.4
Diffstat (limited to 'part/commands_file.cpp')
-rw-r--r--part/commands_file.cpp158
1 files changed, 158 insertions, 0 deletions
diff --git a/part/commands_file.cpp b/part/commands_file.cpp
new file mode 100644
index 0000000..f30ff2d
--- /dev/null
+++ b/part/commands_file.cpp
@@ -0,0 +1,158 @@
+/***************************************************************************
+ commands_file - description
+ -------------------
+ begin : Wed Nov 26 2003
+ copyright : (C) 2003 by The KXMLEditor Team
+ email : a_charytoniuk@user.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 "commands_file.h"
+#include <qstring.h>
+#include <kurl.h>
+#include <kmessagebox.h>
+//////////////////////////////////////////////////////////////////////////////////////////
+/////////// Setting Version & Encoding //////////
+//////////////////////////////////////////////////////////////////////////////////////////
+
+KXEVersionEncodingCommand::KXEVersionEncodingCommand(KXEDocument* pDocument, const QString& oldData, const QString &newData)
+ : KXECommand(pDocument)
+{
+ m_strOldData = oldData;
+ m_strNewData = newData;
+}
+
+KXEVersionEncodingCommand::~KXEVersionEncodingCommand()
+{
+}
+
+void KXEVersionEncodingCommand::execute()
+{
+ m_pDocument->setSpecProcInstr("xml",m_strNewData);
+}
+
+void KXEVersionEncodingCommand::unexecute()
+{
+ m_pDocument->setSpecProcInstr("xml",m_strOldData);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+/////////// Attaching stylesheet //////////
+//////////////////////////////////////////////////////////////////////////////////////////
+
+KXEStylesheetAttachCommand::KXEStylesheetAttachCommand(KXEDocument* pDocument,const QString& prevStylesheet,const QString& newStylesheet)
+ : KXECommand(pDocument)
+{
+ m_strNewStylesheet = newStylesheet;
+ m_strPrevStylesheet = prevStylesheet;
+}
+
+KXEStylesheetAttachCommand::~KXEStylesheetAttachCommand()
+{
+}
+
+void KXEStylesheetAttachCommand::execute()
+{
+ m_pDocument->detachStylesheet();
+ m_pDocument->attachStylesheet(KURL(m_strNewStylesheet));
+}
+
+void KXEStylesheetAttachCommand::unexecute()
+{
+ m_pDocument->detachStylesheet();
+ if(!m_strPrevStylesheet.isEmpty())
+ m_pDocument->attachStylesheet(KURL(m_strPrevStylesheet));
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+/////////// Detaching Stylesheet //////////
+//////////////////////////////////////////////////////////////////////////////////////////
+
+KXEStylesheetDetachCommand::KXEStylesheetDetachCommand(KXEDocument* pDocument,const QString& prevStylesheet)
+ : KXECommand(pDocument)
+{
+ m_strPrevStylesheet = prevStylesheet;
+}
+
+KXEStylesheetDetachCommand::~KXEStylesheetDetachCommand()
+{
+}
+
+void KXEStylesheetDetachCommand::execute()
+{
+ m_pDocument->detachStylesheet();
+}
+
+void KXEStylesheetDetachCommand::unexecute()
+{
+ if (!m_strPrevStylesheet.isEmpty())
+ m_pDocument->attachStylesheet(KURL(m_strPrevStylesheet));
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+/////////// Attaching Schema //////////
+//////////////////////////////////////////////////////////////////////////////////////////
+
+KXESchemaAttachCommand::KXESchemaAttachCommand(KXEDocument *pDocument,const QString& newSchema)
+ : KXECommand(pDocument)
+{
+ m_pDocument = pDocument;
+ m_strNewSchema = newSchema;
+ m_strPrevSchema = "";
+}
+KXESchemaAttachCommand::KXESchemaAttachCommand(KXEDocument *pDocument,const QString& newSchema,const QString& prevSchema)
+ : KXECommand(pDocument)
+{
+ m_strNewSchema = newSchema;
+ m_strPrevSchema = prevSchema;
+}
+
+KXESchemaAttachCommand::~KXESchemaAttachCommand()
+{
+}
+
+void KXESchemaAttachCommand::execute()
+{
+ m_pDocument->detachSchema(); // old schema is removed
+ m_pDocument->attachSchema(KURL(m_strNewSchema)); // new schema is applited
+}
+
+void KXESchemaAttachCommand::unexecute()
+{
+ m_pDocument->detachSchema(); // new schema is removed
+ if (!m_strPrevSchema.isEmpty())
+ m_pDocument->attachSchema(KURL(m_strPrevSchema)); // old schema is applied
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+/////////// Detaching schema //////////
+//////////////////////////////////////////////////////////////////////////////////////////
+
+KXESchemaDetachCommand::KXESchemaDetachCommand(KXEDocument* pDocument, const QString& schema)
+ : KXECommand(pDocument)
+{
+ m_schema = schema;
+}
+
+KXESchemaDetachCommand::~KXESchemaDetachCommand()
+{
+}
+
+void KXESchemaDetachCommand::execute()
+{
+ m_pDocument->detachSchema();
+}
+
+void KXESchemaDetachCommand::unexecute()
+{
+ if (!m_schema.isEmpty())
+ m_pDocument->attachSchema(KURL(m_schema));
+}
+