• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

KPIMTextedit Library

  • sources
  • kde-4.14
  • kdepimlibs
  • kpimtextedit
tableformatdialog.cpp
1 /*
2  Copyright (c) 2012 Montel Laurent <montel@kde.org>
3 
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.
8 
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.
13 
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
17  02110-1301, USA.
18 
19 */
20 
21 #include "tableformatdialog.h"
22 #include "inserttabledialog.h"
23 
24 #include <KLocalizedString>
25 #include <KComboBox>
26 #include <KSeparator>
27 #include <KColorButton>
28 
29 #include <QVBoxLayout>
30 #include <QHBoxLayout>
31 #include <QSpinBox>
32 #include <QLabel>
33 #include <QCheckBox>
34 
35 using namespace KPIMTextEdit;
36 
37 class TableFormatDialog::TableFormatDialogPrivate
38 {
39  public:
40  TableFormatDialogPrivate( TableFormatDialog *qq )
41  :q( qq )
42  {
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 );
50 
51  KSeparator *sep = new KSeparator;
52  lay->addWidget( sep );
53 
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 );
63 
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 );
73 
74  sep = new KSeparator;
75  lay->addWidget( sep );
76 
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 );
82 
83  hbox = new QHBoxLayout;
84  lab = new QLabel( i18n( "Table Alignment:" ) );
85  hbox->addWidget( lab );
86  hbox->addWidget( alignment );
87 
88  lay->addLayout( hbox );
89 
90  sep = new KSeparator;
91  lay->addWidget( sep );
92 
93  hbox = new QHBoxLayout;
94  useBackgroundColor = new QCheckBox( i18n( "Background Color:" ) );
95 
96  hbox->addWidget( useBackgroundColor );
97  backgroundColor = new KColorButton;
98  backgroundColor->setDefaultColor(Qt::white);
99  hbox->addWidget( backgroundColor );
100  lay->addLayout(hbox);
101 
102  sep = new KSeparator;
103  lay->addWidget( sep );
104  backgroundColor->setEnabled(false);
105  q->connect( useBackgroundColor, SIGNAL(toggled(bool)),
106  backgroundColor, SLOT(setEnabled(bool)) );
107 
108  }
109 
110  QCheckBox *useBackgroundColor;
111  KColorButton *backgroundColor;
112  KComboBox *alignment;
113  QSpinBox *spacing;
114  QSpinBox *padding;
115  KPIMTextEdit::InsertTableWidget *tableWidget;
116  TableFormatDialog *q;
117 };
118 
119 TableFormatDialog::TableFormatDialog( QWidget *parent )
120  : KDialog( parent ), d( new TableFormatDialogPrivate( this ) )
121 {
122 }
123 
124 TableFormatDialog::~TableFormatDialog()
125 {
126  delete d;
127 }
128 
129 int TableFormatDialog::columns() const
130 {
131  return d->tableWidget->columns();
132 }
133 
134 int TableFormatDialog::rows() const
135 {
136  return d->tableWidget->rows();
137 }
138 
139 int TableFormatDialog::border() const
140 {
141  return d->tableWidget->border();
142 }
143 
144 void TableFormatDialog::setColumns( int col )
145 {
146  d->tableWidget->setColumns( col );
147 }
148 
149 void TableFormatDialog::setRows( int row )
150 {
151  d->tableWidget->setRows( row );
152 }
153 
154 void TableFormatDialog::setBorder( int border )
155 {
156  d->tableWidget->setBorder( border );
157 }
158 
159 int TableFormatDialog::padding() const
160 {
161  return d->padding->value();
162 }
163 
164 void TableFormatDialog::setPadding( int value )
165 {
166  d->padding->setValue( value );
167 }
168 
169 int TableFormatDialog::spacing() const
170 {
171  return d->spacing->value();
172 }
173 
174 void TableFormatDialog::setSpacing( int value )
175 {
176  d->spacing->setValue( value );
177 }
178 
179 void TableFormatDialog::setAlignment( Qt::Alignment alignment )
180 {
181  d->alignment->setCurrentIndex( d->alignment->findData( QVariant( alignment ) ) );
182 }
183 
184 Qt::Alignment TableFormatDialog::alignment() const
185 {
186  return ( Qt::Alignment )d->alignment->itemData( d->alignment->currentIndex () ).toInt();
187 }
188 
189 QTextLength::Type TableFormatDialog::typeOfLength() const
190 {
191  return d->tableWidget->typeOfLength();
192 }
193 
194 int TableFormatDialog::length() const
195 {
196  return d->tableWidget->length();
197 }
198 
199 void TableFormatDialog::setLength( int val )
200 {
201  d->tableWidget->setLength( val );
202 }
203 
204 void TableFormatDialog::setTypeOfLength( QTextLength::Type type )
205 {
206  d->tableWidget->setTypeOfLength( type );
207 }
208 
209 QColor TableFormatDialog::tableBackgroundColor() const
210 {
211  return d->backgroundColor->color();
212 }
213 
214 void TableFormatDialog::setTableBackgroundColor( const QColor &col )
215 {
216  d->backgroundColor->setColor( col );
217  d->useBackgroundColor->setChecked( true );
218 }
219 
220 bool TableFormatDialog::useBackgroundColor() const
221 {
222  return d->useBackgroundColor->isChecked();
223 }
224 
QSpinBox::setMinimum
void setMinimum(int min)
QWidget
QHBoxLayout
Qt::Alignment
typedef Alignment
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QCheckBox
QVBoxLayout
QColor
QSpinBox
QLabel
QBoxLayout::addLayout
void addLayout(QLayout *layout, int stretch)
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:37:23 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KPIMTextedit Library

Skip menu "KPIMTextedit Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Members
  • File List
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal