7 #include <QTableWidget> 8 #include <QTableWidgetItem> 11 #include <QMessageBox> 12 #include <QAbstractItemView> 16 #include "ui_dialog_select_ros_topics.h" 23 ui(new
Ui::dialogSelectRosTopics),
24 _default_selected_topics(config.selected_topics),
25 _select_all(QKeySequence(
Qt::CTRL +
Qt::Key_A), this),
26 _deselect_all(QKeySequence(
Qt::CTRL +
Qt::SHIFT +
Qt::Key_A), this)
29 auto flags = this->windowFlags();
30 this->setWindowFlags(
flags | Qt::WindowStaysOnTopHint);
40 ui->radioMaxDiscard->setChecked(
true);
43 ui->radioMaxClamp->setChecked(
true);
47 labels.push_back(
"Topic name");
48 labels.push_back(
"Datatype");
50 ui->listRosTopics->setHorizontalHeaderLabels(labels);
51 ui->listRosTopics->verticalHeader()->setVisible(
false);
55 if(
ui->listRosTopics->rowCount() == 1)
57 ui->listRosTopics->selectRow(0);
59 ui->listRosTopics->setFocus();
65 ui->listRosTopics, &QAbstractItemView::selectAll );
68 ui->listRosTopics, &QAbstractItemView::clearSelection );
73 restoreGeometry(settings.value(
"DialogSelectRosTopics.geometry").toByteArray());
79 std::set<QString> newly_added;
82 for (
const auto& it: topic_list)
84 const QString& topic_name = it.first ;
85 const QString& type_name = it.second ;
88 for(
int r=0; r <
ui->listRosTopics->rowCount(); r++ )
90 const QTableWidgetItem *item =
ui->listRosTopics->item(r,0);
91 if( item->text() == topic_name){
99 int new_row =
ui->listRosTopics->rowCount();
100 ui->listRosTopics->setRowCount( new_row+1 );
103 ui->listRosTopics->setItem(new_row, 1,
new QTableWidgetItem( type_name ));
104 ui->listRosTopics->setItem(new_row, 0,
new QTableWidgetItem( topic_name ));
105 newly_added.insert(topic_name);
109 ui->listRosTopics->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
110 ui->listRosTopics->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
111 ui->listRosTopics->sortByColumn(0, Qt::AscendingOrder);
114 QModelIndexList selection =
ui->listRosTopics->selectionModel()->selectedRows();
116 for(
int row=0; row <
ui->listRosTopics->rowCount(); row++ )
118 const QTableWidgetItem *item =
ui->listRosTopics->item(row,0);
119 QString topic_name = item->text();
123 bool selected =
false;
124 for (
const auto& selected_item: selection)
126 if( selected_item.row() == row)
133 ui->listRosTopics->selectRow(row);
160 QModelIndexList selected_indexes =
ui->listRosTopics->selectionModel()->selectedIndexes();
161 QString selected_topics;
163 foreach(QModelIndex index, selected_indexes)
165 if(index.column() == 0){
166 _topic_list.push_back( index.data(Qt::DisplayRole).toString() );
174 QModelIndexList indexes =
ui->listRosTopics->selectionModel()->selectedIndexes();
176 ui->buttonBox->setEnabled( indexes.size() > 0) ;
182 ui->pushButtonEditRules->setEnabled( checked );
188 rule_editing->exec();
194 settings.setValue(
"DialogSelectRosTopics.geometry", saveGeometry());
199 for (
const auto& it: flat_msg.
value)
207 if( leaf2 && leaf2->
value() ==
"header" && leaf1->
value() ==
"stamp")
209 return it.second.convert<
double>();
218 msgBox.setWindowTitle(
"Help");
219 msgBox.setText(
"Maximum Size of Arrays:\n\n" 220 "If the size of an Arrays is larger than this maximum value, the entire array is skipped.\n\n" 221 "This parameter is used to prevent the user from loading HUGE arrays, " 222 "such as images, pointclouds, maps, etc.\n" 223 "The term 'array' refers to the array in a message field,\n\n" 224 " See http://wiki.ros.org/msg.\n\n" 225 "This is NOT about the duration of a time series!\n\n" 226 "MOTIVATION: pretend that a user tries to load a RGB image, which probably contains " 227 "a few millions pixels.\n" 228 "Plotjuggler would naively create a single time series for each pixel of the image! " 229 "That makes no sense, of course, and it would probably freeze your system.\n" 236 int visible_count = 0;
237 bool updated =
false;
239 QStringList spaced_items = search_string.split(
' ');
241 for (
int row=0; row <
ui->listRosTopics->rowCount(); row++)
243 auto item =
ui->listRosTopics->item(row,0);
244 QString
name = item->text();
248 for (
const auto& item: spaced_items)
250 if( !name.contains(item) )
256 ui->listRosTopics->setRowHidden(row, toHide );
264 ui->spinBoxArraySize->setStyleSheet(
"QSpinBox { color: red; }");
267 ui->spinBoxArraySize->setStyleSheet(
"QSpinBox { color: black; }");
void on_listRosTopics_itemSelectionChanged()
void updateTopicList(std::vector< std::pair< QString, QString >> topic_list)
bool discard_large_arrays
void on_lineEditFilter_textChanged(const QString &search_string)
void closeEvent(QCloseEvent *event) override
const TreeNode * parent() const
QStringList selected_topics
void on_spinBoxArraySize_valueChanged(int value)
void on_maximumSizeHelp_pressed()
void on_pushButtonEditRules_pressed()
void on_buttonBox_accepted()
QStringList _default_selected_topics
std::vector< std::pair< StringTreeLeaf, Variant > > value
Configuration getResult() const
void on_checkBoxEnableRules_toggled(bool checked)
Ui::dialogSelectRosTopics * ui
DialogSelectRosTopics(const std::vector< std::pair< QString, QString >> &topic_list, const Configuration &default_info, QWidget *parent=nullptr)
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)
~DialogSelectRosTopics() override
nonstd::optional< double > FlatContainerContainHeaderStamp(const RosIntrospection::FlatMessage &flat_msg)