filters

exportdialog.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2005 Bram Schoenmakers <bramschoenmakers@kde.nl>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include <qcheckbox.h>
00021 #include <qcombobox.h>
00022 #include <qlistbox.h>
00023 #include <qradiobutton.h>
00024 #include <qspinbox.h>
00025 #include <qtextcodec.h>
00026 
00027 #include <kapplication.h>
00028 #include <kglobal.h>
00029 #include <klocale.h>
00030 #include <kurlrequester.h>
00031 
00032 #include <exportdialog.h>
00033 #include <exportwidget.h>
00034 
00035 ExportDialog::ExportDialog( QWidget *parent, const char *name )
00036   : KDialogBase( parent, name, true, i18n("Export Sheet to HTML"), Ok|Cancel, No, true ), m_mainwidget( new ExportWidget( this ) )
00037 {
00038   kapp->restoreOverrideCursor();
00039 
00040   connect( m_mainwidget->mCustomButton, SIGNAL( toggled( bool ) ),
00041            m_mainwidget->mCustomURL, SLOT( setEnabled( bool ) ) );
00042   connect( m_mainwidget->mSelectAllButton, SIGNAL( clicked() ), SLOT( selectAll() ) );
00043   connect( m_mainwidget->mDeselectAllButton, SIGNAL( clicked() ),
00044            m_mainwidget->mSheets, SLOT( clearSelection() ) );
00045 
00046   m_mainwidget->mEncodingBox->insertItem( i18n( "Recommended: UTF-8" ) );
00047   m_mainwidget->mEncodingBox->insertItem( i18n( "Locale (%1)" ).arg( KGlobal::locale()->codecForEncoding()->name() ) );
00048 
00049   m_mainwidget->mCustomURL->setMode( KFile::ExistingOnly );
00050 
00051   setMainWidget( m_mainwidget );
00052 }
00053 
00054 void ExportDialog::selectAll()
00055 {
00056   m_mainwidget->mSheets->selectAll( true );
00057 }
00058 
00059 ExportDialog::~ExportDialog()
00060 {
00061   kapp->setOverrideCursor(Qt::waitCursor);
00062 }
00063 
00064 QTextCodec *ExportDialog::encoding() const
00065 {
00066   if( m_mainwidget->mEncodingBox->currentItem() == 1 ) // locale selected
00067     return KGlobal::locale()->codecForEncoding();
00068 
00069   return QTextCodec::codecForName( "utf8" ); // utf8 is default
00070 }
00071 
00072 bool ExportDialog::useBorders() const
00073 {
00074   return m_mainwidget->mUseBorders->isChecked();
00075 }
00076 
00077 bool ExportDialog::separateFiles() const
00078 {
00079   return m_mainwidget->mSeparateFiles->isChecked();
00080 }
00081 
00082 QString ExportDialog::customStyleURL() const
00083 {
00084   QString url = m_mainwidget->mCustomURL->url();
00085   if( m_mainwidget->mCustomButton->isChecked() && KURL( url ).isValid() )
00086     return url;
00087 
00088   return QString::null;
00089 }
00090 
00091 void ExportDialog::setSheets( const QStringList &list )
00092 {
00093   m_mainwidget->mSheets->insertStringList( list );
00094   selectAll();
00095 }
00096 
00097 QStringList ExportDialog::sheets() const
00098 {
00099   QStringList list;
00100   for( uint i = 0; i < m_mainwidget->mSheets->count() ; i++ )
00101   {
00102     if( m_mainwidget->mSheets->isSelected( i ) )
00103       list.append( m_mainwidget->mSheets->text( i ) );
00104   }
00105   return list;
00106 }
00107 
00108 int ExportDialog::pixelsBetweenCells() const
00109 {
00110   return m_mainwidget->mPixelsBetweenCells->value();
00111 }
00112 
00113 #include <exportdialog.moc>
KDE Home | KDE Accessibility Home | Description of Access Keys