kspread

kspread_dlg_show.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1999-2004 Laurent Montel <montel@kde.org>
3 (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
4 (C) 2003 Norbert Andres <nandres@web.de>
5 (C) 2002 John Dailey <dailey@vt.edu>
6 (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
7 (C) 1998-1999 Torben Weis <weis@kde.org>
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23*/
24
25#include <tqlayout.h>
26#include <tdelocale.h>
27#include <tqlistbox.h>
28#include <tqlabel.h>
29
30#include <kcommand.h>
31
32#include "kspread_view.h"
33#include "kspread_doc.h"
34#include "kspread_map.h"
35#include "commands.h"
36
37#include "kspread_dlg_show.h"
38
39using namespace KSpread;
40
41ShowDialog::ShowDialog( View* parent, const char* name )
42 : KDialogBase( parent, name,true,i18n("Show Sheet"),Ok|Cancel )
43{
44 m_pView = parent;
45 TQWidget *page = new TQWidget( this );
46 setMainWidget(page);
47 TQVBoxLayout *lay1 = new TQVBoxLayout( page, 0, spacingHint() );
48
49 TQLabel *label = new TQLabel( i18n("Select hidden sheets to show:"), page );
50 lay1->addWidget( label );
51
52 list=new TQListBox(page);
53 lay1->addWidget( list );
54
55 list->setSelectionMode(TQListBox::Multi);
56 TQString text;
57 TQStringList::Iterator it;
58 TQStringList tabsList=m_pView->doc()->map()->hiddenSheets();
59 for ( it = tabsList.begin(); it != tabsList.end(); ++it )
60 {
61 text=*it;
62 list->insertItem(text);
63 }
64 if(!list->count())
65 enableButtonOK(false);
66 connect( this, TQ_SIGNAL( okClicked() ), this, TQ_SLOT( slotOk() ) );
67 connect( list, TQ_SIGNAL(doubleClicked(TQListBoxItem *)),this,TQ_SLOT(slotDoubleClicked(TQListBoxItem *)));
68 resize( 200, 150 );
69 setFocus();
70}
71
72void ShowDialog::slotDoubleClicked(TQListBoxItem *)
73{
74 slotOk();
75}
76
77
78
79void ShowDialog::slotOk()
80{
81 m_pView->doc()->emitBeginOperation( false );
82
83 TQStringList listSheet;
84
85 for (int i=0; i < list->numRows(); i++)
86 {
87 if (list->isSelected(i))
88 {
89 listSheet.append( list->text(i));
90 }
91 }
92
93 //m_pView->tabBar()->showSheet(listSheet);
94
95 if ( listSheet.count()==0 )
96 return;
97
98 Sheet *sheet;
99 KMacroCommand *macroUndo=new KMacroCommand( i18n("Show Sheet") );
100 for ( TQStringList::Iterator it = listSheet.begin(); it != listSheet.end(); ++it )
101 {
102 sheet=m_pView->doc()->map()->findSheet( *it );
103 KCommand* command = new ShowSheetCommand( sheet );
104 macroUndo->addCommand( command );
105 }
106 m_pView->doc()->addCommand( macroUndo );
107 macroUndo->execute();
108 m_pView->slotUpdateView( m_pView->activeSheet() );
109 accept();
110}
111
112#include "kspread_dlg_show.moc"
Sheet * findSheet(const TQString &_name)
searches for a sheet named _name
The View class displays a KSpread document.
The KSpread namespace.
Definition commands.h:39