TelescopeConfigurationDialog.cpp   TelescopeConfigurationDialog.cpp 
skipping to change at line 37 skipping to change at line 37
#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 "StelTranslator.hpp" #include "StelTranslator.hpp"
#include <QDebug> #include <QDebug>
#include <QCompleter> #include <QCompleter>
#include <QFrame> #include <QFrame>
#include <QTimer> #include <QTimer>
#include <QtSerialPort/QSerialPortInfo>
#include <QFile>
#include <QDir>
TelescopeConfigurationDialog::TelescopeConfigurationDialog() TelescopeConfigurationDialog::TelescopeConfigurationDialog()
: configuredSlot(0) : configuredSlot(0)
{ {
ui = new Ui_telescopeConfigurationDialog; ui = new Ui_telescopeConfigurationDialog;
telescopeManager = GETSTELMODULE(TelescopeControl); telescopeManager = GETSTELMODULE(TelescopeControl);
telescopeNameValidator = new QRegExpValidator (QRegExp("[^:\"]+"), t his);//Test the update for JSON telescopeNameValidator = new QRegExpValidator (QRegExp("[^:\"]+"), t his);//Test the update for JSON
hostNameValidator = new QRegExpValidator (QRegExp("[a-zA-Z0-9\\-\\.] +"), this);//TODO: Write a proper host/IP regexp? hostNameValidator = new QRegExpValidator (QRegExp("[a-zA-Z0-9\\-\\.] +"), this);//TODO: Write a proper host/IP regexp?
circleListValidator = new QRegExpValidator (QRegExp("[0-9,\\.\\s]+") , this); circleListValidator = new QRegExpValidator (QRegExp("[0-9,\\.\\s]+") , this);
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
serialPortValidator = new QRegExpValidator (QRegExp("COM[0-9]+"), th is); serialPortValidator = new QRegExpValidator (QRegExp("COM[0-9]+"), th is);
#else #else
serialPortValidator = new QRegExpValidator (QRegExp("/dev/.*"), this ); serialPortValidator = new QRegExpValidator (QRegExp("/.*"), this);
#endif #endif
} }
TelescopeConfigurationDialog::~TelescopeConfigurationDialog() TelescopeConfigurationDialog::~TelescopeConfigurationDialog()
{ {
delete ui; delete ui;
delete telescopeNameValidator; delete telescopeNameValidator;
delete hostNameValidator; delete hostNameValidator;
delete circleListValidator; delete circleListValidator;
delete serialPortValidator; delete serialPortValidator;
} }
QStringList* TelescopeConfigurationDialog::listSerialPorts()
{
// list real serial ports
QStringList *plist = new QStringList();
foreach (const QSerialPortInfo &serialPortInfo, QSerialPortInfo::ava
ilablePorts()) {
plist->append(serialPortInfo.systemLocation());
}
// on linux find some virtual ports
#ifdef Q_OS_LINUX
QStringList filters;
filters << "ttyNET*" << "ttynet*" << "Telescope*";
// look in /dev/*
QDir dev("/dev");
dev.setFilter(QDir::System);
dev.setSorting(QDir::Reversed);
dev.setNameFilters(filters);
QFileInfoList list = dev.entryInfoList();
for (int i = 0; i < list.size(); i ++) {
QFileInfo fileInfo = list.at(i);
plist->append(fileInfo.absoluteFilePath());
}
// look in /tmp/* for non-root virtual ports (append ttyS8 and ttyUS
B*)
filters << "ttyS*" << "ttyUSB*";
QDir tmp("/tmp");
tmp.setFilter(QDir::System);
tmp.setSorting(QDir::Reversed);
tmp.setNameFilters(filters);
list = tmp.entryInfoList();
for (int i = 0; i < list.size(); i ++) {
QFileInfo fileInfo = list.at(i);
plist->append(fileInfo.absoluteFilePath());
}
#endif
return plist;
}
void TelescopeConfigurationDialog::retranslate() void TelescopeConfigurationDialog::retranslate()
{ {
if (dialog) if (dialog)
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
} }
// Initialize the dialog widgets and connect the signals/slots // Initialize the dialog widgets and connect the signals/slots
void TelescopeConfigurationDialog::createDialogContent() void TelescopeConfigurationDialog::createDialogContent()
{ {
ui->setupUi(dialog); ui->setupUi(dialog);
skipping to change at line 95 skipping to change at line 136
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->comboSerialPort->setValidator(serialPortValidator);
} }
//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();
//Name //Name
ui->lineEditTelescopeName->clear(); ui->lineEditTelescopeName->clear();
//Equinox //Equinox
ui->radioButtonJ2000->setChecked(true); 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(); QStringList *plist = listSerialPorts();
ui->lineEditSerialPort->setCompleter(new QCompleter(SERIAL_PORT_NAME ui->comboSerialPort->clear();
S, this)); ui->comboSerialPort->addItems(*plist);
ui->lineEditSerialPort->setText(SERIAL_PORT_NAMES.value(0)); ui->comboSerialPort->activated(plist->value(0));
ui->comboSerialPort->setEditText(plist->value(0));
delete(plist);
//Populating the list of available devices //Populating the list of available devices
ui->comboBoxDeviceModel->clear(); ui->comboBoxDeviceModel->clear();
if (!deviceModelNames.isEmpty()) if (!deviceModelNames.isEmpty())
{ {
deviceModelNames.sort(); deviceModelNames.sort();
ui->comboBoxDeviceModel->addItems(deviceModelNames); ui->comboBoxDeviceModel->addItems(deviceModelNames);
} }
ui->comboBoxDeviceModel->setCurrentIndex(0); ui->comboBoxDeviceModel->setCurrentIndex(0);
skipping to change at line 201 skipping to change at line 245
{ {
qDebug() << "TelescopeConfigurationDialog: Current d evice model is not in the list?"; qDebug() << "TelescopeConfigurationDialog: Current d evice model is not in the list?";
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->comboSerialPort->activated(serialPortName);
ui->comboSerialPort->setEditText(serialPortName);
} }
else if (connectionType == ConnectionRemote) else if (connectionType == ConnectionRemote)
{ {
ui->radioButtonTelescopeConnection->setChecked(true);//Calls toggleTypeConnection(true) ui->radioButtonTelescopeConnection->setChecked(true);//Calls toggleTypeConnection(true)
ui->lineEditHostName->setText(host); ui->lineEditHostName->setText(host);
} }
else if (connectionType == ConnectionLocal) else if (connectionType == ConnectionLocal)
{ {
ui->radioButtonTelescopeConnection->setChecked(true); ui->radioButtonTelescopeConnection->setChecked(true);
ui->lineEditHostName->setText("localhost"); ui->lineEditHostName->setText("localhost");
skipping to change at line 251 skipping to change at line 296
//Connect at startup //Connect at startup
ui->checkBoxConnectAtStartup->setChecked(connectAtStartup); ui->checkBoxConnectAtStartup->setChecked(connectAtStartup);
} }
void TelescopeConfigurationDialog::toggleTypeLocal(bool isChecked) void TelescopeConfigurationDialog::toggleTypeLocal(bool isChecked)
{ {
if(isChecked) if(isChecked)
{ {
//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)); QStringList *plist = listSerialPorts();
ui->comboSerialPort->activated(plist->value(0));
ui->comboSerialPort->setEditText(plist->value(0));
delete(plist);
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->scrollArea->ensureWidgetVisible(ui->groupBoxTelescopePro perties); ui->scrollArea->ensureWidgetVisible(ui->groupBoxTelescopePro perties);
} }
else else
skipping to change at line 343 skipping to change at line 391
QString equinox("J2000"); QString equinox("J2000");
if (ui->radioButtonJNow->isChecked()) if (ui->radioButtonJNow->isChecked())
equinox = "JNow"; 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->comboSerialPort->currentText();
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, equinox, host, portTCP, delay, connectAtStartup, circles, ui->comboBox DeviceModel->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;
 End of changes. 8 change blocks. 
9 lines changed or deleted 58 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/