void MpcImportWindow::createDialogContent() { ui->setupUi(dialog); //Signals connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint))); connect(ui->pushButtonAcquire, SIGNAL(clicked()), this, SLOT(acquireObjectData())); connect(ui->pushButtonAbortDownload, SIGNAL(clicked()), this, SLOT(abortDownload())); connect(ui->pushButtonAdd, SIGNAL(clicked()), this, SLOT(addObjects())); connect(ui->pushButtonDiscard, SIGNAL(clicked()), this, SLOT(discardObjects())); connect(ui->pushButtonBrowse, SIGNAL(clicked()), this, SLOT(selectFile())); connect(ui->comboBoxBookmarks, SIGNAL(currentIndexChanged(QString)), this, SLOT(bookmarkSelected(QString))); connect(ui->radioButtonFile, SIGNAL(toggled(bool)), ui->frameFile, SLOT(setVisible(bool))); connect(ui->radioButtonURL, SIGNAL(toggled(bool)), ui->frameURL, SLOT(setVisible(bool))); connect(ui->radioButtonAsteroids, SIGNAL(toggled(bool)), this, SLOT(switchImportType(bool))); connect(ui->radioButtonComets, SIGNAL(toggled(bool)), this, SLOT(switchImportType(bool))); connect(ui->pushButtonMarkAll, SIGNAL(clicked()), this, SLOT(markAll())); connect(ui->pushButtonMarkNone, SIGNAL(clicked()), this, SLOT(unmarkAll())); connect(ui->pushButtonSendQuery, SIGNAL(clicked()), this, SLOT(sendQuery())); connect(ui->lineEditQuery, SIGNAL(returnPressed()), this, SLOT(sendQuery())); connect(ui->pushButtonAbortQuery, SIGNAL(clicked()), this, SLOT(abortQuery())); connect(ui->lineEditQuery, SIGNAL(textEdited(QString)), this, SLOT(resetNotFound())); //connect(ui->lineEditQuery, SIGNAL(editingFinished()), this, SLOT(sendQuery())); connect(countdownTimer, SIGNAL(timeout()), this, SLOT(updateCountdown())); QSortFilterProxyModel * filterProxyModel = new QSortFilterProxyModel(this); filterProxyModel->setSourceModel(candidateObjectsModel); filterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); ui->listViewObjects->setModel(filterProxyModel); connect(ui->lineEditSearch, SIGNAL(textChanged(const QString&)), filterProxyModel, SLOT(setFilterFixedString(const QString&))); loadBookmarks(); updateTexts(); resetCountdown(); resetDialog(); }
void SearchDialog::onSearchFields(const QString &AId, const ISearchFields &AFields) { if (FRequestId == AId) { resetDialog(); if (!setDataForm(AFields.form)) { ui.lblInstructions->setText(AFields.instructions); ui.lneFirst->setText(AFields.item.firstName); ui.lblFirst->setVisible((AFields.fieldMask & ISearchFields::First) > 0); ui.lneFirst->setVisible((AFields.fieldMask & ISearchFields::First) > 0); ui.lneLast->setText(AFields.item.lastName); ui.lblLast->setVisible((AFields.fieldMask & ISearchFields::Last) > 0); ui.lneLast->setVisible((AFields.fieldMask & ISearchFields::Last) > 0); ui.lneNick->setText(AFields.item.nick); ui.lblNick->setVisible((AFields.fieldMask & ISearchFields::Nick) > 0); ui.lneNick->setVisible((AFields.fieldMask & ISearchFields::Nick) > 0); ui.lneEmail->setText(AFields.item.email); ui.lblEmail->setVisible((AFields.fieldMask & ISearchFields::Email) > 0); ui.lneEmail->setVisible((AFields.fieldMask & ISearchFields::Email) > 0); ui.stwWidgets->setCurrentWidget(ui.pgeFields); } ui.dbbButtons->setStandardButtons(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); } }
void SearchDialog::requestResult() { if (!FCurrentForm || FCurrentForm->checkForm(true)) { ISearchSubmit submit; submit.serviceJid = FServiceJid; if (!FCurrentForm) { submit.item.firstName = ui.lneFirst->text(); submit.item.lastName = ui.lneLast->text(); submit.item.nick = ui.lneNick->text(); submit.item.email = ui.lneEmail->text(); } else { submit.form = FDataForms->dataSubmit(FCurrentForm->userDataForm()); } FRequestId = FSearch->sendSubmit(FStreamJid,submit); resetDialog(); if (!FRequestId.isEmpty()) { ui.lblInstructions->setText(tr("Waiting for host response ...")); ui.dbbButtons->setStandardButtons(QDialogButtonBox::Cancel); } else { ui.lblInstructions->setText(tr("Error: Can't send request to host.")); ui.dbbButtons->setStandardButtons(QDialogButtonBox::Retry|QDialogButtonBox::Close); } } }
void RegisterDialog::onRegisterError(const QString &AId, const XmppError &AError) { if (FRequestId == AId) { resetDialog(); ui.lblInstuctions->setText(tr("Requested operation failed: %1").arg(AError.errorMessage())); ui.dbbButtons->setStandardButtons(QDialogButtonBox::Retry|QDialogButtonBox::Cancel); } }
void RegisterDialog::doChangePassword() { resetDialog(); ui.lblInstuctions->setText(tr("Enter your username and new password.")); ui.lneUserName->setVisible(true); ui.lblUserName->setVisible(true); ui.lnePassword->setVisible(true); ui.lblPassword->setVisible(true); ui.dbbButtons->setStandardButtons(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); }
void RegisterDialog::doRegister() { FRequestId = FRegistration->sendRegisterRequest(FStreamJid,FServiceJid); resetDialog(); if (!FRequestId.isEmpty()) ui.lblInstuctions->setText(tr("Waiting for host response ...")); else ui.lblInstuctions->setText(tr("Error: Can't send request to host.")); ui.dbbButtons->setStandardButtons(QDialogButtonBox::Cancel); }
void RegisterDialog::onRegisterSuccess(const QString &AId) { if (FRequestId == AId) { resetDialog(); if (FOperation == IRegistration::Register) ui.lblInstuctions->setText(tr("You are successfully registered at %1").arg(Qt::escape(FSubmit.serviceJid.uFull()))); else if (FOperation == IRegistration::Unregister) ui.lblInstuctions->setText(tr("You are successfully unregistered from %1").arg(Qt::escape(FSubmit.serviceJid.uFull()))); else if (FOperation == IRegistration::ChangePassword) ui.lblInstuctions->setText(tr("Password was successfully changed at %1").arg(Qt::escape(FSubmit.serviceJid.uFull()))); ui.dbbButtons->setStandardButtons(QDialogButtonBox::Close); } }
void SearchDialog::requestFields() { FRequestId = FSearch->sendRequest(FStreamJid,FServiceJid); resetDialog(); if (!FRequestId.isEmpty()) { ui.lblInstructions->setText(tr("Waiting for host response ...")); ui.dbbButtons->setStandardButtons(QDialogButtonBox::Cancel); } else { ui.lblInstructions->setText(tr("Error: Can't send request to host.")); ui.dbbButtons->setStandardButtons(QDialogButtonBox::Retry|QDialogButtonBox::Cancel); } }
void RegisterDialog::onDialogButtonsClicked(QAbstractButton *AButton) { QDialogButtonBox::StandardButton button = ui.dbbButtons->standardButton(AButton); if (button == QDialogButtonBox::Ok) { if (FOperation == IRegistration::Register) { if (!FCurrentForm || FCurrentForm->checkForm(true)) { FSubmit.username = ui.lneUserName->text(); FSubmit.password = ui.lnePassword->text(); FSubmit.email = ui.lneEMail->text(); FSubmit.form = FCurrentForm!=NULL ? FDataForms->dataSubmit(FCurrentForm->userDataForm()) : IDataForm(); FRequestId = FRegistration->sendRequestSubmit(FStreamJid,FSubmit); } } else if (FOperation == IRegistration::Unregister) { FRequestId = FRegistration->sendUnregisterRequest(FStreamJid,FServiceJid); } else if (FOperation == IRegistration::ChangePassword) { FRequestId = FRegistration->sendChangePasswordRequest(FStreamJid,FServiceJid,ui.lneUserName->text(),ui.lnePassword->text()); } resetDialog(); if (!FRequestId.isEmpty()) ui.lblInstuctions->setText(tr("Waiting for host response ...")); else ui.lblInstuctions->setText(tr("Error: Can't send request to host.")); ui.dbbButtons->setStandardButtons(QDialogButtonBox::Cancel); } else if (button == QDialogButtonBox::Retry) { doRegisterOperation(); } else if (button == QDialogButtonBox::Cancel) { setResult(QDialogButtonBox::Cancel); close(); } else if (button == QDialogButtonBox::Close) { setResult(QDialogButtonBox::Close); close(); } }
void RegisterDialog::onRegisterFields(const QString &AId, const IRegisterFields &AFields) { if (FRequestId == AId) { resetDialog(); FSubmit.key = AFields.key; if (AFields.fieldMask & IRegisterFields::Form) { FSubmit.fieldMask = IRegisterFields::Form; IDataForm form = FDataForms->localizeForm(AFields.form); FCurrentForm = FDataForms->formWidget(form,ui.spgDataForm); if (!form.title.isEmpty()) setWindowTitle(form.title); ui.spgDataForm->layout()->addWidget(FCurrentForm->instance()); ui.stwForm->setCurrentWidget(ui.spgDataForm); } else { FSubmit.fieldMask = AFields.fieldMask; if (!AFields.instructions.isEmpty()) ui.lblInstuctions->setText(AFields.instructions); ui.lneUserName->setText(AFields.username); ui.lnePassword->setText(AFields.password); ui.lneEMail->setText(AFields.email); ui.lneUserName->setVisible((AFields.fieldMask & IRegisterFields::Username) > 0); ui.lblUserName->setVisible((AFields.fieldMask & IRegisterFields::Username) > 0); ui.lnePassword->setVisible((AFields.fieldMask & IRegisterFields::Password) > 0); ui.lblPassword->setVisible((AFields.fieldMask & IRegisterFields::Password) > 0); ui.lneEMail->setVisible((AFields.fieldMask & IRegisterFields::Email) > 0); ui.lblEmail->setVisible((AFields.fieldMask & IRegisterFields::Email) > 0); ui.stwForm->setCurrentWidget(ui.spgForm); } ui.dbbButtons->setStandardButtons(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); } }
void SearchDialog::onSearchResult(const QString &AId, const ISearchResult &AResult) { if (FRequestId == AId) { resetDialog(); if (!setDataForm(AResult.form)) { int row = 0; ui.tbwResult->setRowCount(AResult.items.count()); foreach(const ISearchItem &item, AResult.items) { QTableWidgetItem *itemJid = new QTableWidgetItem(item.itemJid.uFull()); itemJid->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable); QTableWidgetItem *itemFirst = new QTableWidgetItem(item.firstName); itemFirst->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable); QTableWidgetItem *itemLast = new QTableWidgetItem(item.lastName); itemLast->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable); QTableWidgetItem *itemNick = new QTableWidgetItem(item.nick); itemNick->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable); QTableWidgetItem *itemEmail = new QTableWidgetItem(item.email); itemEmail->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable); ui.tbwResult->setItem(row,COL_JID,itemJid); ui.tbwResult->setItem(row,COL_FIRST,itemFirst); ui.tbwResult->setItem(row,COL_LAST,itemLast); ui.tbwResult->setItem(row,COL_NICK,itemNick); ui.tbwResult->setItem(row,COL_EMAIL,itemEmail); row++; } ui.tbwResult->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); ui.tbwResult->verticalHeader()->resizeSections(QHeaderView::ResizeToContents); ui.stwWidgets->setCurrentWidget(ui.pgeResult); }
void RegisterDialog::doUnregister() { resetDialog(); ui.lblInstuctions->setText(tr("Do you really want to remove registration from %1?").arg(Qt::escape(FServiceJid.uFull()))); ui.dbbButtons->setStandardButtons(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); }
void MpcImportWindow::discardObjects() { resetDialog(); }
void MpcImportWindow::addObjects() { disconnect(ssoManager, SIGNAL(solarSystemChanged()), this, SLOT(resetDialog())); QList<QString> checkedObjectsNames; //Extract the marked objects //TODO: Something smarter? for (int row = 0; row < candidateObjectsModel->rowCount(); row++) { QStandardItem * item = candidateObjectsModel->item(row); if (item->checkState() == Qt::Checked) { checkedObjectsNames.append(item->text()); } } //qDebug() << "Checked:" << checkedObjectsNames; QList<SsoElements> approvedForAddition; for (int i = 0; i < candidatesForAddition.count(); i++) { QString name = candidatesForAddition.at(i).value("name").toString(); if (checkedObjectsNames.contains(name)) approvedForAddition.append(candidatesForAddition.at(i)); } bool overwrite = ui->radioButtonOverwrite->isChecked(); QList<SsoElements> approvedForUpdate; for (int j = 0; j < candidatesForUpdate.count(); j++) { QString name = candidatesForUpdate.at(j).value("name").toString(); if (checkedObjectsNames.contains(name)) { if (overwrite) { approvedForAddition.append(candidatesForUpdate.at(j)); } else { approvedForUpdate.append(candidatesForUpdate.at(j)); } } } //Write to file ssoManager->appendToSolarSystemConfigurationFile(approvedForAddition); if (ui->radioButtonUpdate->isChecked()) { SolarSystemEditor::UpdateFlags flags(SolarSystemEditor::UpdateNameAndNumber | SolarSystemEditor::UpdateOrbitalElements); if (!ui->checkBoxOnlyOrbitalElements->isChecked()) { flags |= SolarSystemEditor::UpdateType; flags |= SolarSystemEditor::UpdateMagnitudeParameters; } ssoManager->updateSolarSystemConfigurationFile(approvedForUpdate, flags); } //Refresh the Solar System GETSTELMODULE(SolarSystem)->reloadPlanets(); resetDialog(); emit objectsImported(); }