ArmarXManagerRepositoryDialog.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarX::Gui
19 * @author Jan Issac ( jan.issac at gmail dot com)
20 * @date 2012
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
26
27#include <iostream>
28#include <string>
29#include <vector>
30
31#include <QInputDialog>
32#include <QItemSelectionModel>
33#include <QList>
34#include <QMessageBox>
35#include <QPersistentModelIndex>
36#include <QStandardItem>
37
38#include <ArmarXCore/interface/core/ArmarXManagerInterface.h>
39
40#include <ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ui_ArmarXManagerRepositoryDialog.h>
41
42namespace armarx
43{
45 ArmarXManagerModel* managerRepositoryModel,
46 ArmarXManagerModel* monitoredManagerModel,
47 QWidget* parent) :
48 QDialog(parent), ui(new Ui::ArmarXManagerRepositoryDialog), parent(parent)
49 {
50 this->managerRepositoryModel = managerRepositoryModel->clone();
51 this->monitoredManagerModel = monitoredManagerModel->clone();
52
53 setupView();
54 }
55
60
61 void
63 {
64 ui->setupUi(this);
65
66 ui->managerRepository->setModel(managerRepositoryModel);
67 ui->monitoredManagers->setModel(monitoredManagerModel);
68
69 connect(ui->addNewManager, SIGNAL(clicked()), this, SLOT(addNewManager()));
70 connect(ui->cancelOkBox, SIGNAL(accepted()), this, SLOT(accept()));
71 connect(ui->cancelOkBox, SIGNAL(rejected()), this, SLOT(reject()));
72
73 connect(ui->moveToMonitoredManagersButton,
74 SIGNAL(clicked()),
75 this,
77 connect(ui->moveToManagerRepositoryButton,
78 SIGNAL(clicked()),
79 this,
81 connect(ui->removeSelectedManagersButton,
82 SIGNAL(clicked()),
83 this,
85
86 connect(ui->scanButton, SIGNAL(clicked()), this, SLOT(scanForManagers()));
87
88 connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearRepository()));
89 }
90
91 void
93 {
94 QStringList::ConstIterator it = managers.begin();
95
96 QBrush brush;
97 brush.setColor(QColor(78, 238, 148));
98 brush.setStyle(Qt::SolidPattern);
99
100 while (it != managers.end())
101 {
102 ArmarXManagerItem* item = managerRepositoryModel->getManagerItemByName(*it);
103 if (!item)
104 {
105 item = monitoredManagerModel->getManagerItemByName(*it);
106 }
107
108 if (!item)
109 {
110 item = new ArmarXManagerItem(*it);
111
112 // ScopedLock lock(managerRepositoryModel->getMutex());
113 managerRepositoryModel->appendRow(item);
114 }
115
116 // ScopedLock lock(item->getMutex());
117 item->setBackground(brush);
118
119 ++it;
120 }
121 }
122
123 void
125 {
126 bool ok;
127 QString managerName = QInputDialog::getText(parent,
128 tr("New ArmarXManager"),
129 tr("Manager name"),
130 QLineEdit::Normal,
131 tr("SampleApplicationManager"),
132 &ok);
133
134 if (ok)
135 {
136 ArmarXManagerItem* item = managerRepositoryModel->getManagerItemByName(managerName);
137
138 if (!item)
139 {
140 //ScopedLock lock(managerRepositoryModel->getMutex());
141 managerRepositoryModel->appendRow(new ArmarXManagerItem(managerName));
142 }
143 else
144 {
145 QMessageBox::information(parent,
146 "Add new manager",
147 managerName + " manager already in repository",
148 QMessageBox::Ok);
149 }
150 }
151 }
152
153 void
155 {
156 monitoredManagerModel->takeSelectionFrom(ui->managerRepository->selectionModel(),
157 managerRepositoryModel);
158 }
159
160 void
162 {
163 monitoredManagerModel->moveSelectionTo(ui->monitoredManagers->selectionModel(),
164 managerRepositoryModel);
165 }
166
167 void
172
173 void
175 {
176 managerRepositoryModel->clear();
177 }
178
181 {
182 return managerRepositoryModel;
183 }
184
187 {
188 return monitoredManagerModel;
189 }
190
191 void
193 {
194 managerRepositoryModel->deleteSelection(ui->managerRepository->selectionModel());
195 }
196} // namespace armarx
ArmarXManagerModel * clone()
Returns a clone of this ArmarXManagerModel.
void deleteSelection(QItemSelectionModel *selectionModel)
Deletes the selected set of rows from this model.
ArmarXManagerRepositoryDialog(ArmarXManagerModel *managerRepositoryModel, ArmarXManagerModel *monitoredManagerModel, QWidget *parent=0)
void addOnlineManagers(const QStringList &managers)
ArmarX Headers.
This file offers overloads of toIce() and fromIce() functions for STL container types.