filters
ImportDialog.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <qtextcodec.h>
00022 #include <qradiobutton.h>
00023 #include <qbuttongroup.h>
00024
00025 #include <klocale.h>
00026 #include <kcharsets.h>
00027 #include <kglobal.h>
00028 #include <kdebug.h>
00029 #include <kapplication.h>
00030 #include <kcombobox.h>
00031 #include <kmessagebox.h>
00032
00033 #include <ImportDialogUI.h>
00034 #include <ImportDialog.h>
00035
00036 AsciiImportDialog :: AsciiImportDialog(QWidget* parent)
00037 : KDialogBase(parent, 0, true, i18n("KWord's Plain Text Import Filter"), Ok|Cancel, No, true),
00038 m_dialog(new ImportDialogUI(this))
00039 {
00040
00041 kapp->restoreOverrideCursor();
00042
00043 QStringList encodings;
00044 encodings << i18n( "Descriptive encoding name", "Recommended ( %1 )" ).arg( "UTF-8" );
00045 encodings << i18n( "Descriptive encoding name", "Locale ( %1 )" ).arg( QTextCodec::codecForLocale()->name() );
00046 encodings += KGlobal::charsets()->descriptiveEncodingNames();
00047
00048 const QString description(i18n("Descriptive encoding name","Other ( %1 )"));
00049 encodings << description.arg("Apple Roman");
00050 encodings << description.arg("IBM 850") << description.arg("IBM 866");
00051 encodings << description.arg("CP 1258");
00052
00053 m_dialog->comboBoxEncoding->insertStringList(encodings);
00054
00055 setMainWidget(m_dialog);
00056 }
00057
00058 AsciiImportDialog :: ~AsciiImportDialog(void)
00059 {
00060 kapp->setOverrideCursor(Qt::waitCursor);
00061 }
00062
00063 QTextCodec* AsciiImportDialog::getCodec(void) const
00064 {
00065 const QString strCodec( KGlobal::charsets()->encodingForName( m_dialog->comboBoxEncoding->currentText() ) );
00066 kdDebug(30502) << "Encoding: " << strCodec << endl;
00067
00068 bool ok = false;
00069 QTextCodec* codec = QTextCodec::codecForName( strCodec.utf8() );
00070
00071
00072 if ( codec )
00073 {
00074 ok = true;
00075 }
00076 else
00077 {
00078 codec = KGlobal::charsets()->codecForName( strCodec, ok );
00079 }
00080
00081
00082 if ( !codec || !ok )
00083 {
00084
00085 kdWarning(30502) << "Cannot find encoding:" << strCodec << endl;
00086
00087 KMessageBox::error( 0, i18n("Cannot find encoding: %1").arg( strCodec ) );
00088 return 0;
00089 }
00090
00091 return codec;
00092 }
00093
00094 int AsciiImportDialog::getParagraphStrategy(void) const
00095 {
00096 if (m_dialog->radioParagraphAsIs==m_dialog->buttonGroupParagraph->selected())
00097 {
00098 return 0;
00099 }
00100 if (m_dialog->radioParagraphSentence==m_dialog->buttonGroupParagraph->selected())
00101 {
00102 return 1;
00103 }
00104 else if (m_dialog->radioParagraphOldWay==m_dialog->buttonGroupParagraph->selected())
00105 {
00106 return 999;
00107 }
00108 return 0;
00109 }
00110
00111 #include <ImportDialog.moc>
|