• 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
inserttabledialog.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 "inserttabledialog.h"
22 
23 #include <KLocalizedString>
24 #include <KComboBox>
25 #include <KDebug>
26 #include <KSeparator>
27 
28 #include <QSpinBox>
29 #include <QFormLayout>
30 
31 using namespace KPIMTextEdit;
32 
33 class InsertTableWidget::InsertTableWidgetPrivate
34 {
35  public:
36  InsertTableWidgetPrivate( InsertTableWidget *qq )
37  :q( qq )
38  {
39  mRows = new QSpinBox;
40  mRows->setMinimum( 1 );
41  mRows->setValue( 2 );
42 
43  mColumns = new QSpinBox;
44  mColumns->setMinimum( 1 );
45  mColumns->setValue( 2 );
46 
47  mBorder = new QSpinBox;
48  mBorder->setMinimum( 0 );
49  mBorder->setValue( 1 );
50  mBorder->setSuffix( i18n( " px" ) );
51 
52  QFormLayout *formLayout = new QFormLayout;
53  formLayout->addRow( i18n( "Rows:" ), mRows );
54  formLayout->addRow( i18n( "Columns:" ), mColumns );
55  formLayout->addRow( i18n( "Border:" ), mBorder );
56 
57  QHBoxLayout *lay = new QHBoxLayout;
58  mTypeOfLength = new KComboBox;
59  q->connect( mTypeOfLength, SIGNAL(activated(int)),q,SLOT(slotTypeOfLengthChanged(int)) );
60  // xgettext: no-c-format
61  mTypeOfLength->addItem( i18n( "% of windows" ), QTextLength::PercentageLength );
62  mTypeOfLength->addItem( i18n( "pixels" ), QTextLength::FixedLength );
63  mLength = new QSpinBox;
64  mLength->setMinimum( 1 );
65  mLength->setMaximum( 100 );
66  mLength->setValue( 100 );
67  lay->addWidget( mLength );
68  lay->addWidget( mTypeOfLength );
69 
70  formLayout->addRow( i18n( "Width:" ), lay );
71  q->setLayout( formLayout );
72  }
73 
74  QSpinBox *mColumns;
75  QSpinBox *mRows;
76  QSpinBox *mBorder;
77  QSpinBox *mLength;
78  KComboBox *mTypeOfLength;
79 
80  InsertTableWidget *q;
81 };
82 
83 InsertTableWidget::InsertTableWidget( QWidget *parent )
84  : QWidget( parent ), d( new InsertTableWidgetPrivate( this ) )
85 {
86 }
87 
88 InsertTableWidget::~InsertTableWidget()
89 {
90  delete d;
91 }
92 
93 void InsertTableWidget::slotTypeOfLengthChanged( int index )
94 {
95  switch ( index ) {
96  case 0:
97  d->mLength->setMaximum( 100 );
98  d->mLength->setValue( qMin( d->mLength->value(), 100 ) );
99  break;
100  case 1:
101  d->mLength->setMaximum( 9999 );
102  break;
103  default:
104  kDebug() << " index not defined " << index;
105  break;
106  }
107 }
108 
109 QTextLength::Type InsertTableWidget::typeOfLength() const
110 {
111  return
112  ( QTextLength::Type )d->mTypeOfLength->itemData(
113  d->mTypeOfLength->currentIndex() ).toInt();
114 }
115 
116 void InsertTableWidget::setTypeOfLength( QTextLength::Type type )
117 {
118  const int index = d->mTypeOfLength->findData( QVariant( type ) );
119  d->mTypeOfLength->setCurrentIndex( index );
120  slotTypeOfLengthChanged( index );
121 }
122 
123 int InsertTableWidget::length() const
124 {
125  return d->mLength->value();
126 }
127 
128 void InsertTableWidget::setLength( int val )
129 {
130  d->mLength->setValue(val);
131 }
132 
133 void InsertTableWidget::setColumns( int col )
134 {
135  d->mColumns->setValue( col );
136 }
137 
138 void InsertTableWidget::setRows( int rows )
139 {
140  d->mRows->setValue( rows );
141 }
142 
143 void InsertTableWidget::setBorder( int border )
144 {
145  d->mBorder->setValue( border );
146 }
147 
148 int InsertTableWidget::columns() const
149 {
150  return d->mColumns->value();
151 }
152 
153 int InsertTableWidget::rows() const
154 {
155  return d->mRows->value();
156 }
157 
158 int InsertTableWidget::border() const
159 {
160  return d->mBorder->value();
161 }
162 
163 class InsertTableDialog::InsertTableDialogPrivate
164 {
165  public:
166  InsertTableDialogPrivate( InsertTableDialog *qq )
167  : q( qq )
168  {
169  q->setCaption( i18n( "Insert Table" ) );
170  q->setButtons( Ok|Cancel );
171  q->setButtonText( KDialog::Ok, i18n( "Insert" ) );
172  QWidget *page = new QWidget;
173  QVBoxLayout *lay = new QVBoxLayout;
174  page->setLayout(lay);
175  insertTableWidget = new InsertTableWidget;
176  lay->addWidget(insertTableWidget);
177  KSeparator *sep = new KSeparator;
178  lay->addWidget( sep );
179 
180  q->setMainWidget( page );
181  }
182 
183  InsertTableWidget *insertTableWidget;
184  InsertTableDialog *q;
185 };
186 
187 InsertTableDialog::InsertTableDialog( QWidget *parent )
188  : KDialog( parent ), d( new InsertTableDialogPrivate( this ) )
189 {
190 }
191 
192 InsertTableDialog::~InsertTableDialog()
193 {
194  delete d;
195 }
196 
197 int InsertTableDialog::columns() const
198 {
199  return d->insertTableWidget->columns();
200 }
201 
202 int InsertTableDialog::rows() const
203 {
204  return d->insertTableWidget->rows();
205 }
206 
207 int InsertTableDialog::border() const
208 {
209  return d->insertTableWidget->border();
210 }
211 
212 QTextLength::Type InsertTableDialog::typeOfLength() const
213 {
214  return d->insertTableWidget->typeOfLength();
215 }
216 
217 int InsertTableDialog::length() const
218 {
219  return d->insertTableWidget->length();
220 }
221 
222 void InsertTableDialog::setColumns( int col )
223 {
224  d->insertTableWidget->setColumns( col );
225 }
226 
227 void InsertTableDialog::setRows( int rows )
228 {
229  d->insertTableWidget->setRows( rows );
230 }
231 
232 void InsertTableDialog::setBorder( int border )
233 {
234  d->insertTableWidget->setBorder( border );
235 }
236 
237 void InsertTableDialog::setLength( int val )
238 {
239  d->insertTableWidget->setLength( val );
240 }
241 
242 void InsertTableDialog::setTypeOfLength( QTextLength::Type type )
243 {
244  d->insertTableWidget->setTypeOfLength( type );
245 }
QSpinBox::setMinimum
void setMinimum(int min)
QWidget
QHBoxLayout
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QWidget::setLayout
void setLayout(QLayout *layout)
QVBoxLayout
QFormLayout::addRow
void addRow(QWidget *label, QWidget *field)
QSpinBox
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QFormLayout
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