hbfloaterteleporthistory.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /**
  2. * @file hbfloaterteleporthistory.h
  3. * @author Henri Beauchamp
  4. * @brief HBFloaterTeleportHistory class definition
  5. *
  6. * $LicenseInfo:firstyear=2018&license=viewergpl$
  7. *
  8. * Copyright (c) 2018, Henri Beauchamp
  9. *
  10. * Second Life Viewer Source Code
  11. * The source code in this file ("Source Code") is provided by Linden Lab
  12. * to you under the terms of the GNU General Public License, version 2.0
  13. * ("GPL"), unless you have obtained a separate licensing agreement
  14. * ("Other License"), formally executed by you and Linden Lab. Terms of
  15. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17. *
  18. * There are special exceptions to the terms and conditions of the GPL as
  19. * it is applied to this Source Code. View the full text of the exception
  20. * in the file doc/FLOSS-exception.txt in this software distribution, or
  21. * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_HBFLOATERTELEPORTHISTORY_H
  33. #define LL_HBFLOATERTELEPORTHISTORY_H
  34. #include "linden_common.h"
  35. #include "boost/signals2.hpp"
  36. #include "llfloater.h"
  37. class LLButton;
  38. class LLFlyoutButton;
  39. class LLScrollListCtrl;
  40. class LLScrollListItem;
  41. class LLSearchEditor;
  42. class LLTabContainer;
  43. class HBFloaterTeleportHistory final : public LLFloater
  44. {
  45. protected:
  46. LOG_CLASS(HBFloaterTeleportHistory);
  47. public:
  48. HBFloaterTeleportHistory();
  49. ~HBFloaterTeleportHistory() override;
  50. // Toggles the floater on and off (i.e. shown and hidden)
  51. void toggle();
  52. // Loads the saved teleport history
  53. void loadEntries();
  54. // Adds the pending teleport destination
  55. void addPendingEntry(const std::string& region_name, LLVector3 pos);
  56. // Adds a source teleport SLURL to the visited places.
  57. void addSourceEntry(const std::string& source_slurl,
  58. const std::string& parcel_name);
  59. private:
  60. // Reimplemented to check for selection changes in the TP history list
  61. // scrolllist
  62. void onFocusReceived() override;
  63. // Reimplemented to allow initial resize
  64. void onOpen() override;
  65. // Reimplemented to make the menu toggle work
  66. void onClose(bool app_quitting) override;
  67. // Reimplemented to prevent this floater from closing while the viewer is
  68. // shutting down
  69. bool canClose() override;
  70. bool postBuild() override;
  71. void draw() override;
  72. enum HISTORY_COLUMN_ORDER
  73. {
  74. LIST_TYPE,
  75. LIST_PARCEL,
  76. LIST_REGION,
  77. LIST_POSITION,
  78. LIST_TIMESTAMP
  79. };
  80. enum FAVORITES_COLUMN_ORDER
  81. {
  82. FAV_PARCEL,
  83. FAV_REGION,
  84. FAV_POSITION,
  85. FAV_VISITS
  86. };
  87. enum RESULTS_COLUMN_ORDER
  88. {
  89. RES_PARCEL,
  90. RES_REGION,
  91. RES_POSITION,
  92. RES_TIMESTAMP
  93. };
  94. // Returns the history file name. If fallback is 'true' (useful for reads),
  95. // also use the old history file name if the new one does not correspond to
  96. // and existing file.
  97. std::string getHistoryFileName(bool fallback = false) const;
  98. void addPlacesListComment();
  99. void removePlacesListComment();
  100. void populateLists(const LLSD& file_data);
  101. void updateSearchResults();
  102. void saveList();
  103. // Adds the destination to the list of visited places
  104. void addEntry(std::string parcel_name, bool departure = false);
  105. // Enables/disables or shows/hides the buttons depending on selected tab
  106. // and selected list entry.
  107. void setButtonsStatus();
  108. bool getSelectedLocation(std::string& region, LLVector3& pos);
  109. // Teleport callbacks
  110. static void onTeleportArriving();
  111. static void onTeleportFinished(const LLVector3d& pos, bool local);
  112. static void onTeleportFailed();
  113. // UI callbacks
  114. static void onTabChanged(void* data, bool);
  115. static void onPlacesSelected(LLUICtrl* ctrl, void* data);
  116. static void onTeleport(void* data);
  117. static void onShowOnMap(void* data);
  118. static void onCopySLURL(void* data);
  119. static void onRefresh(void* data);
  120. static void onButtonClose(void* data);
  121. static void onRemove(LLUICtrl* ctrl, void* data);
  122. static void onSearchEdit(const std::string& search_string, void* data);
  123. private:
  124. LLTabContainer* mTabContainer;
  125. LLScrollListCtrl* mPlacesList;
  126. LLScrollListCtrl* mFavoritesList;
  127. LLScrollListCtrl* mResultsList;
  128. LLScrollListItem* mPlacesListComment;
  129. LLSearchEditor* mSearchEditor;
  130. LLButton* mTeleportBtn;
  131. LLButton* mShowOnMapBtn;
  132. LLButton* mCopySLURLBtn;
  133. LLButton* mRefreshBtn;
  134. LLFlyoutButton* mRemoveFlyoutBtn;
  135. S32 mCount;
  136. std::string mNumEntriesStr;
  137. std::string mNoEntryStr;
  138. std::string mPendingRegionName;
  139. std::string mPendingPosition;
  140. std::string mPendingTimeString;
  141. std::string mSearchString;
  142. LLSD mTPlist;
  143. boost::signals2::connection mTeleportArrivingConnection;
  144. boost::signals2::connection mTeleportFinishConnection;
  145. boost::signals2::connection mTeleportFailedConnection;
  146. bool mFirstOpen;
  147. bool mCanTeleport;
  148. };
  149. // Global
  150. extern HBFloaterTeleportHistory* gFloaterTeleportHistoryp;
  151. #endif