Qt4 interface changes:

- Made solar system browser automatically expand top level items
- Changed the way that browser tools invoke the selection popup menu
ver1_5_1
Chris Laurel 2008-01-22 10:35:08 +00:00
parent 5c37614d54
commit a97bc06603
8 changed files with 51 additions and 9 deletions

View File

@ -11,7 +11,6 @@
// of the License, or (at your option) any later version.
#include "qtcelestialbrowser.h"
#include "qtselectionpopup.h"
#include "qtcolorswatchwidget.h"
#include <QAbstractItemModel>
#include <QTreeView>
@ -627,8 +626,7 @@ void CelestialBrowser::slotContextMenu(const QPoint& pos)
if (!sel.empty())
{
SelectionPopup* menu = new SelectionPopup(sel, appCore, this);
menu->popupAtGoto(treeView->mapToGlobal(pos));
emit selectionContextMenuRequested(treeView->mapToGlobal(pos), sel);
}
}

View File

@ -14,6 +14,7 @@
#define _QTCELESTIALBROWSER_H_
#include <QWidget>
#include "qtselectionpopup.h"
class QAbstractItemModel;
class QTreeView;
@ -41,6 +42,9 @@ Q_OBJECT
void slotMarkSelected();
void slotClearMarkers();
signals:
void selectionContextMenuRequested(const QPoint& pos, Selection& sel);
private:
CelestiaCore* appCore;

View File

@ -11,7 +11,6 @@
// of the License, or (at your option) any later version.
#include "qtdeepskybrowser.h"
#include "qtselectionpopup.h"
#include "qtcolorswatchwidget.h"
#include <QAbstractItemModel>
#include <QTreeView>
@ -551,8 +550,7 @@ void DeepSkyBrowser::slotContextMenu(const QPoint& pos)
if (!sel.empty())
{
SelectionPopup* menu = new SelectionPopup(sel, appCore, this);
menu->popupAtGoto(treeView->mapToGlobal(pos));
emit selectionContextMenuRequested(treeView->mapToGlobal(pos), sel);
}
}

View File

@ -14,6 +14,7 @@
#define _QTDEEPSKYBROWSER_H_
#include <QWidget>
#include "celengine/selection.h"
class QAbstractItemModel;
class QTreeView;
@ -41,6 +42,9 @@ Q_OBJECT
void slotMarkSelected();
void slotClearMarkers();
signals:
void selectionContextMenuRequested(const QPoint& pos, Selection& sel);
private:
CelestiaCore* appCore;

View File

@ -130,6 +130,7 @@ SelectionPopup::SelectionPopup(const Selection& sel,
addSeparator();
QAction* selectAction = new QAction(tr("&Select"), this);
connect(selectAction, SIGNAL(triggered()), this, SLOT(slotSelect()));
addAction(selectAction);
centerAction = new QAction(tr("&Center"), this);
@ -152,6 +153,7 @@ SelectionPopup::SelectionPopup(const Selection& sel,
}
QAction* infoAction = new QAction("Info", this);
connect(infoAction, SIGNAL(triggered()), this, SLOT(slotInfo()));
addAction(infoAction);
// Marker submenu
@ -403,6 +405,13 @@ void SelectionPopup::popupAtCenter(const QPoint& pt)
/******** Slots *********/
void SelectionPopup::slotSelect()
{
appCore->getSimulation()->setSelection(selection);
}
void SelectionPopup::slotCenterSelection()
{
appCore->getSimulation()->setSelection(selection);
@ -496,6 +505,9 @@ void SelectionPopup::slotMark()
(Marker::Symbol) symbol,
1,
"");
// Automatically enable markers
appCore->getRenderer()->setRenderFlags(appCore->getRenderer()->getRenderFlags() | Renderer::ShowMarkers);
}
}
}
@ -537,3 +549,9 @@ void SelectionPopup::slotGotoEndDate()
selection.body()->getLifespan(startDate, endDate);
appCore->getSimulation()->setTime(endDate);
}
void SelectionPopup::slotInfo()
{
emit selectionInfoRequested(selection);
}

View File

@ -29,6 +29,7 @@ Q_OBJECT
~SelectionPopup();
public slots:
void slotSelect();
void slotCenterSelection();
void slotGotoSelection();
void slotFollowSelection();
@ -39,10 +40,14 @@ Q_OBJECT
void slotToggleReferenceVector();
void slotGotoStartDate();
void slotGotoEndDate();
void slotInfo();
void popupAtGoto(const QPoint& p);
void popupAtCenter(const QPoint& p);
signals:
void selectionInfoRequested(Selection& sel);
private:
QMenu* createMarkMenu();
QMenu* createReferenceVectorMenu();

View File

@ -11,7 +11,6 @@
// of the License, or (at your option) any later version.
#include "qtsolarsystembrowser.h"
#include "qtselectionpopup.h"
#include <QAbstractItemModel>
#include <QTreeView>
#include <QPushButton>
@ -679,6 +678,19 @@ void SolarSystemBrowser::slotRefreshTree()
treeView->resizeColumnToContents(SolarSystemTreeModel::NameColumn);
treeView->clearSelection();
// Automatically expand stars in the model (to a max depth of 2)
QModelIndex primary = solarSystemModel->index(0, 0, QModelIndex());
if (primary.isValid() && solarSystemModel->objectAtIndex(primary).star() != NULL)
{
treeView->setExpanded(primary, true);
QModelIndex secondary = solarSystemModel->index(0, 0, primary);
if (secondary.isValid() && solarSystemModel->objectAtIndex(secondary).star() != NULL)
{
treeView->setExpanded(secondary, true);
}
}
}
@ -689,8 +701,7 @@ void SolarSystemBrowser::slotContextMenu(const QPoint& pos)
if (!sel.empty())
{
SelectionPopup* menu = new SelectionPopup(sel, appCore, this);
menu->popupAtGoto(treeView->mapToGlobal(pos));
emit selectionContextMenuRequested(treeView->mapToGlobal(pos), sel);
}
}

View File

@ -14,6 +14,7 @@
#define _QTSOLARSYSTEMBROWSER_H_
#include <QWidget>
#include "celengine/selection.h"
class QAbstractItemModel;
class QTreeView;
@ -36,6 +37,9 @@ Q_OBJECT
void slotMarkSelected();
//void slotChooseMarkerColor();
signals:
void selectionContextMenuRequested(const QPoint& pos, Selection& sel);
private:
void setMarkerColor(QColor color);