kspread

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., 51 Franklin Street, Fifth Floor,
00021  * Boston, MA 02110-1301, USA.
00022 */
00023 
00024 #include <qmultilineedit.h>
00025 #include <qpushbutton.h>
00026 #include <qlayout.h>
00027 
00028 #include <klocale.h>
00029 #include <kbuttonbox.h>
00030 
00031 #include "kspread_canvas.h"
00032 #include "kspread_doc.h"
00033 #include "selection.h"
00034 #include "kspread_sheet.h"
00035 #include "kspread_view.h"
00036 
00037 #include "kspread_dlg_comment.h"
00038 
00039 using namespace KSpread;
00040 
00041 CommentDialog::CommentDialog( View* parent, const char* name,const QPoint &_marker)
00042     : KDialogBase( parent, name,TRUE,i18n("Cell Comment"),Ok|Cancel )
00043 {
00044     m_pView = parent;
00045     marker= _marker;
00046     QWidget *page = new QWidget( this );
00047     setMainWidget(page);
00048     QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
00049 
00050     multiLine = new QMultiLineEdit( page );
00051     lay1->addWidget(multiLine);
00052 
00053     multiLine->setFocus();
00054 
00055 
00056     Cell *cell = m_pView->activeSheet()->cellAt( m_pView->canvasWidget()->markerColumn(), m_pView->canvasWidget()->markerRow() );
00057     if(!cell->format()->comment(marker.x(),marker.y()).isEmpty())
00058       multiLine->setText(cell->format()->comment(marker.x(),marker.y()));
00059 
00060     connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
00061     connect(multiLine, SIGNAL(textChanged ()),this, SLOT(slotTextChanged()));
00062 
00063     slotTextChanged();
00064 
00065     resize( 400, height() );
00066 }
00067 
00068 void CommentDialog::slotTextChanged()
00069 {
00070     enableButtonOK( !multiLine->text().isEmpty());
00071 }
00072 
00073 void CommentDialog::slotOk()
00074 {
00075     m_pView->doc()->emitBeginOperation( false );
00076     m_pView->activeSheet()->setSelectionComment( m_pView->selectionInfo(),
00077                                                  multiLine->text().stripWhiteSpace() );
00078     m_pView->slotUpdateView( m_pView->activeSheet(), *m_pView->selectionInfo() );
00079     // m_pView->doc()->emitEndOperation();
00080     accept();
00081 }
00082 
00083 #include "kspread_dlg_comment.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys