filters

ImportDialog.cc

00001 /*
00002    This file is part of the KDE project
00003    Copyright (C) 2001, 2002 Nicolas GOUTTE <goutte@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include <qtextcodec.h>
00022 
00023 #include <klocale.h>
00024 #include <kcharsets.h>
00025 #include <kglobal.h>
00026 #include <kdebug.h>
00027 #include <kapplication.h>
00028 
00029 #include <ImportDialogUI.h>
00030 #include <ImportDialog.h>
00031 #include <qlabel.h>
00032 #include <qlayout.h>
00033 #include <qradiobutton.h>
00034 #include <qvbuttongroup.h>
00035 #include <qcombobox.h>
00036 #include <qcheckbox.h>
00037 
00038 MSWriteImportDialog :: MSWriteImportDialog(QWidget* parent)
00039     : KDialogBase(parent, 0, true,  i18n("KWord's MS Write Import Filter"), Ok|Cancel, No, true),
00040       m_dialog(new ImportDialogUI(this))
00041 {
00042     kapp->restoreOverrideCursor();
00043 
00044    m_dialog->comboBoxEncoding->insertStringList(KGlobal::charsets()->availableEncodingNames());
00045     //m_dialog->comboBoxEncoding->insertStringList(KGlobal::charsets()->descriptiveEncodingNames());
00046 
00047     resize(size()); // Is this right?
00048 
00049     setMainWidget(m_dialog);
00050 
00051     connect(m_dialog->comboBoxEncoding, SIGNAL(activated(int)), this,
00052         SLOT(comboBoxEncodingActivated(int)));
00053 }
00054 
00055 MSWriteImportDialog :: ~MSWriteImportDialog(void)
00056 {
00057     kapp->setOverrideCursor(Qt::waitCursor);
00058 }
00059 
00060 QTextCodec* MSWriteImportDialog::getCodec(void) const
00061 {
00062     QTextCodec* codec=NULL;
00063 
00064     if (m_dialog->radioEncodingDefault==m_dialog->buttonGroupEncoding->selected())
00065     {
00066         kdDebug(30509) << "Encoding: CP 1252" << endl;
00067         codec=QTextCodec::codecForName("CP 1252");
00068     }
00069     /*else if (m_dialog->radioEncodingLocal==m_dialog->buttonGroupEncoding->selected())
00070     {
00071         kdDebug(30503) << "Encoding: Locale" << endl;
00072         codec=QTextCodec::codecForLocale();
00073     }*/
00074     else if (m_dialog->radioEncodingOther==m_dialog->buttonGroupEncoding->selected())
00075     {
00076         QString strCodec=m_dialog->comboBoxEncoding->currentText();
00077         kdDebug(30509) << "Encoding: " << strCodec << endl;
00078         if (strCodec.isEmpty())
00079         {
00080             codec=QTextCodec::codecForLocale();
00081         }
00082         else
00083         {
00084             // We do not use QTextCodec::codecForName here
00085             //   because we fear subtle problems
00086             codec=KGlobal::charsets()->codecForName(strCodec);
00087         }
00088     }
00089 
00090     if (!codec)
00091     {
00092         // Default: UTF-8
00093         kdWarning(30509) << "No codec set, assuming UTF-8" << endl;
00094         codec=QTextCodec::codecForName("UTF-8");
00095     }
00096 
00097     return codec;
00098 }
00099 
00100 bool MSWriteImportDialog::getSimulateLinespacing (void) const
00101 {
00102      return (m_dialog->checkBoxLinespacing->isChecked ());
00103 }
00104 
00105 bool MSWriteImportDialog::getSimulateImageOffset (void) const
00106 {
00107      return (m_dialog->checkBoxImageOffset->isChecked ());
00108 }
00109 
00110 void MSWriteImportDialog::comboBoxEncodingActivated(int)
00111 {
00112      m_dialog->buttonGroupEncoding->setButton(1); // Select the "Other Encoding" button
00113 }
00114 
00115 
00116 #include <ImportDialog.moc>
KDE Home | KDE Accessibility Home | Description of Access Keys