Qt Virtual Chart Table (QVCT)
CRouteContainerEditView.cpp
Go to the documentation of this file.
1 // INDENTING (emacs/vi): -*- mode:c++; tab-width:2; c-basic-offset:2; intent-tabs-mode:nil; -*- ex: set tabstop=2 expandtab:
2 
3 /*
4  * Qt Virtual Chart Table (QVCT)
5  * Copyright (C) 2012 Cedric Dufour <http://cedric.dufour.name>
6  * Author: Cedric Dufour <http://cedric.dufour.name>
7  *
8  * The Qt Virtual Chart Table (QVCT) is free software:
9  * you can redistribute it and/or modify it under the terms of the GNU General
10  * Public License as published by the Free Software Foundation, Version 3.
11  *
12  * The Qt Virtual Chart Table (QVCT) is distributed in the hope
13  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU General Public License for more details.
17  */
18 
19 // QT
20 #include <QDialogButtonBox>
21 #include <QFormLayout>
22 #include <QHBoxLayout>
23 #include <QLabel>
24 #include <QLineEdit>
25 #include <QVBoxLayout>
26 
27 // QVCT
31 
32 
33 //------------------------------------------------------------------------------
34 // CONSTRUCTORS / DESTRUCTOR
35 //------------------------------------------------------------------------------
36 
38  : COverlayObjectEditView( _poRouteContainer )
39 {
41 }
42 
44 {
45  // Create layout
46  QVBoxLayout* __pqVBoxLayout = new QVBoxLayout();
47 
48  // Add header
49  QFont __qFontHeader;
50  __qFontHeader.setPixelSize( 16 );
51  __qFontHeader.setBold( true );
52  QHBoxLayout* __pqHBoxLayoutHeader = new QHBoxLayout();
53  QLabel* __pqLabelIcon = new QLabel();
54  __pqLabelIcon->setPixmap( QPixmap( ":icons/32x32/route.png" ) );
55  __pqHBoxLayoutHeader->addWidget( __pqLabelIcon, 0, Qt::AlignTop );
56  QLabel* __pqLabelEdit = new QLabel( tr("Edit")+"..." );
57  __pqLabelEdit->setFont( __qFontHeader );
58  __pqHBoxLayoutHeader->addWidget( __pqLabelEdit, 1 );
59  // ... [end]
60  __pqVBoxLayout->addLayout( __pqHBoxLayoutHeader );
61 
62  // Add data
63  CRouteContainer* __poRouteContainer = (CRouteContainer*)poOverlayObject;
64  QFormLayout* __pqFormLayout = new QFormLayout();
65 
66  // ... name
67  pqLineEditName = new QLineEdit();
68  pqLineEditName->setToolTip( tr("Name") );
69  pqLineEditName->setText( __poRouteContainer->getName() );
70  __pqFormLayout->addRow( tr("Name")+":", pqLineEditName );
71 
72  // ... type
73  pqLineEditType = new QLineEdit();
74  pqLineEditType->setToolTip( tr("Type") );
75  pqLineEditType->setText( __poRouteContainer->getType() );
76  __pqFormLayout->addRow( tr("Type")+":", pqLineEditType );
77 
78  // ... description
79  pqTextEditDescription = new QTextEdit();
80  pqTextEditDescription->setToolTip( tr("Description") );
81  pqTextEditDescription->setAcceptRichText( false );
82  pqTextEditDescription->setPlainText( __poRouteContainer->getDescription() );
83  __pqFormLayout->addRow( tr("Description")+":", pqTextEditDescription );
84 
85  // ... comment
86  pqTextEditComment = new QTextEdit();
87  pqTextEditComment->setToolTip( tr("Comment") );
88  pqTextEditComment->setAcceptRichText( false );
89  pqTextEditComment->setPlainText( __poRouteContainer->getComment() );
90  __pqFormLayout->addRow( tr("Comment")+":", pqTextEditComment );
91 
92  // ... url
93  pqLineEditUrl = new QLineEdit();
94  pqLineEditUrl->setToolTip( tr("URL") );
95  pqLineEditUrl->setText( __poRouteContainer->getUrl() );
96  __pqFormLayout->addRow( tr("URL")+":", pqLineEditUrl );
97 
98  // ... [end]
99  __pqVBoxLayout->addLayout( __pqFormLayout );
100 
101  // Add buttons
102  QDialogButtonBox* __pqDialogButtonBox = new QDialogButtonBox( QDialogButtonBox::Cancel|QDialogButtonBox::Save, Qt::Horizontal );
103  QDialog::connect( __pqDialogButtonBox, SIGNAL(accepted()), this, SLOT(accept()) );
104  QDialog::connect( __pqDialogButtonBox, SIGNAL(rejected()), this, SLOT(reject()) );
105  __pqVBoxLayout->addWidget( __pqDialogButtonBox );
106 
107  // Set the layout
108  COverlayObjectEditView::setLayout( __pqVBoxLayout );
109 
110 }
111 
112 
113 //------------------------------------------------------------------------------
114 // METHODS: QDialog (override)
115 //------------------------------------------------------------------------------
116 
118 {
119  CRouteContainer* __poRouteContainer = (CRouteContainer*)poOverlayObject;
120 
121  // Set data
122  // ... name
123  __poRouteContainer->setText( CRouteOverlay::NAME, pqLineEditName->text() ); // NOTE: Container's name will be updated via QTreeWidget::containerChanged()
124  // ... type
125  __poRouteContainer->setType( pqLineEditType->text() );
126  // ... description
127  __poRouteContainer->setDescription( pqTextEditDescription->toPlainText() );
128  // ... comment
129  __poRouteContainer->setComment( pqTextEditComment->toPlainText() );
130  // ... url
131  __poRouteContainer->setUrl( pqLineEditUrl->text() );
132 
133  // Done
134  QDialog::accept();
135 }
[UI] Generic overlay object's edit view
const COverlayObject * poOverlayObject
Overlay object being edited.
QString getName() const
Returns this object's name.
QLineEdit * pqLineEditUrl
[UI:LineEdit] URL
QLineEdit * pqLineEditName
[UI:LineEdit] Name
QTextEdit * pqTextEditDescription
[UI:TextEdit] Description
QLineEdit * pqLineEditType
[UI:LineEdit] Type
QTextEdit * pqTextEditComment
[UI:TextEdit] Comment
void constructLayout()
Constructs the layout of the user-interface.
CRouteContainerEditView(CRouteContainer *_poRouteContainer)
[UI] Route overlay container
void setType(const QString &_rqsType)
Sets this route's type.
void setComment(const QString &_rqsComment)
Sets this route's comment.
void setDescription(const QString &_rqsDescription)
Sets this route's description.
QString getUrl() const
Returns this route's URL.
QString getType() const
Returns this route's type.
QString getDescription() const
Returns this route's description.
QString getComment() const
Returns this route's comment.
void setUrl(const QString &_rqsUrl)
Sets this route's URL.
@ NAME
Route name.