workaround segfault in compiler on macos-clang-intel
[LibreOffice.git] / include / sfx2 / listview.hxx
blob72d4ae7e79f4b6c3d4d0897e9b9f0787d820a8df
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #pragma once
12 #include <vcl/weld.hxx>
14 enum TemplateViewMode
16 eListView,
17 eThumbnailView
19 class SfxDocumentTemplates;
20 class TemplateContainerItem;
21 struct ListViewItem;
23 class ListView
25 public:
26 ListView(std::unique_ptr<weld::TreeView> xTreeView);
27 ~ListView();
29 void AppendItem(const OUString& rId, const OUString& rTitle, const OUString& rSubtitle,
30 const OUString& rPath, bool bDefault);
32 void AppendRow(const OUString& rImage, const OUString& rTitle, const OUString& rSubtitle,
33 const OUString& rApplication, const OUString& rModify, const OUString& rSize,
34 const OUString& rId);
36 void UpdateRow(int nIndex, const OUString& rImage, const OUString& rTitle,
37 const OUString& rSubtitle, const OUString& rApplication, const OUString& rModify,
38 const OUString& rSize, const OUString& rId);
40 void ReloadRows();
42 bool UpdateRows();
44 void sortColumn(const int col);
46 void sort();
48 void clearListView();
50 void ShowListView() { mxTreeView->show(); }
52 void HideListView() { mxTreeView->hide(); }
54 void unselect_all() { mxTreeView->unselect_all(); }
56 void grab_focus() { mxTreeView->grab_focus(); }
58 void rename(const OUString& rId, const OUString& rTitle);
60 void refreshDefaultColumn();
62 protected:
63 sal_uInt16 get_nId(int pos) const;
65 void select_id(const OUString& sId) { mxTreeView->select_id(sId); }
67 int get_selected_index() const { return mxTreeView->get_selected_index(); }
69 std::vector<int> get_selected_rows() const { return mxTreeView->get_selected_rows(); }
71 bool IsListViewVisible() const { return mxTreeView->is_visible(); }
73 OUString get_id(int pos) const { return mxTreeView->get_id(pos); }
75 void set_cursor(int pos) { mxTreeView->set_cursor(pos); }
77 int get_cursor_index() const { return mxTreeView->get_cursor_index(); }
79 sal_uInt16 get_cursor_nId() const { return get_nId(mxTreeView->get_cursor_index()); }
81 void select(int pos) { mxTreeView->select(pos); }
83 int get_index(sal_uInt16 nId) const { return mxTreeView->find_id(OUString::number(nId)); }
85 DECL_LINK(ColumnClickedHdl, const int, void);
87 DECL_LINK(QueryTooltipHdl, const weld::TreeIter&, OUString);
89 protected:
90 std::unique_ptr<weld::TreeView> mxTreeView;
91 std::vector<std::unique_ptr<ListViewItem>> mListViewItems;
92 int mnSortColumn;
95 struct ListViewItem
97 public:
98 OUString maId;
99 OUString maTitle;
100 OUString maSubtitle;
101 OUString maApplication;
102 OUString maPath;
103 bool mbDefault;
105 /** Last modify time in seconds since 1/1/1970. */
106 sal_uInt32 mnModify;
107 /** Size in bytes of the file. */
108 sal_uInt64 mnSize;
110 OUString maDisplayModify;
111 OUString maDisplaySize;
112 OUString maDisplayPath;
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */