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

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • annotate
TextEditor.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2009 Andrew Manson <g.real.ate@gmail.com>
9 // Copyright 2013 Thibaut Gridel <tgridel@free.fr>
10 //
11 
12 #include "TextEditor.h"
13 
14 #include "GeoDataPlacemark.h"
15 #include "MarbleDebug.h"
16 
17 #include <QAction>
18 #include <QApplication>
19 #include <QLineEdit>
20 #include <QToolButton>
21 #include <QTextEdit>
22 #include <QHBoxLayout>
23 
24 
25 namespace Marble
26 {
27 
28 TextEditor::TextEditor( GeoDataPlacemark *placemark )
29  : QWidget(),
30  m_placemark( placemark )
31 {
32  setCursor( Qt::ArrowCursor );
33 
34  m_buttonLayout = new QHBoxLayout;
35  m_layout = new QVBoxLayout;
36 
37  /*
38  * Note: these widgets do not need to be constructed with a parent
39  * as adding them to a layout automatically sets the parent. If a
40  * parent is already set it will mess up the layouts.
41  */
42  m_description = new QTextEdit;
43  m_description->setText( placemark->description() );
44  m_description->setMinimumHeight( 50 );
45  m_description->setSizePolicy( QSizePolicy::Fixed,
46  QSizePolicy::MinimumExpanding );
47  m_description->viewport()->setSizePolicy( QSizePolicy::Fixed,
48  QSizePolicy::MinimumExpanding );
49  m_description->viewport()->setAutoFillBackground( true );
50  QApplication::setPalette( QPalette() );
51  m_description->setBackgroundRole( QPalette::Window );
52  connect( m_description, SIGNAL(textChanged()),
53  this, SLOT(updateDescription()) );
54 
55  m_name = new QLineEdit;
56  m_name->setText( placemark->name() );
57  connect( m_name, SIGNAL(textChanged(QString)),
58  this, SLOT(updateName()) );
59 
60  // setup the actions and create the buttons
61  m_boldAction = new QAction( this );
62  m_boldAction->setText( tr("Bold") );
63  m_boldButton = new QToolButton;
64  m_boldButton->setDefaultAction( m_boldAction );
65 
66  m_italicAction = new QAction( this );
67  m_italicAction->setText( tr("Italic") );
68  m_italicButton = new QToolButton;
69  m_italicButton->setDefaultAction( m_italicAction );
70 
71  m_underLineAction = new QAction( this );
72  m_underLineAction->setText( tr("Underline") );
73  m_underLineButton = new QToolButton;
74  m_underLineButton->setDefaultAction( m_underLineAction );
75 
76  //add them all to their correct places
77  m_buttonLayout->addWidget( m_boldButton );
78  m_buttonLayout->addWidget( m_italicButton );
79  m_buttonLayout->addWidget( m_underLineButton );
80 
81  m_layout->addWidget( m_name );
82  m_layout->addLayout( m_buttonLayout );
83  m_layout->addWidget( m_description );
84 
85  setLayout( m_layout );
86  setMaximumWidth( 250 );
87  setMinimumHeight( 50 );
88  setSizePolicy( QSizePolicy::Fixed, QSizePolicy::MinimumExpanding );
89 }
90 
91 TextEditor::~TextEditor()
92 {
93  // nothing to do
94 }
95 
96 void TextEditor::updateName()
97 {
98  m_placemark->setName( m_name->text() );
99 }
100 
101 void TextEditor::updateDescription()
102 {
103  m_placemark->setDescription( m_description->toHtml() );
104 }
105 
106 }
107 
108 #include "TextEditor.moc"
QAction::setText
void setText(const QString &text)
Marble::TextEditor::~TextEditor
~TextEditor()
Definition: TextEditor.cpp:91
QWidget
QWidget::setCursor
void setCursor(const QCursor &)
QLineEdit::setText
void setText(const QString &)
QToolButton::setDefaultAction
void setDefaultAction(QAction *action)
QTextEdit::toHtml
QString toHtml() const
Marble::GeoDataFeature::setDescription
void setDescription(const QString &value)
Set the description of this feature to value.
Definition: GeoDataFeature.cpp:593
QHBoxLayout
Marble::GeoDataFeature::description
QString description() const
Return the text description of the feature.
Definition: GeoDataFeature.cpp:588
QAbstractScrollArea::viewport
QWidget * viewport() const
MarbleDebug.h
QObject::tr
QString tr(const char *sourceText, const char *disambiguation, int n)
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
TextEditor.h
QWidget::setLayout
void setLayout(QLayout *layout)
Marble::GeoDataFeature::setName
void setName(const QString &value)
Set a new name for this feature.
Definition: GeoDataFeature.cpp:549
QApplication::setPalette
void setPalette(const QPalette &palette, const char *className)
Marble::TextEditor::TextEditor
TextEditor(GeoDataPlacemark *placemark)
Definition: TextEditor.cpp:28
QVBoxLayout
QString
GeoDataPlacemark.h
QWidget::setSizePolicy
void setSizePolicy(QSizePolicy)
Marble::TextEditor::updateDescription
void updateDescription()
Definition: TextEditor.cpp:101
QToolButton
QWidget::setMaximumWidth
void setMaximumWidth(int maxw)
Marble::GeoDataFeature::name
QString name() const
The name of the feature.
Definition: GeoDataFeature.cpp:544
Marble::TextEditor::updateName
void updateName()
Definition: TextEditor.cpp:96
QAction
QWidget::setMinimumHeight
void setMinimumHeight(int minh)
QWidget::setAutoFillBackground
void setAutoFillBackground(bool enabled)
QLineEdit
QWidget::setBackgroundRole
void setBackgroundRole(QPalette::ColorRole role)
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QTextEdit
QTextEdit::setText
void setText(const QString &text)
Marble::GeoDataPlacemark
a class representing a point of interest on the map
Definition: GeoDataPlacemark.h:54
QPalette
QBoxLayout::addLayout
void addLayout(QLayout *layout, int stretch)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:42 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

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