kspread
kspread_dlg_showColRow.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <qlabel.h>
00024 #include <qlayout.h>
00025
00026 #include <klocale.h>
00027
00028 #include "kspread_doc.h"
00029 #include "kspread_sheet.h"
00030 #include "kspread_util.h"
00031 #include "kspread_view.h"
00032 #include "region.h"
00033
00034 #include "kspread_dlg_showColRow.h"
00035
00036 using namespace KSpread;
00037
00038 ShowColRow::ShowColRow( View* parent, const char* name, Type _type )
00039 : KDialogBase( parent, name,TRUE,"",Ok|Cancel )
00040 {
00041 m_pView = parent;
00042 typeShow=_type;
00043
00044 QWidget *page = new QWidget( this );
00045 setMainWidget(page);
00046 QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
00047
00048 QLabel *label = new QLabel( page );
00049
00050 if(_type==Column) {
00051 setCaption( i18n("Show Columns") );
00052 label->setText(i18n("Select hidden columns to show:"));
00053 }
00054 else if(_type==Row) {
00055 setCaption( i18n("Show Rows") );
00056 label->setText(i18n("Select hidden rows to show:"));
00057 }
00058
00059 list=new QListBox(page);
00060
00061 lay1->addWidget( label );
00062 lay1->addWidget( list );
00063
00064 bool showColNumber=m_pView->activeSheet()->getShowColumnNumber();
00065 if(_type==Column)
00066 {
00067 ColumnFormat *col=m_pView->activeSheet()->firstCol();
00068
00069 QString text;
00070 QStringList listCol;
00071 for( ; col; col = col->next() )
00072 {
00073 if(col->isHide())
00074 listInt.append(col->column());
00075 }
00076 qHeapSort(listInt);
00077 QValueList<int>::Iterator it;
00078 for( it = listInt.begin(); it != listInt.end(); ++it )
00079 {
00080 if(!showColNumber)
00081 listCol+=i18n("Column: %1").arg(Cell::columnName(*it));
00082 else
00083 listCol+=i18n("Column: %1").arg(text.setNum(*it));
00084 }
00085 list->insertStringList(listCol);
00086 }
00087 else if(_type==Row)
00088 {
00089 RowFormat *row=m_pView->activeSheet()->firstRow();
00090
00091 QString text;
00092 QStringList listRow;
00093 for( ; row; row = row->next() )
00094 {
00095 if(row->isHide())
00096 listInt.append(row->row());
00097 }
00098 qHeapSort(listInt);
00099 QValueList<int>::Iterator it;
00100 for( it = listInt.begin(); it != listInt.end(); ++it )
00101 listRow+=i18n("Row: %1").arg(text.setNum(*it));
00102
00103 list->insertStringList(listRow);
00104 }
00105
00106 if(!list->count())
00107 enableButtonOK(false);
00108
00109
00110 list->setSelectionMode(QListBox::Multi);
00111 connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
00112 connect( list, SIGNAL(doubleClicked(QListBoxItem *)),this,SLOT(slotDoubleClicked(QListBoxItem *)));
00113 resize( 200, 150 );
00114 setFocus();
00115 }
00116
00117 void ShowColRow::slotDoubleClicked(QListBoxItem *)
00118 {
00119 slotOk();
00120 }
00121
00122 void ShowColRow::slotOk()
00123 {
00124 Region region;
00125 for(unsigned int i=0; i < list->count(); i++)
00126 {
00127 if (list->isSelected(i))
00128 {
00129 if (typeShow == Column)
00130 {
00131 region.add(QRect(*listInt.at(i), 1, 1, KS_rowMax));
00132 }
00133 if (typeShow == Row)
00134 {
00135 region.add(QRect(1, *listInt.at(i), KS_colMax, 1));
00136 }
00137 }
00138 }
00139
00140 if (typeShow == Column)
00141 {
00142 m_pView->activeSheet()->showColumn(region);
00143 }
00144 if (typeShow == Row)
00145 {
00146 m_pView->activeSheet()->showRow(region);
00147 }
00148
00149 accept();
00150 }
00151
00152 #include "kspread_dlg_showColRow.moc"
|