kspread Library API Documentation

kspread_dlg_showColRow.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Norbert Andres <nandres@web.de>
00003              (C) 2000-2002 Laurent Montel <montel@kde.org>
00004              (C) 2001-2002 Philipp Mueller <philipp.mueller@gmx.de>
00005              (C) 2002 John Dailey <dailey@vt.edu>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020    Boston, MA 02111-1307, USA.
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   //selection multiple
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"
KDE Logo
This file is part of the documentation for kspread Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:43:02 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003