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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/* This file is part of the KDE project
Copyright (C) 2002 Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
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 <tqlabel.h>
#include <tqlayout.h>
#include <tqstringlist.h>
#include <tqtextedit.h>
#include <tqtooltip.h>
#include <tqvariant.h>
#include <tqwhatsthis.h>
#include <tdeapplication.h>
#include <tdemessagebox.h>
#include <tdelocale.h>
#include <kstdguiitem.h>
#include <kpushbutton.h>
#include "formulastring.h"
#include "kformula_view.h"
FormulaString::FormulaString( KFormulaPartView* parent, const char* name, bool modal, WFlags fl )
: TQDialog( parent, name, modal, fl ), view( parent )
{
if ( !name )
setName( "FormulaString" );
resize( 511, 282 );
setCaption( i18n( "Formula String" ) );
setSizeGripEnabled( TRUE );
TQVBoxLayout* FormulaStringLayout = new TQVBoxLayout( this, 11, 6, "FormulaStringLayout");
textWidget = new TQTextEdit( this, "textWidget" );
FormulaStringLayout->addWidget( textWidget );
TQHBoxLayout* Layout2 = new TQHBoxLayout( 0, 0, 6, "Layout2");
TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
Layout2->addItem( spacer );
position = new TQLabel( this, "position" );
position->setText( trUtf8( "1:1" ) );
Layout2->addWidget( position );
FormulaStringLayout->addLayout( Layout2 );
TQHBoxLayout* Layout1 = new TQHBoxLayout( 0, 0, 6, "Layout1");
buttonHelp = new KPushButton( KStdGuiItem::help(), this, "buttonHelp" );
buttonHelp->setAccel( 4144 );
buttonHelp->setAutoDefault( TRUE );
Layout1->addWidget( buttonHelp );
spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
Layout1->addItem( spacer );
buttonOk = new KPushButton( KStdGuiItem::ok(), this, "buttonOk" );
buttonOk->setAccel( 0 );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
Layout1->addWidget( buttonOk );
buttonCancel = new KPushButton( KStdGuiItem::cancel(), this, "buttonCancel" );
buttonCancel->setAccel( 0 );
buttonCancel->setAutoDefault( TRUE );
Layout1->addWidget( buttonCancel );
FormulaStringLayout->addLayout( Layout1 );
// signals and slots connections
connect( buttonOk, TQT_SIGNAL( clicked() ), this, TQT_SLOT( accept() ) );
connect( buttonCancel, TQT_SIGNAL( clicked() ), this, TQT_SLOT( reject() ) );
connect( buttonHelp, TQT_SIGNAL(clicked() ), this, TQT_SLOT( helpButtonClicked() ) );
connect( textWidget, TQT_SIGNAL( cursorPositionChanged( int, int ) ),
this, TQT_SLOT( cursorPositionChanged( int, int ) ) );
}
/*
* Destroys the object and frees any allocated resources
*/
FormulaString::~FormulaString()
{
// no need to delete child widgets, TQt does it all for us
}
void FormulaString::accept()
{
TQStringList errorList = view->readFormulaString( textWidget->text() );
if ( errorList.count() == 0 ) {
TQDialog::accept();
}
else {
KMessageBox::sorry( this, errorList.join( "\n" ), i18n( "Parser Error" ) );
}
}
void FormulaString::helpButtonClicked()
{
kapp->invokeHelp( "formula-strings", "kformula" );
}
void FormulaString::cursorPositionChanged( int para, int pos )
{
position->setText( TQString( "%1:%2" ).arg( para+1 ).arg( pos+1 ) );
}
#include "formulastring.moc"
|