21 #include "tableformatdialog.h"
22 #include "inserttabledialog.h"
24 #include <KLocalizedString>
27 #include <KColorButton>
29 #include <QVBoxLayout>
30 #include <QHBoxLayout>
35 using namespace KPIMTextEdit;
37 class TableFormatDialog::TableFormatDialogPrivate
40 TableFormatDialogPrivate( TableFormatDialog *qq )
43 q->setCaption( i18n(
"Table Format" ) );
44 q->setButtons( Ok|Cancel );
46 q->setMainWidget( page );
48 tableWidget =
new InsertTableWidget;
51 KSeparator *sep =
new KSeparator;
60 lab =
new QLabel( i18n(
"pixels between cells" ) );
65 lab =
new QLabel( i18n(
"Padding:" ) );
70 lab =
new QLabel( i18n(
"pixels between cell border and content" ) );
77 alignment =
new KComboBox;
78 alignment->addItem( i18n(
"Left" ), Qt::AlignLeft );
79 alignment->addItem( i18n(
"Right" ), Qt::AlignRight );
80 alignment->addItem( i18n(
"Center" ), Qt::AlignHCenter );
81 alignment->addItem( i18n(
"Justify" ), Qt::AlignJustify );
84 lab =
new QLabel( i18n(
"Table Alignment:" ) );
94 useBackgroundColor =
new QCheckBox( i18n(
"Background Color:" ) );
97 backgroundColor =
new KColorButton;
98 backgroundColor->setDefaultColor(Qt::white);
102 sep =
new KSeparator;
104 backgroundColor->setEnabled(
false);
105 q->connect( useBackgroundColor, SIGNAL(toggled(
bool)),
106 backgroundColor, SLOT(setEnabled(
bool)) );
111 KColorButton *backgroundColor;
112 KComboBox *alignment;
115 KPIMTextEdit::InsertTableWidget *tableWidget;
116 TableFormatDialog *q;
119 TableFormatDialog::TableFormatDialog(
QWidget *parent )
120 : KDialog( parent ), d( new TableFormatDialogPrivate( this ) )
124 TableFormatDialog::~TableFormatDialog()
129 int TableFormatDialog::columns()
const
131 return d->tableWidget->columns();
134 int TableFormatDialog::rows()
const
136 return d->tableWidget->rows();
139 int TableFormatDialog::border()
const
141 return d->tableWidget->border();
144 void TableFormatDialog::setColumns(
int col )
146 d->tableWidget->setColumns( col );
149 void TableFormatDialog::setRows(
int row )
151 d->tableWidget->setRows( row );
154 void TableFormatDialog::setBorder(
int border )
156 d->tableWidget->setBorder( border );
159 int TableFormatDialog::padding()
const
161 return d->padding->value();
164 void TableFormatDialog::setPadding(
int value )
166 d->padding->setValue( value );
169 int TableFormatDialog::spacing()
const
171 return d->spacing->value();
174 void TableFormatDialog::setSpacing(
int value )
176 d->spacing->setValue( value );
179 void TableFormatDialog::setAlignment(
Qt::Alignment alignment )
181 d->alignment->setCurrentIndex( d->alignment->findData(
QVariant( alignment ) ) );
186 return (
Qt::Alignment )d->alignment->itemData( d->alignment->currentIndex () ).toInt();
189 QTextLength::Type TableFormatDialog::typeOfLength()
const
191 return d->tableWidget->typeOfLength();
194 int TableFormatDialog::length()
const
196 return d->tableWidget->length();
199 void TableFormatDialog::setLength(
int val )
201 d->tableWidget->setLength( val );
204 void TableFormatDialog::setTypeOfLength( QTextLength::Type type )
206 d->tableWidget->setTypeOfLength( type );
209 QColor TableFormatDialog::tableBackgroundColor()
const
211 return d->backgroundColor->color();
214 void TableFormatDialog::setTableBackgroundColor(
const QColor &col )
216 d->backgroundColor->setColor( col );
217 d->useBackgroundColor->setChecked(
true );
220 bool TableFormatDialog::useBackgroundColor()
const
222 return d->useBackgroundColor->isChecked();
void addLayout(QLayout *layout, int stretch)