kspread
kspread_dlg_show.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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"
|