2 Copyright (c) 2012 Montel Laurent <montel@kde.org>
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
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 the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include "composertabledialog.h"
23 #include <KPIMTextEdit/InsertTableWidget>
27 #include <QWebElement>
29 namespace ComposerEditorNG
31 class ComposerTableDialogPrivate
34 ComposerTableDialogPrivate(ComposerTableDialog
*qq
)
43 KPIMTextEdit::InsertTableWidget
*insertTableWidget
;
44 ComposerTableDialog
*q
;
48 QString
ComposerTableDialogPrivate::html() const
50 const int numberOfColumns( insertTableWidget
->columns() );
51 const int numberRow( insertTableWidget
->rows() );
53 QString htmlTable
= QString::fromLatin1("<table border='%1'").arg(insertTableWidget
->border());
54 htmlTable
+= QString::fromLatin1(" width='%1%2'").arg(insertTableWidget
->length()).arg(insertTableWidget
->typeOfLength() == QTextLength::PercentageLength
? QLatin1String("%") : QString());
55 htmlTable
+= QString::fromLatin1(">");
56 for(int i
= 0; i
<numberRow
; ++i
) {
57 htmlTable
+= QLatin1String("<tr>");
58 for(int j
= 0; j
<numberOfColumns
; ++j
) {
59 htmlTable
+= QLatin1String("<td><br></td>");
61 htmlTable
+= QLatin1String("</tr>");
63 htmlTable
+= QLatin1String("</table>");
67 void ComposerTableDialogPrivate::initialize()
69 q
->setCaption( i18n( "Insert Table" ) );
70 q
->setButtons( KDialog::Ok
|KDialog::Cancel
);
71 q
->setButtonText( KDialog::Ok
, i18n( "Insert" ) );
72 insertTableWidget
= new KPIMTextEdit::InsertTableWidget( q
);
73 q
->setMainWidget( insertTableWidget
);
74 q
->connect(q
,SIGNAL(okClicked()),q
,SLOT(slotOkClicked()));
77 ComposerTableDialog::ComposerTableDialog(QWidget
*parent
)
78 : KDialog(parent
), d(new ComposerTableDialogPrivate(this))
84 ComposerTableDialog::~ComposerTableDialog()
89 QString
ComposerTableDialog::html() const
94 void ComposerTableDialog::slotOkClicked()
102 #include "composertabledialog.moc"