mswrite/ImportDialog.cpp
1/*
2 This file is part of the KDE project
3 Copyright (C) 2001, 2002 Nicolas GOUTTE <goutte@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include <tqtextcodec.h>
22
23#include <tdelocale.h>
24#include <kcharsets.h>
25#include <tdeglobal.h>
26#include <kdebug.h>
27#include <tdeapplication.h>
28
29#include <ImportDialogUI.h>
30#include <ImportDialog.h>
31#include <tqlabel.h>
32#include <tqlayout.h>
33#include <tqradiobutton.h>
34#include <tqvbuttongroup.h>
35#include <tqcombobox.h>
36#include <tqcheckbox.h>
37
38MSWriteImportDialog :: MSWriteImportDialog(TQWidget* parent)
39 : KDialogBase(parent, 0, true, i18n("KWord's MS Write Import Filter"), Ok|Cancel, No, true),
40 m_dialog(new ImportDialogUI(this))
41{
42 kapp->restoreOverrideCursor();
43
44 m_dialog->comboBoxEncoding->insertStringList(TDEGlobal::charsets()->availableEncodingNames());
45 //m_dialog->comboBoxEncoding->insertStringList(TDEGlobal::charsets()->descriptiveEncodingNames());
46
47 resize(size()); // Is this right?
48
49 setMainWidget(m_dialog);
50
51 connect(m_dialog->comboBoxEncoding, TQ_SIGNAL(activated(int)), this,
52 TQ_SLOT(comboBoxEncodingActivated(int)));
53}
54
55MSWriteImportDialog :: ~MSWriteImportDialog(void)
56{
57 kapp->setOverrideCursor(TQt::waitCursor);
58}
59
60TQTextCodec* MSWriteImportDialog::getCodec(void) const
61{
62 TQTextCodec* codec=NULL;
63
64 if (m_dialog->radioEncodingDefault==m_dialog->buttonGroupEncoding->selected())
65 {
66 kdDebug(30509) << "Encoding: CP 1252" << endl;
67 codec=TQTextCodec::codecForName("CP 1252");
68 }
69 /*else if (m_dialog->radioEncodingLocal==m_dialog->buttonGroupEncoding->selected())
70 {
71 kdDebug(30503) << "Encoding: Locale" << endl;
72 codec=TQTextCodec::codecForLocale();
73 }*/
74 else if (m_dialog->radioEncodingOther==m_dialog->buttonGroupEncoding->selected())
75 {
76 TQString strCodec=m_dialog->comboBoxEncoding->currentText();
77 kdDebug(30509) << "Encoding: " << strCodec << endl;
78 if (strCodec.isEmpty())
79 {
80 codec=TQTextCodec::codecForLocale();
81 }
82 else
83 {
84 // We do not use TQTextCodec::codecForName here
85 // because we fear subtle problems
86 codec=TDEGlobal::charsets()->codecForName(strCodec);
87 }
88 }
89
90 if (!codec)
91 {
92 // Default: UTF-8
93 kdWarning(30509) << "No codec set, assuming UTF-8" << endl;
94 codec=TQTextCodec::codecForName("UTF-8");
95 }
96
97 return codec;
98}
99
100bool MSWriteImportDialog::getSimulateLinespacing (void) const
101{
102 return (m_dialog->checkBoxLinespacing->isChecked ());
103}
104
105bool MSWriteImportDialog::getSimulateImageOffset (void) const
106{
107 return (m_dialog->checkBoxImageOffset->isChecked ());
108}
109
110void MSWriteImportDialog::comboBoxEncodingActivated(int)
111{
112 m_dialog->buttonGroupEncoding->setButton(1); // Select the "Other Encoding" button
113}
114
115
116#include <ImportDialog.moc>