summaryrefslogtreecommitdiffstats
path: root/kexi/plugins/macros/kexipart/keximacrotextview.cpp
blob: deec96331c5b0d3b572ca687b0b4f2e4100dcde9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* This file is part of the KDE project
   Copyright (C) 2006 Sebastian Sauer <mail@dipe.org>

   This library 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 library 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 library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#include "keximacrotextview.h"

#include <ktextedit.h>
#include <kdebug.h>

#include <kexidialogbase.h>
#include <kexidb/connection.h>

#include "../lib/macro.h"
#include "../lib/xmlhandler.h"

/**
* \internal d-pointer class to be more flexible on future extension of the
* functionality without to much risk to break the binary compatibility.
*/
class KexiMacroTextView::Private
{
	public:

		/**
		* The Editor used to display and edit the XML text.
		*/
		KTextEdit* editor;

};

KexiMacroTextView::KexiMacroTextView(KexiMainWindow *mainwin, TQWidget *tqparent, ::KoMacro::Macro* const macro)
	: KexiMacroView(mainwin, tqparent, macro, "KexiMacroTextView")
	, d( new Private() )
{
	TQHBoxLayout* tqlayout = new TQHBoxLayout(this);
	d->editor = new KTextEdit(this);
	d->editor->setTextFormat(TQt::PlainText);
	d->editor->setWordWrap(TQTextEdit::NoWrap);
	tqlayout->addWidget(d->editor);

	connect(d->editor, TQT_SIGNAL(textChanged()), this, TQT_SLOT(editorChanged()));
}

KexiMacroTextView::~KexiMacroTextView()
{
	delete d;
}

void KexiMacroTextView::editorChanged()
{
	setDirty(true);
}

bool KexiMacroTextView::loadData()
{
	TQString data;
	if(! loadDataBlock(data)) {
		kexipluginsdbg << "KexiMacroTextView::loadData(): no DataBlock" << endl;
		return false;
	}

	kdDebug() << TQString("KexiMacroTextView::loadData()\n%1").tqarg(data) << endl;
	//d->editor->blockSignals(true);
	d->editor->setText(data);
	//d->editor->blockSignals(false);
	setDirty(false);
	return true;
}

tristate KexiMacroTextView::storeData(bool /*dontAsk*/)
{
	kexipluginsdbg << TQString("KexiMacroTextView::storeData() %1 [%2]\n%3").tqarg(tqparentDialog()->partItem()->name()).tqarg(tqparentDialog()->id()).tqarg(d->editor->text()) << endl;
	return storeDataBlock( d->editor->text() );
}

#include "keximacrotextview.moc"