kspread_dlg_show.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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"
This file is part of the documentation for kspread Library Version 1.4.2.