casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dDBus.qo.h
Go to the documentation of this file.
1 #ifndef _DDBUS_QO_H_
2 #define _DDBUS_QO_H_
3 #include <string>
4 #include <QtCore/QObject>
5 #include <QMainWindow>
6 #include <QLineEdit>
7 #include <QtDBus/QDBusAbstractAdaptor>
9 
10 
11 namespace casa {
12 
13  class EditlineGuiAdaptor;
14 
15  class EditlineGui : public QMainWindow {
16  Q_OBJECT
17  public:
18  EditlineGui( const std::string &dbus_name="", QWidget *parent = 0 );
19  ~EditlineGui( );
20 
21  void set( const QString &txt ) { le->setText(txt); }
22  QString get( ) { return le->text( ); }
23 
24  private:
25  QLineEdit *le;
27  };
28 
29 
30  class EditlineGuiAdaptor: public QDBusAbstractAdaptor, public QtDBusApp {
31  Q_OBJECT
32  Q_CLASSINFO("D-Bus Interface", "edu.nrao.casa.editlinegui")
33  public:
34  QString dbusName( ) const { return "editlinegui"; }
35  bool connectToDBus( const QString &dbus_name="" )
36  { return QtDBusApp::connectToDBus( parent(), dbus_name ); }
37 
38  EditlineGuiAdaptor( EditlineGui *elg ) : QDBusAbstractAdaptor(new QObject()), editline_(elg) { }
40 
41  public slots:
42  void set( const QString &txt ) { editline_->set(txt); }
43  QString get( ) { return editline_->get( ); }
44 
45  private:
47  };
48 
49  inline EditlineGui::~EditlineGui( ) { delete adaptor; }
50 
51  inline EditlineGui::EditlineGui( const std::string &dbus_name, QWidget *parent ) : QMainWindow(parent),
52  le(new QLineEdit("*some*text*",this)),
53  adaptor(new EditlineGuiAdaptor(this)) {
54  le->setMinimumWidth(200);
55  setCentralWidget(le);
56  setFixedHeight(30);
57 
58  adaptor->connectToDBus( dbus_name.c_str( ) );
59  }
60 
61 }
62 
63 #endif
virtual bool connectToDBus(const QString &dbus_name="")=0
Connects to the DBus server using the name provided (if non-null).
EditlineGuiAdaptor * adaptor
Definition: dDBus.qo.h:26
void set(const QString &txt)
Definition: dDBus.qo.h:42
QString dbusName() const
Definition: dDBus.qo.h:34
bool connectToDBus(const QString &dbus_name="")
Connects to the DBus server using the name provided (if non-null).
Definition: dDBus.qo.h:35
EditlineGui(const std::string &dbus_name="", QWidget *parent=0)
Definition: dDBus.qo.h:51
EditlineGui * editline_
Definition: dDBus.qo.h:46
EditlineGuiAdaptor(EditlineGui *elg)
Definition: dDBus.qo.h:38
QString get()
Definition: dDBus.qo.h:22
QLineEdit * le
Definition: dDBus.qo.h:25
void set(const QString &txt)
Definition: dDBus.qo.h:21