standaloneBookmarkWnd.py (5581B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\bookmarks\standaloneBookmarkWnd.py 2 from carbon.common.script.util.format import FmtDate 3 from carbonui import uiconst 4 from carbonui.primitives.container import Container 5 from clientsettings.setting import CharSettingBool 6 from eve.client.script.ui.control.entries.util import GetFromClass 7 from eve.client.script.ui.control.eveScroll import Scroll 8 from carbonui.control.window import Window 9 from eve.client.script.ui.quickFilter import QuickFilterEdit 10 from eve.client.script.ui.shared.addressBookEntries import PlaceEntry 11 from eve.client.script.util.bookmarkUtil import IsBookmarkAvailable 12 import blue 13 from eveexceptions import ExceptionEater 14 from localization import GetByLabel 15 system_location_filter_visible = CharSettingBool('system_location_filter_visible', True) 16 17 class StandaloneBookmarkWnd(Window): 18 __notifyevents__ = ['OnRefreshBookmarks', 'OnSessionChanged'] 19 default_windowID = 'standaloneBookmarkWnd' 20 default_isCompact = True 21 default_scope = uiconst.SCOPE_INFLIGHT 22 default_minSize = (100, 100) 23 24 def ApplyAttributes(self, attributes): 25 Window.ApplyAttributes(self, attributes) 26 self.ConstructLayout() 27 self.LoadBookmarkScroll() 28 self.UpdateCaption() 29 sm.RegisterNotify(self) 30 system_location_filter_visible.on_change.connect(self.ChangeFilterVisibility) 31 32 def ConstructLayout(self): 33 self._textFilter = QuickFilterEdit(name='quickFilterEdit', parent=self.content, align=uiconst.TOTOP) 34 self._textFilter.ReloadFunction = self.LoadBookmarkScroll 35 self._textFilter.display = system_location_filter_visible.get() 36 self.scroll = Scroll(parent=self.content, id='StandaloneBookmarkWndScroll', pushContent=True) 37 38 def ChangeFilterVisibility(self, visible): 39 self._textFilter.display = visible 40 self.LoadBookmarkScroll() 41 42 def OnRefreshBookmarks(self): 43 self.LoadBookmarkScroll() 44 45 def OnSessionChanged(self, isRemote, session, change): 46 if session.solarsystemid2 and 'solarsystemid2' in change: 47 self.LoadBookmarkScroll() 48 self.UpdateCaption() 49 50 def UpdateCaption(self): 51 text = GetByLabel('UI/AclBookmarks/LocationsInSystem', system=cfg.evelocations.Get(session.solarsystemid2).name) 52 self.SetCaption(text) 53 54 def LoadBookmarkScroll(self): 55 if not session.solarsystemid2: 56 return 57 bookmarkSvc = sm.GetService('bookmarkSvc') 58 bookmarks = bookmarkSvc.GetBookmarksForLocationID(session.solarsystemid2) 59 now = blue.os.GetWallclockTime() 60 headers = [GetByLabel('UI/PeopleAndPlaces/Label'), GetByLabel('UI/AclBookmarks/FolderHeader'), GetByLabel('UI/AclBookmarks/Expiry')] 61 entries = [] 62 labelSortText = 'sort_%s' % GetByLabel('UI/PeopleAndPlaces/Label') 63 folderSortText = 'sort_%s' % GetByLabel('UI/AclBookmarks/FolderHeader') 64 expirySortText = 'sort_%s' % GetByLabel('UI/AclBookmarks/Expiry') 65 if self._textFilter.display: 66 filterText = self._textFilter.GetValue().strip().lower() 67 else: 68 filterText = '' 69 for bookmark in bookmarks: 70 if not bookmark: 71 continue 72 if bookmark.locationID != session.solarsystemid2: 73 continue 74 if not IsBookmarkAvailable(bookmark.creatorID, bookmark.created, now): 75 continue 76 hint, comment = bookmarkSvc.UnzipMemo(bookmark.memo) 77 if filterText and filterText not in hint.lower(): 78 continue 79 expiry = FmtDate(bookmark.expiry, 'ls') if bookmark.expiry else '-' 80 creatorID = getattr(bookmark, 'creatorID', None) 81 isBookmarkAvailable = IsBookmarkAvailable(creatorID, bookmark.created, now) 82 folderNames, isPersonal = bookmarkSvc.GetFolderNamesAndType(bookmark.folderID, bookmark.subfolderID) 83 folderText = ' / '.join(folderNames) 84 hintForBookmark = hint 85 if getattr(bookmark, 'note', None): 86 truncatedNote = bookmark.note[:50] + '...' if len(bookmark.note) > 50 else bookmark.note 87 hintForBookmark += '<br>- %s' % truncatedNote 88 entry = GetFromClass(PlaceEntry, {'bm': bookmark, 89 'itemID': bookmark.bookmarkID, 90 'tabs': [], 91 'hint': hintForBookmark, 92 'comment': comment, 93 'label': '<t>'.join((unicode(x) for x in (hint, folderText, expiry))), 94 'isGroupPersonal': isPersonal, 95 'isBookmarkAvailable': isBookmarkAvailable, 96 labelSortText: hint.lower(), 97 folderSortText: [ x.lower() for x in folderNames ], 98 expirySortText: expiry}) 99 entry.charIndex = None 100 entries.append(entry) 101 102 noContentHint = GetByLabel('UI/AclBookmarks/NoLocalSavedLocation') 103 self.scroll.Load(contentList=entries, headers=headers, noContentHint=noContentHint) 104 105 def GetMenuMoreOptions(self): 106 menuData = super(StandaloneBookmarkWnd, self).GetMenuMoreOptions() 107 menuData.AddCheckbox(text=GetByLabel('UI/AclBookmarks/ShowFilters'), setting=system_location_filter_visible) 108 return menuData 109 110 def Close(self, setClosed = False, *args, **kwds): 111 with ExceptionEater('Failure when closing StandaloneBookmarkWnd'): 112 system_location_filter_visible.on_change.disconnect(self.ChangeFilterVisibility) 113 super(StandaloneBookmarkWnd, self).Close(setClosed, *args, **kwds)