lib

KoCommentDia.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2002 Montel Laurent <lmontel@mandrakesoft.com>
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
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <tdelocale.h>
21#include <tqvbox.h>
22#include <tqmultilineedit.h>
23#include "KoCommentDia.h"
24#include <tqlayout.h>
25#include <tqpushbutton.h>
26#include <tdeglobal.h>
27#include <tqdatetime.h>
28#include <tqlabel.h>
29#include <kdebug.h>
30
31KoCommentDia::KoCommentDia( TQWidget *parent, const TQString &_note, const TQString & _authorName, const TQString &_createNote, const char *name )
32 : KDialogBase( parent, name , true, "", Ok|Cancel, Ok, true )
33{
34 setCaption( i18n("Edit Comment") );
35 authorName = _authorName;
36 TQVBox *page = makeVBoxMainWidget();
37 kdDebug()<<"_createNote :"<<_createNote<<endl;
38 if ( !_createNote.isEmpty() )
39 new TQLabel( _createNote, page );
40
41 m_multiLine = new TQMultiLineEdit( page );
42 m_multiLine->setText( _note );
43 m_multiLine->setFocus();
44 pbAddAuthorName = new TQPushButton(i18n("Add Author Name"),page);
45 if ( authorName.isEmpty() )
46 pbAddAuthorName->setEnabled( false );
47 else
48 connect (pbAddAuthorName, TQ_SIGNAL(clicked ()), this , TQ_SLOT(slotAddAuthorName()));
49 connect ( m_multiLine , TQ_SIGNAL( textChanged()), this, TQ_SLOT( slotTextChanged( )));
50 slotTextChanged( );
51
52 resize( 300,100 );
53}
54
55void KoCommentDia::slotTextChanged( )
56{
57 enableButtonOK( !m_multiLine->text().isEmpty() );
58}
59
60TQString KoCommentDia::commentText()
61{
62 return m_multiLine->text();
63}
64
65void KoCommentDia::slotAddAuthorName()
66{
67 TQString date = TDEGlobal::locale()->formatDate( TQDate::currentDate() );
68 TQString time = TDEGlobal::locale()->formatTime( TQTime::currentTime() );
69 TQString result = TQString("--------%1 ,%2, %3------\n").arg(authorName).arg(date).arg(time);
70 m_multiLine->insertLine( result, m_multiLine->numLines() );
71}
72
73#include "KoCommentDia.moc"
void enableButtonOK(bool state)
const char * name(StdAction id)