[Kstars-devel] KDE/kdeedu/kstars/kstars
Jasem Mutlaq
mutlaqja at ikarustech.com
Fri Apr 28 12:52:36 CEST 2006
SVN commit 535001 by mutlaqja:
Updating code to reflect changes in QMenu, thanks to Jason for the notice!
A truck-load of porting is still due, however :)
CCMAIL: kstars-devel at kde.org
M +9 -9 indiproperty.cpp
M +2 -2 indiproperty.h
M +19 -12 kspopupmenu.cpp
--- trunk/KDE/kdeedu/kstars/kstars/indiproperty.cpp #535000:535001
@@ -46,6 +46,7 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QAbstractButton>
+ #include <QAction>
#include <unistd.h>
#include <stdlib.h>
@@ -74,7 +75,6 @@
light = NULL;
label_w = NULL;
set_w = NULL;
- assosiatedPopup = NULL;
groupB = NULL;
}
@@ -208,25 +208,23 @@
}
-void INDI_P::convertSwitch(int id)
+void INDI_P::convertSwitch(QAction *action)
{
INDI_E *lp;
int switchIndex=0;
- if (assosiatedPopup == NULL)
- return;
-
+
//kDebug() << "Name: " << name << " ID: " << id << endl;
/* Special case is CCD_EXPOSE_DURATION, not a switch */
- if (stdID == CCD_EXPOSE_DURATION && assosiatedPopup->text(id) == label)
+ if (stdID == CCD_EXPOSE_DURATION && action->text() == label)
{
newText();
return;
}
/* Another special case, center telescope */
- if (assosiatedPopup->text(id) == i18n("Center && Track Crosshair"))
+ if (action->text() == i18n("Center && Track Crosshair"))
{
if (!indistd->stdDev->dp->isOn()) return;
if (indistd->stdDev->telescopeSkyObject == NULL) return;
@@ -236,20 +234,22 @@
return;
}
- lp = findElement(assosiatedPopup->text(id));
+ lp = findElement(action->text());
if (!lp)
return;
for (int i=0; i < el.size(); i++)
{
- if (el[i]->label == assosiatedPopup->text(id))
+ if (el[i]->label == action->text())
{
switchIndex = i;
break;
}
}
+ // If INDI Standard can handle the swtich then process and return, otherwise
+ // Just issue a new generic switch.
if (indistd->convertSwitch(switchIndex, lp))
return;
else if (lp->state == PS_OFF)
--- trunk/KDE/kdeedu/kstars/kstars/indiproperty.h #535000:535001
@@ -32,6 +32,7 @@
class QVBoxLayout;
class QButtonGroup;
class QAbstractButton;
+class QAction;
/* INDI property */
class INDI_P : public QObject
@@ -45,7 +46,6 @@
QString label; /* property label */
INDI_G *pg; /* parent group */
- KMenu *assosiatedPopup; /* assosiated popup menu, if any */
INDIStdProperty *indistd; /* Assosciated std routines class */
double timeout; /* timeout, seconds */
PState state; /* state light code */
@@ -101,7 +101,7 @@
void newSwitch(int id);
void newAbstractButton(QAbstractButton *button);
void newBlob();
- void convertSwitch(int id);
+ void convertSwitch(QAction* action);
signals:
void okState();
--- trunk/KDE/kdeedu/kstars/kstars/kspopupmenu.cpp #535000:535001
@@ -170,35 +170,40 @@
menuDevice->addSeparator();
- prop->assosiatedPopup = menuDevice;
+ //prop->assosiatedPopup = menuDevice;
if (prop->stdID == CCD_EXPOSE_DURATION)
{
- menuDevice->insertItem (prop->label, id);
- menuDevice->setItemChecked(id, false);
+ //menuDevice->insertItem (prop->label, id);
+ //menuDevice->setItemChecked(id, false);
//kDebug() << "Expose ID: " << id << endl;
- id++;
+ //id++;
+ QAction *a = menuDevice->addAction( prop->label );
+ a->setCheckable( true );
+ a->setChecked( false );
}
else
{
foreach ( element, prop->el )
{
- menuDevice->insertItem (element->label, id++);
+ //menuDevice->insertItem (element->label, id++);
+ QAction *a = menuDevice->addAction(element->label);
if (element->state == PS_ON)
{
// Slew, Track, Sync, Exppse are never checked in the skymap
if ( (element->name != "SLEW") && (element->name != "TRACK") &&
(element->name != "SYNC") )
- menuDevice->setItemChecked(id, true);
+ a->setChecked(true);
else
- menuDevice->setItemChecked(id, false);
+ a->setChecked(false);
}
else
- menuDevice->setItemChecked(id, false);
+ a->setChecked(false);
}
}
- QObject::connect(menuDevice, SIGNAL(activated(int)), prop, SLOT (convertSwitch(int)));
+ //QObject::connect(menuDevice, SIGNAL(activated(int)), prop, SLOT (convertSwitch(int)));
+ connect( menuDevice, SIGNAL( triggered(QAction*) ), prop, SLOT(convertSwitch(QAction*) ) );
} // end property
} // end group
@@ -207,14 +212,16 @@
if ( dev->findElem("RA") || dev->findElem("ALT"))
{
menuDevice->addSeparator();
- menuDevice->insertItem(i18n("Center && Track Crosshair"), id++);
+ //menuDevice->insertItem(i18n("Center && Track Crosshair"), id++);
+ QAction *a = menuDevice->addAction(i18n("Center && Track Crosshair"));
if (dev->findElem("RA"))
prop = dev->findElem("RA")->pp;
else
prop = dev->findElem("ALT")->pp;
- prop->assosiatedPopup = menuDevice;
- QObject::connect(menuDevice, SIGNAL(activated(int)), prop, SLOT(convertSwitch(int)));
+ //prop->assosiatedPopup = menuDevice;
+ //QObject::connect(menuDevice, SIGNAL(activated(int)), prop, SLOT(convertSwitch(int)));
+ connect( menuDevice, SIGNAL( triggered(QAction*) ), prop, SLOT(convertSwitch(QAction*) ) );
}
} // end device
} // end device manager
More information about the Kstars-devel
mailing list