kspread

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., 51 Franklin Street, Fifth Floor,
00022  * Boston, MA 02110-1301, USA.
00023 */
00024 
00025 #include <qlayout.h>
00026 #include <klocale.h>
00027 #include <qlistbox.h>
00028 #include <qlabel.h>
00029 
00030 #include <kcommand.h>
00031 
00032 #include "kspread_view.h"
00033 #include "kspread_doc.h"
00034 #include "kspread_map.h"
00035 #include "commands.h"
00036 
00037 #include "kspread_dlg_show.h"
00038 
00039 using namespace KSpread;
00040 
00041 ShowDialog::ShowDialog( View* parent, const char* name )
00042     : KDialogBase( parent, name,TRUE,i18n("Show Sheet"),Ok|Cancel )
00043 {
00044   m_pView = parent;
00045   QWidget *page = new QWidget( this );
00046   setMainWidget(page);
00047   QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
00048 
00049   QLabel *label = new QLabel( i18n("Select hidden sheets to show:"), page );
00050   lay1->addWidget( label );
00051 
00052   list=new QListBox(page);
00053   lay1->addWidget( list );
00054 
00055   list->setSelectionMode(QListBox::Multi);
00056   QString text;
00057   QStringList::Iterator it;
00058   QStringList tabsList=m_pView->doc()->map()->hiddenSheets();
00059   for ( it = tabsList.begin(); it != tabsList.end(); ++it )
00060         {
00061         text=*it;
00062         list->insertItem(text);
00063         }
00064   if(!list->count())
00065     enableButtonOK(false);
00066   connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
00067   connect( list, SIGNAL(doubleClicked(QListBoxItem *)),this,SLOT(slotDoubleClicked(QListBoxItem *)));
00068   resize( 200, 150 );
00069   setFocus();
00070 }
00071 
00072 void ShowDialog::slotDoubleClicked(QListBoxItem *)
00073 {
00074     slotOk();
00075 }
00076 
00077 
00078 
00079 void ShowDialog::slotOk()
00080 {
00081     m_pView->doc()->emitBeginOperation( false );
00082 
00083     QStringList listSheet;
00084 
00085     for (int i=0; i < list->numRows(); i++)
00086     {
00087         if (list->isSelected(i))
00088         {
00089             listSheet.append( list->text(i));
00090         }
00091     }
00092 
00093     //m_pView->tabBar()->showSheet(listSheet);
00094 
00095     if ( listSheet.count()==0 )
00096         return;
00097 
00098     Sheet *sheet;
00099     KMacroCommand *macroUndo=new KMacroCommand( i18n("Show Sheet") );
00100     for ( QStringList::Iterator it = listSheet.begin(); it != listSheet.end(); ++it )
00101     {
00102         sheet=m_pView->doc()->map()->findSheet( *it );
00103         KCommand* command = new ShowSheetCommand( sheet );
00104         macroUndo->addCommand( command );
00105     }
00106     m_pView->doc()->addCommand( macroUndo );
00107     macroUndo->execute();
00108     m_pView->slotUpdateView( m_pView->activeSheet() );
00109     accept();
00110 }
00111 
00112 #include "kspread_dlg_show.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys