CurveListWidget.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 <QKeyEvent>
20 
22 
23 namespace rqt_multiplot {
24 
25 /*****************************************************************************/
26 /* Constructors and Destructor */
27 /*****************************************************************************/
28 
30  QListWidget(parent) {
31 }
32 
34 }
35 
36 /*****************************************************************************/
37 /* Accessors */
38 /*****************************************************************************/
39 
41  return count();
42 }
43 
45  QListWidgetItem* widgetItem = item(index);
46 
47  if (widgetItem)
48  return static_cast<CurveItemWidget*>(itemWidget(widgetItem));
49  else
50  return 0;
51 }
52 
53 /*****************************************************************************/
54 /* Methods */
55 /*****************************************************************************/
56 
58  CurveItemWidget* itemWidget = new CurveItemWidget(this);
59  itemWidget->setConfig(config);
60 
61  QListWidgetItem* widgetItem = new QListWidgetItem(this);
62  widgetItem->setSizeHint(itemWidget->sizeHint());
63 
64  addItem(widgetItem);
65  setItemWidget(widgetItem, itemWidget);
66 
67  emit curveAdded(row(widgetItem));
68 }
69 
70 void CurveListWidget::removeCurve(size_t index) {
71  QListWidgetItem* widgetItem = item(index);
72 
73  if (widgetItem) {
74  delete widgetItem;
75 
76  emit curveRemoved(index);
77  }
78 }
79 
80 void CurveListWidget::keyPressEvent(QKeyEvent* event) {
81  if ((event->modifiers() == Qt::ControlModifier) &&
82  (event->key() == Qt::Key_A)) {
83  for (size_t index = 0; index < count(); ++index)
84  item(index)->setSelected(true);
85  }
86 
87  QListWidget::keyPressEvent(event);
88 }
89 
90 }
CurveListWidget(QWidget *parent=0)
void setConfig(CurveConfig *config)
void keyPressEvent(QKeyEvent *event)
void curveAdded(size_t index)
CurveItemWidget * getCurveItem(size_t index) const
void addCurve(CurveConfig *config)
void curveRemoved(size_t index)


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