• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Property Editing Library
 

KDevelop Property Editing Library

  • lib
  • widgets
  • propeditor
psymbolcombo.cpp
1 /***************************************************************************
2  * Copyright (C) 2002-2004 by Alexander Dymo *
3  * cloudtemple@mskat.net *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU Library General Public License as *
7  * published by the Free Software Foundation; either version 2 of the *
8  * License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU Library General Public *
16  * License along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #include <tqlayout.h>
22 #include <tqpainter.h>
23 #include <tqpushbutton.h>
24 #include <klineedit.h>
25 
26 #ifndef PURE_QT
27 #include <kcharselect.h>
28 #include <tdelocale.h>
29 #include <kpushbutton.h>
30 #include <kstdguiitem.h>
31 #include <tqdialog.h>
32 #endif
33 
34 #include "psymbolcombo.h"
35 
36 namespace PropertyLib{
37 
38 PSymbolCombo::PSymbolCombo(MultiProperty *property, TQWidget *parent, const char *name)
39  :PropertyWidget(property, parent, name)
40 {
41  l = new TQHBoxLayout(this);
42  m_edit = new KLineEdit(this);
43  m_edit->setSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding);
44  m_edit->setMaxLength(1);
45  l->addWidget(m_edit);
46  m_select = new TQPushButton("...", this);
47  m_select->setSizePolicy(TQSizePolicy::Maximum, TQSizePolicy::MinimumExpanding);
48  l->addWidget(m_select);
49 
50 #ifdef PURE_QT
51  m_select->hide();
52 #endif
53 
54  connect(m_select, TQT_SIGNAL(clicked()), this, TQT_SLOT(selectChar()));
55  connect(m_edit, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(updateProperty(const TQString&)));
56 }
57 
58 TQVariant PSymbolCombo::value() const
59 {
60  if (!(m_edit->text().isNull()))
61  return TQVariant(TQString("%1").arg(m_edit->text().at(0).unicode()));
62  else
63  return TQVariant(0);
64 }
65 
66 void PSymbolCombo::setValue(const TQVariant &value, bool emitChange)
67 {
68  if (!(value.isNull()))
69  {
70  disconnect(m_edit, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(updateProperty(const TQString&)));
71  m_edit->setText(TQChar(value.toInt()));
72  connect(m_edit, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(updateProperty(const TQString&)));
73  if (emitChange)
74  emit propertyChanged(m_property, value);
75  }
76 }
77 
78 void PSymbolCombo::selectChar()
79 {
80 #ifndef PURE_QT
81  TQDialog* dia = new TQDialog(this, "select_dialog", true);
82  TQVBoxLayout *dv = new TQVBoxLayout(dia, 2);
83 
84  KCharSelect *select = new KCharSelect(dia, "select_char");
85  dv->addWidget(select);
86 
87  TQHBoxLayout *dh = new TQHBoxLayout(dv, 6);
88  KPushButton *pbOk = new KPushButton(KStdGuiItem::ok(), dia);
89  KPushButton *pbCancel = new KPushButton(KStdGuiItem::cancel(), dia);
90  TQSpacerItem *si = new TQSpacerItem(30, 0, TQSizePolicy::Expanding, TQSizePolicy::Expanding);
91 
92  connect(pbOk, TQT_SIGNAL(clicked()), dia, TQT_SLOT(accept()));
93  connect(pbCancel, TQT_SIGNAL(clicked()), dia, TQT_SLOT(reject()));
94 
95  dh->addItem(si);
96  dh->addWidget(pbOk);
97  dh->addWidget(pbCancel);
98 
99  if (!(m_edit->text().isNull()))
100  select->setChar(m_edit->text().at(0));
101 
102  if (dia->exec() == TQDialog::Accepted)
103  {
104  m_edit->setText(select->chr());
105  }
106  delete dia;
107 #endif
108 }
109 
110 void PSymbolCombo::updateProperty(const TQString& val)
111 {
112  emit propertyChanged(m_property, TQVariant(TQString("%1").arg(val.at(0).unicode())));
113 }
114 
115 void PSymbolCombo::drawViewer(TQPainter *p, const TQColorGroup &cg, const TQRect &r, const TQVariant &value)
116 {
117  p->setBrush(cg.background());
118  p->setPen(TQt::NoPen);
119  p->drawRect(r);
120  p->drawText(r, TQt::AlignLeft | TQt::AlignVCenter | TQt::SingleLine, TQChar(value.toInt()));
121 }
122 
123 }
124 
125 #ifndef PURE_QT
126 #include "psymbolcombo.moc"
127 #endif
PropertyLib::PSymbolCombo::setValue
virtual void setValue(const TQVariant &value, bool emitChange=true)
Sets the value shown in the editor widget.
Definition: psymbolcombo.cpp:66
PropertyLib
Namespace which contain property editing classes.
Definition: childproperty.cpp:29
PropertyLib::PStringListEdit::value
virtual TQVariant value() const
Definition: pstringlistedit.cpp:55
PropertyLib::PSymbolCombo::drawViewer
virtual void drawViewer(TQPainter *p, const TQColorGroup &cg, const TQRect &r, const TQVariant &value)
Function to draw a property viewer when the editor isn&#39;t shown.
Definition: psymbolcombo.cpp:115
PropertyLib::PropertyWidget::propertyChanged
void propertyChanged(MultiProperty *property, const TQVariant &value)
Emit this signal when property value is changed.
PropertyLib::PSymbolCombo::value
virtual TQVariant value() const
Definition: psymbolcombo.cpp:58

KDevelop Property Editing Library

Skip menu "KDevelop Property Editing Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

KDevelop Property Editing Library

Skip menu "KDevelop Property Editing Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Property Editing Library by doxygen 1.8.13
This website is maintained by Timothy Pearson.