kspread Library API Documentation

kspread_dlg_show.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 1999-2004 Laurent Montel <montel@kde.org>
00003              (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
00004              (C) 2003 Norbert Andres <nandres@web.de>
00005              (C) 2002 John Dailey <dailey@vt.edu>
00006              (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
00007              (C) 1998-1999 Torben Weis <weis@kde.org>
00008 
00009    This library is free software; you can redistribute it and/or
00010    modify it under the terms of the GNU Library General Public
00011    License as published by the Free Software Foundation; either
00012    version 2 of the License, or (at your option) any later version.
00013 
00014    This library is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017    Library General Public License for more details.
00018 
00019    You should have received a copy of the GNU Library General Public License
00020    along with this library; see the file COPYING.LIB.  If not, write to
00021    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022    Boston, MA 02111-1307, USA.
00023 */
00024 
00025 
00026 
00027 #include "kspread_dlg_show.h"
00028 #include "kspread_view.h"
00029 #include "kspread_doc.h"
00030 #include "kspread_map.h"
00031 #include "commands.h"
00032 #include <qlayout.h>
00033 #include <klocale.h>
00034 #include <qlistbox.h>
00035 #include <qlabel.h>
00036 #include <kcommand.h>
00037 
00038 KSpreadshow::KSpreadshow( KSpreadView* parent, const char* name )
00039     : KDialogBase( parent, name,TRUE,i18n("Show Sheet"),Ok|Cancel )
00040 {
00041   m_pView = parent;
00042   QWidget *page = new QWidget( this );
00043   setMainWidget(page);
00044   QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
00045 
00046   QLabel *label = new QLabel( i18n("Select hidden sheets to show:"), page );
00047   lay1->addWidget( label );
00048 
00049   list=new QListBox(page);
00050   lay1->addWidget( list );
00051 
00052   list->setSelectionMode(QListBox::Multi);
00053   QString text;
00054   QStringList::Iterator it;
00055   QStringList tabsList=m_pView->doc()->map()->hiddenSheets();
00056   for ( it = tabsList.begin(); it != tabsList.end(); ++it )
00057         {
00058         text=*it;
00059         list->insertItem(text);
00060         }
00061   if(!list->count())
00062     enableButtonOK(false);
00063   connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
00064   connect( list, SIGNAL(doubleClicked(QListBoxItem *)),this,SLOT(slotDoubleClicked(QListBoxItem *)));
00065   resize( 200, 150 );
00066   setFocus();
00067 }
00068 
00069 void KSpreadshow::slotDoubleClicked(QListBoxItem *)
00070 {
00071     slotOk();
00072 }
00073 
00074 
00075 
00076 void KSpreadshow::slotOk()
00077 {
00078     m_pView->doc()->emitBeginOperation( false );
00079 
00080     QStringList listSheet;
00081 
00082     for (int i=0; i < list->numRows(); i++)
00083     {
00084         if (list->isSelected(i))
00085         {
00086             listSheet.append( list->text(i));
00087         }
00088     }
00089 
00090     //m_pView->tabBar()->showSheet(listSheet);
00091 
00092     if ( listSheet.count()==0 )
00093         return;
00094 
00095     KSpreadSheet *sheet;
00096     KMacroCommand *macroUndo=new KMacroCommand( i18n("Show Sheet") );
00097     for ( QStringList::Iterator it = listSheet.begin(); it != listSheet.end(); ++it )
00098     {
00099         sheet=m_pView->doc()->map()->findSheet( *it );
00100         KCommand* command = new ShowSheetCommand( sheet );
00101         macroUndo->addCommand( command );
00102     }
00103     m_pView->doc()->addCommand( macroUndo );
00104     macroUndo->execute();
00105     m_pView->slotUpdateView( m_pView->activeSheet() );
00106     accept();
00107 }
00108 
00109 #include "kspread_dlg_show.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:43:02 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003