kexi
kexiscripteditor.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "kexiscripteditor.h"
00024
00025 #include <kross/main/scriptaction.h>
00026
00027 #include <kdebug.h>
00028
00029
00030
00031
00032 #include <kpopupmenu.h>
00033
00034 #include <kexidialogbase.h>
00035
00037 class KexiScriptEditor::Private
00038 {
00039 public:
00040 Kross::Api::ScriptAction* scriptaction;
00041 };
00042
00043 KexiScriptEditor::KexiScriptEditor(KexiMainWindow *mainWin, QWidget *parent, const char *name)
00044 : KexiEditor(mainWin, parent, name)
00045 , d( new Private() )
00046 {
00047 }
00048
00049 KexiScriptEditor::~KexiScriptEditor()
00050 {
00051 delete d;
00052 }
00053
00054 void KexiScriptEditor::initialize(Kross::Api::ScriptAction* scriptaction)
00055 {
00056 d->scriptaction = scriptaction;
00057 Q_ASSERT(d->scriptaction);
00058
00059 disconnect(this, SIGNAL(textChanged()), this, SLOT(slotTextChanged()));
00060
00061 QString code = d->scriptaction->getCode();
00062 if(code.isNull()) {
00063
00065 code = "# " + QStringList::split("\n", i18n(
00066 "This note will appear for a user in the script's source code "
00067 "as a comment. Keep every row not longer than 60 characters and use '\n.'",
00068
00069 "This is Technology Preview (BETA) version of scripting\n"
00070 "support in Kexi. The scripting API may change in details\n"
00071 "in the next Kexi version.\n"
00072 "For more information and documentation see\n%1"
00073 ).arg("http://www.kexi-project.org/scripting/"), true).join("\n# ") + "\n";
00074 }
00075 KexiEditor::setText(code);
00076
00077
00078 setHighlightMode(d->scriptaction->getInterpreterName());
00079
00080 clearUndoRedo();
00081 KexiEditor::setDirty(false);
00082 connect(this, SIGNAL(textChanged()), this, SLOT(slotTextChanged()));
00083 }
00084
00085 void KexiScriptEditor::slotTextChanged()
00086 {
00087 KexiScriptEditor::setDirty(true);
00088 if(d->scriptaction)
00089 d->scriptaction->setCode( KexiEditor::text() );
00090 }
00091
00092 void KexiScriptEditor::setLineNo(long lineno)
00093 {
00094 setCursorPosition(lineno, 0);
00095 }
00096
00097 #include "kexiscripteditor.moc"
00098
|