Commit 481d535b authored by Samikshan Bairagya's avatar Samikshan Bairagya

Resolved problem regarding "multiple views" of WI interface.

parent 8a5451ca
......@@ -39,6 +39,7 @@
#include "dialogs/exportimagedialog.h"
#include "observinglist.h"
#include "oal/execute.h"
#include "whatsinteresting/wiview.h"
#include "kstarsadaptor.h"
......@@ -56,8 +57,8 @@ KStars::KStars( bool doSplash, bool clockrun, const QString &startdate )
: KXmlGuiWindow(), kstarsData(0), skymap(0), TimeStep(0),
colorActionMenu(0), fovActionMenu(0), findDialog(0),
imgExportDialog(0), obsList(0), execute(0),
avt(0), wut(0), wi(0), skycal(0), sb(0), pv(0), jmt(0),
fm(0), astrocalc(0), printingWizard(0), indimenu(0), indidriver(0),
avt(0), wut(0), wi(0), wiWiz(0), wiDock(0), skycal(0), sb(0), pv(0),
jmt(0), fm(0), astrocalc(0), printingWizard(0), indimenu(0), indidriver(0),
indiseq(0), ekosmenu(0), DialogIsObsolete(false), StartClockRunning( clockrun ),
StartDateString( startdate )
{
......@@ -304,15 +305,24 @@ void KStars::selectPreviousFov()
map()->update();
}
void KStars::setWIView(QDeclarativeView *wiView)
void KStars::showWI(ObsConditions *obs)
{
QDockWidget *wiDock = new QDockWidget(this);
wiDock->setObjectName("What's Interesting");
wiDock->setAllowedAreas(Qt::RightDockWidgetArea);
wiDock->setWidget(wiView);
wiDock->setFixedWidth(wiView->width());
wiDock->addAction(wiDock->toggleViewAction());
addDockWidget(Qt::RightDockWidgetArea, wiDock);
if ( ! wi )
{
wi = new WIView(0, obs);
wiDock = new QDockWidget(this);
wiDock->setObjectName("What's Interesting");
wiDock->setAllowedAreas(Qt::RightDockWidgetArea);
wiDock->setWidget(wi->getWIBaseView());
wiDock->setFixedWidth(wi->getWIBaseView()->width());
addDockWidget(Qt::RightDockWidgetArea, wiDock);
wiDock->setVisible(true);
}
else
{
wi->updateModels(obs);
wiDock->setVisible(true);
}
}
void KStars::updateTime( const bool automaticDSTchange ) {
......
......@@ -44,7 +44,9 @@ class INDIDriver;
class imagesequence;
class AltVsTime;
class WUTDialog;
class WIView;
class WIUserSettings;
class ObsConditions;
class AstroCalc;
class SkyCalendar;
class ScriptBuilder;
......@@ -173,7 +175,7 @@ public:
void selectPreviousFov();
void setWIView(QDeclarativeView *wiBaseView);
void showWI(ObsConditions *obs);
public Q_SLOTS:
/**DBUS interface function.
......@@ -655,7 +657,9 @@ private:
Execute *execute;
AltVsTime *avt;
WUTDialog *wut;
WIUserSettings *wi;
WIView *wi;
WIUserSettings *wiWiz;
QDockWidget *wiDock;
SkyCalendar *skycal;
ScriptBuilder *sb;
PlanetViewer *pv;
......
......@@ -27,6 +27,7 @@
#include <QDir>
#include <QTextStream>
#include <QDialog>
#include <QDockWidget>
#include <kdebug.h>
#include <kaction.h>
......@@ -74,6 +75,7 @@
#include "tools/astrocalc.h"
#include "tools/altvstime.h"
#include "tools/wutdialog.h"
#include "tools/whatsinteresting/wiview.h"
#include "tools/whatsinteresting/wiusersettings.h"
#include "tools/skycalendar.h"
#include "tools/scriptbuilder.h"
......@@ -277,8 +279,9 @@ void KStars::slotWUT() {
}
void KStars::slotWI() {
if (! wi ) wi = new WIUserSettings(this);
wi->show();
if ( ! wiWiz ) wiWiz = new WIUserSettings(this);
if ( wiDock && wiDock->isVisible() ) return;
wiWiz->show();
}
void KStars::slotCalendar() {
......
......@@ -36,7 +36,7 @@ ModelManager::ModelManager(ObsConditions *obs)
initobjects["Constellation"] = QList<SkyObject *>();
initobjects["Cluster"] = QList<SkyObject *>();
initobjects["Nebula"] = QList<SkyObject *>();
updateModels();
updateModels(obs);
}
ModelManager::~ModelManager()
......@@ -49,8 +49,12 @@ ModelManager::~ModelManager()
delete nebModel;
}
void ModelManager::updateModels()
void ModelManager::updateModels(ObsConditions *obs)
{
obsconditions = obs;
initobjects.clear();
resetModels();
KStarsData *data = KStarsData::Instance();
KSFileReader fileReader;
......@@ -144,6 +148,16 @@ void ModelManager::updateModels()
}
}
void ModelManager::resetModels()
{
planetsModel->resetModel();
starsModel->resetModel();
conModel->resetModel();
galModel->resetModel();
clustModel->resetModel();
nebModel->resetModel();
}
SkyObjListModel* ModelManager::returnModel(int type)
{
switch(type)
......
......@@ -24,7 +24,8 @@ class ModelManager
public:
ModelManager(ObsConditions *obs);
~ModelManager();
void updateModels();
void updateModels(ObsConditions *obs);
void resetModels();
SkyObjListModel *returnModel (int type);
......
......@@ -53,3 +53,8 @@ SkyObjItem* SkyObjListModel::getSkyObjItem(int index)
{
return soItemList[index];
}
void SkyObjListModel::resetModel()
{
soItemList.clear();
}
......@@ -32,6 +32,7 @@ public:
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
QList<SkyObjItem *> getSkyObjItems();
SkyObjItem *getSkyObjItem(int index);
void resetModel();
private:
QList<SkyObjItem *> soItemList;
......
......@@ -19,6 +19,7 @@
#include "wiusersettings.h"
#include "wiview.h"
#include "obsconditions.h"
#include "kstars.h"
#include "kdebug.h"
WIUserSettings::WIUserSettings(QWidget *parent, Qt::WindowFlags flags): QWizard(parent, flags)
......@@ -42,11 +43,10 @@ void WIUserSettings::slotFinished(int)
? (binocularsCheck->isChecked() ? ObsConditions::Both : ObsConditions::Telescope)
: (binocularsCheck->isChecked() ? ObsConditions::Binoculars : ObsConditions::None));
type = (equipmentType->currentText()=="Reflector") ? ObsConditions::Reflector : ObsConditions::Refractor;
kDebug()<<bortleClass->value()<<eq<<aperture->value()<<type;
WIView *wi = new WIView(0, new ObsConditions(bortleClass->value(), aperture->value(), eq, type));
KStars *kstars = KStars::Instance();
kstars->showWI(new ObsConditions(bortleClass->value(), aperture->value(), eq, type));
}
void WIUserSettings::slotTelescopeCheck(bool on)
......
......@@ -39,6 +39,7 @@ private:
void makeConnections();
ObsConditions::Equipment eq;
ObsConditions::EquipmentType type;
WIView *m_WI;
};
#endif
......@@ -28,15 +28,13 @@ WIView::WIView(QWidget *parent, ObsConditions *obs) : QWidget(parent)
m = new ModelManager(obs);
KStars *kstars = KStars::Instance();
QDeclarativeView *baseView = new QDeclarativeView();
m_BaseView = new QDeclarativeView();
ctxt = baseView->rootContext();
ctxt = m_BaseView->rootContext();
baseView->setSource(KStandardDirs::locate("appdata","tools/whatsinteresting/qml/wiview.qml"));
m_BaseView->setSource(KStandardDirs::locate("appdata","tools/whatsinteresting/qml/wiview.qml"));
m_BaseObj = dynamic_cast<QObject *>(baseView->rootObject());
m_BaseObj = dynamic_cast<QObject *>(m_BaseView->rootObject());
//soTypeTextObj = m_BaseObj->findChild<QObject *>("soTypeTextObj");
......@@ -59,9 +57,8 @@ WIView::WIView(QWidget *parent, ObsConditions *obs) : QWidget(parent)
m_DetailsButtonObj = m_BaseObj->findChild<QObject *>("detailsButtonObj");
connect(m_DetailsButtonObj, SIGNAL(detailsButtonClicked()), this, SLOT(onDetailsButtonClicked()));
baseView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
baseView->show();
kstars->setWIView(baseView);
m_BaseView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
m_BaseView->show();
}
WIView::~WIView()
......
......@@ -57,6 +57,10 @@ public:
*/
void loadDetailsView(SkyObjItem* soitem, int index);
inline void updateModels(ObsConditions *obs) { m->updateModels(obs); }
inline QDeclarativeView *getWIBaseView() const { return m_BaseView; }
public slots:
/**
......@@ -99,6 +103,7 @@ private:
QObject *m_BaseObj, *m_ViewsRowObj, *m_SoListObj, *m_DetailsViewObj,
*m_NextObj, *m_PrevObj, *m_SlewButtonObj, *m_DetailsButtonObj;
QDeclarativeContext *ctxt;
QDeclarativeView *m_BaseView;
ModelManager *m;
SkyObjItem *m_CurSoItem; ///Current sky-object item.
int m_CurIndex; ///Index of current sky-object item in details-view.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment