kspread Library API Documentation

kspread_dlg_comment.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Norbert Andres <nandres@web.de>
00003              (C) 2002 Ariya Hidayat <ariya@kde.org>
00004              (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
00005              (C) 1999-2002 Laurent Montel <montel@kde.org> 
00006              (C) 1998-1999 Torben Weis <weis@kde.org>
00007 
00008    This library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Library General Public
00010    License as published by the Free Software Foundation; either
00011    version 2 of the License, or (at your option) any later version.
00012 
00013    This library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Library General Public License for more details.
00017 
00018    You should have received a copy of the GNU Library General Public License
00019    along with this library; see the file COPYING.LIB.  If not, write to
00020    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00021    Boston, MA 02111-1307, USA.
00022 */
00023 
00024 
00025 #include "kspread_dlg_comment.h"
00026 #include "kspread_canvas.h"
00027 #include "kspread_doc.h"
00028 #include "kspread_selection.h"
00029 #include "kspread_sheet.h"
00030 #include "kspread_view.h"
00031 #include <klocale.h>
00032 #include <qlayout.h>
00033 #include <kbuttonbox.h>
00034 #include <qmultilineedit.h>
00035 #include <qpushbutton.h>
00036 
00037 KSpreadComment::KSpreadComment( KSpreadView* parent, const char* name,const QPoint &_marker)
00038     : KDialogBase( parent, name,TRUE,i18n("Cell Comment"),Ok|Cancel )
00039 {
00040     m_pView = parent;
00041     marker= _marker;
00042     QWidget *page = new QWidget( this );
00043     setMainWidget(page);
00044     QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
00045 
00046     multiLine = new QMultiLineEdit( page );
00047     lay1->addWidget(multiLine);
00048 
00049     multiLine->setFocus();
00050 
00051 
00052     KSpreadCell *cell = m_pView->activeSheet()->cellAt( m_pView->canvasWidget()->markerColumn(), m_pView->canvasWidget()->markerRow() );
00053     if(!cell->comment(marker.x(),marker.y()).isEmpty())
00054         multiLine->setText(cell->comment(marker.x(),marker.y()));
00055 
00056     connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
00057     connect(multiLine, SIGNAL(textChanged ()),this, SLOT(slotTextChanged()));
00058 
00059     slotTextChanged();
00060 
00061     resize( 400, height() );
00062 }
00063 
00064 void KSpreadComment::slotTextChanged()
00065 {
00066     enableButtonOK( !multiLine->text().isEmpty());
00067 }
00068 
00069 void KSpreadComment::slotOk()
00070 {
00071     m_pView->doc()->emitBeginOperation( false );
00072     m_pView->activeSheet()->setSelectionComment( m_pView->selectionInfo(),
00073                                                  multiLine->text().stripWhiteSpace() );
00074     m_pView->slotUpdateView( m_pView->activeSheet(), m_pView->selectionInfo()->selection() );
00075     // m_pView->doc()->emitEndOperation();
00076     accept();
00077 }
00078 
00079 #include "kspread_dlg_comment.moc"
KDE Logo
This file is part of the documentation for kspread Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:42:54 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003