TelescopeConfigurationDialog.cpp   TelescopeConfigurationDialog.cpp 
skipping to change at line 93 skipping to change at line 93
connect(ui->pushButtonSave, SIGNAL(clicked()), this, SLOT(buttonSave Pressed())); connect(ui->pushButtonSave, SIGNAL(clicked()), this, SLOT(buttonSave Pressed()));
connect(ui->pushButtonDiscard, SIGNAL(clicked()), this, SLOT(buttonD iscardPressed())); connect(ui->pushButtonDiscard, SIGNAL(clicked()), this, SLOT(buttonD iscardPressed()));
connect(ui->comboBoxDeviceModel, SIGNAL(currentIndexChanged(const QS tring&)), this, SLOT(deviceModelSelected(const QString&))); connect(ui->comboBoxDeviceModel, SIGNAL(currentIndexChanged(const QS tring&)), this, SLOT(deviceModelSelected(const QString&)));
//Setting validators //Setting validators
ui->lineEditTelescopeName->setValidator(telescopeNameValidator); ui->lineEditTelescopeName->setValidator(telescopeNameValidator);
ui->lineEditHostName->setValidator(hostNameValidator); ui->lineEditHostName->setValidator(hostNameValidator);
ui->lineEditCircleList->setValidator(circleListValidator); ui->lineEditCircleList->setValidator(circleListValidator);
ui->lineEditSerialPort->setValidator(serialPortValidator); ui->lineEditSerialPort->setValidator(serialPortValidator);
//Initialize the style
updateStyle();
} }
//Set the configuration panel in a predictable state //Set the configuration panel in a predictable state
void TelescopeConfigurationDialog::initConfigurationDialog() void TelescopeConfigurationDialog::initConfigurationDialog()
{ {
//Reusing code used in both methods that call this one //Reusing code used in both methods that call this one
deviceModelNames = telescopeManager->getDeviceModels().keys(); deviceModelNames = telescopeManager->getDeviceModels().keys();
//Type //Type
ui->radioButtonTelescopeLocal->setEnabled(true); ui->radioButtonTelescopeLocal->setEnabled(true);
//Name //Name
ui->lineEditTelescopeName->clear(); ui->lineEditTelescopeName->clear();
//Equinox
ui->radioButtonJ2000->setChecked(true);
//Connect at startup //Connect at startup
ui->checkBoxConnectAtStartup->setChecked(false); ui->checkBoxConnectAtStartup->setChecked(false);
//Serial port //Serial port
ui->lineEditSerialPort->clear(); ui->lineEditSerialPort->clear();
ui->lineEditSerialPort->setCompleter(new QCompleter(SERIAL_PORT_NAME S, this)); ui->lineEditSerialPort->setCompleter(new QCompleter(SERIAL_PORT_NAME S, this));
ui->lineEditSerialPort->setText(SERIAL_PORT_NAMES.value(0)); ui->lineEditSerialPort->setText(SERIAL_PORT_NAMES.value(0));
//Populating the list of available devices //Populating the list of available devices
ui->comboBoxDeviceModel->clear(); ui->comboBoxDeviceModel->clear();
skipping to change at line 164 skipping to change at line 164
void TelescopeConfigurationDialog::initExistingTelescopeConfiguration(int s lot) void TelescopeConfigurationDialog::initExistingTelescopeConfiguration(int s lot)
{ {
configuredSlot = slot; configuredSlot = slot;
initConfigurationDialog(); initConfigurationDialog();
ui->stelWindowTitle->setText("Configure Telescope"); ui->stelWindowTitle->setText("Configure Telescope");
//Read the telescope properties //Read the telescope properties
QString name; QString name;
ConnectionType connectionType; ConnectionType connectionType;
QString equinox;
QString host; QString host;
int portTCP; int portTCP;
int delay; int delay;
bool connectAtStartup; bool connectAtStartup;
QList<double> circles; QList<double> circles;
QString deviceModelName; QString deviceModelName;
QString serialPortName; QString serialPortName;
if(!telescopeManager->getTelescopeAtSlot(slot, connectionType, name, host, portTCP, delay, connectAtStartup, circles, deviceModelName, serialPo rtName)) if(!telescopeManager->getTelescopeAtSlot(slot, connectionType, name, equinox, host, portTCP, delay, connectAtStartup, circles, deviceModelName, serialPortName))
{ {
//TODO: Add debug //TODO: Add debug
return; return;
} }
ui->lineEditTelescopeName->setText(name); ui->lineEditTelescopeName->setText(name);
if(!deviceModelName.isEmpty()) if(!deviceModelName.isEmpty())
{ {
ui->radioButtonTelescopeLocal->setChecked(true); ui->radioButtonTelescopeLocal->setChecked(true);
skipping to change at line 200 skipping to change at line 201
emit changesDiscarded(); emit changesDiscarded();
return; return;
} }
else else
{ {
ui->comboBoxDeviceModel->setCurrentIndex(index); ui->comboBoxDeviceModel->setCurrentIndex(index);
} }
//Initialize the serial port value //Initialize the serial port value
ui->lineEditSerialPort->setText(serialPortName); ui->lineEditSerialPort->setText(serialPortName);
} }
else //Local or remote connection else if (connectionType == ConnectionRemote)
{ {
ui->radioButtonTelescopeConnection->setChecked(true);//Calls toggleTypeConnection(true) ui->radioButtonTelescopeConnection->setChecked(true);//Calls toggleTypeConnection(true)
if (connectionType == ConnectionRemote) ui->lineEditHostName->setText(host);
ui->lineEditHostName->setText(host); }
else
{
ui->radioButtonTelescopeVirtual->setChecked(true);
} }
//Equinox
if (equinox == "JNow")
ui->radioButtonJNow->setChecked(true);
else
ui->radioButtonJ2000->setChecked(true);
//Circles //Circles
if(!circles.isEmpty()) if(!circles.isEmpty())
{ {
ui->checkBoxCircles->setChecked(true); ui->checkBoxCircles->setChecked(true);
QStringList circleList; QStringList circleList;
for(int i = 0; i < circles.size(); i++) for(int i = 0; i < circles.size(); i++)
circleList.append(QString::number(circles[i])); circleList.append(QString::number(circles[i]));
ui->lineEditCircleList->setText(circleList.join(", ")); ui->lineEditCircleList->setText(circleList.join(", "));
} }
skipping to change at line 242 skipping to change at line 252
//Re-initialize values that may have been changed //Re-initialize values that may have been changed
ui->comboBoxDeviceModel->setCurrentIndex(0); ui->comboBoxDeviceModel->setCurrentIndex(0);
ui->lineEditSerialPort->setText(SERIAL_PORT_NAMES.value(0)); ui->lineEditSerialPort->setText(SERIAL_PORT_NAMES.value(0));
ui->lineEditHostName->setText("localhost"); ui->lineEditHostName->setText("localhost");
ui->spinBoxTCPPort->setValue(DEFAULT_TCP_PORT_FOR_SLOT(confi guredSlot)); ui->spinBoxTCPPort->setValue(DEFAULT_TCP_PORT_FOR_SLOT(confi guredSlot));
//Enable/disable controls //Enable/disable controls
ui->labelHost->setEnabled(false); ui->labelHost->setEnabled(false);
ui->lineEditHostName->setEnabled(false); ui->lineEditHostName->setEnabled(false);
ui->toolBoxSettings->setCurrentIndex(ui->toolBoxSettings->in dexOf(ui->pageTelescopeProperties)); ui->scrollArea->ensureWidgetVisible(ui->groupBoxTelescopePro perties);
} }
else else
{ {
ui->labelHost->setEnabled(true); ui->labelHost->setEnabled(true);
ui->lineEditHostName->setEnabled(true); ui->lineEditHostName->setEnabled(true);
} }
} }
void TelescopeConfigurationDialog::toggleTypeConnection(bool isChecked) void TelescopeConfigurationDialog::toggleTypeConnection(bool isChecked)
{ {
if(isChecked) if(isChecked)
{ {
//Re-initialize values that may have been changed //Re-initialize values that may have been changed
ui->lineEditHostName->setText("localhost"); ui->lineEditHostName->setText("localhost");
ui->spinBoxTCPPort->setValue(DEFAULT_TCP_PORT_FOR_SLOT(confi guredSlot)); ui->spinBoxTCPPort->setValue(DEFAULT_TCP_PORT_FOR_SLOT(confi guredSlot));
ui->toolBoxSettings->setItemEnabled(ui->toolBoxSettings->ind exOf(ui->pageDeviceSettings), false); ui->groupBoxDeviceSettings->setEnabled(false);
ui->toolBoxSettings->setCurrentIndex(ui->toolBoxSettings->in dexOf(ui->pageTelescopeProperties)); ui->scrollArea->ensureWidgetVisible(ui->groupBoxTelescopePro perties);
} }
else else
{ {
ui->toolBoxSettings->setItemEnabled(ui->toolBoxSettings->ind exOf(ui->pageDeviceSettings), true); ui->groupBoxDeviceSettings->setEnabled(true);
} }
} }
void TelescopeConfigurationDialog::toggleTypeVirtual(bool isChecked) void TelescopeConfigurationDialog::toggleTypeVirtual(bool isChecked)
{ {
if(isChecked) //TODO: This really should be done in the GUI
{ ui->groupBoxDeviceSettings->setEnabled(!isChecked);
ui->toolBoxSettings->setItemEnabled(ui->toolBoxSettings->ind ui->groupBoxConnectionSettings->setEnabled(!isChecked);
exOf(ui->pageDeviceSettings), false);
ui->toolBoxSettings->setItemEnabled(ui->toolBoxSettings->ind
exOf(ui->pageConnectionSettings), false);
ui->toolBoxSettings->setCurrentIndex(ui->toolBoxSettings->in ui->scrollArea->ensureWidgetVisible(ui->groupBoxTelescopeProperties)
dexOf(ui->pageTelescopeProperties)); ;
}
else
{
ui->toolBoxSettings->setItemEnabled(ui->toolBoxSettings->ind
exOf(ui->pageDeviceSettings), true);
ui->toolBoxSettings->setItemEnabled(ui->toolBoxSettings->ind
exOf(ui->pageConnectionSettings), true);
}
} }
void TelescopeConfigurationDialog::buttonSavePressed() void TelescopeConfigurationDialog::buttonSavePressed()
{ {
//Main telescope properties //Main telescope properties
QString name = ui->lineEditTelescopeName->text().trimmed(); QString name = ui->lineEditTelescopeName->text().trimmed();
if(name.isEmpty()) if(name.isEmpty())
return; return;
QString host = ui->lineEditHostName->text(); QString host = ui->lineEditHostName->text();
if(host.isEmpty())//TODO: Validate host if(host.isEmpty())//TODO: Validate host
skipping to change at line 320 skipping to change at line 323
for(int i = 0; i < circleStrings.size(); i++) for(int i = 0; i < circleStrings.size(); i++)
{ {
if(i >= MAX_CIRCLE_COUNT) if(i >= MAX_CIRCLE_COUNT)
break; break;
double circle = circleStrings.at(i).toDouble(); double circle = circleStrings.at(i).toDouble();
if(circle > 0.0) if(circle > 0.0)
circles.append(circle); circles.append(circle);
} }
} }
QString equinox("J2000");
if (ui->radioButtonJNow->isChecked())
equinox = "JNow";
//Type and server properties //Type and server properties
//TODO: When adding, check for success! //TODO: When adding, check for success!
ConnectionType type = ConnectionNA; ConnectionType type = ConnectionNA;
if(ui->radioButtonTelescopeLocal->isChecked()) if(ui->radioButtonTelescopeLocal->isChecked())
{ {
//Read the serial port //Read the serial port
QString serialPortName = ui->lineEditSerialPort->text(); QString serialPortName = ui->lineEditSerialPort->text();
if(!serialPortName.startsWith(SERIAL_PORT_PREFIX)) if(!serialPortName.startsWith(SERIAL_PORT_PREFIX))
return;//TODO: Add more validation! return;//TODO: Add more validation!
type = ConnectionInternal; type = ConnectionInternal;
telescopeManager->addTelescopeAtSlot(configuredSlot, type, n ame, host, portTCP, delay, connectAtStartup, circles, ui->comboBoxDeviceMod el->currentText(), serialPortName); telescopeManager->addTelescopeAtSlot(configuredSlot, type, n ame, equinox, host, portTCP, delay, connectAtStartup, circles, ui->comboBox DeviceModel->currentText(), serialPortName);
} }
else if (ui->radioButtonTelescopeConnection->isChecked()) else if (ui->radioButtonTelescopeConnection->isChecked())
{ {
if(host == "localhost") if(host == "localhost")
type = ConnectionLocal; type = ConnectionLocal;
else else
type = ConnectionRemote; type = ConnectionRemote;
telescopeManager->addTelescopeAtSlot(configuredSlot, type, n ame, host, portTCP, delay, connectAtStartup, circles); telescopeManager->addTelescopeAtSlot(configuredSlot, type, n ame, equinox, host, portTCP, delay, connectAtStartup, circles);
} }
else if (ui->radioButtonTelescopeVirtual->isChecked()) else if (ui->radioButtonTelescopeVirtual->isChecked())
{ {
type = ConnectionVirtual; type = ConnectionVirtual;
telescopeManager->addTelescopeAtSlot(configuredSlot, type, n ame, QString(), portTCP, delay, connectAtStartup, circles); telescopeManager->addTelescopeAtSlot(configuredSlot, type, n ame, equinox, QString(), portTCP, delay, connectAtStartup, circles);
} }
emit changesSaved(name, type); emit changesSaved(name, type);
} }
void TelescopeConfigurationDialog::buttonDiscardPressed() void TelescopeConfigurationDialog::buttonDiscardPressed()
{ {
emit changesDiscarded(); emit changesDiscarded();
} }
void TelescopeConfigurationDialog::deviceModelSelected(const QString& devic eModelName) void TelescopeConfigurationDialog::deviceModelSelected(const QString& devic eModelName)
{ {
ui->labelDeviceModelDescription->setText(telescopeManager->getDevice Models().value(deviceModelName).description); ui->labelDeviceModelDescription->setText(telescopeManager->getDevice Models().value(deviceModelName).description);
ui->doubleSpinBoxTelescopeDelay->setValue(SECONDS_FROM_MICROSECONDS( telescopeManager->getDeviceModels().value(deviceModelName).defaultDelay)); ui->doubleSpinBoxTelescopeDelay->setValue(SECONDS_FROM_MICROSECONDS( telescopeManager->getDeviceModels().value(deviceModelName).defaultDelay));
} }
void TelescopeConfigurationDialog::updateStyle()
{
if (dialog)
{
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance()
.getGui());
Q_ASSERT(gui);
dialog->setStyleSheet(telescopeManager->getModuleStyleSheet(
gui->getStelStyle()).qtStyleSheet);
}
}
 End of changes. 18 change blocks. 
30 lines changed or deleted 33 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/