keximacrotextview.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2006 Sebastian Sauer <mail@dipe.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12 You should have received a copy of the GNU Library General Public License
13 along with this library; see the file COPYING.LIB. If not, write to
14 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
15 Boston, MA 02110-1301, USA.
16*/
17
18#include "keximacrotextview.h"
19
20#include <ktextedit.h>
21#include <kdebug.h>
22
23#include <kexidialogbase.h>
24#include <kexidb/connection.h>
25
26#include "../lib/macro.h"
27#include "../lib/xmlhandler.h"
28
33class KexiMacroTextView::Private
34{
35 public:
36
40 KTextEdit* editor;
41
42};
43
45 : KexiMacroView(mainwin, parent, macro, "KexiMacroTextView")
46 , d( new Private() )
47{
48 TQHBoxLayout* layout = new TQHBoxLayout(this);
49 d->editor = new KTextEdit(this);
50 d->editor->setTextFormat(TQt::PlainText);
51 d->editor->setWordWrap(TQTextEdit::NoWrap);
52 layout->addWidget(d->editor);
53
54 connect(d->editor, TQ_SIGNAL(textChanged()), this, TQ_SLOT(editorChanged()));
55}
56
61
62void KexiMacroTextView::editorChanged()
63{
64 setDirty(true);
65}
66
68{
69 TQString data;
70 if(! loadDataBlock(data)) {
71 kexipluginsdbg << "KexiMacroTextView::loadData(): no DataBlock" << endl;
72 return false;
73 }
74
75 kdDebug() << TQString("KexiMacroTextView::loadData()\n%1").arg(data) << endl;
76 //d->editor->blockSignals(true);
77 d->editor->setText(data);
78 //d->editor->blockSignals(false);
79 setDirty(false);
80 return true;
81}
82
84{
85 kexipluginsdbg << TQString("KexiMacroTextView::storeData() %1 [%2]\n%3").arg(parentDialog()->partItem()->name()).arg(parentDialog()->id()).arg(d->editor->text()) << endl;
86 return storeDataBlock( d->editor->text() );
87}
88
89#include "keximacrotextview.moc"
90
virtual ~KexiMacroTextView()
Destructor.
KexiMacroTextView(KexiMainWindow *mainwin, TQWidget *parent, ::KoMacro::Macro *const macro)
Constructor.
virtual tristate storeData(bool dontAsk=false)
Try to store the modified data in the already opened and currently used KexiDB::SchemaData instance.
virtual bool loadData()
Load the data and display it in the editor.
The KexiMacroView implements KexiViewBase to provide a base KexiView instance for Macros.
Kexi's main window interface This interface is implemented by KexiMainWindowImpl class.
bool storeDataBlock(const TQString &dataString, const TQString &dataID=TQString())
bool loadDataBlock(TQString &dataString, const TQString &dataID=TQString(), bool canBeEmpty=false)
KexiDialogBase * parentDialog() const
The Macro class implements all the action-handling.
Definition macro.h:45
3-state logical type with three values: true, false and cancelled and convenient operators.
Definition tristate.h:100