kspread
ShowDialog.cppGo to the documentation of this file.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 #include "ShowDialog.h"
00027
00028 #include <QLabel>
00029 #include <QVBoxLayout>
00030 #include <QListWidget>
00031
00032 #include <klocale.h>
00033
00034 #include "part/Doc.h"
00035 #include "Map.h"
00036 #include "part/View.h"
00037
00038
00039 #include "commands/SheetCommands.h"
00040
00041 using namespace KSpread;
00042
00043 ShowDialog::ShowDialog(View* parent, const char* name)
00044 : KDialog(parent)
00045 {
00046 setCaption(i18n("Show Sheet"));
00047 setModal(true);
00048 setButtons(Ok | Cancel);
00049 setObjectName(name);
00050
00051 m_pView = parent;
00052 QWidget *page = new QWidget(this);
00053 setMainWidget(page);
00054 QVBoxLayout *lay1 = new QVBoxLayout(page);
00055 lay1->setMargin(0);
00056 lay1->setSpacing(spacingHint());
00057
00058 QLabel *label = new QLabel(i18n("Select hidden sheets to show:"), page);
00059 lay1->addWidget(label);
00060
00061 list = new QListWidget(page);
00062 lay1->addWidget(list);
00063
00064 list->setSelectionMode(QAbstractItemView::MultiSelection);
00065 QString text;
00066 QStringList::Iterator it;
00067 QStringList tabsList = m_pView->doc()->map()->hiddenSheets();
00068 for (it = tabsList.begin(); it != tabsList.end(); ++it) {
00069 text = *it;
00070 list->addItem(text);
00071 }
00072 if (!list->count())
00073 enableButtonOk(false);
00074 connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
00075 connect(list, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotDoubleClicked(QListWidgetItem *)));
00076 resize(200, 150);
00077 setFocus();
00078 }
00079
00080 void ShowDialog::slotDoubleClicked(QListWidgetItem *)
00081 {
00082 slotOk();
00083 }
00084
00085
00086
00087 void ShowDialog::slotOk()
00088 {
00089 QStringList listSheet;
00090
00091 for (int i = 0; i < list->count(); i++) {
00092 if (list->item(i)->isSelected()) {
00093 listSheet.append(list->item(i)->text());
00094 }
00095 }
00096
00097
00098
00099 if (listSheet.count() == 0)
00100 return;
00101
00102 Sheet *sheet;
00103 QUndoCommand* macroCommand = new QUndoCommand(i18n("Show Sheet"));
00104 for (QStringList::Iterator it = listSheet.begin(); it != listSheet.end(); ++it) {
00105 sheet = m_pView->doc()->map()->findSheet(*it);
00106 if (!sheet)
00107 continue;
00108 new ShowSheetCommand(sheet, macroCommand);
00109 }
00110 m_pView->doc()->addCommand(macroCommand);
00111 m_pView->slotUpdateView(m_pView->activeSheet());
00112 accept();
00113 }
00114
00115 #include "ShowDialog.moc"
|