Qt Virtual Chart Table (QVCT)
CTrackContainerEditView.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( _poTrackContainer )
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/track.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  CTrackContainer* __poTrackContainer = (CTrackContainer*)poOverlayObject;
64  QFormLayout* __pqFormLayout = new QFormLayout();
65 
66  // ... name
67  pqLineEditName = new QLineEdit();
68  pqLineEditName->setToolTip( tr("Name") );
69  pqLineEditName->setText( __poTrackContainer->getName() );
70  __pqFormLayout->addRow( tr("Name")+":", pqLineEditName );
71 
72  // ... type
73  pqLineEditType = new QLineEdit();
74  pqLineEditType->setToolTip( tr("Type") );
75  pqLineEditType->setText( __poTrackContainer->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( __poTrackContainer->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( __poTrackContainer->getComment() );
90  __pqFormLayout->addRow( tr("Comment")+":", pqTextEditComment );
91 
92  // ... url
93  pqLineEditUrl = new QLineEdit();
94  pqLineEditUrl->setToolTip( tr("URL") );
95  pqLineEditUrl->setText( __poTrackContainer->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  CTrackContainer* __poTrackContainer = (CTrackContainer*)poOverlayObject;
120 
121  // Set data
122  // ... name
123  __poTrackContainer->setText( CTrackOverlay::NAME, pqLineEditName->text() ); // NOTE: Container's name will be updated via QTreeWidget::containerChanged()
124  // ... type
125  __poTrackContainer->setType( pqLineEditType->text() );
126  // ... description
127  __poTrackContainer->setDescription( pqTextEditDescription->toPlainText() );
128  // ... comment
129  __poTrackContainer->setComment( pqTextEditComment->toPlainText() );
130  // ... url
131  __poTrackContainer->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
QTextEdit * pqTextEditComment
[UI:TextEdit] Comment
QLineEdit * pqLineEditType
[UI:LineEdit] Type
CTrackContainerEditView(CTrackContainer *_poTrackContainer)
QTextEdit * pqTextEditDescription
[UI:TextEdit] Description
void constructLayout()
Constructs the layout of the user-interface.
QLineEdit * pqLineEditName
[UI:LineEdit] Name
[UI] Track overlay container
QString getUrl() const
Returns this track's URL.
QString getType() const
Returns this track's type.
QString getDescription() const
Returns this track's description.
void setUrl(const QString &_rqsUrl)
Sets this track's URL.
void setType(const QString &_rqsType)
Sets this track's type.
void setComment(const QString &_rqsComment)
Sets this track's comment.
QString getComment() const
Returns this track's comment.
void setDescription(const QString &_rqsDescription)
Sets this track's description.
@ NAME
Track name.