From a00500d35bcc66c502aa57e50ba8117b8569d03d Mon Sep 17 00:00:00 2001 From: Udo Eberhardt Date: Sun, 17 Mar 2019 18:21:18 +0100 Subject: [PATCH] Make current columns settings (for each view) persistent in the .dbconf file. --- DebugView++/LogView.cpp | 51 +++++++++++++++++++++++++++++++++++++++ DebugView++/LogView.h | 5 ++++ DebugView++/MainFrame.cpp | 5 ++++ 3 files changed, 61 insertions(+) diff --git a/DebugView++/LogView.cpp b/DebugView++/LogView.cpp index fe6b0fb7..707b4e49 100644 --- a/DebugView++/LogView.cpp +++ b/DebugView++/LogView.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "CobaltFusion/AtlWinExt.h" #include "CobaltFusion/stringbuilder.h" #include "CobaltFusion/dbgstream.h" @@ -1338,6 +1339,11 @@ void CLogView::SetAutoScrollStop(bool enable) m_autoScrollStop = enable; } +const std::vector& CLogView::GetColumns() const +{ + return m_columns; +} + void CLogView::Clear() { m_firstLine = m_logFile.Count(); @@ -1691,6 +1697,51 @@ bool CLogView::FindPrevious(std::wstring_view text) return Find(text, -1); } +boost::property_tree::ptree MakePTree(const std::vector& columns) +{ + boost::property_tree::ptree pt; + for (int i = 0; i < Column::Count; ++i) + { + const ColumnInfo& col = columns[i]; + boost::property_tree::ptree colPt; + colPt.put("Index", i); + colPt.put("Enable", col.enable); + colPt.put("Width", col.column.cx); + colPt.put("Order", col.column.iOrder); + pt.add_child("Column", colPt); + } + return pt; +} + +void CLogView::ReadColumns(const boost::property_tree::ptree& pt) +{ + for (auto& item : pt) + { + if (item.first == "Column") + { + const auto& colPt = item.second; + auto index = colPt.get_optional("Index"); + if (index && *index < m_columns.size()) + { + ColumnInfo& col = m_columns[*index]; + + auto enable = colPt.get_optional("Enable"); + if (enable) + col.enable = *enable; + + auto width = colPt.get_optional("Width"); + if (width) + col.column.cx = *width; + + auto order = colPt.get_optional("Order"); + if (order) + col.column.iOrder = *order; + } + } + } + UpdateColumns(); +} + void CLogView::LoadSettings(CRegKey& reg) { SetName(Win32::RegGetStringValue(reg)); diff --git a/DebugView++/LogView.h b/DebugView++/LogView.h index 044bf8b8..b5ef1a50 100644 --- a/DebugView++/LogView.h +++ b/DebugView++/LogView.h @@ -9,6 +9,7 @@ #include #include +#include #include "Win32/Window.h" #include "Win32/Win32Lib.h" #include "CobaltFusion/AtlWinExt.h" @@ -89,6 +90,8 @@ struct ColumnInfo LVCOLUMN column; }; +boost::property_tree::ptree MakePTree(const std::vector& columns); + class CMyHeaderCtrl : public CWindowImpl { public: @@ -156,6 +159,8 @@ class CLogView : public CDoubleBufferWindowImpl& GetColumns() const; + void ReadColumns(const boost::property_tree::ptree& pt); void Clear(); int GetFocusLine() const; void SetFocusLine(int line); diff --git a/DebugView++/MainFrame.cpp b/DebugView++/MainFrame.cpp index 54a8619b..ecbb87b0 100644 --- a/DebugView++/MainFrame.cpp +++ b/DebugView++/MainFrame.cpp @@ -883,6 +883,7 @@ struct View bool clockTime; bool processColors; LogFilter filters; + boost::optional columnsPt; }; struct SourceInfoHelper @@ -919,6 +920,7 @@ void CMainFrame::LoadConfiguration(const std::wstring& fileName) view.processColors = viewPt.get("ProcessColors"); view.filters.messageFilters = MakeFilters(viewPt.get_child("MessageFilters")); view.filters.processFilters = MakeFilters(viewPt.get_child("ProcessFilters")); + view.columnsPt = viewPt.get_child_optional("Columns"); views.push_back(view); } } @@ -937,6 +939,8 @@ void CMainFrame::LoadConfiguration(const std::wstring& fileName) auto& logView = GetView(i); logView.SetClockTime(views[i].clockTime); logView.SetViewProcessColors(views[i].processColors); + if (views[i].columnsPt) + logView.ReadColumns(*(views[i].columnsPt)); } int i = GetViewCount(); @@ -1005,6 +1009,7 @@ void CMainFrame::SaveConfiguration(const std::wstring& fileName) viewPt.put("ProcessColors", logView.GetViewProcessColors()); viewPt.put_child("MessageFilters", MakePTree(filters.messageFilters)); viewPt.put_child("ProcessFilters", MakePTree(filters.processFilters)); + viewPt.put_child("Columns", MakePTree(logView.GetColumns())); mainPt.add_child("Views.View", viewPt); }