kexi

keximacrotextview.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2006 Sebastian Sauer <mail@dipe.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012    You should have received a copy of the GNU Library General Public License
00013    along with this library; see the file COPYING.LIB.  If not, write to
00014    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00015    Boston, MA 02110-1301, USA.
00016 */
00017 
00018 #include "keximacrotextview.h"
00019 
00020 #include <ktextedit.h>
00021 #include <kdebug.h>
00022 
00023 #include <kexidialogbase.h>
00024 #include <kexidb/connection.h>
00025 
00026 #include "../lib/macro.h"
00027 #include "../lib/xmlhandler.h"
00028 
00033 class KexiMacroTextView::Private
00034 {
00035     public:
00036 
00040         KTextEdit* editor;
00041 
00042 };
00043 
00044 KexiMacroTextView::KexiMacroTextView(KexiMainWindow *mainwin, QWidget *parent, ::KoMacro::Macro* const macro)
00045     : KexiMacroView(mainwin, parent, macro, "KexiMacroTextView")
00046     , d( new Private() )
00047 {
00048     QHBoxLayout* layout = new QHBoxLayout(this);
00049     d->editor = new KTextEdit(this);
00050     d->editor->setTextFormat(Qt::PlainText);
00051     d->editor->setWordWrap(QTextEdit::NoWrap);
00052     layout->addWidget(d->editor);
00053 
00054     connect(d->editor, SIGNAL(textChanged()), this, SLOT(editorChanged()));
00055 }
00056 
00057 KexiMacroTextView::~KexiMacroTextView()
00058 {
00059     delete d;
00060 }
00061 
00062 void KexiMacroTextView::editorChanged()
00063 {
00064     setDirty(true);
00065 }
00066 
00067 bool KexiMacroTextView::loadData()
00068 {
00069     QString data;
00070     if(! loadDataBlock(data)) {
00071         kexipluginsdbg << "KexiMacroTextView::loadData(): no DataBlock" << endl;
00072         return false;
00073     }
00074 
00075     kdDebug() << QString("KexiMacroTextView::loadData()\n%1").arg(data) << endl;
00076     //d->editor->blockSignals(true);
00077     d->editor->setText(data);
00078     //d->editor->blockSignals(false);
00079     setDirty(false);
00080     return true;
00081 }
00082 
00083 tristate KexiMacroTextView::storeData(bool /*dontAsk*/)
00084 {
00085     kexipluginsdbg << QString("KexiMacroTextView::storeData() %1 [%2]\n%3").arg(parentDialog()->partItem()->name()).arg(parentDialog()->id()).arg(d->editor->text()) << endl;
00086     return storeDataBlock( d->editor->text() );
00087 }
00088 
00089 #include "keximacrotextview.moc"
00090 
KDE Home | KDE Accessibility Home | Description of Access Keys