21 #include "inserttabledialog.h"
23 #include <KLocalizedString>
29 #include <QFormLayout>
31 using namespace KPIMTextEdit;
33 class InsertTableWidget::InsertTableWidgetPrivate
36 InsertTableWidgetPrivate( InsertTableWidget *qq )
45 mColumns->setValue( 2 );
49 mBorder->setValue( 1 );
50 mBorder->setSuffix( i18n(
" px" ) );
53 formLayout->
addRow( i18n(
"Rows:" ), mRows );
54 formLayout->
addRow( i18n(
"Columns:" ), mColumns );
55 formLayout->
addRow( i18n(
"Border:" ), mBorder );
58 mTypeOfLength =
new KComboBox;
59 q->
connect( mTypeOfLength, SIGNAL(activated(
int)),q,SLOT(slotTypeOfLengthChanged(
int)) );
61 mTypeOfLength->addItem( i18n(
"% of windows" ), QTextLength::PercentageLength );
62 mTypeOfLength->addItem( i18n(
"pixels" ), QTextLength::FixedLength );
65 mLength->setMaximum( 100 );
66 mLength->setValue( 100 );
70 formLayout->
addRow( i18n(
"Width:" ), lay );
71 q->setLayout( formLayout );
78 KComboBox *mTypeOfLength;
83 InsertTableWidget::InsertTableWidget(
QWidget *parent )
84 :
QWidget( parent ), d( new InsertTableWidgetPrivate( this ) )
88 InsertTableWidget::~InsertTableWidget()
93 void InsertTableWidget::slotTypeOfLengthChanged(
int index )
97 d->mLength->setMaximum( 100 );
98 d->mLength->setValue( qMin( d->mLength->value(), 100 ) );
101 d->mLength->setMaximum( 9999 );
104 kDebug() <<
" index not defined " << index;
109 QTextLength::Type InsertTableWidget::typeOfLength()
const
112 ( QTextLength::Type )d->mTypeOfLength->itemData(
113 d->mTypeOfLength->currentIndex() ).toInt();
116 void InsertTableWidget::setTypeOfLength( QTextLength::Type type )
118 const int index = d->mTypeOfLength->findData(
QVariant( type ) );
119 d->mTypeOfLength->setCurrentIndex( index );
120 slotTypeOfLengthChanged( index );
123 int InsertTableWidget::length()
const
125 return d->mLength->value();
128 void InsertTableWidget::setLength(
int val )
130 d->mLength->setValue(val);
133 void InsertTableWidget::setColumns(
int col )
135 d->mColumns->setValue( col );
138 void InsertTableWidget::setRows(
int rows )
140 d->mRows->setValue( rows );
143 void InsertTableWidget::setBorder(
int border )
145 d->mBorder->setValue( border );
148 int InsertTableWidget::columns()
const
150 return d->mColumns->value();
153 int InsertTableWidget::rows()
const
155 return d->mRows->value();
158 int InsertTableWidget::border()
const
160 return d->mBorder->value();
163 class InsertTableDialog::InsertTableDialogPrivate
166 InsertTableDialogPrivate( InsertTableDialog *qq )
169 q->setCaption( i18n(
"Insert Table" ) );
170 q->setButtons( Ok|Cancel );
171 q->setButtonText( KDialog::Ok, i18n(
"Insert" ) );
175 insertTableWidget =
new InsertTableWidget;
177 KSeparator *sep =
new KSeparator;
180 q->setMainWidget( page );
183 InsertTableWidget *insertTableWidget;
184 InsertTableDialog *q;
187 InsertTableDialog::InsertTableDialog(
QWidget *parent )
188 : KDialog( parent ), d( new InsertTableDialogPrivate( this ) )
192 InsertTableDialog::~InsertTableDialog()
197 int InsertTableDialog::columns()
const
199 return d->insertTableWidget->columns();
202 int InsertTableDialog::rows()
const
204 return d->insertTableWidget->rows();
207 int InsertTableDialog::border()
const
209 return d->insertTableWidget->border();
212 QTextLength::Type InsertTableDialog::typeOfLength()
const
214 return d->insertTableWidget->typeOfLength();
217 int InsertTableDialog::length()
const
219 return d->insertTableWidget->length();
222 void InsertTableDialog::setColumns(
int col )
224 d->insertTableWidget->setColumns( col );
227 void InsertTableDialog::setRows(
int rows )
229 d->insertTableWidget->setRows( rows );
232 void InsertTableDialog::setBorder(
int border )
234 d->insertTableWidget->setBorder( border );
237 void InsertTableDialog::setLength(
int val )
239 d->insertTableWidget->setLength( val );
242 void InsertTableDialog::setTypeOfLength( QTextLength::Type type )
244 d->insertTableWidget->setTypeOfLength( type );
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)