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 Private() : scriptaction(0) {}
00042 };
00043
00044 KexiScriptEditor::KexiScriptEditor(KexiMainWindow *mainWin, QWidget *parent, const char *name)
00045 : KexiEditor(mainWin, parent, name)
00046 , d( new Private() )
00047 {
00048 }
00049
00050 KexiScriptEditor::~KexiScriptEditor()
00051 {
00052 delete d;
00053 }
00054
00055 bool KexiScriptEditor::isInitialized() const
00056 {
00057 return d->scriptaction != 0;
00058 }
00059
00060 void KexiScriptEditor::initialize(Kross::Api::ScriptAction* scriptaction)
00061 {
00062 d->scriptaction = scriptaction;
00063 Q_ASSERT(d->scriptaction);
00064
00065 disconnect(this, SIGNAL(textChanged()), this, SLOT(slotTextChanged()));
00066
00067 QString code = d->scriptaction->getCode();
00068 if(code.isNull()) {
00069
00071 code = "# " + QStringList::split("\n", i18n(
00072 "This note will appear for a user in the script's source code "
00073 "as a comment. Keep every row not longer than 60 characters and use '\n.'",
00074
00075 "This is Technology Preview (BETA) version of scripting\n"
00076 "support in Kexi. The scripting API may change in details\n"
00077 "in the next Kexi version.\n"
00078 "For more information and documentation see\n%1"
00079 ).arg("http://www.kexi-project.org/scripting/"), true).join("\n# ") + "\n";
00080 }
00081 KexiEditor::setText(code);
00082
00083
00084 setHighlightMode(d->scriptaction->getInterpreterName());
00085
00086 clearUndoRedo();
00087 KexiEditor::setDirty(false);
00088 connect(this, SIGNAL(textChanged()), this, SLOT(slotTextChanged()));
00089 }
00090
00091 void KexiScriptEditor::slotTextChanged()
00092 {
00093 KexiScriptEditor::setDirty(true);
00094 if(d->scriptaction)
00095 d->scriptaction->setCode( KexiEditor::text() );
00096 }
00097
00098 void KexiScriptEditor::setLineNo(long lineno)
00099 {
00100 setCursorPosition(lineno, 0);
00101 }
00102
00103 #include "kexiscripteditor.moc"
00104
|