From 0c46afe65f677d072daefaaf92930ab4e219c732 Mon Sep 17 00:00:00 2001 From: msharov Date: Tue, 3 Oct 2006 18:37:08 +0000 Subject: [PATCH] Moved dependency class to tde --- elist.cc | 2 +- elist.h | 6 +++--- tddoc.cc | 6 +++--- tddoc.h | 36 +++++++++--------------------------- tde.h | 27 ++++++++++++++++++++++++++- 5 files changed, 42 insertions(+), 35 deletions(-) diff --git a/elist.cc b/elist.cc index 3beae6d..c22474e 100644 --- a/elist.cc +++ b/elist.cc @@ -39,7 +39,7 @@ CTodoList::CTodoList (void) } /// Sets the list to display. -void CTodoList::SetList (pctodolist_t pl) +void CTodoList::SetList (pctdevec_t pl) { SetCommandKeys (VectorBlock (c_CmdKeys)); m_pTodos = pl; diff --git a/elist.h b/elist.h index 6d6b364..8b344d1 100644 --- a/elist.h +++ b/elist.h @@ -9,10 +9,10 @@ /// List of todo entries. class CTodoList : public CListbox { public: - typedef const todolist_t* pctodolist_t; + typedef const tdevec_t* pctdevec_t; public: CTodoList (void); - void SetList (pctodolist_t pl); + void SetList (pctdevec_t pl); virtual void OnDrawItem (CGC& gc, rcpos_t pos, uint32_t ii); virtual void OnKey (wchar_t key); protected: @@ -28,7 +28,7 @@ private: inline pcdoc_t Document (void) const { return (TDocument()); } inline void EditEntry (void); private: - pctodolist_t m_pTodos; ///< Link to the data. + pctdevec_t m_pTodos; ///< Link to the data. itemid_t m_CopiedId; ///< Cut-n-paste link buffer. static const SCommandKey c_CmdKeys[]; }; diff --git a/tddoc.cc b/tddoc.cc index 412c0de..2ae97c3 100644 --- a/tddoc.cc +++ b/tddoc.cc @@ -73,7 +73,7 @@ inline CTodoDocument::iitem_t CTodoDocument::FindCurrentItem (void) /// This is the same as the list of items in m_List. inline CTodoDocument::deprange_t CTodoDocument::CurrentItemDeps (void) { - return (equal_range (m_Deps, CDependency(ItemId()))); + return (equal_range (m_Deps, CTodoDep(ItemId()))); } CTodoDocument::rcentry_t CTodoDocument::CurrentEntry (void) const @@ -180,7 +180,7 @@ void CTodoDocument::Save (void) /// Verifies and corrects any defects in the data. void CTodoDocument::VerifyData (void) { - foreach (depmap_t::iterator, i, m_Deps) { + foreach (tddepmap_t::iterator, i, m_Deps) { if (FindItem (i->m_ItemId) == m_Todos.end() || FindItem (i->m_DepId) == m_Todos.end()) { assert (!"Found a dependency pointing to a nonexistent item!"); --(i = m_Deps.erase (i)); @@ -388,7 +388,7 @@ void CTodoDocument::PasteLinkToEntry (itemid_t id) iitem_t i = FindItem (id); if (i == m_Todos.end()) throw runtime_error ("the pasted item no longer exists"); - m_Deps.insert (ir.second, CDependency (ItemId(), i->Id())); + m_Deps.insert (ir.second, CTodoDep (ItemId(), i->Id())); i->AddRef(); SetFlag (f_Changed); // Update the new item's status. diff --git a/tddoc.h b/tddoc.h index 18c29ef..86a39b1 100644 --- a/tddoc.h +++ b/tddoc.h @@ -33,25 +33,10 @@ enum { class CTodoDocument : public CDocument { public: typedef set todoset_t; - typedef const todolist_t& rctodolist_t; + typedef const tdevec_t& rctdevec_t; typedef const CTodoEntry& rcentry_t; typedef CTodoEntry::id_t itemid_t; typedef const string& rcfname_t; - /// Provides dependency links between todo items. - class DLL_LOCAL CDependency { - public: - typedef const CDependency& rcself_t; - public: - CDependency (itemid_t item = 0, itemid_t dep = 0) : m_ItemId (item), m_DepId (dep) { } - inline bool operator< (rcself_t v) const { return (m_ItemId < v.m_ItemId); } - inline bool operator== (rcself_t v) const { return (m_ItemId == v.m_ItemId); } - inline void read (istream& is) { is >> m_ItemId >> m_DepId; } - inline void write (ostream& os) const { os << m_ItemId << m_DepId; } - inline size_t stream_size (void) const { return (stream_size_of (m_ItemId) + stream_size_of (m_DepId)); } - public: - itemid_t m_ItemId; ///< Item id that has ... - itemid_t m_DepId; ///< ... this dependency. - }; enum { f_CompleteVisible = CDocument::f_Last, f_Last @@ -67,7 +52,7 @@ public: rcentry_t CurrentEntry (void) const; inline uint32_t Selection (void) const { return (m_Selection.back()); } inline size_t ListSize (void) const { return (m_List.size()); } - inline rctodolist_t List (void) const { return (m_List); } + inline rctdevec_t List (void) const { return (m_List); } inline void SetSelection (uoff_t v) { m_Selection.back() = v; UpdateAllViews(); } inline void ToggleCompleteVisible (void) { SetFlag (f_CompleteVisible, !Flag (f_CompleteVisible)); ReloadList(); } inline size_t NestingDepth (void) const { return (m_Stack.size() - 1); } @@ -82,12 +67,11 @@ protected: virtual void OnCommand (cmd_t c); virtual void OnUpdateCommandUI (rcmd_t rc) const; private: - typedef vector depmap_t; - typedef todolist_t::iterator iitem_t; - typedef todolist_t::const_iterator icitem_t; - typedef depmap_t::iterator idep_t; - typedef depmap_t::const_iterator icdep_t; - typedef pair deprange_t; + typedef tdevec_t::iterator iitem_t; + typedef tdevec_t::const_iterator icitem_t; + typedef tddepmap_t::iterator idep_t; + typedef tddepmap_t::const_iterator icdep_t; + typedef pair deprange_t; typedef vector itstack_t; typedef vector selstack_t; private: @@ -109,13 +93,11 @@ private: void ResortVisibleList (void); private: todoset_t m_Todos; ///< List of all entries. - todolist_t m_List; ///< Currently selected list. - depmap_t m_Deps; ///< List of dependencies between todos. + tdevec_t m_List; ///< Currently selected list. + tddepmap_t m_Deps; ///< List of dependencies between todos. itstack_t m_Stack; ///< The callstack of the currently active list. selstack_t m_Selection; ///< Index of the selected entry. }; -STD_STREAMABLE (CTodoDocument::CDependency) - #endif diff --git a/tde.h b/tde.h index d1255e5..d1d326e 100644 --- a/tde.h +++ b/tde.h @@ -6,6 +6,8 @@ #include +//---------------------------------------------------------------------- + /// ToDo list entry. class CTodoEntry { public: @@ -63,9 +65,32 @@ private: uint8_t m_Refs; ///< Number of dependent items. }; -typedef vector todolist_t; +//---------------------------------------------------------------------- + +/// Provides dependency links between todo items. +class CTodoDep { +public: + typedef CTodoEntry::id_t itemid_t; + typedef const CTodoDep& rcself_t; +public: + CTodoDep (itemid_t item = 0, itemid_t dep = 0) : m_ItemId (item), m_DepId (dep) { } + inline bool operator< (rcself_t v) const { return (m_ItemId < v.m_ItemId); } + inline bool operator== (rcself_t v) const { return (m_ItemId == v.m_ItemId); } + inline void read (istream& is) { is >> m_ItemId >> m_DepId; } + inline void write (ostream& os) const { os << m_ItemId << m_DepId; } + inline size_t stream_size (void) const { return (stream_size_of (m_ItemId) + stream_size_of (m_DepId)); } +public: + itemid_t m_ItemId; ///< Item id that has ... + itemid_t m_DepId; ///< ... this dependency. +}; + +//---------------------------------------------------------------------- + +typedef vector tdevec_t; +typedef vector tddepmap_t; STD_STREAMABLE (CTodoEntry) +STD_STREAMABLE (CTodoDep) #endif -- 2.11.4.GIT