[qt] Change InfoPanel data when selection is changed in a *Browser
parent
8c613c67f5
commit
334c6e76f7
|
@ -264,22 +264,29 @@ void CelestiaAppWindow::init(const QString& qConfigFileName,
|
|||
toolsDock->setAllowedAreas(Qt::LeftDockWidgetArea |
|
||||
Qt::RightDockWidgetArea);
|
||||
|
||||
// Info browser for a selected object
|
||||
infoPanel = new InfoPanel(m_appCore, _("Info Browser"), this);
|
||||
infoPanel->setObjectName("info-panel");
|
||||
infoPanel->setAllowedAreas(Qt::LeftDockWidgetArea |
|
||||
Qt::RightDockWidgetArea);
|
||||
infoPanel->setVisible(false);
|
||||
|
||||
// Create the various browser widgets
|
||||
celestialBrowser = new CelestialBrowser(m_appCore, nullptr);
|
||||
celestialBrowser = new CelestialBrowser(m_appCore, nullptr, infoPanel);
|
||||
celestialBrowser->setObjectName("celestia-browser");
|
||||
connect(celestialBrowser,
|
||||
SIGNAL(selectionContextMenuRequested(const QPoint&, Selection&)),
|
||||
this,
|
||||
SLOT(slotShowSelectionContextMenu(const QPoint&, Selection&)));
|
||||
|
||||
QWidget* deepSkyBrowser = new DeepSkyBrowser(m_appCore, nullptr);
|
||||
QWidget* deepSkyBrowser = new DeepSkyBrowser(m_appCore, nullptr, infoPanel);
|
||||
deepSkyBrowser->setObjectName("deepsky-browser");
|
||||
connect(deepSkyBrowser,
|
||||
SIGNAL(selectionContextMenuRequested(const QPoint&, Selection&)),
|
||||
this,
|
||||
SLOT(slotShowSelectionContextMenu(const QPoint&, Selection&)));
|
||||
|
||||
SolarSystemBrowser* solarSystemBrowser = new SolarSystemBrowser(m_appCore, nullptr);
|
||||
SolarSystemBrowser* solarSystemBrowser = new SolarSystemBrowser(m_appCore, nullptr, infoPanel);
|
||||
solarSystemBrowser->setObjectName("ssys-browser");
|
||||
connect(solarSystemBrowser,
|
||||
SIGNAL(selectionContextMenuRequested(const QPoint&, Selection&)),
|
||||
|
@ -294,12 +301,7 @@ void CelestiaAppWindow::init(const QString& qConfigFileName,
|
|||
toolsDock->setWidget(tabWidget);
|
||||
addDockWidget(Qt::LeftDockWidgetArea, toolsDock);
|
||||
|
||||
infoPanel = new InfoPanel(_("Info Browser"), this);
|
||||
infoPanel->setObjectName("info-panel");
|
||||
infoPanel->setAllowedAreas(Qt::LeftDockWidgetArea |
|
||||
Qt::RightDockWidgetArea);
|
||||
addDockWidget(Qt::RightDockWidgetArea, infoPanel);
|
||||
infoPanel->setVisible(false);
|
||||
|
||||
eventFinder = new EventFinder(m_appCore, _("Event Finder"), this);
|
||||
eventFinder->setObjectName("event-finder");
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <celestia/celestiacore.h>
|
||||
#include "qtcelestialbrowser.h"
|
||||
#include "qtcolorswatchwidget.h"
|
||||
#include "qtinfopanel.h"
|
||||
#include <QAbstractItemModel>
|
||||
#include <QTreeView>
|
||||
#include <QPushButton>
|
||||
|
@ -74,19 +75,22 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class StarTableModel : public QAbstractTableModel
|
||||
class StarTableModel : public QAbstractTableModel, public ModelHelper
|
||||
{
|
||||
public:
|
||||
StarTableModel(const Universe* _universe) : universe(_universe) {};
|
||||
virtual ~StarTableModel() = default;
|
||||
|
||||
// Methods from QAbstractTableModel
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
int rowCount(const QModelIndex& index) const;
|
||||
int columnCount(const QModelIndex& index) const;
|
||||
void sort(int column, Qt::SortOrder order);
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
int rowCount(const QModelIndex& index) const override;
|
||||
int columnCount(const QModelIndex& index) const override;
|
||||
void sort(int column, Qt::SortOrder order) override;
|
||||
|
||||
// Methods from ModelHelper
|
||||
Selection itemForInfoPanel(const QModelIndex&) override;
|
||||
|
||||
enum Predicate
|
||||
{
|
||||
|
@ -233,6 +237,13 @@ int StarTableModel::columnCount(const QModelIndex& /*unused*/) const
|
|||
}
|
||||
|
||||
|
||||
Selection StarTableModel::itemForInfoPanel(const QModelIndex& _index)
|
||||
{
|
||||
Selection sel = itemAtRow((unsigned int) _index.row());
|
||||
return sel;
|
||||
}
|
||||
|
||||
|
||||
StarPredicate::StarPredicate(Criterion _criterion,
|
||||
const UniversalCoord& _observerPos,
|
||||
const Universe *_universe) :
|
||||
|
@ -451,14 +462,10 @@ Selection StarTableModel::itemAtRow(unsigned int row)
|
|||
}
|
||||
|
||||
|
||||
CelestialBrowser::CelestialBrowser(CelestiaCore* _appCore, QWidget* parent) :
|
||||
CelestialBrowser::CelestialBrowser(CelestiaCore* _appCore, QWidget* parent, InfoPanel* _infoPanel) :
|
||||
QWidget(parent),
|
||||
appCore(_appCore),
|
||||
starModel(nullptr),
|
||||
treeView(nullptr),
|
||||
searchResultLabel(nullptr),
|
||||
closestButton(nullptr),
|
||||
brightestButton(nullptr)
|
||||
infoPanel(_infoPanel)
|
||||
{
|
||||
treeView = new QTreeView();
|
||||
treeView->setRootIsDecorated(false);
|
||||
|
@ -482,6 +489,9 @@ CelestialBrowser::CelestialBrowser(CelestiaCore* _appCore, QWidget* parent) :
|
|||
connect(treeView, SIGNAL(customContextMenuRequested(const QPoint&)),
|
||||
this, SLOT(slotContextMenu(const QPoint&)));
|
||||
|
||||
connect(treeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
|
||||
this, SLOT(slotSelectionChanged(const QItemSelection&, const QItemSelection&)));
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->addWidget(treeView);
|
||||
|
||||
|
@ -714,3 +724,9 @@ void CelestialBrowser::slotClearMarkers()
|
|||
{
|
||||
appCore->getSimulation()->getUniverse()->unmarkAll();
|
||||
}
|
||||
|
||||
void CelestialBrowser::slotSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel)
|
||||
{
|
||||
if (infoPanel)
|
||||
infoPanel->updateHelper(starModel, newSel, oldSel);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "qtselectionpopup.h"
|
||||
|
||||
class QAbstractItemModel;
|
||||
class QItemSelection;
|
||||
class QTreeView;
|
||||
class QRadioButton;
|
||||
class QComboBox;
|
||||
|
@ -25,6 +26,7 @@ class QLabel;
|
|||
class QLineEdit;
|
||||
class ColorSwatchWidget;
|
||||
class CelestiaCore;
|
||||
class InfoPanel;
|
||||
|
||||
class StarTableModel;
|
||||
|
||||
|
@ -33,7 +35,7 @@ class CelestialBrowser : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CelestialBrowser(CelestiaCore* _appCore, QWidget* parent);
|
||||
CelestialBrowser(CelestiaCore* _appCore, QWidget* parent, InfoPanel* infoPanel);
|
||||
~CelestialBrowser() = default;
|
||||
|
||||
public slots:
|
||||
|
@ -43,6 +45,7 @@ Q_OBJECT
|
|||
void slotContextMenu(const QPoint& pos);
|
||||
void slotMarkSelected();
|
||||
void slotClearMarkers();
|
||||
void slotSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel);
|
||||
|
||||
signals:
|
||||
void selectionContextMenuRequested(const QPoint& pos, Selection& sel);
|
||||
|
@ -50,24 +53,25 @@ Q_OBJECT
|
|||
private:
|
||||
CelestiaCore* appCore;
|
||||
|
||||
StarTableModel* starModel;
|
||||
QTreeView* treeView;
|
||||
StarTableModel* starModel{nullptr};
|
||||
QTreeView* treeView{nullptr};
|
||||
|
||||
QLabel* searchResultLabel;
|
||||
QLabel* searchResultLabel{nullptr};
|
||||
|
||||
QRadioButton* closestButton;
|
||||
QRadioButton* brightestButton;
|
||||
QRadioButton* closestButton{nullptr};
|
||||
QRadioButton* brightestButton{nullptr};
|
||||
|
||||
QCheckBox* withPlanetsFilterBox;
|
||||
QCheckBox* multipleFilterBox;
|
||||
QCheckBox* barycentersFilterBox;
|
||||
QLineEdit* spectralTypeFilterBox;
|
||||
QCheckBox* withPlanetsFilterBox{nullptr};
|
||||
QCheckBox* multipleFilterBox{nullptr};
|
||||
QCheckBox* barycentersFilterBox{nullptr};
|
||||
QLineEdit* spectralTypeFilterBox{nullptr};
|
||||
|
||||
QComboBox* markerSymbolBox;
|
||||
QComboBox* markerSizeBox;
|
||||
QCheckBox* labelMarkerBox;
|
||||
QComboBox* markerSymbolBox{nullptr};
|
||||
QComboBox* markerSizeBox{nullptr};
|
||||
QCheckBox* labelMarkerBox{nullptr};
|
||||
|
||||
ColorSwatchWidget* colorSwatch;
|
||||
ColorSwatchWidget* colorSwatch{nullptr};
|
||||
InfoPanel* infoPanel{nullptr};
|
||||
};
|
||||
|
||||
#endif // _QTCELESTIALBROWSER_H_
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
#include <celestia/celestiacore.h>
|
||||
#include "qtdeepskybrowser.h"
|
||||
#include "qtcolorswatchwidget.h"
|
||||
#include "qtinfopanel.h"
|
||||
#include <QAbstractItemModel>
|
||||
#include <QItemSelection>
|
||||
#include <QTreeView>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
|
@ -70,19 +72,22 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class DSOTableModel : public QAbstractTableModel
|
||||
class DSOTableModel : public QAbstractTableModel, public ModelHelper
|
||||
{
|
||||
public:
|
||||
DSOTableModel(const Universe* _universe);
|
||||
virtual ~DSOTableModel() = default;
|
||||
|
||||
// Methods from QAbstractTableModel
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
int rowCount(const QModelIndex& index) const;
|
||||
int columnCount(const QModelIndex& index) const;
|
||||
void sort(int column, Qt::SortOrder order);
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
int rowCount(const QModelIndex& index) const override;
|
||||
int columnCount(const QModelIndex& index) const override;
|
||||
void sort(int column, Qt::SortOrder order) override;
|
||||
|
||||
// Methods from ModelHelper
|
||||
Selection itemForInfoPanel(const QModelIndex&) override;
|
||||
|
||||
enum Predicate
|
||||
{
|
||||
|
@ -202,6 +207,12 @@ int DSOTableModel::columnCount(const QModelIndex& /*unused*/) const
|
|||
}
|
||||
|
||||
|
||||
Selection DSOTableModel::itemForInfoPanel(const QModelIndex& _index)
|
||||
{
|
||||
Selection sel = itemAtRow((unsigned int) _index.row());
|
||||
return sel;
|
||||
}
|
||||
|
||||
DSOPredicate::DSOPredicate(Criterion _criterion,
|
||||
const Vector3d& _observerPos,
|
||||
const Universe* _universe) :
|
||||
|
@ -381,16 +392,10 @@ DeepSkyObject* DSOTableModel::itemAtRow(unsigned int row)
|
|||
}
|
||||
|
||||
|
||||
DeepSkyBrowser::DeepSkyBrowser(CelestiaCore* _appCore, QWidget* parent) :
|
||||
DeepSkyBrowser::DeepSkyBrowser(CelestiaCore* _appCore, QWidget* parent, InfoPanel* _infoPanel) :
|
||||
QWidget(parent),
|
||||
appCore(_appCore),
|
||||
dsoModel(nullptr),
|
||||
treeView(nullptr),
|
||||
searchResultLabel(nullptr),
|
||||
globularsButton(nullptr),
|
||||
galaxiesButton(nullptr),
|
||||
nebulaeButton(nullptr),
|
||||
openClustersButton(nullptr)
|
||||
infoPanel(_infoPanel)
|
||||
{
|
||||
treeView = new QTreeView();
|
||||
treeView->setRootIsDecorated(false);
|
||||
|
@ -407,6 +412,9 @@ DeepSkyBrowser::DeepSkyBrowser(CelestiaCore* _appCore, QWidget* parent) :
|
|||
connect(treeView, SIGNAL(customContextMenuRequested(const QPoint&)),
|
||||
this, SLOT(slotContextMenu(const QPoint&)));
|
||||
|
||||
connect(treeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
|
||||
this, SLOT(slotSelectionChanged(const QItemSelection&, const QItemSelection&)));
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->addWidget(treeView);
|
||||
|
||||
|
@ -623,3 +631,10 @@ void DeepSkyBrowser::slotClearMarkers()
|
|||
{
|
||||
appCore->getSimulation()->getUniverse()->unmarkAll();
|
||||
}
|
||||
|
||||
|
||||
void DeepSkyBrowser::slotSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel)
|
||||
{
|
||||
if (infoPanel)
|
||||
infoPanel->updateHelper(dsoModel, newSel, oldSel);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "celengine/selection.h"
|
||||
|
||||
class QAbstractItemModel;
|
||||
class QItemSelection;
|
||||
class QTreeView;
|
||||
class QRadioButton;
|
||||
class QComboBox;
|
||||
|
@ -25,6 +26,7 @@ class QLabel;
|
|||
class QLineEdit;
|
||||
class ColorSwatchWidget;
|
||||
class CelestiaCore;
|
||||
class InfoPanel;
|
||||
|
||||
class DSOTableModel;
|
||||
|
||||
|
@ -33,7 +35,7 @@ class DeepSkyBrowser : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DeepSkyBrowser(CelestiaCore* _appCore, QWidget* parent);
|
||||
DeepSkyBrowser(CelestiaCore* _appCore, QWidget* parent, InfoPanel* infoPanel);
|
||||
~DeepSkyBrowser() = default;
|
||||
|
||||
public slots:
|
||||
|
@ -41,6 +43,7 @@ Q_OBJECT
|
|||
void slotContextMenu(const QPoint& pos);
|
||||
void slotMarkSelected();
|
||||
void slotClearMarkers();
|
||||
void slotSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel);
|
||||
|
||||
signals:
|
||||
void selectionContextMenuRequested(const QPoint& pos, Selection& sel);
|
||||
|
@ -48,23 +51,25 @@ Q_OBJECT
|
|||
private:
|
||||
CelestiaCore* appCore;
|
||||
|
||||
DSOTableModel* dsoModel;
|
||||
QTreeView* treeView;
|
||||
DSOTableModel* dsoModel{nullptr};
|
||||
QTreeView* treeView{nullptr};
|
||||
|
||||
QLabel* searchResultLabel;
|
||||
QLabel* searchResultLabel{nullptr};
|
||||
|
||||
QRadioButton* globularsButton;
|
||||
QRadioButton* galaxiesButton;
|
||||
QRadioButton* nebulaeButton;
|
||||
QRadioButton* openClustersButton;
|
||||
QRadioButton* globularsButton{nullptr};
|
||||
QRadioButton* galaxiesButton{nullptr};
|
||||
QRadioButton* nebulaeButton{nullptr};
|
||||
QRadioButton* openClustersButton{nullptr};
|
||||
|
||||
QLineEdit* objectTypeFilterBox;
|
||||
QLineEdit* objectTypeFilterBox{nullptr};
|
||||
|
||||
QComboBox* markerSymbolBox;
|
||||
QComboBox* markerSizeBox;
|
||||
QCheckBox* labelMarkerBox;
|
||||
QComboBox* markerSymbolBox{nullptr};
|
||||
QComboBox* markerSizeBox{nullptr};
|
||||
QCheckBox* labelMarkerBox{nullptr};
|
||||
|
||||
ColorSwatchWidget* colorSwatch;
|
||||
ColorSwatchWidget* colorSwatch{nullptr};
|
||||
|
||||
InfoPanel* infoPanel{nullptr};
|
||||
};
|
||||
|
||||
#endif // _QTDEEPSKYBROWSER_H_
|
||||
|
|
|
@ -10,10 +10,13 @@
|
|||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
|
||||
#include "celengine/astro.h"
|
||||
#include "celutil/utf8.h"
|
||||
#include "celengine/universe.h"
|
||||
|
||||
#include <celestia/celestiacore.h>
|
||||
#include <celengine/astro.h>
|
||||
#include <celutil/utf8.h>
|
||||
#include <celengine/universe.h>
|
||||
#include <QTextBrowser>
|
||||
#include <QItemSelection>
|
||||
#include "qtinfopanel.h"
|
||||
|
||||
using namespace Eigen;
|
||||
|
@ -36,9 +39,9 @@ static void CalculateOsculatingElements(const Orbit& orbit,
|
|||
OrbitalElements* elements);
|
||||
|
||||
|
||||
InfoPanel::InfoPanel(const QString& title, QWidget* parent) :
|
||||
InfoPanel::InfoPanel(CelestiaCore* _appCore, const QString& title, QWidget* parent) :
|
||||
QDockWidget(title, parent),
|
||||
textBrowser(nullptr)
|
||||
appCore(_appCore)
|
||||
{
|
||||
textBrowser = new QTextBrowser(this);
|
||||
textBrowser->setOpenExternalLinks(true);
|
||||
|
@ -69,7 +72,7 @@ void InfoPanel::buildInfoPage(Selection sel,
|
|||
}
|
||||
else
|
||||
{
|
||||
stream << "Error: no object selected!\n";
|
||||
stream << QString(_("Error: no object selected!\n"));
|
||||
}
|
||||
|
||||
pageFooter(stream);
|
||||
|
@ -80,7 +83,7 @@ void InfoPanel::buildInfoPage(Selection sel,
|
|||
|
||||
void InfoPanel::pageHeader(QTextStream& stream)
|
||||
{
|
||||
stream << "<html><head><title>Info</title></head><body>";
|
||||
stream << "<html><head><title>" << QString(_("Info")) << "</title></head><body>";
|
||||
}
|
||||
|
||||
|
||||
|
@ -192,7 +195,7 @@ void InfoPanel::buildSolarSystemBodyPage(const Body* body,
|
|||
orbitalPeriod /= 365.25;
|
||||
}
|
||||
|
||||
stream << "<br><big><b>" << _("Orbit information") << "</b></big><br>\n";
|
||||
stream << "<br><big><b>" << QString(_("Orbit information")) << "</b></big><br>\n";
|
||||
stream << QString(_("Osculating elements for %1")).arg(QString::fromUtf8(astro::TDBtoUTC(t).toCStr())) << "<br>\n";
|
||||
stream << "<br>\n";
|
||||
// stream << "<i>[ Orbit reference plane info goes here ]</i><br>\n";
|
||||
|
@ -300,6 +303,19 @@ void InfoPanel::buildDSOPage(const DeepSkyObject* dso,
|
|||
}
|
||||
|
||||
|
||||
void InfoPanel::updateHelper(ModelHelper* model, const QItemSelection& newSel, const QItemSelection& oldSel)
|
||||
{
|
||||
if (!isVisible() || newSel == oldSel || newSel.indexes().length() == 0)
|
||||
return;
|
||||
|
||||
Selection sel = model->itemForInfoPanel(newSel.indexes().at(0));
|
||||
if (!sel.empty())
|
||||
{
|
||||
buildInfoPage(sel,
|
||||
appCore->getSimulation()->getUniverse(),
|
||||
appCore->getSimulation()->getTime());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void StateVectorToElements(const Vector3d& position,
|
||||
|
|
|
@ -19,15 +19,27 @@
|
|||
|
||||
class QTextBrowser;
|
||||
class Universe;
|
||||
class QModelIndex;
|
||||
class Selection;
|
||||
class QItemSelection;
|
||||
class CelestiaCore;
|
||||
|
||||
class ModelHelper
|
||||
{
|
||||
public:
|
||||
virtual Selection itemForInfoPanel(const QModelIndex&) = 0;
|
||||
};
|
||||
|
||||
class InfoPanel : public QDockWidget
|
||||
{
|
||||
public:
|
||||
InfoPanel(const QString& title, QWidget* parent);
|
||||
InfoPanel(CelestiaCore* appCore, const QString& title, QWidget* parent);
|
||||
~InfoPanel() = default;
|
||||
|
||||
void buildInfoPage(Selection sel, Universe*, double tdb);
|
||||
|
||||
void updateHelper(ModelHelper*, const QItemSelection&, const QItemSelection&);
|
||||
|
||||
private:
|
||||
void pageHeader(QTextStream&);
|
||||
void pageFooter(QTextStream&);
|
||||
|
@ -35,8 +47,10 @@ class InfoPanel : public QDockWidget
|
|||
void buildStarPage(const Star* star, const Universe* u, double tdb, QTextStream&);
|
||||
void buildDSOPage(const DeepSkyObject* dso, const Universe* u, QTextStream&);
|
||||
|
||||
CelestiaCore* appCore;
|
||||
|
||||
public:
|
||||
QTextBrowser* textBrowser;
|
||||
QTextBrowser* textBrowser{nullptr};
|
||||
};
|
||||
|
||||
#endif // _INFOPANEL_H_
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
|
||||
#include <celestia/celestiacore.h>
|
||||
#include "qtsolarsystembrowser.h"
|
||||
#include "qtinfopanel.h"
|
||||
#include <QAbstractItemModel>
|
||||
#include <QItemSelection>
|
||||
#include <QTreeView>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
@ -28,7 +30,7 @@
|
|||
using namespace std;
|
||||
|
||||
|
||||
class SolarSystemTreeModel : public QAbstractTableModel
|
||||
class SolarSystemTreeModel : public QAbstractTableModel, public ModelHelper
|
||||
{
|
||||
public:
|
||||
SolarSystemTreeModel(const Universe* _universe);
|
||||
|
@ -48,6 +50,9 @@ public:
|
|||
void sort(int column, Qt::SortOrder order) override;
|
||||
QModelIndex sibling(int row, int column, const QModelIndex &index) const override;
|
||||
|
||||
// Methods from ModelHelper
|
||||
Selection itemForInfoPanel(const QModelIndex&) override;
|
||||
|
||||
enum
|
||||
{
|
||||
NameColumn = 0,
|
||||
|
@ -653,11 +658,16 @@ void SolarSystemTreeModel::sort(int /* column */, Qt::SortOrder /* order */)
|
|||
}
|
||||
|
||||
|
||||
SolarSystemBrowser::SolarSystemBrowser(CelestiaCore* _appCore, QWidget* parent) :
|
||||
Selection SolarSystemTreeModel::itemForInfoPanel(const QModelIndex& _index)
|
||||
{
|
||||
return objectAtIndex(_index);
|
||||
}
|
||||
|
||||
|
||||
SolarSystemBrowser::SolarSystemBrowser(CelestiaCore* _appCore, QWidget* parent, InfoPanel* _infoPanel) :
|
||||
QWidget(parent),
|
||||
appCore(_appCore),
|
||||
solarSystemModel(nullptr),
|
||||
treeView(nullptr)
|
||||
infoPanel(_infoPanel)
|
||||
{
|
||||
treeView = new QTreeView();
|
||||
treeView->setRootIsDecorated(true);
|
||||
|
@ -676,6 +686,9 @@ SolarSystemBrowser::SolarSystemBrowser(CelestiaCore* _appCore, QWidget* parent)
|
|||
connect(treeView, SIGNAL(customContextMenuRequested(const QPoint&)),
|
||||
this, SLOT(slotContextMenu(const QPoint&)));
|
||||
|
||||
connect(treeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
|
||||
this, SLOT(slotSelectionChanged(const QItemSelection&, const QItemSelection&)));
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->addWidget(treeView);
|
||||
|
||||
|
@ -804,3 +817,10 @@ void SolarSystemBrowser::slotClearMarkers()
|
|||
appCore->getSimulation()->getUniverse()->unmarkAll();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void SolarSystemBrowser::slotSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel)
|
||||
{
|
||||
if (infoPanel)
|
||||
infoPanel->updateHelper(solarSystemModel, newSel, oldSel);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
class QAbstractItemModel;
|
||||
class QTreeView;
|
||||
class QCheckBox;
|
||||
class QItemSelection;
|
||||
class CelestiaCore;
|
||||
class InfoPanel;
|
||||
|
||||
class SolarSystemTreeModel;
|
||||
|
||||
|
@ -28,7 +30,7 @@ class SolarSystemBrowser : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SolarSystemBrowser(CelestiaCore* _appCore, QWidget* parent);
|
||||
SolarSystemBrowser(CelestiaCore* _appCore, QWidget* parent, InfoPanel* infoPanel);
|
||||
~SolarSystemBrowser() = default;
|
||||
|
||||
public slots:
|
||||
|
@ -36,6 +38,7 @@ Q_OBJECT
|
|||
void slotContextMenu(const QPoint& pos);
|
||||
void slotMarkSelected();
|
||||
//void slotChooseMarkerColor();
|
||||
void slotSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel);
|
||||
|
||||
signals:
|
||||
void selectionContextMenuRequested(const QPoint& pos, Selection& sel);
|
||||
|
@ -46,10 +49,12 @@ Q_OBJECT
|
|||
private:
|
||||
CelestiaCore* appCore;
|
||||
|
||||
SolarSystemTreeModel* solarSystemModel{};
|
||||
QTreeView* treeView{};
|
||||
SolarSystemTreeModel* solarSystemModel{nullptr};
|
||||
QTreeView* treeView{nullptr};
|
||||
|
||||
QCheckBox* groupCheckBox{};
|
||||
QCheckBox* groupCheckBox{nullptr};
|
||||
|
||||
InfoPanel* infoPanel{nullptr};
|
||||
};
|
||||
|
||||
#endif // _QTSOLARSYSTEMBROWSER_H_
|
||||
|
|
Loading…
Reference in New Issue