MessageFieldLineEdit.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002  * Copyright (C) 2015 by Ralf Kaestner                                        *
00003  * ralf.kaestner@gmail.com                                                    *
00004  *                                                                            *
00005  * This program is free software; you can redistribute it and/or modify       *
00006  * it under the terms of the Lesser GNU General Public License as published by*
00007  * the Free Software Foundation; either version 3 of the License, or          *
00008  * (at your option) any later version.                                        *
00009  *                                                                            *
00010  * This program is distributed in the hope that it will be useful,            *
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the               *
00013  * Lesser GNU General Public License for more details.                        *
00014  *                                                                            *
00015  * You should have received a copy of the Lesser GNU General Public License   *
00016  * along with this program. If not, see <http://www.gnu.org/licenses/>.       *
00017  ******************************************************************************/
00018 
00019 #include <QCompleter>
00020 
00021 #include <variant_topic_tools/MessageVariable.h>
00022 
00023 #include "rqt_multiplot/MessageFieldLineEdit.h"
00024 
00025 namespace rqt_multiplot {
00026 
00027 /*****************************************************************************/
00028 /* Constructors and Destructor                                               */
00029 /*****************************************************************************/
00030 
00031 MessageFieldLineEdit::MessageFieldLineEdit(QWidget* parent) :
00032   QLineEdit(parent),
00033   completer_(new MessageFieldCompleter(this)),
00034   completerModel_(new MessageFieldItemModel(this)) {
00035   completer_->setModel(completerModel_);
00036   setCompleter(completer_);
00037     
00038   connect(this, SIGNAL(editingFinished()), this, SLOT(editingFinished()));
00039 }
00040 
00041 MessageFieldLineEdit::~MessageFieldLineEdit() {
00042 }
00043 
00044 /*****************************************************************************/
00045 /* Accessors                                                                 */
00046 /*****************************************************************************/
00047 
00048 void MessageFieldLineEdit::setMessageDataType(const variant_topic_tools::
00049     MessageDataType& dataType) {
00050   completerModel_->setMessageDataType(dataType);
00051 }
00052 
00053 variant_topic_tools::MessageDataType MessageFieldLineEdit::
00054     getMessageDataType() const {
00055   return completerModel_->getMessageDataType();
00056 }
00057 
00058 void MessageFieldLineEdit::setCurrentField(const QString& field) {
00059   if (field != currentField_) {
00060     currentField_ = field;
00061     
00062     setText(field);
00063     
00064     emit currentFieldChanged(currentField_);
00065   }
00066 }
00067 
00068 QString MessageFieldLineEdit::getCurrentField() const {
00069   return currentField_;
00070 }
00071 
00072 variant_topic_tools::DataType MessageFieldLineEdit::
00073     getCurrentFieldDataType() const {
00074   return completerModel_->getFieldDataType(currentField_);
00075 }
00076 
00077 bool MessageFieldLineEdit::isCurrentFieldDefined() const {
00078   return getCurrentFieldDataType().isValid();
00079 }
00080 
00081 /*****************************************************************************/
00082 /* Slots                                                                     */
00083 /*****************************************************************************/
00084 
00085 void MessageFieldLineEdit::editingFinished() {
00086   setCurrentField(text());
00087 }
00088 
00089 }


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Thu Jun 6 2019 21:49:11