From 3e94aa0edadfcfe8f59d4d914d333aff6c436151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Poizl?= Date: Tue, 14 Jun 2022 22:46:40 +0200 Subject: [PATCH] Add search by RA and DEC point --- databaseview.cpp | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/databaseview.cpp b/databaseview.cpp index c54785c..7418f00 100644 --- a/databaseview.cpp +++ b/databaseview.cpp @@ -8,10 +8,34 @@ #include #include #include +#include #include const QStringList DEFAULT_COLUMNS = {"EXPTIME", "OBJECT", "RA", "DEC"}; +double RA(const QString &ra) +{ + QRegularExpression reg("(\\d+)\\s*(\\d+)?\\s*(\\d+)?"); + QRegularExpressionMatch match = reg.match(ra); + double h = match.captured(1).toDouble(); + double m = match.captured(2).toDouble(); + double s = match.captured(3).toDouble(); + qDebug() << match.capturedTexts() << h << m << s; + return h*15 + m*0.25 + s*15/3600; +} + +double DEC(const QString &dec) +{ + QRegularExpression reg("([\\+\\-])?(\\d+)\\s*(\\d+)?\\s*(\\d+)?"); + QRegularExpressionMatch match = reg.match(dec); + double sign = match.captured(1) == "-" ? -1 : 1; + double d = match.captured(2).toDouble(); + double m = match.captured(3).toDouble(); + double s = match.captured(4).toDouble(); + qDebug() << match.capturedTexts() << sign << d << m << s; + return sign * (d + m/60 + s/3600); +} + SelectColumnsDialog::SelectColumnsDialog(QWidget *parent) : QDialog(parent) { m_listWidget = new QListWidget(this); @@ -130,12 +154,16 @@ void FITSFileModel::prepareQuery() { QString cols; QString join; - QString where; + QStringList where; QString sql = "SELECT f.file,"; for(int i=0; ifilesUnmarked(indexes); }); + QStringList fitsKeywords = m_database->getFitsKeywords(); for(int i=0; i<3; i++) { m_filterKeyword[i] = new QComboBox(this); m_filterKeyword[i]->addItem("file"); - m_filterKeyword[i]->addItems(m_database->getFitsKeywords()); + m_filterKeyword[i]->addItem("RA pos"); + m_filterKeyword[i]->addItem("DEC pos"); + m_filterKeyword[i]->addItems(fitsKeywords); + m_search[i] = new QLineEdit(this); m_search[i]->setPlaceholderText(tr("Text to search, you can % as wildcard")); connect(m_search[i], &QLineEdit::returnPressed, this, &DataBaseView::applyFilter);