UrlComboBox.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2015 by Ralf Kaestner *
3  * ralf.kaestner@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the Lesser GNU General Public License as published by*
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (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  * Lesser GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the Lesser GNU General Public License *
16  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17  ******************************************************************************/
18 
19 #include <QLineEdit>
20 
22 
23 namespace rqt_multiplot {
24 
25 /*****************************************************************************/
26 /* Constructors and Destructor */
27 /*****************************************************************************/
28 
29 UrlComboBox::UrlComboBox(QWidget* parent) :
30  QComboBox(parent),
31  completer_(new UrlCompleter(this)) {
32  connect(this, SIGNAL(activated(int)), this, SLOT(activated(int)));
33  connect(this, SIGNAL(currentIndexChanged(const QString&)), this,
34  SLOT(currentIndexChanged(const QString&)));
35 }
36 
38 }
39 
40 /*****************************************************************************/
41 /* Accessors */
42 /*****************************************************************************/
43 
44 void UrlComboBox::setEditable(bool editable) {
45  if (editable != QComboBox::isEditable()) {
46  QComboBox::setEditable(editable);
47 
48  if (lineEdit()) {
49  lineEdit()->setCompleter(completer_);
50 
51  connect(lineEdit(), SIGNAL(editingFinished()), this,
52  SLOT(lineEditEditingFinished()));
53  }
54  }
55 }
56 
58  return completer_;
59 }
60 
61 void UrlComboBox::setCurrentUrl(const QString& url) {
62  int index = findText(url);
63 
64  if (index < 0) {
65  setEditText(url);
67  }
68  else
69  setCurrentIndex(index);
70 }
71 
72 QString UrlComboBox::getCurrentUrl() const {
73  return currentUrl_;
74 }
75 
77  return (findText(currentUrl_) >= 0);
78 }
79 
80 /*****************************************************************************/
81 /* Slots */
82 /*****************************************************************************/
83 
84 void UrlComboBox::activated(int index) {
85  if (currentUrl_ != itemText(index)) {
86  currentUrl_ = itemText(index);
87 
89  }
90 }
91 
92 void UrlComboBox::currentIndexChanged(const QString& text) {
93  if (currentUrl_ != text) {
94  currentUrl_ = text;
95 
97  }
98 }
99 
101  if (currentUrl_ != currentText()) {
102  currentUrl_ = currentText();
103 
105  }
106 }
107 
108 }
UrlComboBox(QWidget *parent=0)
Definition: UrlComboBox.cpp:29
void currentUrlChanged(const QString &url)
UrlCompleter * completer_
Definition: UrlComboBox.h:46
void activated(int index)
Definition: UrlComboBox.cpp:84
bool isCurrentUrlSelectable() const
Definition: UrlComboBox.cpp:76
void setEditable(bool editable)
Definition: UrlComboBox.cpp:44
UrlCompleter * getCompleter() const
Definition: UrlComboBox.cpp:57
void currentIndexChanged(const QString &text)
Definition: UrlComboBox.cpp:92
void setCurrentUrl(const QString &url)
Definition: UrlComboBox.cpp:61
QString getCurrentUrl() const
Definition: UrlComboBox.cpp:72


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Wed Jul 10 2019 03:49:44