Skip to content

Commit

Permalink
Added few improvements for Search Tool and AstroCalc/WUT
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-w committed Jul 1, 2018
1 parent 139366b commit bae304b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 2 deletions.
Binary file added data/gui/backspace-white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/gui/guiRes.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,6 @@
<file>tabicon-AstroCalc-MonthlyElevation.png</file>
<file>btSurveys-off.png</file>
<file>btSurveys-on.png</file>
<file>backspace-white.png</file>
</qresource>
</RCC>
21 changes: 21 additions & 0 deletions src/gui/AstroCalcDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,16 @@ void AstroCalcDialog::createDialogContent()
connect(ui->wutCategoryListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(calculateWutObjects()));
connect(ui->wutMatchingObjectsListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(selectWutObject()));
connect(ui->saveObjectsButton, SIGNAL(clicked()), this, SLOT(saveWutObjects()));
connect(ui->wutMatchingObjectsLineEdit, SIGNAL(textChanged(QString)), this, SLOT(searchWutObjects(QString)));
connect(dsoMgr, SIGNAL(catalogFiltersChanged(Nebula::CatalogGroup)), this, SLOT(calculateWutObjects()));
connect(dsoMgr, SIGNAL(typeFiltersChanged(Nebula::TypeGroup)), this, SLOT(calculateWutObjects()));
connect(dsoMgr, SIGNAL(flagSizeLimitsUsageChanged(bool)), this, SLOT(calculateWutObjects()));
connect(dsoMgr, SIGNAL(minSizeLimitChanged(double)), this, SLOT(calculateWutObjects()));
connect(dsoMgr, SIGNAL(maxSizeLimitChanged(double)), this, SLOT(calculateWutObjects()));

QAction *clearAction = ui->wutMatchingObjectsLineEdit->addAction(QIcon(":/graphicGui/backspace-white.png"), QLineEdit::ActionPosition::TrailingPosition);
connect(clearAction, SIGNAL(triggered()), this, SLOT(searchWutClear()));

currentCelestialPositions();

currentTimeLine = new QTimer(this);
Expand Down Expand Up @@ -316,6 +320,12 @@ void AstroCalcDialog::createDialogContent()
ui->monthlyElevationPositiveCheckBox->setStyleSheet(style);
}

void AstroCalcDialog::searchWutClear()
{
ui->wutMatchingObjectsLineEdit->clear();
ui->wutMatchingObjectsListWidget->reset();
}

void AstroCalcDialog::updateAstroCalcData()
{
drawAltVsTimeDiagram();
Expand Down Expand Up @@ -4182,6 +4192,17 @@ void AstroCalcDialog::saveWutObjects()
objlist.close();
}

void AstroCalcDialog::searchWutObjects(const QString &newText)
{
QList<QListWidgetItem*> items = ui->wutMatchingObjectsListWidget->findItems(newText, Qt::MatchStartsWith);
ui->wutMatchingObjectsListWidget->clearSelection();
if (!items.isEmpty())
{
items.at(0)->setSelected(true);
ui->wutMatchingObjectsListWidget->scrollToItem(items.at(0));
}
}

void AstroCalcDialog::saveFirstCelestialBody(int index)
{
Q_ASSERT(ui->firstCelestialBodyComboBox);
Expand Down
2 changes: 2 additions & 0 deletions src/gui/AstroCalcDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ private slots:
void calculateWutObjects();
void selectWutObject();
void saveWutObjects();
void searchWutObjects(const QString& newText);
void searchWutClear();

void updateAstroCalcData();

Expand Down
10 changes: 9 additions & 1 deletion src/gui/SearchDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ void SearchDialog::createDialogContent()
// list views initialization
connect(ui->objectTypeComboBox, SIGNAL(activated(int)), this, SLOT(updateListWidget(int)));
connect(ui->searchInListLineEdit, SIGNAL(textChanged(QString)), this, SLOT(searchListChanged(QString)));
connect(ui->searchInEnglishCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateListTab()));
connect(ui->searchInEnglishCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateListTab()));
QAction *clearAction = ui->searchInListLineEdit->addAction(QIcon(":/graphicGui/backspace-white.png"), QLineEdit::ActionPosition::TrailingPosition);
connect(clearAction, SIGNAL(triggered()), this, SLOT(searchListClear()));
updateListTab();

connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(changeTab(int)));
Expand Down Expand Up @@ -763,6 +765,12 @@ void SearchDialog::searchListChanged(const QString &newText)
}
}

void SearchDialog::searchListClear()
{
ui->searchInListLineEdit->clear();
ui->objectsListWidget->reset();
}

bool SearchDialog::eventFilter(QObject*, QEvent *event)
{
if (event->type() == QEvent::KeyRelease)
Expand Down
1 change: 1 addition & 0 deletions src/gui/SearchDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ private slots:
void gotoObject(QListWidgetItem* item);

void searchListChanged(const QString& newText);
void searchListClear();

//! Called when the user edit the manual position controls
void manualPositionChanged();
Expand Down
9 changes: 8 additions & 1 deletion src/gui/astroCalcDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
<number>6</number>
</property>
<widget class="QWidget" name="stackedWidgetPage1">
<layout class="QGridLayout" name="gridLayout_2">
Expand Down Expand Up @@ -1112,6 +1112,13 @@
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="wutMatchingObjectsLineEdit">
<property name="placeholderText">
<string>Search in list...</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="wutMatchingObjectsListWidget"/>
</item>
Expand Down

0 comments on commit bae304b

Please sign in to comment.