ConnectDialog.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
17  * @date 2021
18  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19  * GNU General Public License
20  */
21 
22 #pragma once
23 
24 #include <QDialog>
25 #include <QDialogButtonBox>
26 #include <QVBoxLayout>
27 
29 
31 
32 
34 {
35  template <class ProxyT>
36  class ConnectDialog : public QDialog
37  {
38  public:
39  ConnectDialog(QString searchMask, ManagedIceObject& component, QWidget* parent = nullptr) :
40  QDialog(parent), component(component)
41  {
43  finder->setIceManager(component.getIceManager());
44  finder->setSearchMask(searchMask);
45 
46  QDialogButtonBox* buttonBox =
47  new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
48 
49  setLayout(new QVBoxLayout);
50  layout()->addWidget(finder);
51  layout()->addWidget(buttonBox);
52 
53  connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
54  connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
55  }
56 
57  virtual ~ConnectDialog() override
58  {
59  }
60 
61 
62  ProxyT
64  {
65  QString name = finder->getSelectedProxyName();
66  if (name.size() > 0)
67  {
68  return component.getProxy<ProxyT>(name.toStdString());
69  }
70  else
71  {
72  return nullptr;
73  }
74  }
75 
76 
77  public:
80  };
81 
82 
83 } // namespace armarx::navigation::qt_plugins::location_graph_editor
armarx::ManagedIceObject::getIceManager
IceManagerPtr getIceManager() const
Returns the IceManager.
Definition: ManagedIceObject.cpp:353
ManagedIceObject.h
armarx::navigation::qt_plugins::location_graph_editor::ConnectDialog::finder
armarx::IceProxyFinder< ProxyT > * finder
Definition: ConnectDialog.h:79
IceProxyFinder.h
armarx::navigation::qt_plugins::location_graph_editor::ConnectDialog
Definition: ConnectDialog.h:36
armarx::navigation::qt_plugins::location_graph_editor::ConnectDialog::~ConnectDialog
virtual ~ConnectDialog() override
Definition: ConnectDialog.h:57
armarx::navigation::qt_plugins::location_graph_editor
Definition: GuiGraph.cpp:29
armarx::navigation::qt_plugins::location_graph_editor::ConnectDialog::getProxy
ProxyT getProxy()
Definition: ConnectDialog.h:63
armarx::ManagedIceObject
The ManagedIceObject is the base class for all ArmarX objects.
Definition: ManagedIceObject.h:163
armarx::navigation::qt_plugins::location_graph_editor::ConnectDialog::ConnectDialog
ConnectDialog(QString searchMask, ManagedIceObject &component, QWidget *parent=nullptr)
Definition: ConnectDialog.h:39
armarx::IceProxyFinder< ProxyT >
armarx::navigation::qt_plugins::location_graph_editor::ConnectDialog::component
ManagedIceObject & component
Definition: ConnectDialog.h:78
armarx::ManagedIceObject::getProxy
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
Definition: ManagedIceObject.cpp:393