filters

exportdialog.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2005 Bram Schoenmakers <bramschoenmakers@kde.nl>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <tqcheckbox.h>
21#include <tqcombobox.h>
22#include <tqlistbox.h>
23#include <tqradiobutton.h>
24#include <tqspinbox.h>
25#include <tqtextcodec.h>
26
27#include <tdeapplication.h>
28#include <tdeglobal.h>
29#include <tdelocale.h>
30#include <kurlrequester.h>
31
32#include <exportdialog.h>
33#include <exportwidget.h>
34
35ExportDialog::ExportDialog( TQWidget *parent, const char *name )
36 : KDialogBase( parent, name, true, i18n("Export Sheet to HTML"), Ok|Cancel, No, true ), m_mainwidget( new ExportWidget( this ) )
37{
38 kapp->restoreOverrideCursor();
39
40 connect( m_mainwidget->mCustomButton, TQ_SIGNAL( toggled( bool ) ),
41 m_mainwidget->mCustomURL, TQ_SLOT( setEnabled( bool ) ) );
42 connect( m_mainwidget->mSelectAllButton, TQ_SIGNAL( clicked() ), TQ_SLOT( selectAll() ) );
43 connect( m_mainwidget->mDeselectAllButton, TQ_SIGNAL( clicked() ),
44 m_mainwidget->mSheets, TQ_SLOT( clearSelection() ) );
45
46 m_mainwidget->mEncodingBox->insertItem( i18n( "Recommended: UTF-8" ) );
47 m_mainwidget->mEncodingBox->insertItem( i18n( "Locale (%1)" ).arg( TDEGlobal::locale()->codecForEncoding()->name() ) );
48
49 m_mainwidget->mCustomURL->setMode( KFile::ExistingOnly );
50
51 setMainWidget( m_mainwidget );
52}
53
54void ExportDialog::selectAll()
55{
56 m_mainwidget->mSheets->selectAll( true );
57}
58
59ExportDialog::~ExportDialog()
60{
61 kapp->setOverrideCursor(TQt::waitCursor);
62}
63
64TQTextCodec *ExportDialog::encoding() const
65{
66 if( m_mainwidget->mEncodingBox->currentItem() == 1 ) // locale selected
67 return TDEGlobal::locale()->codecForEncoding();
68
69 return TQTextCodec::codecForName( "utf8" ); // utf8 is default
70}
71
72bool ExportDialog::useBorders() const
73{
74 return m_mainwidget->mUseBorders->isChecked();
75}
76
77bool ExportDialog::separateFiles() const
78{
79 return m_mainwidget->mSeparateFiles->isChecked();
80}
81
82TQString ExportDialog::customStyleURL() const
83{
84 TQString url = m_mainwidget->mCustomURL->url();
85 if( m_mainwidget->mCustomButton->isChecked() && KURL( url ).isValid() )
86 return url;
87
88 return TQString();
89}
90
91void ExportDialog::setSheets( const TQStringList &list )
92{
93 m_mainwidget->mSheets->insertStringList( list );
94 selectAll();
95}
96
97TQStringList ExportDialog::sheets() const
98{
99 TQStringList list;
100 for( uint i = 0; i < m_mainwidget->mSheets->count() ; i++ )
101 {
102 if( m_mainwidget->mSheets->isSelected( i ) )
103 list.append( m_mainwidget->mSheets->text( i ) );
104 }
105 return list;
106}
107
108int ExportDialog::pixelsBetweenCells() const
109{
110 return m_mainwidget->mPixelsBetweenCells->value();
111}
112
113#include <exportdialog.moc>