Commit d6eaa1ec authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

initial porting to cumbia

parent 5f560e61
include(/usr/local/qtango/include/qtango6/qtango.pri)
TEMPLATE = app
CONFIG += warn_on debug qt app_bundle
QT += sql
QT += multimedia
lessThan(QT_MAJOR_VERSION, 5) {
message("Qt4 detected: using phonon for sound")
QT += phonon
}
DEFINES += QT_NO_DEBUG_OUTPUT
RESOURCES += alarm.qrc
INCLUDEPATH += src
SOURCES += src/alarm.cpp \
src/main.cpp \
src/AlarmTreeWidget.cpp \
src/AlarmTreeWidgetItem.cpp \
src/Sound.cpp \
src/AlarmHistoryTree.cpp \
src/mysqlmodel.cpp
HEADERS += src/alarm.h \
src/AlarmTreeWidget.h \
src/AlarmTreeWidgetItem.h \
src/filter.h \
src/Sound.h \
src/AlarmHistoryTree.h \
src/mysqlmodel.h
FORMS = src/alarm.ui
TARGET = bin/alarm
......@@ -7,7 +7,7 @@
#include <QtDebug>
#include <QApplication>
#include <QCoreApplication>
#include <macros.h>
#include <cumacros.h>
AlarmHistoryTree::AlarmHistoryTree(QWidget *parent) : QTreeView(parent)
{
......
......@@ -8,7 +8,7 @@
#include "AlarmTreeWidgetItem.h"
#include <QMouseEvent>
#include <QMenu>
#include <macros.h>
#include <cumacros.h>
#include <QAction>
#include <QDesktopServices>
#include <QUrl>
......
......@@ -5,7 +5,7 @@
#include <QtDebug>
#include <elettracolors.h>
#include <iostream>
#include <macros.h>
#include <cumacros.h>
AlarmTreeWidgetItem::AlarmTreeWidgetItem(QTreeWidget *parent, QStringList &strings)
: QTreeWidgetItem(parent, strings)
......
......@@ -2,7 +2,6 @@
#include <QString>
#include <QSound>
#include <QtDebug>
#include <macros.h>
#if QT_VERSION > 0x050000
Sound::Sound(const QString& sound_file)
......
This diff is collapsed.
......@@ -22,32 +22,42 @@
#ifndef alarm_H
#define alarm_H
#include "ui_alarm.h"
#include <qtangocore.h>
#include <com_proxy_reader.h>
#include "ui/ui_alarm.h"
#include <vector>
#include <QString>
#include <QHash>
#include <QMap>
#include <tango.h>
#include "Sound.h"
// cumbia
#include <qulogimpl.h>
#include <cucontrolsfactorypool.h>
class CumbiaPool;
class CuData;
// cumbia
class AlarmFilter;
class AlarmSQLHandle;
class AlarmHistoryTree;
class AlarmTreeWidgetItem;
class QTreeWidgetItem;
class Alarm: public QWidget, public QTangoComProxyReader
class Alarm: public QWidget
{
Q_OBJECT
public:
Alarm(QWidget *);
Alarm(CumbiaPool *cu_p, QWidget *);
~Alarm();
public slots:
protected slots:
void refresh(const TVariant &);
void refresh(const CuData &);
void onNewProps(const CuData& da);
void m_connect_devs(const CuData& da);
void ack();
void ackAll();
void silence();
......@@ -60,6 +70,7 @@ protected slots:
void enableFrameHistoryInterval(int);
void raiseFromDbus();
protected:
void playSound(const QStringList &s);
void closeEvent(QCloseEvent *);
......@@ -67,7 +78,7 @@ protected:
private:
void insertItem(const QStringList &s, int index);
void tangoStringListCommand(vector<string> &names, const char *cmdname);
void tangoStringListCommand(std::vector<std::string> &names, const char *cmdname);
/* checks if the tree already contains the item related to the
* string list passed as input. Returns true if the item is contained
......@@ -83,7 +94,7 @@ private:
QString tangoException(Tango::DevFailed &e);
Ui::Alarm ui;
Ui::Alarm *ui;
QVector<QString> oldData;
QString device_name, instance_name;
Sound *sound;
......@@ -91,6 +102,12 @@ private:
// SysTray *d_systray;
QHash<QString, AlarmTreeWidgetItem*> mItemsHash;
// cumbia
CumbiaPool *cu_pool;
QuLogImpl m_log_impl;
CuControlsFactoryPool m_ctrl_factory_pool;
// cumbia
};
......
......@@ -68,7 +68,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
......@@ -103,7 +112,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
......@@ -118,7 +136,16 @@
<bool>true</bool>
</property>
<layout class="QGridLayout">
<property name="margin">
<property name="leftMargin">
<number>7</number>
</property>
<property name="topMargin">
<number>7</number>
</property>
<property name="rightMargin">
<number>7</number>
</property>
<property name="bottomMargin">
<number>7</number>
</property>
<property name="spacing">
......@@ -185,7 +212,16 @@
</sizepolicy>
</property>
<layout class="QGridLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
......@@ -315,29 +351,23 @@
</property>
<layout class="QVBoxLayout">
<item>
<widget class="TPushButton" name="tPBTestAlarm">
<widget class="QuButton" name="tPBTestAlarm">
<property name="toolTip">
<string>Click to test the Alarm System with a simulation. You must then click on Stop Test when happy.</string>
</property>
<property name="text">
<string>Start Test</string>
</property>
<property name="targets">
<string>;</string>
</property>
</widget>
</item>
<item>
<widget class="TPushButton" name="tPBTestAlarmStop">
<widget class="QuButton" name="tPBTestAlarmStop">
<property name="toolTip">
<string>Click this button to stop the test.</string>
</property>
<property name="text">
<string>Stop Test</string>
</property>
<property name="targets">
<string>;</string>
</property>
</widget>
</item>
</layout>
......@@ -388,7 +418,16 @@
<bool>false</bool>
</property>
<layout class="QGridLayout">
<property name="margin">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="spacing">
......@@ -586,7 +625,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
......@@ -603,22 +651,22 @@
</spacer>
</item>
<item>
<widget class="TPushButton" name="pBStopSound">
<widget class="QuButton" name="pBStopSound">
<property name="text">
<string>Stop Beep</string>
</property>
<property name="targets">
<string>$1-&gt;stopnew;</string>
<property name="target">
<string>$1-&gt;stopnew</string>
</property>
</widget>
</item>
<item>
<widget class="TPushButton" name="pBAckAll">
<widget class="QuButton" name="pBAckAll">
<property name="text">
<string>Acknowledge All</string>
</property>
<property name="targets">
<string>$1-&gt;stopnew;</string>
<property name="target">
<string>$1-&gt;stopnew</string>
</property>
</widget>
</item>
......@@ -651,9 +699,9 @@
</widget>
<customwidgets>
<customwidget>
<class>TPushButton</class>
<class>QuButton</class>
<extends>QPushButton</extends>
<header>TPushButton</header>
<header>qubutton.h</header>
</customwidget>
<customwidget>
<class>AlarmTreeWidget</class>
......
......@@ -17,93 +17,84 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
// cumbia
#include <cumbiapool.h>
#include <cuthreadfactoryimpl.h>
#include <qthreadseventbridgefactory.h>
// cumbia
#include <tutil.h>
#include <euniqueapplication.h>
#include <TApplication>
#include <quapplication.h>
#include "alarm.h"
#include <X11/Xlib.h>
#include <QX11Info>
#include <QDebug>
/* uncomment to set application color */
#include <elettracolors.h>
#define CVSVERSION "$Name: $"
int main( int argc, char ** argv )
{
char identifier[128];
QString appname;
QString version(CVSVERSION);
appname = QString(argv[0]);
if(argc > 1)
appname += QString("-%1").arg(argv[1]);
appname += QString("-%1").arg(argv[1]);
snprintf(identifier, 128, "%s", appname.toStdString().c_str());
for(unsigned int i = 0; i < strlen(identifier); i++)
if(identifier[i] == '/' || identifier[i] == '.')
identifier[i] = '-';
if(identifier[i] == '/' || identifier[i] == '.')
identifier[i] = '-';
// EUniqueApplication a( argc, argv, identifier);
TApplication a(argc, argv);
a.setApplicationVersion(version);
a.setProperty("author", "Giacomo");
a.setProperty("mail", "giacomo.strangolino@elettra.trieste.it");
a.setProperty("phone", "375-8073");
a.setProperty("office", "T2PT025");
a.setProperty("hwReferent", "Graziano"); /* name of the referent that provides the device server */
QuApplication qu_app( argc, argv );
qu_app.setOrganizationName("Elettra");
qu_app.setApplicationName("Spbpm");
qu_app.setProperty("author", "Giacomo");
qu_app.setProperty("mail", "giacomo.strangolino@elettra.eu");
qu_app.setProperty("phone", "0403758073");
qu_app.setProperty("office", "T2PT025");
qu_app.setProperty("hwReferent", "Graziano"); /* name of the referent that provides the device server */
CumbiaPool *cu_p = new CumbiaPool();
Alarm *w = new Alarm(cu_p, NULL);
w->show();
// SysTray *systray = new SysTray(0);
Alarm mw(0);
for(int j = 0; j < qApp->arguments().size(); j++)
{
if(qApp->arguments().at(j).contains(QRegExp("style\\s*=?\\s*booster")))
{
a.setPalette(EPalette("booster"));
mw.setWindowIcon(QIcon(":icons/booster-alarm.png"));
break;
}
if(qApp->arguments().at(j).contains(QRegExp("style\\s*=?\\s*booster")))
{
w->setWindowIcon(QIcon(":icons/booster-alarm.png"));
break;
}
else if(qApp->arguments().at(j).contains(QRegExp("style\\s*=?\\s*elettra")))
{
a.setPalette(EPalette("elettra"));
mw.setWindowIcon(QIcon(":icons/elettra-alarm.png"));
break;
}
{
w->setWindowIcon(QIcon(":icons/elettra-alarm.png"));
break;
}
else if(qApp->arguments().at(j).contains(QRegExp("style\\s*=?\\s*fermi")))
{
a.setPalette(EPalette("fermi"));
mw.setWindowIcon(QIcon(":icons/fermi-alarm.png"));
break;
}
{
w->setWindowIcon(QIcon(":icons/fermi-alarm.png"));
break;
}
else
{
//qDebug()<< "style = elettra|booster|fermi on the command line if you want to personalize the style";
a.setPalette(EPalette("elettra"));
}
{
//qDebug()<< "style = elettra|booster|fermi on the command line if you want to personalize the style";
}
}
// systray->attach(&mw);
// systray->setToolTip(QString("%1\nClick to hide/show the main window, right click\nand choose \"Quit Application\" to exit the panel").arg(appname));
TUtil::instance()->setLoggingTarget(argv[0]);
mw.show();
if(argc > 1)
mw.setWindowTitle(argv[1]);
/* register to window manager */
Display *disp = QX11Info::display();
Window root_win = (Window) mw.winId();
XSetCommand(disp, root_win, argv, argc);
w->setWindowTitle(argv[1]);
/* Finally call UniqueExec() instead of the exec():
*/
// QObject::connect(&a, SIGNAL(Rise()), &mw, SLOT(raise()));
// QObject::connect(&a, SIGNAL(Rise()), &mw, SLOT(show()));
// exec application loop
int ret = qu_app.exec();
// delete resources and return
delete w;
// return a.UniqueExec();
return a.exec();
for(std::string n : cu_p->names())
if(cu_p->get(n))
delete cu_p->get(n);
return ret;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment