From 8362bf63dea22bbf6736609b0f49c152f975eb63 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 20 Jan 2010 01:29:50 +0000 Subject: Added old abandoned KDE3 version of koffice git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- .../scripting/kexiscripting/kexiscripteditor.cpp | 104 +++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 kexi/plugins/scripting/kexiscripting/kexiscripteditor.cpp (limited to 'kexi/plugins/scripting/kexiscripting/kexiscripteditor.cpp') diff --git a/kexi/plugins/scripting/kexiscripting/kexiscripteditor.cpp b/kexi/plugins/scripting/kexiscripting/kexiscripteditor.cpp new file mode 100644 index 000000000..a638af36b --- /dev/null +++ b/kexi/plugins/scripting/kexiscripting/kexiscripteditor.cpp @@ -0,0 +1,104 @@ +/* This file is part of the KDE project + Copyright (C) 2003 Lucijan Busch + Copyright (C) 2004-2005 Jaroslaw Staniek + Copyright (C) 2005 Cedric Pasteur + Copyright (C) 2005 Sebastian Sauer + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include "kexiscripteditor.h" + +#include + +#include +//#include +//#include +//#include +//#include +#include + +#include + +/// \internal d-pointer class +class KexiScriptEditor::Private +{ + public: + Kross::Api::ScriptAction* scriptaction; + Private() : scriptaction(0) {} +}; + +KexiScriptEditor::KexiScriptEditor(KexiMainWindow *mainWin, QWidget *parent, const char *name) + : KexiEditor(mainWin, parent, name) + , d( new Private() ) +{ +} + +KexiScriptEditor::~KexiScriptEditor() +{ + delete d; +} + +bool KexiScriptEditor::isInitialized() const +{ + return d->scriptaction != 0; +} + +void KexiScriptEditor::initialize(Kross::Api::ScriptAction* scriptaction) +{ + d->scriptaction = scriptaction; + Q_ASSERT(d->scriptaction); + + disconnect(this, SIGNAL(textChanged()), this, SLOT(slotTextChanged())); + + QString code = d->scriptaction->getCode(); + if(code.isNull()) { + // If there is no code we just add some information. +///@todo remove after release + code = "# " + QStringList::split("\n", i18n( + "This note will appear for a user in the script's source code " + "as a comment. Keep every row not longer than 60 characters and use '\n.'", + + "This is Technology Preview (BETA) version of scripting\n" + "support in Kexi. The scripting API may change in details\n" + "in the next Kexi version.\n" + "For more information and documentation see\n%1" + ).arg("http://www.kexi-project.org/scripting/"), true).join("\n# ") + "\n"; + } + KexiEditor::setText(code); + // We assume Kross and the HighlightingInterface are using same + // names for the support languages... + setHighlightMode(d->scriptaction->getInterpreterName()); + + clearUndoRedo(); + KexiEditor::setDirty(false); + connect(this, SIGNAL(textChanged()), this, SLOT(slotTextChanged())); +} + +void KexiScriptEditor::slotTextChanged() +{ + KexiScriptEditor::setDirty(true); + if(d->scriptaction) + d->scriptaction->setCode( KexiEditor::text() ); +} + +void KexiScriptEditor::setLineNo(long lineno) +{ + setCursorPosition(lineno, 0); +} + +#include "kexiscripteditor.moc" + -- cgit v1.2.3