kspread_dlg_showColRow.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 #include "kspread_dlg_showColRow.h"
00026 #include "kspread_doc.h"
00027 #include "kspread_view.h"
00028 #include "kspread_sheet.h"
00029 #include "kspread_util.h"
00030 #include <qlabel.h>
00031 #include <qlayout.h>
00032 #include <klocale.h>
00033
00034 KSpreadShowColRow::KSpreadShowColRow( KSpreadView* parent, const char* name,ShowColRow _type )
00035 : KDialogBase( parent, name,TRUE,"",Ok|Cancel )
00036 {
00037 m_pView = parent;
00038 typeShow=_type;
00039
00040 QWidget *page = new QWidget( this );
00041 setMainWidget(page);
00042 QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
00043
00044 QLabel *label = new QLabel( page );
00045
00046 if(_type==Column) {
00047 setCaption( i18n("Show Columns") );
00048 label->setText(i18n("Select hidden columns to show:"));
00049 }
00050 else if(_type==Row) {
00051 setCaption( i18n("Show Rows") );
00052 label->setText(i18n("Select hidden rows to show:"));
00053 }
00054
00055 list=new QListBox(page);
00056
00057 lay1->addWidget( label );
00058 lay1->addWidget( list );
00059
00060 bool showColNumber=m_pView->activeSheet()->getShowColumnNumber();
00061 if(_type==Column)
00062 {
00063 ColumnFormat *col=m_pView->activeSheet()->firstCol();
00064
00065 QString text;
00066 QStringList listCol;
00067 for( ; col; col = col->next() )
00068 {
00069 if(col->isHide())
00070 listInt.append(col->column());
00071 }
00072 qHeapSort(listInt);
00073 QValueList<int>::Iterator it;
00074 for( it = listInt.begin(); it != listInt.end(); ++it )
00075 {
00076 if(!showColNumber)
00077 listCol+=i18n("Column: %1").arg(KSpreadCell::columnName(*it));
00078 else
00079 listCol+=i18n("Column: %1").arg(text.setNum(*it));
00080 }
00081 list->insertStringList(listCol);
00082 }
00083 else if(_type==Row)
00084 {
00085 RowFormat *row=m_pView->activeSheet()->firstRow();
00086
00087 QString text;
00088 QStringList listRow;
00089 for( ; row; row = row->next() )
00090 {
00091 if(row->isHide())
00092 listInt.append(row->row());
00093 }
00094 qHeapSort(listInt);
00095 QValueList<int>::Iterator it;
00096 for( it = listInt.begin(); it != listInt.end(); ++it )
00097 listRow+=i18n("Row: %1").arg(text.setNum(*it));
00098
00099 list->insertStringList(listRow);
00100 }
00101
00102 if(!list->count())
00103 enableButtonOK(false);
00104
00105
00106 list->setSelectionMode(QListBox::Multi);
00107 connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
00108 connect( list, SIGNAL(doubleClicked(QListBoxItem *)),this,SLOT(slotDoubleClicked(QListBoxItem *)));
00109 resize( 200, 150 );
00110 setFocus();
00111 }
00112
00113 void KSpreadShowColRow::slotDoubleClicked(QListBoxItem *)
00114 {
00115 slotOk();
00116 }
00117
00118 void KSpreadShowColRow::slotOk()
00119 {
00120 m_pView->doc()->emitBeginOperation( false );
00121
00122 QValueList<int>listSelected;
00123 for(unsigned int i=0;i<list->count();i++)
00124 {
00125 if(list->isSelected(i))
00126 listSelected.append(*listInt.at(i));
00127 }
00128 if( typeShow==Column)
00129 {
00130 if(listSelected.count()!=0)
00131 m_pView->activeSheet()->showColumn(0,-1,listSelected);
00132 }
00133 if( typeShow==Row)
00134 {
00135 if(listSelected.count()!=0)
00136 m_pView->activeSheet()->showRow(0,-1,listSelected);
00137 }
00138
00139 m_pView->slotUpdateView( m_pView->activeSheet() );
00140 accept();
00141 }
00142
00143 #include "kspread_dlg_showColRow.moc"
This file is part of the documentation for kspread Library Version 1.4.2.