Changeset View
Changeset View
Standalone View
Standalone View
kstars/tools/whatsinteresting/wiview.cpp
Context not available. | |||||
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * | ||
---|---|---|---|---|---|
15 | * * | 15 | * * | ||
16 | ***************************************************************************/ | 16 | ***************************************************************************/ | ||
17 | #include <QtQuick/QQuickView> | 17 | | ||
18 | #include <QtQuick/QQuickItem> | 18 | #include <QQuickView> | ||
19 | #include <QQuickItem> | ||||
20 | #include <QQmlContext> | ||||
19 | #include <QStandardPaths> | 21 | #include <QStandardPaths> | ||
20 | #include <QGraphicsObject> | 22 | #include <QGraphicsObject> | ||
21 | #include "wiview.h" | 23 | #include "wiview.h" | ||
Context not available. | |||||
258 | QtConcurrent::run(m_ModManager, &ModelManager::loadSharplessCatalog); | 260 | QtConcurrent::run(m_ModManager, &ModelManager::loadSharplessCatalog); | ||
259 | return; | 261 | return; | ||
260 | } | 262 | } | ||
261 | updateModel(m_Obs); | 263 | updateModel(*m_Obs); | ||
262 | } | 264 | } | ||
263 | 265 | | |||
264 | void WIView::onSoListItemClicked(int index) | 266 | void WIView::onSoListItemClicked(int index) | ||
Context not available. | |||||
376 | { | 378 | { | ||
377 | if (m_CurrentObjectListName != "") | 379 | if (m_CurrentObjectListName != "") | ||
378 | { | 380 | { | ||
379 | updateModel(m_Obs); | 381 | updateModel(*m_Obs); | ||
380 | m_CurIndex = m_ModManager->returnModel(m_CurrentObjectListName)->getSkyObjIndex(m_CurSoItem); | 382 | m_CurIndex = m_ModManager->returnModel(m_CurrentObjectListName)->getSkyObjIndex(m_CurSoItem); | ||
381 | } | 383 | } | ||
382 | loadDetailsView(m_CurSoItem, m_CurIndex); | 384 | loadDetailsView(m_CurSoItem, m_CurIndex); | ||
Context not available. | |||||
397 | void WIView::onUpdateIconClicked() | 399 | void WIView::onUpdateIconClicked() | ||
398 | { | 400 | { | ||
399 | QMessageBox mbox; | 401 | QMessageBox mbox; | ||
400 | mbox.setText("Please choose which object(s) to try to update with Wikipedia data."); | | |||
401 | QPushButton *currentObject = mbox.addButton("Current Object", QMessageBox::AcceptRole); | 402 | QPushButton *currentObject = mbox.addButton("Current Object", QMessageBox::AcceptRole); | ||
402 | QPushButton *missingObjects; | 403 | QPushButton *missingObjects = nullptr; | ||
403 | QPushButton *allObjects; | 404 | QPushButton *allObjects = nullptr; | ||
405 | | ||||
406 | mbox.setText("Please choose which object(s) to try to update with Wikipedia data."); | ||||
404 | if (m_CurrentObjectListName != "") | 407 | if (m_CurrentObjectListName != "") | ||
405 | { | 408 | { | ||
406 | missingObjects = mbox.addButton("Objects with no data", QMessageBox::AcceptRole); | 409 | missingObjects = mbox.addButton("Objects with no data", QMessageBox::AcceptRole); | ||
Context not available. | |||||
442 | m_SoListObj->setProperty("currentIndex", m_CurIndex); | 445 | m_SoListObj->setProperty("currentIndex", m_CurIndex); | ||
443 | } | 446 | } | ||
444 | 447 | | |||
445 | void WIView::updateModel(ObsConditions *obs) | 448 | void WIView::updateModel(ObsConditions& obs) | ||
446 | { | 449 | { | ||
447 | if (m_CurrentObjectListName != "") | 450 | if (m_CurrentObjectListName != "") | ||
448 | { | 451 | { | ||
449 | m_Obs = obs; | 452 | m_Obs = &obs; | ||
450 | m_ModManager->updateModel(m_Obs, m_CurrentObjectListName); | 453 | m_ModManager->updateModel(m_Obs, m_CurrentObjectListName); | ||
451 | } | 454 | } | ||
452 | } | 455 | } | ||
453 | 456 | | |||
454 | void WIView::inspectSkyObject(QString name) | 457 | void WIView::inspectSkyObject(const QString& name) | ||
455 | { | 458 | { | ||
456 | if (name != "" && name != "star") | 459 | if (!name.isEmpty() && name != "star") | ||
457 | { | 460 | { | ||
458 | SkyObject *obj = KStarsData::Instance()->skyComposite()->findByName(name); | 461 | SkyObject *obj = KStarsData::Instance()->skyComposite()->findByName(name); | ||
462 | | ||||
459 | if (obj) | 463 | if (obj) | ||
460 | inspectSkyObject(obj); | 464 | inspectSkyObject(obj); | ||
461 | } | 465 | } | ||
Context not available. | |||||
464 | void WIView::inspectSkyObjectOnClick(SkyObject *obj) | 468 | void WIView::inspectSkyObjectOnClick(SkyObject *obj) | ||
465 | { | 469 | { | ||
466 | if (inspectOnClick && KStars::Instance()->isWIVisible()) | 470 | if (inspectOnClick && KStars::Instance()->isWIVisible()) | ||
467 | { | | |||
468 | inspectSkyObject(obj); | 471 | inspectSkyObject(obj); | ||
469 | } | | |||
470 | } | 472 | } | ||
471 | 473 | | |||
472 | void WIView::inspectSkyObject(SkyObject *obj) | 474 | void WIView::inspectSkyObject(SkyObject *obj) | ||
473 | { | 475 | { | ||
474 | if (obj) | 476 | if (!obj) | ||
477 | return; | ||||
478 | | ||||
479 | if (obj->name() != "star") | ||||
475 | { | 480 | { | ||
476 | if (obj->name() != "star") | 481 | m_CurrentObjectListName = ""; | ||
477 | { | 482 | loadDetailsView(new SkyObjItem(obj), -1); | ||
478 | m_CurrentObjectListName = ""; | 483 | m_BaseObj->setProperty("state", "singleItemSelected"); | ||
479 | loadDetailsView(new SkyObjItem(obj), -1); | 484 | m_CategoryTitle->setProperty("text", "Selected Object"); | ||
480 | m_BaseObj->setProperty("state", "singleItemSelected"); | | |||
481 | m_CategoryTitle->setProperty("text", "Selected Object"); | | |||
482 | } | | |||
483 | } | 485 | } | ||
484 | } | 486 | } | ||
485 | 487 | | |||
Context not available. | |||||
487 | { | 489 | { | ||
488 | if (!soitem) | 490 | if (!soitem) | ||
489 | return; | 491 | return; | ||
490 | m_CurSoItem = soitem; | 492 | | ||
491 | m_CurIndex = index; | 493 | int modelSize = -1; | ||
492 | int modelSize; | 494 | | ||
493 | if (index == -1) | 495 | if (index != -1) | ||
494 | modelSize = -1; | | |||
495 | else | | |||
496 | modelSize = m_ModManager->returnModel(m_CurrentObjectListName)->rowCount(); | 496 | modelSize = m_ModManager->returnModel(m_CurrentObjectListName)->rowCount(); | ||
497 | 497 | | |||
498 | m_CurSoItem = soitem; | ||||
499 | m_CurIndex = index; | ||||
498 | if (modelSize <= 1) | 500 | if (modelSize <= 1) | ||
499 | { | 501 | { | ||
500 | m_NextObj->setProperty("visible", "false"); | 502 | m_NextObj->setProperty("visible", "false"); | ||
Context not available. | |||||
506 | m_ModManager->returnModel(m_CurrentObjectListName)->getSkyObjItem((m_CurIndex + 1) % modelSize); | 508 | m_ModManager->returnModel(m_CurrentObjectListName)->getSkyObjItem((m_CurIndex + 1) % modelSize); | ||
507 | SkyObjItem *prevItem = | 509 | SkyObjItem *prevItem = | ||
508 | m_ModManager->returnModel(m_CurrentObjectListName)->getSkyObjItem((m_CurIndex - 1 + modelSize) % modelSize); | 510 | m_ModManager->returnModel(m_CurrentObjectListName)->getSkyObjItem((m_CurIndex - 1 + modelSize) % modelSize); | ||
511 | | ||||
509 | m_NextObj->setProperty("visible", "true"); | 512 | m_NextObj->setProperty("visible", "true"); | ||
510 | m_PrevObj->setProperty("visible", "true"); | 513 | m_PrevObj->setProperty("visible", "true"); | ||
511 | QObject *nextTextObj = m_NextObj->findChild<QObject *>("nextTextObj"); | 514 | QObject *nextTextObj = m_NextObj->findChild<QObject *>("nextTextObj"); | ||
515 | | ||||
512 | nextTextObj->setProperty("text", nextItem->getName()); | 516 | nextTextObj->setProperty("text", nextItem->getName()); | ||
513 | QObject *prevTextObj = m_PrevObj->findChild<QObject *>("prevTextObj"); | 517 | QObject *prevTextObj = m_PrevObj->findChild<QObject *>("prevTextObj"); | ||
518 | | ||||
514 | prevTextObj->setProperty("text", prevItem->getName()); | 519 | prevTextObj->setProperty("text", prevItem->getName()); | ||
515 | } | 520 | } | ||
516 | 521 | | |||
Context not available. |