2 * @file DirViewColItems.h
4 * @brief Declaration file for DirColInfo
6 * @date Created: 2003-08-19
10 #include "UnicodeString.h"
17 // DirViewColItems typedefs
18 typedef String (*ColGetFncPtrType)(const CDiffContext *, const void *, int);
19 typedef int (*ColSortFncPtrType)(const CDiffContext *, const void *, const void *, int);
23 * @brief Information about one column of dirview list info
29 ALIGN_LEFT = 0, // LVCFMT_LEFT
30 ALIGN_RIGHT = 1, // LVCFMT_RIGHT
31 ALIGN_CENTER = 2 // LVCFMT_CENTER
33 const TCHAR *regName; /**< Internal name used for registry entries etc */
34 // localized string resources
35 const char *idNameContext;
36 const char *idName; /**< Displayed name, ID of string resource */
37 const char *idDesc; /**< Description, ID of string resource */
38 ColGetFncPtrType getfnc; /**< Handler giving display string */
39 ColSortFncPtrType sortfnc; /**< Handler for sorting this column */
40 size_t offset; /**< Offset into DIFFITEM::diffFileInfo[] */
41 int physicalIndex; /**< Current physical index, -1 if not displayed */
42 bool defSortUp; /**< Does column start with ascending sort (most do) */
43 int alignment; /**< Column alignment */
45 String GetDisplayName() const;
46 String GetDescription() const;
49 extern const int g_ncols;
50 extern const int g_ncols3;
55 explicit DirViewColItems(int nDirs, const std::vector<String>& additionalPropertyNames);
56 String GetColRegValueNameBase(int col) const;
57 int GetColDefaultOrder(int col) const;
58 const DirColInfo * GetDirColInfo(int col) const;
59 bool IsColById(int col, const char *idname) const;
60 bool IsColName(int col) const;
61 bool IsColLmTime(int col) const;
62 bool IsColMmTime(int col) const;
63 bool IsColRmTime(int col) const;
64 bool IsColStatus(int col) const;
65 bool IsColStatusAbbr(int col) const;
66 bool IsDefaultSortAscending(int col) const;
67 String GetColDisplayName(int col) const;
68 String GetColDescription(int col) const;
69 int GetColCount() const { return m_numcols; };
70 int GetDispColCount() const { return m_dispcols; }
71 String ColGetTextToDisplay(const CDiffContext *pCtxt, int col, const DIFFITEM &di) const;
72 int ColSort(const CDiffContext *pCtxt, int col, const DIFFITEM &ldi, const DIFFITEM &rdi, bool bTreeMode) const;
74 int ColPhysToLog(int i) const { return m_invcolorder[i]; }
75 int ColLogToPhys(int i) const { return m_colorder[i]; } /**< -1 if not displayed */
76 void ClearColumnOrders();
77 void MoveColumn(int psrc, int pdest);
78 void ResetColumnOrdering();
79 void SetColumnOrdering(const int colorder[]);
80 String ResetColumnWidths(int defcolwidth);
81 void LoadColumnOrders(const String& colOrders);
82 String SaveColumnOrders();
83 const std::vector<String>& GetAdditionalPropertyNames() const { return m_additionalPropertyNames; }
84 void SetAdditionalPropertyNames(const std::vector<String>& propertyNames);
86 /// Update all column widths (from registry to screen)
87 // Necessary when user reorders columns
88 template<class SetColumnWidthFunc>
89 void LoadColumnWidths(String colwidths, SetColumnWidthFunc setcolwidth, int defcolwidth)
91 std::basic_istringstream<TCHAR> ss(colwidths);
92 for (int i = 0; i < m_numcols; ++i)
94 int phy = ColLogToPhys(i);
99 setcolwidth(phy, max(w, 10));
104 /** @brief store current column widths into registry */
105 template<class GetColumnWidthFunc>
106 String SaveColumnWidths(GetColumnWidthFunc getcolwidth)
109 for (int i = 0; i < m_numcols; i++)
111 int phy = ColLogToPhys(i);
114 if (!result.empty()) result += ' ';
115 result += strutils::to_str(getcolwidth(phy));
123 void AddAdditionalPropertyName(const String& propertyName);
124 void RemoveAdditionalPropertyName(const String& propertyName);
129 std::vector<int> m_colorder; /**< colorder[logical#]=physical# */
130 std::vector<int> m_invcolorder; /**< invcolorder[physical]=logical# */
131 std::vector<DirColInfo> m_cols;
132 std::vector<String> m_additionalPropertyNames;
133 std::list<String> m_strpool;