Merge lp:~alexwolf/stellarium/bookmarks into lp:stellarium
- bookmarks
- Merge into trunk
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~alexwolf/stellarium/bookmarks | ||||
Merge into: | lp:stellarium | ||||
Diff against target: |
916 lines (+708/-35) 12 files modified
plugins/TelescopeControl/src/gui/StoredPointsDialog.hpp (+1/-1) po/stellarium/POTFILES.in (+2/-0) src/CMakeLists.txt (+3/-0) src/core/modules/Nebula.cpp (+39/-33) src/core/modules/Nebula.hpp (+4/-0) src/core/modules/NebulaMgr.cpp (+17/-1) src/core/modules/NebulaMgr.hpp (+5/-0) src/gui/BookmarksDialog.cpp (+317/-0) src/gui/BookmarksDialog.hpp (+93/-0) src/gui/StelGui.cpp (+9/-0) src/gui/StelGui.hpp (+2/-0) src/gui/bookmarksDialog.ui (+216/-0) |
||||
To merge this branch: | bzr merge lp:~alexwolf/stellarium/bookmarks | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
gzotti | Needs Fixing | ||
Alexander Wolf | Needs Information | ||
Review via email:
|
This proposal has been superseded by a proposal from 2016-04-03.
Commit message
Description of the change
Added implementation of bookmarks: users can add objects with proper name or designation into bookmarks (date and location is optional) for quick access to objects from this list in subsequently.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexander Wolf (alexwolf) wrote : | # |
The format of bookmarks file has been changed and currenty I can't reproduce the issue. Of course the tool should put in the log info about problems.
- 8250. By Alexander Wolf
-
A small fix for unnamed locations
- 8251. By Alexander Wolf
-
Added movement to bookmark's place through double click
- 8252. By Alexander Wolf
-
Obvious tiny fix
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
gzotti (georg-zotti) wrote : | # |
It seems to work ok now. However, what is the new "search for DSO number" in NebulaMgr? Currently, DSO proper name is stored in the bookmark, and when changing skyculture language, this is lost (bookmark does not load object). I know, changing skyculture language is not too common, but may still happen. Maybe prefer (untranslated) catalog number as object and show a comment column with object name?
- 8253. By Alexander Wolf
-
Change behaviour of bookmarks
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexander Wolf (alexwolf) wrote : | # |
OK, English only names for Solar system bodies and designations only for DSO and stars because user can change skyculture.
- 8254. By Alexander Wolf
-
simplifications...
- 8255. By Alexander Wolf
-
Usability improvements
- 8256. By Alexander Wolf
-
Final fix =)
Unmerged revisions
Preview Diff
1 | === modified file 'plugins/TelescopeControl/src/gui/StoredPointsDialog.hpp' |
2 | --- plugins/TelescopeControl/src/gui/StoredPointsDialog.hpp 2015-06-30 18:51:58 +0000 |
3 | +++ plugins/TelescopeControl/src/gui/StoredPointsDialog.hpp 2016-04-03 19:30:56 +0000 |
4 | @@ -33,7 +33,7 @@ |
5 | #include "StelModuleMgr.hpp" |
6 | #include "StelUtils.hpp" |
7 | |
8 | -#include <AngleSpinBox.hpp> |
9 | +#include "AngleSpinBox.hpp" |
10 | |
11 | class Ui_StoredPoints; |
12 | |
13 | |
14 | === modified file 'po/stellarium/POTFILES.in' |
15 | --- po/stellarium/POTFILES.in 2015-08-22 22:20:20 +0000 |
16 | +++ po/stellarium/POTFILES.in 2016-04-03 19:30:56 +0000 |
17 | @@ -34,6 +34,7 @@ |
18 | src/gui/ShortcutsDialog.cpp |
19 | src/gui/CustomDeltaTEquationDialog.cpp |
20 | src/gui/AstroCalcDialog.cpp |
21 | +src/gui/BookmarksDialog.cpp |
22 | src/main.cpp |
23 | src/StelMainView.cpp |
24 | |
25 | @@ -52,6 +53,7 @@ |
26 | src/ui_atmosphereDialog.h |
27 | src/ui_scriptConsole.h |
28 | src/ui_astroCalcDialog.h |
29 | +src/ui_bookmarksDialog.h |
30 | |
31 | # Plug-in translations |
32 | # NOTE: Plugins should be enabled for building |
33 | |
34 | === modified file 'src/CMakeLists.txt' |
35 | --- src/CMakeLists.txt 2016-01-30 18:35:25 +0000 |
36 | +++ src/CMakeLists.txt 2016-04-03 19:30:56 +0000 |
37 | @@ -334,6 +334,8 @@ |
38 | gui/CustomDeltaTEquationDialog.cpp |
39 | gui/AstroCalcDialog.hpp |
40 | gui/AstroCalcDialog.cpp |
41 | + gui/BookmarksDialog.hpp |
42 | + gui/BookmarksDialog.cpp |
43 | gui/StelDialog.hpp |
44 | gui/StelDialog.cpp |
45 | ) |
46 | @@ -350,6 +352,7 @@ |
47 | gui/atmosphereDialog.ui |
48 | gui/customDeltaTEquationDialog.ui |
49 | gui/astroCalcDialog.ui |
50 | + gui/bookmarksDialog.ui |
51 | gui/addRemoveLandscapesDialog.ui |
52 | ) |
53 | |
54 | |
55 | === modified file 'src/core/modules/Nebula.cpp' |
56 | --- src/core/modules/Nebula.cpp 2016-04-01 17:22:51 +0000 |
57 | +++ src/core/modules/Nebula.cpp 2016-04-03 19:30:56 +0000 |
58 | @@ -659,43 +659,49 @@ |
59 | |
60 | QString str = getNameI18n(); |
61 | if (str.isEmpty()) |
62 | - { |
63 | - // On screen label: one only, priority as given here. |
64 | - if (catalogFilters&CatM && M_nb>0) |
65 | - str = QString("M %1").arg(M_nb); |
66 | - else if (catalogFilters&CatC && C_nb>0) |
67 | - str = QString("C %1").arg(C_nb); |
68 | - else if (catalogFilters&CatNGC && NGC_nb>0) |
69 | - str = QString("NGC %1").arg(NGC_nb); |
70 | - else if (catalogFilters&CatIC && IC_nb>0) |
71 | - str = QString("IC %1").arg(IC_nb); |
72 | - else if (catalogFilters&CatB && B_nb>0) |
73 | - str = QString("B %1").arg(B_nb); |
74 | - else if (catalogFilters&CatSh2 && Sh2_nb>0) |
75 | - str = QString("Sh 2-%1").arg(Sh2_nb); |
76 | - else if (catalogFilters&CatVdB && VdB_nb>0) |
77 | - str = QString("VdB %1").arg(VdB_nb); |
78 | - else if (catalogFilters&CatRCW && RCW_nb>0) |
79 | - str = QString("RCW %1").arg(RCW_nb); |
80 | - else if (catalogFilters&CatLDN && LDN_nb>0) |
81 | - str = QString("LDN %1").arg(LDN_nb); |
82 | - else if (catalogFilters&CatLBN && LBN_nb > 0) |
83 | - str = QString("LBN %1").arg(LBN_nb); |
84 | - else if (catalogFilters&CatCr && Cr_nb > 0) |
85 | - str = QString("Cr %1").arg(Cr_nb); |
86 | - else if (catalogFilters&CatMel && Mel_nb > 0) |
87 | - str = QString("Mel %1").arg(Mel_nb); |
88 | - else if (catalogFilters&CatPGC && PGC_nb > 0) |
89 | - str = QString("PGC %1").arg(PGC_nb); |
90 | - else if (catalogFilters&CatUGC && UGC_nb > 0) |
91 | - str = QString("UGC %1").arg(UGC_nb); |
92 | - else if (catalogFilters&CatCed && !Ced_nb.isEmpty()) |
93 | - str = QString("Ced %1").arg(Ced_nb); |
94 | - } |
95 | + str = getDSODesignation(); |
96 | |
97 | sPainter.drawText(XY[0]+shift, XY[1]+shift, str, 0, 0, 0, false); |
98 | } |
99 | |
100 | +QString Nebula::getDSODesignation() |
101 | +{ |
102 | + QString str = ""; |
103 | + // Get designation for DSO with priority as given here. |
104 | + if (catalogFilters&CatM && M_nb>0) |
105 | + str = QString("M %1").arg(M_nb); |
106 | + else if (catalogFilters&CatC && C_nb>0) |
107 | + str = QString("C %1").arg(C_nb); |
108 | + else if (catalogFilters&CatNGC && NGC_nb>0) |
109 | + str = QString("NGC %1").arg(NGC_nb); |
110 | + else if (catalogFilters&CatIC && IC_nb>0) |
111 | + str = QString("IC %1").arg(IC_nb); |
112 | + else if (catalogFilters&CatB && B_nb>0) |
113 | + str = QString("B %1").arg(B_nb); |
114 | + else if (catalogFilters&CatSh2 && Sh2_nb>0) |
115 | + str = QString("Sh 2-%1").arg(Sh2_nb); |
116 | + else if (catalogFilters&CatVdB && VdB_nb>0) |
117 | + str = QString("VdB %1").arg(VdB_nb); |
118 | + else if (catalogFilters&CatRCW && RCW_nb>0) |
119 | + str = QString("RCW %1").arg(RCW_nb); |
120 | + else if (catalogFilters&CatLDN && LDN_nb>0) |
121 | + str = QString("LDN %1").arg(LDN_nb); |
122 | + else if (catalogFilters&CatLBN && LBN_nb > 0) |
123 | + str = QString("LBN %1").arg(LBN_nb); |
124 | + else if (catalogFilters&CatCr && Cr_nb > 0) |
125 | + str = QString("Cr %1").arg(Cr_nb); |
126 | + else if (catalogFilters&CatMel && Mel_nb > 0) |
127 | + str = QString("Mel %1").arg(Mel_nb); |
128 | + else if (catalogFilters&CatPGC && PGC_nb > 0) |
129 | + str = QString("PGC %1").arg(PGC_nb); |
130 | + else if (catalogFilters&CatUGC && UGC_nb > 0) |
131 | + str = QString("UGC %1").arg(UGC_nb); |
132 | + else if (catalogFilters&CatCed && !Ced_nb.isEmpty()) |
133 | + str = QString("Ced %1").arg(Ced_nb); |
134 | + |
135 | + return str; |
136 | +} |
137 | + |
138 | void Nebula::readDSO(QDataStream &in) |
139 | { |
140 | float ra, dec; |
141 | |
142 | === modified file 'src/core/modules/Nebula.hpp' |
143 | --- src/core/modules/Nebula.hpp 2015-12-06 10:51:40 +0000 |
144 | +++ src/core/modules/Nebula.hpp 2016-04-03 19:30:56 +0000 |
145 | @@ -128,6 +128,10 @@ |
146 | |
147 | void setProperName(QString name) { englishName = name; } |
148 | |
149 | + //! Get designation for DSO (with priority: M, C, NGC, IC, B, Sh2, VdB, RCW, LDN, LBN, Cr, Mel, PGC, UGC, Ced) |
150 | + //! @return a designation |
151 | + QString getDSODesignation(); |
152 | + |
153 | private: |
154 | friend struct DrawNebulaFuncObject; |
155 | |
156 | |
157 | === modified file 'src/core/modules/NebulaMgr.cpp' |
158 | --- src/core/modules/NebulaMgr.cpp 2016-01-31 16:07:32 +0000 |
159 | +++ src/core/modules/NebulaMgr.cpp 2016-04-03 19:30:56 +0000 |
160 | @@ -739,6 +739,21 @@ |
161 | return NebulaP(); |
162 | } |
163 | |
164 | +QString NebulaMgr::getLatestSelectedDSODesignation() |
165 | +{ |
166 | + QString result = ""; |
167 | + |
168 | + const QList<StelObjectP> selected = GETSTELMODULE(StelObjectMgr)->getSelectedObject("Nebula"); |
169 | + if (!selected.empty()) |
170 | + { |
171 | + foreach (const NebulaP& n, dsoArray) |
172 | + if (n==selected[0]) |
173 | + result = n->getDSODesignation(); // Get designation for latest selected DSO |
174 | + } |
175 | + |
176 | + return result; |
177 | +} |
178 | + |
179 | void NebulaMgr::convertDSOCatalog(const QString &in, const QString &out, bool decimal=false) |
180 | { |
181 | QFile dsoIn(in); |
182 | @@ -1842,7 +1857,8 @@ |
183 | QStringList result; |
184 | if (maxNbItem==0) return result; |
185 | |
186 | - QString objw = objPrefix.toUpper(); |
187 | + QString objw = objPrefix.toUpper(); |
188 | + |
189 | // Search by Messier objects number (possible formats are "M31" or "M 31") |
190 | if (objw.size()>=1 && objw.left(1)=="M" && objw.left(2)!="ME") |
191 | { |
192 | |
193 | === modified file 'src/core/modules/NebulaMgr.hpp' |
194 | --- src/core/modules/NebulaMgr.hpp 2015-12-06 10:51:40 +0000 |
195 | +++ src/core/modules/NebulaMgr.hpp 2016-04-03 19:30:56 +0000 |
196 | @@ -122,6 +122,11 @@ |
197 | |
198 | bool objectInDisplayedCatalog(NebulaP n); |
199 | |
200 | + //! Get designation for latest selected DSO with priority |
201 | + //! @note using for bookmarks feature as example |
202 | + //! @return a designation |
203 | + QString getLatestSelectedDSODesignation(); |
204 | + |
205 | /////////////////////////////////////////////////////////////////////////// |
206 | // Properties setters and getters |
207 | public slots: |
208 | |
209 | === added file 'src/gui/BookmarksDialog.cpp' |
210 | --- src/gui/BookmarksDialog.cpp 1970-01-01 00:00:00 +0000 |
211 | +++ src/gui/BookmarksDialog.cpp 2016-04-03 19:30:56 +0000 |
212 | @@ -0,0 +1,317 @@ |
213 | +/* |
214 | + * Stellarium |
215 | + * Copyright (C) 2016 Alexander Wolf |
216 | + * |
217 | + * This program is free software; you can redistribute it and/or |
218 | + * modify it under the terms of the GNU General Public License |
219 | + * as published by the Free Software Foundation; either version 2 |
220 | + * of the License, or (at your option) any later version. |
221 | + * |
222 | + * This program is distributed in the hope that it will be useful, |
223 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
224 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
225 | + * GNU General Public License for more details. |
226 | + * You should have received a copy of the GNU General Public License |
227 | + * along with this program; if not, write to the Free Software |
228 | + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. |
229 | +*/ |
230 | + |
231 | +#include "StelApp.hpp" |
232 | +#include "StelCore.hpp" |
233 | +#include "StelModuleMgr.hpp" |
234 | +#include "StelMovementMgr.hpp" |
235 | +#include "StelObjectMgr.hpp" |
236 | +#include "StelUtils.hpp" |
237 | +#include "StelTranslator.hpp" |
238 | +#include "StelLocaleMgr.hpp" |
239 | +#include "StelLocation.hpp" |
240 | +#include "StelLocationMgr.hpp" |
241 | +#include "StelFileMgr.hpp" |
242 | +#include "StelJsonParser.hpp" |
243 | +#include "AngleSpinBox.hpp" |
244 | +#include "NebulaMgr.hpp" |
245 | + |
246 | +#include "BookmarksDialog.hpp" |
247 | +#include "ui_bookmarksDialog.h" |
248 | + |
249 | +BookmarksDialog::BookmarksDialog(QObject *parent) |
250 | + : StelDialog(parent) |
251 | +{ |
252 | + dialogName = "Bookmarks"; |
253 | + ui = new Ui_bookmarksDialogForm; |
254 | + core = StelApp::getInstance().getCore(); |
255 | + objectMgr = GETSTELMODULE(StelObjectMgr); |
256 | + bookmarksListModel = new QStandardItemModel(0, ColumnCount); |
257 | + bookmarksJsonPath = StelFileMgr::findFile("data", (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/bookmarks.json"; |
258 | +} |
259 | + |
260 | +BookmarksDialog::~BookmarksDialog() |
261 | +{ |
262 | + delete ui; |
263 | + delete bookmarksListModel; |
264 | +} |
265 | + |
266 | +void BookmarksDialog::retranslate() |
267 | +{ |
268 | + if (dialog) |
269 | + { |
270 | + ui->retranslateUi(dialog); |
271 | + setBookmarksHeaderNames(); |
272 | + } |
273 | +} |
274 | + |
275 | +void BookmarksDialog::createDialogContent() |
276 | +{ |
277 | + ui->setupUi(dialog); |
278 | + |
279 | + //Signals and slots |
280 | + connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); |
281 | + connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); |
282 | + connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint))); |
283 | + |
284 | + connect(ui->addBookmarkButton, SIGNAL(clicked()), this, SLOT(addBookmarkButtonPressed())); |
285 | + connect(ui->removeBookmarkButton, SIGNAL(clicked()), this, SLOT(removeBookmarkButtonPressed())); |
286 | + connect(ui->goToButton, SIGNAL(clicked()), this, SLOT(goToBookmarkButtonPressed())); |
287 | + connect(ui->clearBookmarksButton, SIGNAL(clicked()), this, SLOT(clearBookmarksButtonPressed())); |
288 | + connect(ui->bookmarksTreeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectCurrentBookmark(QModelIndex))); |
289 | + |
290 | + //Initializing the list of bookmarks |
291 | + bookmarksListModel->setColumnCount(ColumnCount); |
292 | + setBookmarksHeaderNames(); |
293 | + |
294 | + ui->bookmarksTreeView->setModel(bookmarksListModel); |
295 | + ui->bookmarksTreeView->header()->setSectionsMovable(false); |
296 | + ui->bookmarksTreeView->header()->setSectionResizeMode(ColumnName, QHeaderView::ResizeToContents); |
297 | + ui->bookmarksTreeView->header()->setStretchLastSection(true); |
298 | + ui->bookmarksTreeView->hideColumn(0); |
299 | + |
300 | + loadBookmarks(); |
301 | +} |
302 | + |
303 | +void BookmarksDialog::setBookmarksHeaderNames() |
304 | +{ |
305 | + QStringList headerStrings; |
306 | + headerStrings << "UUID"; // Hide the column |
307 | + headerStrings << q_("Object"); |
308 | + headerStrings << q_("Date and Time"); |
309 | + headerStrings << q_("Location of observer"); |
310 | + |
311 | + bookmarksListModel->setHorizontalHeaderLabels(headerStrings); |
312 | +} |
313 | + |
314 | +void BookmarksDialog::addModelRow(int number, QString uuid, QString name, QString Date, QString Location) |
315 | +{ |
316 | + QStandardItem* tempItem = 0; |
317 | + |
318 | + tempItem = new QStandardItem(uuid); |
319 | + tempItem->setEditable(false); |
320 | + bookmarksListModel->setItem(number, ColumnUUID, tempItem); |
321 | + |
322 | + tempItem = new QStandardItem(name); |
323 | + tempItem->setEditable(false); |
324 | + bookmarksListModel->setItem(number, ColumnName, tempItem); |
325 | + |
326 | + tempItem = new QStandardItem(Date); |
327 | + tempItem->setEditable(false); |
328 | + bookmarksListModel->setItem(number, ColumnDate, tempItem); |
329 | + |
330 | + tempItem = new QStandardItem(Location); |
331 | + tempItem->setEditable(false); |
332 | + bookmarksListModel->setItem(number, ColumnLocation, tempItem); |
333 | + |
334 | + for(int i = 0; i < ColumnCount; ++i) |
335 | + { |
336 | + ui->bookmarksTreeView->resizeColumnToContents(i); |
337 | + } |
338 | +} |
339 | + |
340 | +void BookmarksDialog::addBookmarkButtonPressed() |
341 | +{ |
342 | + const QList<StelObjectP>& selected = objectMgr->getSelectedObject(); |
343 | + if (!selected.isEmpty()) |
344 | + { |
345 | + QString name = selected[0]->getEnglishName(); |
346 | + if (selected[0]->getType()=="Nebula") |
347 | + name = GETSTELMODULE(NebulaMgr)->getLatestSelectedDSODesignation(); |
348 | + |
349 | + if (!name.isEmpty()) // Don't allow adding objects without name! |
350 | + { |
351 | + bool dateTimeFlag = ui->dateTimeCheckBox->isChecked(); |
352 | + bool locationFlag = ui->locationCheckBox->isChecked(); |
353 | + |
354 | + QString JDs = ""; |
355 | + double JD = -1.; |
356 | + |
357 | + if (dateTimeFlag) |
358 | + { |
359 | + JD = core->getJD(); |
360 | + JDs = StelUtils::julianDayToISO8601String(JD + StelUtils::getGMTShiftFromQT(JD)/24.).replace("T", " "); |
361 | + } |
362 | + |
363 | + QString Location = ""; |
364 | + if (locationFlag) |
365 | + { |
366 | + StelLocation loc = core->getCurrentLocation(); |
367 | + if (loc.name.isEmpty()) |
368 | + Location = QString("%1, %2").arg(loc.latitude).arg(loc.longitude); |
369 | + else |
370 | + Location = QString("%1, %2").arg(loc.name).arg(loc.country); |
371 | + } |
372 | + |
373 | + int lastRow = bookmarksListModel->rowCount(); |
374 | + |
375 | + QString uuid = QUuid::createUuid().toString(); |
376 | + addModelRow(lastRow, uuid, name, JDs, Location); |
377 | + |
378 | + bookmark bm; |
379 | + bm.name = name; |
380 | + if (!JDs.isEmpty()) |
381 | + bm.jd = QString::number(JD, 'f', 6); |
382 | + if (!Location.isEmpty()) |
383 | + bm.location = Location; |
384 | + |
385 | + bookmarksCollection.insert(uuid, bm); |
386 | + |
387 | + saveBookmarks(); |
388 | + } |
389 | + } |
390 | +} |
391 | + |
392 | +void BookmarksDialog::removeBookmarkButtonPressed() |
393 | +{ |
394 | + int number = ui->bookmarksTreeView->currentIndex().row(); |
395 | + QString uuid = bookmarksListModel->index(number, ColumnUUID).data().toString(); |
396 | + bookmarksListModel->removeRow(number); |
397 | + bookmarksCollection.remove(uuid); |
398 | + saveBookmarks(); |
399 | +} |
400 | + |
401 | +void BookmarksDialog::clearBookmarksButtonPressed() |
402 | +{ |
403 | + bookmarksListModel->clear(); |
404 | + bookmarksCollection.clear(); |
405 | + setBookmarksHeaderNames(); |
406 | + ui->bookmarksTreeView->hideColumn(0); |
407 | + saveBookmarks(); |
408 | +} |
409 | + |
410 | +void BookmarksDialog::goToBookmarkButtonPressed() |
411 | +{ |
412 | + goToBookmark(bookmarksListModel->index(ui->bookmarksTreeView->currentIndex().row(), ColumnUUID).data().toString()); |
413 | +} |
414 | + |
415 | +void BookmarksDialog::selectCurrentBookmark(const QModelIndex &modelIdx) |
416 | +{ |
417 | + goToBookmark(modelIdx.sibling(modelIdx.row(), ColumnUUID).data().toString()); |
418 | +} |
419 | + |
420 | +void BookmarksDialog::goToBookmark(QString uuid) |
421 | +{ |
422 | + if (!uuid.isEmpty()) |
423 | + { |
424 | + bookmark bm = bookmarksCollection.value(uuid); |
425 | + if (!bm.jd.isEmpty()) |
426 | + { |
427 | + core->setJD(bm.jd.toDouble()); |
428 | + } |
429 | + if (!bm.location.isEmpty()) |
430 | + { |
431 | + StelLocationMgr* locationMgr = &StelApp::getInstance().getLocationMgr(); |
432 | + core->moveObserverTo(locationMgr->locationForString(bm.location)); |
433 | + } |
434 | + |
435 | + objectMgr->unSelect(); |
436 | + if (objectMgr->findAndSelect(bm.name)) |
437 | + { |
438 | + const QList<StelObjectP> newSelected = objectMgr->getSelectedObject(); |
439 | + if (!newSelected.empty()) |
440 | + { |
441 | + StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); |
442 | + mvmgr->moveToObject(newSelected[0], mvmgr->getAutoMoveDuration()); |
443 | + mvmgr->setFlagTracking(true); |
444 | + } |
445 | + } |
446 | + } |
447 | +} |
448 | + |
449 | +void BookmarksDialog::loadBookmarks() |
450 | +{ |
451 | + QVariantMap map; |
452 | + QFile jsonFile(bookmarksJsonPath); |
453 | + if (!jsonFile.open(QIODevice::ReadOnly)) |
454 | + qWarning() << "Bookmarks: cannot open" << QDir::toNativeSeparators(bookmarksJsonPath); |
455 | + else |
456 | + { |
457 | + map = StelJsonParser::parse(jsonFile.readAll()).toMap(); |
458 | + jsonFile.close(); |
459 | + } |
460 | + |
461 | + bookmarksCollection.clear(); |
462 | + QVariantMap bookmarksMap = map.value("bookmarks").toMap(); |
463 | + int i = 0; |
464 | + foreach(QString bookmarkKey, bookmarksMap.keys()) |
465 | + { |
466 | + QVariantMap bookmarkData = bookmarksMap.value(bookmarkKey).toMap(); |
467 | + bookmark bm; |
468 | + |
469 | + QString JDs = ""; |
470 | + |
471 | + bm.name = bookmarkData.value("name").toString(); |
472 | + QString JD = bookmarkData.value("jd").toString(); |
473 | + if (!JD.isEmpty()) |
474 | + { |
475 | + bm.jd = JD; |
476 | + JDs = StelUtils::julianDayToISO8601String(JD.toDouble() + StelUtils::getGMTShiftFromQT(JD.toDouble())/24.).replace("T", " "); |
477 | + } |
478 | + QString Location = bookmarkData.value("location").toString(); |
479 | + if (!Location.isEmpty()) |
480 | + bm.location = Location; |
481 | + |
482 | + bookmarksCollection.insert(bookmarkKey, bm); |
483 | + addModelRow(i, bookmarkKey, bm.name, JDs, Location); |
484 | + i++; |
485 | + } |
486 | +} |
487 | + |
488 | +void BookmarksDialog::saveBookmarks() |
489 | +{ |
490 | + if (bookmarksJsonPath.isEmpty()) |
491 | + { |
492 | + qWarning() << "Bookmarks: Error saving bookmarks"; |
493 | + return; |
494 | + } |
495 | + QFile jsonFile(bookmarksJsonPath); |
496 | + if(!jsonFile.open(QFile::WriteOnly|QFile::Text)) |
497 | + { |
498 | + qWarning() << "Bookmarks: bookmarks can not be saved. A file can not be open for writing:" |
499 | + << QDir::toNativeSeparators(bookmarksJsonPath); |
500 | + return; |
501 | + } |
502 | + |
503 | + QVariantMap bookmarksDataList; |
504 | + QHashIterator<QString, bookmark> i(bookmarksCollection); |
505 | + while (i.hasNext()) |
506 | + { |
507 | + i.next(); |
508 | + |
509 | + bookmark sp = i.value(); |
510 | + QVariantMap bm; |
511 | + bm.insert("name", sp.name); |
512 | + if (!sp.jd.isEmpty()) |
513 | + bm.insert("jd", sp.jd); |
514 | + if (!sp.location.isEmpty()) |
515 | + bm.insert("location", sp.location); |
516 | + |
517 | + bookmarksDataList.insert(i.key(), bm); |
518 | + } |
519 | + |
520 | + QVariantMap bmList; |
521 | + bmList.insert("bookmarks", bookmarksDataList); |
522 | + |
523 | + //Convert the tree to JSON |
524 | + StelJsonParser::write(bmList, &jsonFile); |
525 | + jsonFile.flush(); |
526 | + jsonFile.close(); |
527 | + |
528 | +} |
529 | + |
530 | |
531 | === added file 'src/gui/BookmarksDialog.hpp' |
532 | --- src/gui/BookmarksDialog.hpp 1970-01-01 00:00:00 +0000 |
533 | +++ src/gui/BookmarksDialog.hpp 2016-04-03 19:30:56 +0000 |
534 | @@ -0,0 +1,93 @@ |
535 | +/* |
536 | + * Stellarium |
537 | + * |
538 | + * Copyright (C) 2016 Alexander Wolf |
539 | + * |
540 | + * This program is free software; you can redistribute it and/or |
541 | + * modify it under the terms of the GNU General Public License |
542 | + * as published by the Free Software Foundation; either version 2 |
543 | + * of the License, or (at your option) any later version. |
544 | + * |
545 | + * This program is distributed in the hope that it will be useful, |
546 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
547 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
548 | + * GNU General Public License for more details. |
549 | + * You should have received a copy of the GNU General Public License |
550 | + * along with this program; if not, write to the Free Software |
551 | + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. |
552 | +*/ |
553 | + |
554 | +#ifndef _BOOKMARKSDIALOG_HPP_ |
555 | +#define _BOOKMARKSDIALOG_HPP_ |
556 | + |
557 | +#include <QObject> |
558 | +#include <QStandardItemModel> |
559 | +#include <QMap> |
560 | +#include <QDir> |
561 | +#include <QUuid> |
562 | + |
563 | +#include "StelDialog.hpp" |
564 | +#include "StelCore.hpp" |
565 | + |
566 | +class Ui_bookmarksDialogForm; |
567 | + |
568 | +struct bookmark |
569 | +{ |
570 | + QString name; |
571 | + QString jd; |
572 | + QString location; |
573 | +}; |
574 | +Q_DECLARE_METATYPE(bookmark) |
575 | + |
576 | +class BookmarksDialog : public StelDialog |
577 | +{ |
578 | + Q_OBJECT |
579 | + |
580 | +public: |
581 | + BookmarksDialog(QObject* parent); |
582 | + virtual ~BookmarksDialog(); |
583 | + |
584 | +public slots: |
585 | + void retranslate(); |
586 | + |
587 | +protected: |
588 | + //! Initialize the dialog widgets and connect the signals/slots. |
589 | + virtual void createDialogContent(); |
590 | + Ui_bookmarksDialogForm *ui; |
591 | + |
592 | +private slots: |
593 | + void addBookmarkButtonPressed(); |
594 | + void removeBookmarkButtonPressed(); |
595 | + void goToBookmarkButtonPressed(); |
596 | + void clearBookmarksButtonPressed(); |
597 | + |
598 | + void selectCurrentBookmark(const QModelIndex &modelIdx); |
599 | + |
600 | +private: |
601 | + enum BookmarksColumns { |
602 | + ColumnUUID, //! UUID of bookmark |
603 | + ColumnName, //! name of bookmark |
604 | + ColumnDate, //! date and time (optional) |
605 | + ColumnLocation, //! location (optional) |
606 | + ColumnCount //! total number of columns |
607 | + }; |
608 | + QStandardItemModel * bookmarksListModel; |
609 | + |
610 | + class StelCore* core; |
611 | + class StelObjectMgr* objectMgr; |
612 | + |
613 | + QString bookmarksJsonPath; |
614 | + QHash<QString, bookmark> bookmarksCollection; |
615 | + |
616 | + //! Update header names for bookmarks table |
617 | + void setBookmarksHeaderNames(); |
618 | + |
619 | + void addModelRow(int number, QString uuid, QString name, QString date = "", QString Location = ""); |
620 | + |
621 | + void loadBookmarks(); |
622 | + void saveBookmarks(); |
623 | + void goToBookmark(QString uuid); |
624 | +}; |
625 | + |
626 | + |
627 | +#endif // _BOOKMARKSDIALOG_HPP_ |
628 | |
629 | === modified file 'src/gui/StelGui.cpp' |
630 | --- src/gui/StelGui.cpp 2016-02-05 17:43:12 +0000 |
631 | +++ src/gui/StelGui.cpp 2016-04-03 19:30:56 +0000 |
632 | @@ -60,6 +60,7 @@ |
633 | #include "ViewDialog.hpp" |
634 | #include "ShortcutsDialog.hpp" |
635 | #include "AstroCalcDialog.hpp" |
636 | +#include "BookmarksDialog.hpp" |
637 | |
638 | #include <QDebug> |
639 | #include <QTimeLine> |
640 | @@ -95,6 +96,7 @@ |
641 | , scriptConsole(0) |
642 | #endif |
643 | , astroCalcDialog(0) |
644 | + , bookmarksDialog(0) |
645 | , flagShowFlipButtons(false) |
646 | , flipVert(NULL) |
647 | , flipHoriz(NULL) |
648 | @@ -158,6 +160,11 @@ |
649 | delete astroCalcDialog; |
650 | astroCalcDialog = NULL; |
651 | } |
652 | + if (bookmarksDialog) |
653 | + { |
654 | + delete bookmarksDialog; |
655 | + bookmarksDialog = NULL; |
656 | + } |
657 | } |
658 | |
659 | void StelGui::init(QGraphicsWidget *atopLevelGraphicsWidget) |
660 | @@ -177,6 +184,7 @@ |
661 | scriptConsole = new ScriptConsole(atopLevelGraphicsWidget); |
662 | #endif |
663 | astroCalcDialog = new AstroCalcDialog(atopLevelGraphicsWidget); |
664 | + bookmarksDialog = new BookmarksDialog(atopLevelGraphicsWidget); |
665 | |
666 | /////////////////////////////////////////////////////////////////////// |
667 | // Create all the main actions of the program, associated with shortcuts |
668 | @@ -209,6 +217,7 @@ |
669 | actionsMgr->addAction("actionShow_Location_Window_Global", windowsGroup, N_("Location window"), locationDialog, "visible", "F6", "", true); |
670 | actionsMgr->addAction("actionShow_Shortcuts_Window_Global", windowsGroup, N_("Shortcuts window"), shortcutsDialog, "visible", "F7", "", true); |
671 | actionsMgr->addAction("actionShow_AstroCalc_Window_Global", windowsGroup, N_("AstroCalc window"), astroCalcDialog, "visible", "F10", "Alt+A", true); |
672 | + actionsMgr->addAction("actionShow_Bookmarks_Window_Global", windowsGroup, N_("Bookmarks window"), bookmarksDialog, "visible", "Alt+B", "", true); |
673 | actionsMgr->addAction("actionSave_Copy_Object_Information_Global", miscGroup, N_("Copy selected object information to clipboard"), this, "copySelectedObjectInfo()", "Ctrl+C", "", true); |
674 | |
675 | QSettings* conf = StelApp::getInstance().getSettings(); |
676 | |
677 | === modified file 'src/gui/StelGui.hpp' |
678 | --- src/gui/StelGui.hpp 2016-02-01 14:05:43 +0000 |
679 | +++ src/gui/StelGui.hpp 2016-04-03 19:30:56 +0000 |
680 | @@ -42,6 +42,7 @@ |
681 | class ViewDialog; |
682 | class ShortcutsDialog; |
683 | class AstroCalcDialog; |
684 | +class BookmarksDialog; |
685 | #ifdef ENABLE_SCRIPT_CONSOLE |
686 | class ScriptConsole; |
687 | #endif |
688 | @@ -191,6 +192,7 @@ |
689 | ScriptConsole* scriptConsole; |
690 | #endif |
691 | AstroCalcDialog* astroCalcDialog; |
692 | + BookmarksDialog* bookmarksDialog; |
693 | |
694 | bool flagShowFlipButtons; |
695 | StelButton* flipVert; |
696 | |
697 | === added file 'src/gui/bookmarksDialog.ui' |
698 | --- src/gui/bookmarksDialog.ui 1970-01-01 00:00:00 +0000 |
699 | +++ src/gui/bookmarksDialog.ui 2016-04-03 19:30:56 +0000 |
700 | @@ -0,0 +1,216 @@ |
701 | +<?xml version="1.0" encoding="UTF-8"?> |
702 | +<ui version="4.0"> |
703 | + <class>bookmarksDialogForm</class> |
704 | + <widget class="QWidget" name="bookmarksDialogForm"> |
705 | + <property name="geometry"> |
706 | + <rect> |
707 | + <x>0</x> |
708 | + <y>0</y> |
709 | + <width>677</width> |
710 | + <height>359</height> |
711 | + </rect> |
712 | + </property> |
713 | + <layout class="QGridLayout" name="gridLayout_2"> |
714 | + <property name="leftMargin"> |
715 | + <number>0</number> |
716 | + </property> |
717 | + <property name="topMargin"> |
718 | + <number>0</number> |
719 | + </property> |
720 | + <property name="rightMargin"> |
721 | + <number>0</number> |
722 | + </property> |
723 | + <property name="bottomMargin"> |
724 | + <number>0</number> |
725 | + </property> |
726 | + <property name="spacing"> |
727 | + <number>0</number> |
728 | + </property> |
729 | + <item row="0" column="0"> |
730 | + <widget class="BarFrame" name="TitleBar"> |
731 | + <property name="minimumSize"> |
732 | + <size> |
733 | + <width>16</width> |
734 | + <height>25</height> |
735 | + </size> |
736 | + </property> |
737 | + <property name="maximumSize"> |
738 | + <size> |
739 | + <width>16777215</width> |
740 | + <height>25</height> |
741 | + </size> |
742 | + </property> |
743 | + <property name="frameShape"> |
744 | + <enum>QFrame::StyledPanel</enum> |
745 | + </property> |
746 | + <layout class="QHBoxLayout"> |
747 | + <property name="leftMargin"> |
748 | + <number>0</number> |
749 | + </property> |
750 | + <property name="topMargin"> |
751 | + <number>0</number> |
752 | + </property> |
753 | + <property name="rightMargin"> |
754 | + <number>4</number> |
755 | + </property> |
756 | + <property name="bottomMargin"> |
757 | + <number>0</number> |
758 | + </property> |
759 | + <item> |
760 | + <spacer> |
761 | + <property name="orientation"> |
762 | + <enum>Qt::Horizontal</enum> |
763 | + </property> |
764 | + <property name="sizeHint" stdset="0"> |
765 | + <size> |
766 | + <width>40</width> |
767 | + <height>20</height> |
768 | + </size> |
769 | + </property> |
770 | + </spacer> |
771 | + </item> |
772 | + <item> |
773 | + <widget class="QLabel" name="stelWindowTitle"> |
774 | + <property name="palette"> |
775 | + <palette> |
776 | + <active/> |
777 | + <inactive/> |
778 | + <disabled/> |
779 | + </palette> |
780 | + </property> |
781 | + <property name="font"> |
782 | + <font/> |
783 | + </property> |
784 | + <property name="text"> |
785 | + <string>Bookmarks</string> |
786 | + </property> |
787 | + </widget> |
788 | + </item> |
789 | + <item> |
790 | + <spacer> |
791 | + <property name="orientation"> |
792 | + <enum>Qt::Horizontal</enum> |
793 | + </property> |
794 | + <property name="sizeHint" stdset="0"> |
795 | + <size> |
796 | + <width>40</width> |
797 | + <height>20</height> |
798 | + </size> |
799 | + </property> |
800 | + </spacer> |
801 | + </item> |
802 | + <item> |
803 | + <widget class="QPushButton" name="closeStelWindow"> |
804 | + <property name="minimumSize"> |
805 | + <size> |
806 | + <width>16</width> |
807 | + <height>16</height> |
808 | + </size> |
809 | + </property> |
810 | + <property name="maximumSize"> |
811 | + <size> |
812 | + <width>16</width> |
813 | + <height>16</height> |
814 | + </size> |
815 | + </property> |
816 | + <property name="focusPolicy"> |
817 | + <enum>Qt::NoFocus</enum> |
818 | + </property> |
819 | + <property name="text"> |
820 | + <string/> |
821 | + </property> |
822 | + </widget> |
823 | + </item> |
824 | + </layout> |
825 | + </widget> |
826 | + </item> |
827 | + <item row="1" column="0"> |
828 | + <widget class="QWidget" name="widget" native="true"> |
829 | + <layout class="QGridLayout" name="gridLayout"> |
830 | + <item row="0" column="0"> |
831 | + <widget class="QTreeView" name="bookmarksTreeView"/> |
832 | + </item> |
833 | + <item row="1" column="0"> |
834 | + <widget class="QFrame" name="frame"> |
835 | + <property name="sizePolicy"> |
836 | + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
837 | + <horstretch>0</horstretch> |
838 | + <verstretch>0</verstretch> |
839 | + </sizepolicy> |
840 | + </property> |
841 | + <property name="frameShape"> |
842 | + <enum>QFrame::StyledPanel</enum> |
843 | + </property> |
844 | + <property name="frameShadow"> |
845 | + <enum>QFrame::Raised</enum> |
846 | + </property> |
847 | + <layout class="QVBoxLayout" name="verticalLayout_4"> |
848 | + <item> |
849 | + <layout class="QHBoxLayout" name="horizontalLayout_6"> |
850 | + <item> |
851 | + <widget class="QCheckBox" name="dateTimeCheckBox"> |
852 | + <property name="text"> |
853 | + <string>Add date and time</string> |
854 | + </property> |
855 | + </widget> |
856 | + </item> |
857 | + <item> |
858 | + <widget class="QCheckBox" name="locationCheckBox"> |
859 | + <property name="text"> |
860 | + <string>Add location</string> |
861 | + </property> |
862 | + </widget> |
863 | + </item> |
864 | + </layout> |
865 | + </item> |
866 | + <item> |
867 | + <layout class="QHBoxLayout" name="horizontalLayout_7"> |
868 | + <item> |
869 | + <widget class="QPushButton" name="addBookmarkButton"> |
870 | + <property name="text"> |
871 | + <string>&Add bookmark</string> |
872 | + </property> |
873 | + </widget> |
874 | + </item> |
875 | + <item> |
876 | + <widget class="QPushButton" name="removeBookmarkButton"> |
877 | + <property name="text"> |
878 | + <string>&Remove bookmark</string> |
879 | + </property> |
880 | + </widget> |
881 | + </item> |
882 | + <item> |
883 | + <widget class="QPushButton" name="clearBookmarksButton"> |
884 | + <property name="text"> |
885 | + <string>Clear bookmarks</string> |
886 | + </property> |
887 | + </widget> |
888 | + </item> |
889 | + <item> |
890 | + <widget class="QPushButton" name="goToButton"> |
891 | + <property name="text"> |
892 | + <string>&Go to...</string> |
893 | + </property> |
894 | + </widget> |
895 | + </item> |
896 | + </layout> |
897 | + </item> |
898 | + </layout> |
899 | + </widget> |
900 | + </item> |
901 | + </layout> |
902 | + </widget> |
903 | + </item> |
904 | + </layout> |
905 | + </widget> |
906 | + <customwidgets> |
907 | + <customwidget> |
908 | + <class>BarFrame</class> |
909 | + <extends>QFrame</extends> |
910 | + <header>Dialog.hpp</header> |
911 | + <container>1</container> |
912 | + </customwidget> |
913 | + </customwidgets> |
914 | + <resources/> |
915 | + <connections/> |
916 | +</ui> |
I removed all bookmarks from previous test, now I cannot create new ones. No hint in logfile what can be wrong?