Improved choice of default name for bookmarks in Qt4 front-end.

ver1_6_1
Chris Laurel 2008-04-22 20:57:12 +00:00
parent 4eba15661c
commit 0899f0a635
1 changed files with 22 additions and 4 deletions

View File

@ -777,11 +777,29 @@ void CelestiaAppWindow::slotAddBookmark()
// Set the default bookmark title to the name of the current selection
Selection sel = m_appCore->getSimulation()->getSelection();
QString defaultTitle;
// TODO: Improve the choice of default bookmark title.
if (sel.empty())
if (sel.body() != NULL)
{
defaultTitle = QString::fromUtf8(sel.body()->getName().c_str());
}
else if (sel.star() != NULL)
{
Universe* universe = m_appCore->getSimulation()->getUniverse();
defaultTitle = QString::fromUtf8(universe->getStarCatalog()->getStarName(*sel.star()).c_str());
}
else if (sel.deepsky() != NULL)
{
Universe* universe = m_appCore->getSimulation()->getUniverse();
defaultTitle = QString::fromUtf8(universe->getDSOCatalog()->getDSOName(sel.deepsky()).c_str());
}
else if (sel.location() != NULL)
{
defaultTitle = sel.location()->getName().c_str();
}
if (defaultTitle.isEmpty())
defaultTitle = tr("New bookmark");
else
defaultTitle = sel.getName().c_str();
Url url(m_appCore);
QString urlText(url.getAsString().c_str());