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 );
45 QWidget *page =
new QWidget( q );
46 q->setMainWidget( page );
47 QVBoxLayout *lay =
new QVBoxLayout( page );
48 tableWidget =
new InsertTableWidget;
49 lay->addWidget( tableWidget );
51 KSeparator *sep =
new KSeparator;
52 lay->addWidget( sep );
54 QHBoxLayout *hbox =
new QHBoxLayout;
55 QLabel *lab =
new QLabel( i18n(
"Spacing:" ) );
56 hbox->addWidget( lab );
57 spacing =
new QSpinBox;
58 spacing->setMinimum( 0 );
59 hbox->addWidget( spacing );
60 lab =
new QLabel( i18n(
"pixels between cells" ) );
61 hbox->addWidget( lab );
62 lay->addLayout( hbox );
64 hbox =
new QHBoxLayout;
65 lab =
new QLabel( i18n(
"Padding:" ) );
66 hbox->addWidget( lab );
67 padding =
new QSpinBox;
68 padding->setMinimum( 0 );
69 hbox->addWidget( padding );
70 lab =
new QLabel( i18n(
"pixels between cell border and content" ) );
71 hbox->addWidget( lab );
72 lay->addLayout( hbox );
75 lay->addWidget( sep );
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 );
83 hbox =
new QHBoxLayout;
84 lab =
new QLabel( i18n(
"Table Alignment:" ) );
85 hbox->addWidget( lab );
86 hbox->addWidget( alignment );
88 lay->addLayout( hbox );
91 lay->addWidget( sep );
93 hbox =
new QHBoxLayout;
94 useBackgroundColor =
new QCheckBox( i18n(
"Background Color:" ) );
96 hbox->addWidget( useBackgroundColor );
97 backgroundColor =
new KColorButton;
98 backgroundColor->setDefaultColor(Qt::white);
99 hbox->addWidget( backgroundColor );
100 lay->addLayout(hbox);
102 sep =
new KSeparator;
103 lay->addWidget( sep );
104 backgroundColor->setEnabled(
false);
105 q->connect( useBackgroundColor, SIGNAL(toggled(
bool)),
106 backgroundColor, SLOT(setEnabled(
bool)) );
110 QCheckBox *useBackgroundColor;
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 ) ) );
184 Qt::Alignment TableFormatDialog::alignment()
const
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();