Ran qt3to4
[basket4.git] / src / exporterdialog.cpp
blob9843836aa312eb929c72240e0dddda3507f0a22e
1 /***************************************************************************
2 * Copyright (C) 2003 by Sébastien Laoût *
3 * slaout@linux62.org *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program 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 *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include <kurlrequester.h>
22 #include <klineedit.h>
23 #include <kfiledialog.h>
24 #include <qcheckbox.h>
25 #include <qdir.h>
26 #include <q3hbox.h>
27 #include <q3vbox.h>
28 #include <qlayout.h>
29 #include <qlabel.h>
30 //Added by qt3to4:
31 #include <Q3HBoxLayout>
32 #include <klocale.h>
33 #include <kconfig.h>
35 #include "exporterdialog.h"
36 #include "basket.h"
38 ExporterDialog::ExporterDialog(Basket *basket, QWidget *parent, const char *name)
39 : KDialogBase(parent, name, /*modal=*/true, i18n("Export Basket to HTML"),
40 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, /*separator=*/true),
41 m_basket(basket)
43 Q3VBox *page = makeVBoxMainWidget();
45 QWidget *wid = new QWidget(page);
46 Q3HBoxLayout *hLay = new Q3HBoxLayout(wid, /*margin=*/0, KDialogBase::spacingHint());
47 m_url = new KURLRequester("", wid);
48 m_url->setCaption(i18n("HTML Page Filename"));
49 m_url->setFilter("text/html");
50 m_url->fileDialog()->setOperationMode(KFileDialog::Saving);
51 hLay->addWidget( new QLabel(m_url, i18n("&Filename:"), wid) );
52 hLay->addWidget( m_url );
54 m_embedLinkedFiles = new QCheckBox(i18n("&Embed linked local files"), page);
55 m_embedLinkedFolders = new QCheckBox(i18n("Embed &linked local folders"), page);
56 m_erasePreviousFiles = new QCheckBox(i18n("Erase &previous files in target folder"), page);
57 m_formatForImpression = new QCheckBox(i18n("For&mat for impression"), page);
58 m_formatForImpression->hide();
60 load();
61 m_url->lineEdit()->setFocus();
63 showTile(true);
64 // Add a stretch at the bottom:
65 // Duplicated code from AddBasketWizard::addStretch(QWidget *parent):
66 (new QWidget(page))->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
68 // Double the width, because the filename should be visible
69 QSize size(sizeHint());
70 resize(QSize(size.width() * 2, size.height()));
72 ==========================
73 + [00000000000 ] Progress bar!
74 + newBasket -> name folder as the basket
78 ExporterDialog::~ExporterDialog()
82 void ExporterDialog::show()
84 KDialogBase::show();
86 QString lineEditText = m_url->lineEdit()->text();
87 int selectionStart = lineEditText.findRev("/") + 1;
88 m_url->lineEdit()->setSelection(selectionStart, lineEditText.length() - selectionStart - QString(".html").length());
91 void ExporterDialog::load()
93 KConfig *config = KGlobal::config();
94 config->setGroup("HTML Export");
96 QString folder = config->readEntry("lastFolder", QDir::homeDirPath()) + "/";
97 QString url = folder + QString(m_basket->basketName()).replace("/", "_") + ".html";
98 m_url->setURL(url);
100 m_embedLinkedFiles->setChecked( config->readBoolEntry("embedLinkedFiles", true) );
101 m_embedLinkedFolders->setChecked( config->readBoolEntry("embedLinkedFolders", false) );
102 m_erasePreviousFiles->setChecked( config->readBoolEntry("erasePreviousFiles", true) );
103 m_formatForImpression->setChecked( config->readBoolEntry("formatForImpression", false) );
106 void ExporterDialog::save()
108 KConfig *config = KGlobal::config();
109 config->setGroup("HTML Export");
111 QString folder = KURL(m_url->url()).directory();
112 config->writeEntry( "lastFolder", folder );
113 config->writeEntry( "embedLinkedFiles", m_embedLinkedFiles->isChecked() );
114 config->writeEntry( "embedLinkedFolders", m_embedLinkedFolders->isChecked() );
115 config->writeEntry( "erasePreviousFiles", m_erasePreviousFiles->isChecked() );
116 config->writeEntry( "formatForImpression", m_formatForImpression->isChecked() );
119 void ExporterDialog::slotOk()
121 save();
122 KDialogBase::slotOk();
125 QString ExporterDialog::filePath()
127 return m_url->url();
130 bool ExporterDialog::embedLinkedFiles()
132 return m_embedLinkedFiles->isChecked();
135 bool ExporterDialog::embedLinkedFolders()
137 return m_embedLinkedFolders->isChecked();
140 bool ExporterDialog::erasePreviousFiles()
142 return m_erasePreviousFiles->isChecked();
145 bool ExporterDialog::formatForImpression()
147 return m_formatForImpression->isChecked();
150 #include "exporterdialog.moc"