kspread

kspread_dlg_comment.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2003 Norbert Andres <nandres@web.de>
3 (C) 2002 Ariya Hidayat <ariya@kde.org>
4 (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
5 (C) 1999-2002 Laurent Montel <montel@kde.org>
6 (C) 1998-1999 Torben Weis <weis@kde.org>
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
17
18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#include <tqmultilineedit.h>
25#include <tqpushbutton.h>
26#include <tqlayout.h>
27
28#include <tdelocale.h>
29#include <kbuttonbox.h>
30
31#include "kspread_canvas.h"
32#include "kspread_doc.h"
33#include "selection.h"
34#include "kspread_sheet.h"
35#include "kspread_view.h"
36
37#include "kspread_dlg_comment.h"
38
39using namespace KSpread;
40
41CommentDialog::CommentDialog( View* parent, const char* name,const TQPoint &_marker)
42 : KDialogBase( parent, name,true,i18n("Cell Comment"),Ok|Cancel )
43{
44 m_pView = parent;
45 marker= _marker;
46 TQWidget *page = new TQWidget( this );
47 setMainWidget(page);
48 TQVBoxLayout *lay1 = new TQVBoxLayout( page, 0, spacingHint() );
49
50 multiLine = new TQMultiLineEdit( page );
51 lay1->addWidget(multiLine);
52
53 multiLine->setFocus();
54
55
56 Cell *cell = m_pView->activeSheet()->cellAt( m_pView->canvasWidget()->markerColumn(), m_pView->canvasWidget()->markerRow() );
57 if(!cell->format()->comment(marker.x(),marker.y()).isEmpty())
58 multiLine->setText(cell->format()->comment(marker.x(),marker.y()));
59
60 connect( this, TQ_SIGNAL( okClicked() ), this, TQ_SLOT( slotOk() ) );
61 connect(multiLine, TQ_SIGNAL(textChanged ()),this, TQ_SLOT(slotTextChanged()));
62
63 slotTextChanged();
64
65 resize( 400, height() );
66}
67
68void CommentDialog::slotTextChanged()
69{
70 enableButtonOK( !multiLine->text().isEmpty());
71}
72
73void CommentDialog::slotOk()
74{
75 m_pView->doc()->emitBeginOperation( false );
76 m_pView->activeSheet()->setSelectionComment( m_pView->selectionInfo(),
77 multiLine->text().stripWhiteSpace() );
78 m_pView->slotUpdateView( m_pView->activeSheet(), *m_pView->selectionInfo() );
79 // m_pView->doc()->emitEndOperation();
80 accept();
81}
82
83#include "kspread_dlg_comment.moc"
For every cell in the spread sheet there is a Cell object.
The View class displays a KSpread document.
The KSpread namespace.
Definition commands.h:39