TelescopeDialog.cpp   TelescopeDialog.cpp 
/* /*
* Stellarium Telescope Control Plug-in * Stellarium Telescope Control Plug-in
* *
* Copyright (C) 2009 Bogdan Marinov (this file) * Copyright (C) 2009-2010 Bogdan Marinov (this file)
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 32 skipping to change at line 32
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelStyle.hpp" #include "StelStyle.hpp"
#include "TelescopeControl.hpp" #include "TelescopeControl.hpp"
#include "TelescopeConfigurationDialog.hpp" #include "TelescopeConfigurationDialog.hpp"
#include "TelescopeDialog.hpp" #include "TelescopeDialog.hpp"
#include "ui_telescopeDialog.h" #include "ui_telescopeDialog.h"
#include "StelGui.hpp"
#include <QDebug> #include <QDebug>
#include <QFrame> #include <QFrame>
#include <QTimer> #include <QTimer>
#include <QFile> #include <QFile>
#include <QFileDialog> #include <QFileDialog>
#include <QHash> #include <QHash>
#include <QHeaderView> #include <QHeaderView>
#include <QSettings> #include <QSettings>
#include <QStandardItem> #include <QStandardItem>
skipping to change at line 96 skipping to change at line 96
//Page: Telescopes //Page: Telescopes
connect(ui->pushButtonChangeStatus, SIGNAL(clicked()), this, SLOT(bu ttonChangeStatusPressed())); connect(ui->pushButtonChangeStatus, SIGNAL(clicked()), this, SLOT(bu ttonChangeStatusPressed()));
connect(ui->pushButtonConfigure, SIGNAL(clicked()), this, SLOT(butto nConfigurePressed())); connect(ui->pushButtonConfigure, SIGNAL(clicked()), this, SLOT(butto nConfigurePressed()));
connect(ui->pushButtonAdd, SIGNAL(clicked()), this, SLOT(buttonAddPr essed())); connect(ui->pushButtonAdd, SIGNAL(clicked()), this, SLOT(buttonAddPr essed()));
connect(ui->pushButtonRemove, SIGNAL(clicked()), this, SLOT(buttonRe movePressed())); connect(ui->pushButtonRemove, SIGNAL(clicked()), this, SLOT(buttonRe movePressed()));
connect(ui->telescopeTreeView, SIGNAL(clicked (const QModelIndex &)) , this, SLOT(selectTelecope(const QModelIndex &))); connect(ui->telescopeTreeView, SIGNAL(clicked (const QModelIndex &)) , this, SLOT(selectTelecope(const QModelIndex &)));
//connect(ui->telescopeTreeView, SIGNAL(activated (const QModelIndex &)), this, SLOT(configureTelescope(const QModelIndex &))); //connect(ui->telescopeTreeView, SIGNAL(activated (const QModelIndex &)), this, SLOT(configureTelescope(const QModelIndex &)));
//Page: Options: //Page: Options:
connect(ui->checkBoxMarkers, SIGNAL(stateChanged(int)), this, SLOT(t connect(ui->checkBoxReticles, SIGNAL(stateChanged(int)), this, SLOT(
ogglePointers(int))); toggleReticles(int)));
connect(ui->checkBoxLabels, SIGNAL(stateChanged(int)), this, SLOT(to connect(ui->checkBoxLabels, SIGNAL(stateChanged(int)), this, SLOT(to
ggleNames(int))); ggleLabels(int)));
connect(ui->checkBoxCircles, SIGNAL(stateChanged(int)), this, SLOT(t
oggleCircles(int)));
connect(ui->checkBoxEnableLogs, SIGNAL(toggled(bool)), telescopeMana ger, SLOT(setFlagUseTelescopeServerLogs(bool))); connect(ui->checkBoxEnableLogs, SIGNAL(toggled(bool)), telescopeMana ger, SLOT(setFlagUseTelescopeServerLogs(bool)));
connect(ui->checkBoxUseExecutables, SIGNAL(toggled(bool)), ui->label ExecutablesDirectory, SLOT(setEnabled(bool))); connect(ui->checkBoxUseExecutables, SIGNAL(toggled(bool)), ui->label ExecutablesDirectory, SLOT(setEnabled(bool)));
connect(ui->checkBoxUseExecutables, SIGNAL(toggled(bool)), ui->lineE ditExecutablesDirectory, SLOT(setEnabled(bool))); connect(ui->checkBoxUseExecutables, SIGNAL(toggled(bool)), ui->lineE ditExecutablesDirectory, SLOT(setEnabled(bool)));
connect(ui->checkBoxUseExecutables, SIGNAL(toggled(bool)), ui->pushB uttonPickExecutablesDirectory, SLOT(setEnabled(bool))); connect(ui->checkBoxUseExecutables, SIGNAL(toggled(bool)), ui->pushB uttonPickExecutablesDirectory, SLOT(setEnabled(bool)));
connect(ui->checkBoxUseExecutables, SIGNAL(toggled(bool)), this, SLO T(checkBoxUseExecutablesToggled(bool))); connect(ui->checkBoxUseExecutables, SIGNAL(toggled(bool)), this, SLO T(checkBoxUseExecutablesToggled(bool)));
connect(ui->pushButtonPickExecutablesDirectory, SIGNAL(clicked()), t his, SLOT(buttonBrowseServerDirectoryPressed())); connect(ui->pushButtonPickExecutablesDirectory, SIGNAL(clicked()), t his, SLOT(buttonBrowseServerDirectoryPressed()));
//In other dialogs: //In other dialogs:
connect(&configurationDialog, SIGNAL(discardChanges()), this, SLOT(d connect(&configurationDialog, SIGNAL(changesDiscarded()), this, SLOT
iscardChanges())); (discardChanges()));
connect(&configurationDialog, SIGNAL(saveChanges(QString, TelescopeC connect(&configurationDialog, SIGNAL(changesSaved(QString, Connectio
onnection)), this, SLOT(saveChanges(QString, TelescopeConnection))); nType)), this, SLOT(saveChanges(QString, ConnectionType)));
//Initialize the style //Initialize the style
setStelStyle(*StelApp::getInstance().getCurrentStelStyle()); updateStyle();
//Initializing the list of telescopes //Initializing the list of telescopes
telescopeListModel->setColumnCount(ColumnCount); telescopeListModel->setColumnCount(ColumnCount);
QStringList headerStrings; QStringList headerStrings;
headerStrings << "#"; headerStrings << "#";
//headerStrings << "Start"; //headerStrings << "Start";
headerStrings << "Status"; headerStrings << "Status";
headerStrings << "Type"; headerStrings << "Type";
headerStrings << "Name"; headerStrings << "Name";
telescopeListModel->setHorizontalHeaderLabels(headerStrings); telescopeListModel->setHorizontalHeaderLabels(headerStrings);
skipping to change at line 145 skipping to change at line 146
for (int slotNumber = MIN_SLOT_NUMBER; slotNumber < SLOT_NUMBER_LIMI T; slotNumber++) for (int slotNumber = MIN_SLOT_NUMBER; slotNumber < SLOT_NUMBER_LIMI T; slotNumber++)
{ {
//Slot # //Slot #
//int slotNumber = (i+1)%SLOT_COUNT;//Making sure slot 0 is last //int slotNumber = (i+1)%SLOT_COUNT;//Making sure slot 0 is last
//Make sure that this is initialized for all slots //Make sure that this is initialized for all slots
telescopeStatus[slotNumber] = StatusNA; telescopeStatus[slotNumber] = StatusNA;
//Read the telescope properties //Read the telescope properties
QString name; QString name;
ConnectionType connectionType;
QString host; QString host;
int portTCP; int portTCP;
int delay; int delay;
bool connectAtStartup; bool connectAtStartup;
QList<double> circles; QList<double> circles;
QString serverName; QString serverName;
QString portSerial; QString portSerial;
if(!telescopeManager->getTelescopeAtSlot(slotNumber, name, h ost, portTCP, delay, connectAtStartup, circles, serverName, portSerial)) if(!telescopeManager->getTelescopeAtSlot(slotNumber, connect ionType, name, host, portTCP, delay, connectAtStartup, circles, serverName, portSerial))
continue; continue;
//Determine the server type //Determine the server type
QString serverType; QString connectionTypeLabel;
if (host != "localhost") switch (connectionType)
{ {
telescopeType[slotNumber] = ConnectionRemote; case ConnectionInternal:
serverType = "remote, unknown"; connectionTypeLabel = "local, Stellarium";
} break;
else case ConnectionLocal:
{ connectionTypeLabel = "local, external";
if(!serverName.isEmpty()) break;
{ case ConnectionRemote:
telescopeType[slotNumber] = ConnectionLocalI connectionTypeLabel = "remote, unknown";
nternal; break;
serverType = "local, Stellarium"; case ConnectionVirtual:
} default:
else connectionTypeLabel = "virtual";
{ break;
telescopeType[slotNumber] = ConnectionLocalE
xternal;
serverType = "local, external";
}
} }
telescopeType[slotNumber] = connectionType;
//Determine the telescope's status //Determine the telescope's status
if (telescopeManager->isConnectedClientAtSlot(slotNumber)) if (telescopeManager->isConnectedClientAtSlot(slotNumber))
{ {
telescopeStatus[slotNumber] = StatusConnected; telescopeStatus[slotNumber] = StatusConnected;
} }
else else
{ {
//TODO: Fix this! //TODO: Fix this!
//At startup everything exists and attempts to conne ct //At startup everything exists and attempts to conne ct
skipping to change at line 208 skipping to change at line 209
//tempItem->setCheckState(Qt::Checked); //tempItem->setCheckState(Qt::Checked);
//tempItem->setData("If checked, this telescope will start w hen Stellarium is started", Qt::ToolTipRole); //tempItem->setData("If checked, this telescope will start w hen Stellarium is started", Qt::ToolTipRole);
//telescopeListModel->setItem(lastRow, ColumnStartup, tempIt em);//Start-up checkbox //telescopeListModel->setItem(lastRow, ColumnStartup, tempIt em);//Start-up checkbox
//New column on a new row in the list: Telescope status //New column on a new row in the list: Telescope status
tempItem = new QStandardItem(statusString[telescopeStatus[sl otNumber]]); tempItem = new QStandardItem(statusString[telescopeStatus[sl otNumber]]);
tempItem->setEditable(false); tempItem->setEditable(false);
telescopeListModel->setItem(lastRow, ColumnStatus, tempItem) ; telescopeListModel->setItem(lastRow, ColumnStatus, tempItem) ;
//New column on a new row in the list: Telescope type //New column on a new row in the list: Telescope type
tempItem = new QStandardItem(serverType); tempItem = new QStandardItem(connectionTypeLabel);
tempItem->setEditable(false); tempItem->setEditable(false);
telescopeListModel->setItem(lastRow, ColumnType, tempItem); telescopeListModel->setItem(lastRow, ColumnType, tempItem);
//New column on a new row in the list: Telescope name //New column on a new row in the list: Telescope name
tempItem = new QStandardItem(name); tempItem = new QStandardItem(name);
tempItem->setEditable(false); tempItem->setEditable(false);
telescopeListModel->setItem(lastRow, ColumnName, tempItem); telescopeListModel->setItem(lastRow, ColumnName, tempItem);
//After everything is done, count this as loaded //After everything is done, count this as loaded
telescopeCount++; telescopeCount++;
skipping to change at line 250 skipping to change at line 251
if(telescopeManager->getDeviceModels().isEmpty()) if(telescopeManager->getDeviceModels().isEmpty())
ui->labelWarning->setText(LABEL_TEXT_NO_DEVICE_MODEL S); ui->labelWarning->setText(LABEL_TEXT_NO_DEVICE_MODEL S);
else else
ui->labelWarning->setText(LABEL_TEXT_ADD_TIP); ui->labelWarning->setText(LABEL_TEXT_ADD_TIP);
} }
if(telescopeCount >= SLOT_COUNT) if(telescopeCount >= SLOT_COUNT)
ui->pushButtonAdd->setEnabled(false); ui->pushButtonAdd->setEnabled(false);
//Checkboxes //Checkboxes
ui->checkBoxMarkers->setChecked(telescopeManager->getFlagTelescopes( ui->checkBoxReticles->setChecked(telescopeManager->getFlagTelescopeR
)); eticles());
ui->checkBoxLabels->setChecked(telescopeManager->getFlagTelescopeNam ui->checkBoxLabels->setChecked(telescopeManager->getFlagTelescopeLab
e()); els());
ui->checkBoxCircles->setChecked(telescopeManager->getFlagTelescopeCi
rcles());
ui->checkBoxEnableLogs->setChecked(telescopeManager->getFlagUseTeles copeServerLogs()); ui->checkBoxEnableLogs->setChecked(telescopeManager->getFlagUseTeles copeServerLogs());
//Telescope server directory //Telescope server directory
ui->checkBoxUseExecutables->setChecked(telescopeManager->getFlagUseS erverExecutables()); ui->checkBoxUseExecutables->setChecked(telescopeManager->getFlagUseS erverExecutables());
ui->lineEditExecutablesDirectory->setText(telescopeManager->getServe rExecutablesDirectoryPath()); ui->lineEditExecutablesDirectory->setText(telescopeManager->getServe rExecutablesDirectoryPath());
//About page //About page
//TODO: Expand //TODO: Expand
QString htmlPage = "<html><head></head><body>"; QString htmlPage = "<html><head></head><body>";
htmlPage += "<h2>Stellarium Telescope Control Plug-in</h2>"; htmlPage += "<h2>Stellarium Telescope Control Plug-in</h2>";
htmlPage += "<h3>Version " + QString(PLUGIN_VERSION) + "</h3>"; htmlPage += "<h3>Version " + QString(PLUGIN_VERSION) + "</h3>";
QFile helpFile(":/telescopeControl/help.utf8"); QFile helpFile(":/telescopeControl/help.utf8");
helpFile.open(QFile::ReadOnly | QFile::Text); helpFile.open(QFile::ReadOnly | QFile::Text);
htmlPage += helpFile.readAll(); htmlPage += helpFile.readAll();
helpFile.close(); helpFile.close();
htmlPage += "</body></html>"; htmlPage += "</body></html>";
ui->textBrowserAbout->setHtml(htmlPage); ui->textBrowserAbout->setHtml(htmlPage);
ui->textBrowserAbout->document()->setDefaultStyleSheet(QString(StelA StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui(
pp::getInstance().getCurrentStelStyle()->htmlStyleSheet)); ));
Q_ASSERT(gui);
ui->textBrowserAbout->document()->setDefaultStyleSheet(QString(gui->
getStelStyle().htmlStyleSheet));
//Everything must be initialized by now, start the updateTimer //Everything must be initialized by now, start the updateTimer
//TODO: Find if it's possible to run it only when the dialog is visi ble //TODO: Find if it's possible to run it only when the dialog is visi ble
QTimer* updateTimer = new QTimer(this); QTimer* updateTimer = new QTimer(this);
connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateTelescopeSt ates())); connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateTelescopeSt ates()));
updateTimer->start(200); updateTimer->start(200);
} }
void TelescopeDialog::togglePointers(int state) void TelescopeDialog::toggleReticles(int state)
{ {
if(state == Qt::Checked) if(state == Qt::Checked)
{ {
telescopeManager->setFlagTelescopes(true); telescopeManager->setFlagTelescopeReticles(true);
} }
else else
{ {
telescopeManager->setFlagTelescopes(false); telescopeManager->setFlagTelescopeReticles(false);
} }
//TODO: Decide if this should be done here (if saveSettings() should
be public)
//telescopeManager->saveFlagTelescopeCircles();
} }
void TelescopeDialog::toggleNames(int state) void TelescopeDialog::toggleLabels(int state)
{ {
if(state == Qt::Checked) if(state == Qt::Checked)
{ {
telescopeManager->setFlagTelescopeName(true); telescopeManager->setFlagTelescopeLabels(true);
} }
else else
{ {
telescopeManager->setFlagTelescopeName(false); telescopeManager->setFlagTelescopeLabels(false);
} }
}
//TODO: Decide if this should be done here (if saveSettings() should void TelescopeDialog::toggleCircles(int state)
be public) {
//telescopeManager->saveFlagTelescopeLabels(); if(state == Qt::Checked)
{
telescopeManager->setFlagTelescopeCircles(true);
}
else
{
telescopeManager->setFlagTelescopeCircles(false);
}
} }
void TelescopeDialog::selectTelecope(const QModelIndex & index) void TelescopeDialog::selectTelecope(const QModelIndex & index)
{ {
//Extract selected item index //Extract selected item index
int selectedSlot = telescopeListModel->data( telescopeListModel->ind ex(index.row(),0) ).toInt(); int selectedSlot = telescopeListModel->data( telescopeListModel->ind ex(index.row(),0) ).toInt();
updateStatusButtonForSlot(selectedSlot); updateStatusButtonForSlot(selectedSlot);
//In all cases //In all cases
ui->pushButtonRemove->setEnabled(true); ui->pushButtonRemove->setEnabled(true);
} }
void TelescopeDialog::configureTelescope(const QModelIndex & currentIndex) void TelescopeDialog::configureTelescope(const QModelIndex & currentIndex)
{ {
configuredTelescopeIsNew = false; configuredTelescopeIsNew = false;
configuredSlot = telescopeListModel->data( telescopeListModel->index (currentIndex.row(), ColumnSlot) ).toInt(); configuredSlot = telescopeListModel->data( telescopeListModel->index (currentIndex.row(), ColumnSlot) ).toInt();
//Stop the telescope first if necessary //Stop the telescope first if necessary
if(telescopeType[configuredSlot] != ConnectionLocalInternal && teles copeStatus[configuredSlot] != StatusDisconnected) if(telescopeType[configuredSlot] != ConnectionInternal && telescopeS tatus[configuredSlot] != StatusDisconnected)
{ {
if(telescopeManager->stopTelescopeAtSlot(configuredSlot)) // Act as "Disconnect" if(telescopeManager->stopTelescopeAtSlot(configuredSlot)) // Act as "Disconnect"
telescopeStatus[configuredSlot] = StatusDisc onnected; telescopeStatus[configuredSlot] = StatusDisc onnected;
else else
return; return;
} }
else if(telescopeStatus[configuredSlot] != StatusStopped) else if(telescopeStatus[configuredSlot] != StatusStopped)
{ {
if(telescopeManager->stopTelescopeAtSlot(configuredSlot)) // Act as "Stop" if(telescopeManager->stopTelescopeAtSlot(configuredSlot)) // Act as "Stop"
telescopeStatus[configuredSlot] = St atusStopped; telescopeStatus[configuredSlot] = St atusStopped;
} }
//Update the status in the list //Update the status in the list
telescopeListModel->setData(telescopeListModel->index(ui->telescopeT reeView->currentIndex().row(), ColumnStatus), statusString[telescopeStatus[ configuredSlot]], Qt::DisplayRole); telescopeListModel->setData(telescopeListModel->index(ui->telescopeT reeView->currentIndex().row(), ColumnStatus), statusString[telescopeStatus[ configuredSlot]], Qt::DisplayRole);
dialog->setEnabled(false); setVisible(false);
configurationDialog.setVisible(true); //This should be called first to actually create the dialog content configurationDialog.setVisible(true); //This should be called first to actually create the dialog content
configurationDialog.initExistingTelescopeConfiguration(configuredSlo t); configurationDialog.initExistingTelescopeConfiguration(configuredSlo t);
} }
void TelescopeDialog::buttonChangeStatusPressed() void TelescopeDialog::buttonChangeStatusPressed()
{ {
if(!ui->telescopeTreeView->currentIndex().isValid()) if(!ui->telescopeTreeView->currentIndex().isValid())
return; return;
//Extract selected slot //Extract selected slot
int selectedSlot = telescopeListModel->data( telescopeListModel->ind ex(ui->telescopeTreeView->currentIndex().row(), ColumnSlot) ).toInt(); int selectedSlot = telescopeListModel->data( telescopeListModel->ind ex(ui->telescopeTreeView->currentIndex().row(), ColumnSlot) ).toInt();
//TODO: As most of these are asynchronous actions, it looks like tha t there should be a queue... //TODO: As most of these are asynchronous actions, it looks like tha t there should be a queue...
if(telescopeType[selectedSlot] != ConnectionLocalInternal) if(telescopeType[selectedSlot] != ConnectionInternal)
{ {
//Can't be launched by Stellarium -> can't be stopped by Ste llarium //Can't be launched by Stellarium -> can't be stopped by Ste llarium
//Can be only connected/disconnected //Can be only connected/disconnected
if(telescopeStatus[selectedSlot] == StatusDisconnected) if(telescopeStatus[selectedSlot] == StatusDisconnected)
{ {
if(telescopeManager->startTelescopeAtSlot(selectedSl ot)) //Act as "Connect" if(telescopeManager->startTelescopeAtSlot(selectedSl ot)) //Act as "Connect"
telescopeStatus[selectedSlot] = StatusConnec ting; telescopeStatus[selectedSlot] = StatusConnec ting;
} }
else else
{ {
skipping to change at line 418 skipping to change at line 428
configuredTelescopeIsNew = true; configuredTelescopeIsNew = true;
//Find the first unoccupied slot (there is at least one) //Find the first unoccupied slot (there is at least one)
for (configuredSlot = MIN_SLOT_NUMBER; configuredSlot < SLOT_NUMBER_ LIMIT; configuredSlot++) for (configuredSlot = MIN_SLOT_NUMBER; configuredSlot < SLOT_NUMBER_ LIMIT; configuredSlot++)
{ {
//configuredSlot = (i+1)%SLOT_COUNT; //configuredSlot = (i+1)%SLOT_COUNT;
if(telescopeStatus[configuredSlot] == StatusNA) if(telescopeStatus[configuredSlot] == StatusNA)
break; break;
} }
dialog->setEnabled(false); setVisible(false);
configurationDialog.setVisible(true); //This should be called first to actually create the dialog content configurationDialog.setVisible(true); //This should be called first to actually create the dialog content
configurationDialog.initNewTelescopeConfiguration(configuredSlot); configurationDialog.initNewTelescopeConfiguration(configuredSlot);
} }
void TelescopeDialog::buttonRemovePressed() void TelescopeDialog::buttonRemovePressed()
{ {
if(!ui->telescopeTreeView->currentIndex().isValid()) if(!ui->telescopeTreeView->currentIndex().isValid())
return; return;
//Extract selected slot //Extract selected slot
skipping to change at line 487 skipping to change at line 497
else else
ui->labelWarning->setText(LABEL_TEXT_ADD_TIP); ui->labelWarning->setText(LABEL_TEXT_ADD_TIP);
} }
else else
{ {
ui->labelWarning->setText(LABEL_TEXT_CONTROL_TIP); ui->labelWarning->setText(LABEL_TEXT_CONTROL_TIP);
ui->telescopeTreeView->setCurrentIndex(telescopeListModel->i ndex(0,0)); ui->telescopeTreeView->setCurrentIndex(telescopeListModel->i ndex(0,0));
} }
} }
void TelescopeDialog::saveChanges(QString name, TelescopeConnection type) void TelescopeDialog::saveChanges(QString name, ConnectionType type)
{ {
//Save the changes to file //Save the changes to file
telescopeManager->saveTelescopes(); telescopeManager->saveTelescopes();
//Type and server properties //Type and server properties
telescopeType[configuredSlot] = type; telescopeType[configuredSlot] = type;
QString typeString; QString typeString;
if(type == ConnectionLocalInternal) switch (type)
{
if(configuredTelescopeIsNew)
telescopeStatus[configuredSlot] = StatusStopped;//TO
DO: Is there a point? Isn't it better to force the status update method?
typeString = "local, Stellarium";
}
else if(type == ConnectionLocalExternal)
{
telescopeStatus[configuredSlot] = StatusDisconnected;
typeString = "local, external";
}
else
{ {
telescopeStatus[configuredSlot] = StatusDisconnected; case ConnectionVirtual:
typeString = "remote, unknown"; telescopeStatus[configuredSlot] = StatusStopped;
typeString = "virtual";
break;
case ConnectionInternal:
if(configuredTelescopeIsNew)
telescopeStatus[configuredSlot] = StatusStop
ped;//TODO: Is there a point? Isn't it better to force the status update me
thod?
typeString = "local, Stellarium";
break;
case ConnectionLocal:
telescopeStatus[configuredSlot] = StatusDisconnected
;
typeString = "local, external";
break;
case ConnectionRemote:
default:
telescopeStatus[configuredSlot] = StatusDisconnected
;
typeString = "remote, unknown";
} }
//Update the model/list //Update the model/list
if(configuredTelescopeIsNew) if(configuredTelescopeIsNew)
{ {
QList<QStandardItem *> newRow; QList<QStandardItem *> newRow;
newRow << new QStandardItem(QString::number(configuredSlot)) newRow << new QStandardItem(QString::number(configuredSlot))
<< new QStandardItem(statusString[telescopeStatus[con figuredSlot]]) << new QStandardItem(statusString[telescopeStatus[con figuredSlot]])
<< new QStandardItem(typeString) << new QStandardItem(typeString)
<< new QStandardItem(name); << new QStandardItem(name);
skipping to change at line 562 skipping to change at line 579
ui->telescopeTreeView->setFocus(); ui->telescopeTreeView->setFocus();
ui->telescopeTreeView->setCurrentIndex(telescopeListModel->i ndex(0,0)); ui->telescopeTreeView->setCurrentIndex(telescopeListModel->i ndex(0,0));
ui->pushButtonConfigure->setEnabled(true); ui->pushButtonConfigure->setEnabled(true);
ui->pushButtonRemove->setEnabled(true); ui->pushButtonRemove->setEnabled(true);
ui->telescopeTreeView->header()->setResizeMode(ColumnType, Q HeaderView::ResizeToContents); ui->telescopeTreeView->header()->setResizeMode(ColumnType, Q HeaderView::ResizeToContents);
ui->labelWarning->setText(LABEL_TEXT_CONTROL_TIP); ui->labelWarning->setText(LABEL_TEXT_CONTROL_TIP);
} }
configuredTelescopeIsNew = false; configuredTelescopeIsNew = false;
configurationDialog.setVisible(false); configurationDialog.setVisible(false);
dialog->setEnabled(true);
setVisible(true);//Brings the current window to the foreground setVisible(true);//Brings the current window to the foreground
} }
void TelescopeDialog::discardChanges() void TelescopeDialog::discardChanges()
{ {
configurationDialog.setVisible(false); configurationDialog.setVisible(false);
dialog->setEnabled(true);
setVisible(true);//Brings the current window to the foreground setVisible(true);//Brings the current window to the foreground
if (telescopeCount >= SLOT_COUNT) if (telescopeCount >= SLOT_COUNT)
ui->pushButtonAdd->setEnabled(false); ui->pushButtonAdd->setEnabled(false);
if (telescopeCount == 0) if (telescopeCount == 0)
ui->pushButtonRemove->setEnabled(false); ui->pushButtonRemove->setEnabled(false);
configuredTelescopeIsNew = false; configuredTelescopeIsNew = false;
} }
skipping to change at line 600 skipping to change at line 615
if (telescopeManager->isConnectedClientAtSlot(slotNumber)) if (telescopeManager->isConnectedClientAtSlot(slotNumber))
{ {
telescopeStatus[slotNumber] = StatusConnected; telescopeStatus[slotNumber] = StatusConnected;
} }
else if(telescopeManager->isExistingClientAtSlot(slotNumber) ) else if(telescopeManager->isExistingClientAtSlot(slotNumber) )
{ {
telescopeStatus[slotNumber] = StatusConnecting; telescopeStatus[slotNumber] = StatusConnecting;
} }
else else
{ {
if(telescopeType[slotNumber] == ConnectionLocalInter nal) if(telescopeType[slotNumber] == ConnectionInternal)
telescopeStatus[slotNumber] = StatusStopped; telescopeStatus[slotNumber] = StatusStopped;
else else
telescopeStatus[slotNumber] = StatusDisconne cted; telescopeStatus[slotNumber] = StatusDisconne cted;
} }
//Update the status in the list //Update the status in the list
telescopeListModel->setData(telescopeListModel->index(i, Col umnStatus), statusString[telescopeStatus[slotNumber]], Qt::DisplayRole); telescopeListModel->setData(telescopeListModel->index(i, Col umnStatus), statusString[telescopeStatus[slotNumber]], Qt::DisplayRole);
} }
if(ui->telescopeTreeView->currentIndex().isValid()) if(ui->telescopeTreeView->currentIndex().isValid())
{ {
int selectedSlot = telescopeListModel->data( telescopeListMo del->index(ui->telescopeTreeView->currentIndex().row(), ColumnSlot) ).toInt (); int selectedSlot = telescopeListModel->data( telescopeListMo del->index(ui->telescopeTreeView->currentIndex().row(), ColumnSlot) ).toInt ();
//Update the ChangeStatus button //Update the ChangeStatus button
updateStatusButtonForSlot(selectedSlot); updateStatusButtonForSlot(selectedSlot);
} }
} }
void TelescopeDialog::updateStatusButtonForSlot(int selectedSlot) void TelescopeDialog::updateStatusButtonForSlot(int selectedSlot)
{ {
if(telescopeType[selectedSlot] != ConnectionLocalInternal) if(telescopeType[selectedSlot] != ConnectionInternal)
{ {
//Can't be launched by Stellarium => can't be stopped by Ste llarium //Can't be launched by Stellarium => can't be stopped by Ste llarium
//Can be only connected/disconnected //Can be only connected/disconnected
if(telescopeStatus[selectedSlot] == StatusDisconnected) if(telescopeStatus[selectedSlot] == StatusDisconnected)
{ {
setStatusButtonToConnect(); setStatusButtonToConnect();
ui->pushButtonChangeStatus->setEnabled(true); ui->pushButtonChangeStatus->setEnabled(true);
} }
else else
{ {
skipping to change at line 683 skipping to change at line 698
ui->pushButtonChangeStatus->setText("Connect"); ui->pushButtonChangeStatus->setText("Connect");
ui->pushButtonChangeStatus->setToolTip("Connect to the selected tele scope"); ui->pushButtonChangeStatus->setToolTip("Connect to the selected tele scope");
} }
void TelescopeDialog::setStatusButtonToDisconnect() void TelescopeDialog::setStatusButtonToDisconnect()
{ {
ui->pushButtonChangeStatus->setText("Disconnect"); ui->pushButtonChangeStatus->setText("Disconnect");
ui->pushButtonChangeStatus->setToolTip("Disconnect from the selected telescope"); ui->pushButtonChangeStatus->setToolTip("Disconnect from the selected telescope");
} }
void TelescopeDialog::setStelStyle(const StelStyle& style) void TelescopeDialog::updateStyle()
{ {
if(dialog) if (dialog)
dialog->setStyleSheet(telescopeManager->getModuleStyleSheet( {
style.confSectionName)); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance()
.getGui());
Q_ASSERT(gui);
const StelStyle pluginStyle = telescopeManager->getModuleSty
leSheet(gui->getStelStyle());
dialog->setStyleSheet(pluginStyle.qtStyleSheet);
ui->textBrowserAbout->document()->setDefaultStyleSheet(QStri
ng(pluginStyle.htmlStyleSheet));
}
//Change the styles of all children, too //Change the styles of all children, too
configurationDialog.setStelStyle(style); configurationDialog.updateStyle();
} }
void TelescopeDialog::checkBoxUseExecutablesToggled(bool useExecutables) void TelescopeDialog::checkBoxUseExecutablesToggled(bool useExecutables)
{ {
telescopeManager->setFlagUseServerExecutables(useExecutables); telescopeManager->setFlagUseServerExecutables(useExecutables);
} }
void TelescopeDialog::buttonBrowseServerDirectoryPressed() void TelescopeDialog::buttonBrowseServerDirectoryPressed()
{ {
QString newPath = QFileDialog::getExistingDirectory (0, QString("Sel ect a directory"), telescopeManager->getServerExecutablesDirectoryPath()); QString newPath = QFileDialog::getExistingDirectory (0, QString("Sel ect a directory"), telescopeManager->getServerExecutablesDirectoryPath());
 End of changes. 36 change blocks. 
80 lines changed or deleted 105 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/