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

KPIMTextedit Library

  • 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 <KLocale>
24 #include <KComboBox>
25 #include <KDebug>
26 #include <QSpinBox>
27 #include <QFormLayout>
28 
29 
30 using namespace KPIMTextEdit;
31 
32 class InsertTableWidget::InsertTableWidgetPrivate
33 {
34 public:
35  InsertTableWidgetPrivate(InsertTableWidget *qq)
36  :q( qq )
37  {
38  mRows = new QSpinBox;
39  mRows->setMinimum( 1 );
40  mRows->setValue( 2 );
41 
42  mColumns = new QSpinBox;
43  mColumns->setMinimum( 1 );
44  mColumns->setValue( 2 );
45 
46  mBorder = new QSpinBox;
47  mBorder->setMinimum( 0 );
48  mBorder->setValue( 1 );
49  mBorder->setSuffix( i18n( " px" ) );
50 
51  QFormLayout *formLayout = new QFormLayout;
52  formLayout->addRow( i18n( "Rows:" ), mRows );
53  formLayout->addRow( i18n( "Columns:" ), mColumns );
54  formLayout->addRow( i18n( "Border:" ), mBorder );
55 
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 (QTextLength::Type)d->mTypeOfLength->itemData( d->mTypeOfLength->currentIndex() ).toInt();
112 }
113 
114 void InsertTableWidget::setTypeOfLength(QTextLength::Type type)
115 {
116  const int index = d->mTypeOfLength->findData(QVariant(type));
117  d->mTypeOfLength->setCurrentIndex(index);
118  slotTypeOfLengthChanged(index);
119 }
120 
121 
122 int InsertTableWidget::length() const
123 {
124  return d->mLength->value();
125 }
126 
127 void InsertTableWidget::setLength(int val)
128 {
129  d->mLength->setValue(val);
130 }
131 
132 void InsertTableWidget::setColumns(int col)
133 {
134  d->mColumns->setValue( col );
135 }
136 
137 void InsertTableWidget::setRows(int rows)
138 {
139  d->mRows->setValue( rows );
140 }
141 
142 void InsertTableWidget::setBorder(int border)
143 {
144  d->mBorder->setValue( border );
145 }
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 
164 class InsertTableDialog::InsertTableDialogPrivate
165 {
166 public:
167  InsertTableDialogPrivate(InsertTableDialog *qq)
168  :q( qq )
169  {
170  q->setCaption( i18n( "Insert Table" ) );
171  q->setButtons( Ok|Cancel );
172  q->setButtonText( KDialog::Ok, i18n( "Insert" ) );
173  insertTableWidget = new InsertTableWidget( q );
174  q->setMainWidget( insertTableWidget );
175  }
176  InsertTableWidget *insertTableWidget;
177  InsertTableDialog *q;
178 };
179 
180 InsertTableDialog::InsertTableDialog(QWidget *parent)
181  : KDialog( parent ), d( new InsertTableDialogPrivate( this ) )
182 {
183 }
184 
185 InsertTableDialog::~InsertTableDialog()
186 {
187  delete d;
188 }
189 
190 int InsertTableDialog::columns() const
191 {
192  return d->insertTableWidget->columns();
193 }
194 
195 int InsertTableDialog::rows() const
196 {
197  return d->insertTableWidget->rows();
198 }
199 
200 int InsertTableDialog::border() const
201 {
202  return d->insertTableWidget->border();
203 }
204 
205 QTextLength::Type InsertTableDialog::typeOfLength() const
206 {
207  return d->insertTableWidget->typeOfLength();
208 }
209 
210 int InsertTableDialog::length() const
211 {
212  return d->insertTableWidget->length();
213 }
214 
215 void InsertTableDialog::setColumns(int col)
216 {
217  d->insertTableWidget->setColumns(col);
218 }
219 
220 void InsertTableDialog::setRows(int rows)
221 {
222  d->insertTableWidget->setRows(rows);
223 }
224 
225 void InsertTableDialog::setBorder(int border)
226 {
227  d->insertTableWidget->setBorder(border);
228 }
229 
230 void InsertTableDialog::setLength(int val)
231 {
232  d->insertTableWidget->setLength(val);
233 }
234 
235 void InsertTableDialog::setTypeOfLength(QTextLength::Type type)
236 {
237  d->insertTableWidget->setTypeOfLength(type);
238 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:26:01 by doxygen 1.8.3.1 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-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 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
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