summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVert D <devoptmsoi@gmx.com>2020-09-25 17:58:15 -0500
committerHeiko Tietze <heiko.tietze@documentfoundation.org>2020-11-23 11:29:04 +0100
commit6b1de6057082bd8720594231839f967bff5372ae (patch)
tree57ae7c1982f3b270e3a42dec0bff909f6e250410 /include
parent3c4b09a250605c9d73e48df83a6ee36a8bc2fb8b (diff)
tdf#104154 WIP:Add list view to template manager
*Added Thumbnail View and List View Buttons, *selection is remembered for the next launch of the template manager. *List view added to local view and search view. *Added columns: name, category, application, modified, size and path. *Added column sorting. *Search, move, set as default and other existing tasks. Change-Id: I7615f7e41020916ae518b639dba915a0a9340ff5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103418 Tested-by: Jenkins Tested-by: Heiko Tietze <heiko.tietze@documentfoundation.org> Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/sfx2/listview.hxx118
-rw-r--r--include/sfx2/strings.hrc5
-rw-r--r--include/sfx2/templatedlg.hxx17
-rw-r--r--include/sfx2/templatedlglocalview.hxx62
4 files changed, 199 insertions, 3 deletions
diff --git a/include/sfx2/listview.hxx b/include/sfx2/listview.hxx
new file mode 100644
index 000000000000..0c5714caca33
--- /dev/null
+++ b/include/sfx2/listview.hxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <vcl/weld.hxx>
+
+enum TemplateViewMode
+{
+ eListView,
+ eThumbnailView
+};
+class SfxDocumentTemplates;
+class TemplateContainerItem;
+struct ListViewItem;
+
+class ListView
+{
+public:
+ ListView(std::unique_ptr<weld::TreeView> xTreeView);
+ ~ListView();
+
+ void AppendItem(const OUString& rId, const OUString& rTitle, const OUString& rSubtitle,
+ const OUString& rPath, bool bDefault);
+
+ void AppendRow(const OUString& rImage, const OUString& rTitle, const OUString& rSubtitle,
+ const OUString& rApplication, const OUString& rModify, const OUString& rSize,
+ const OUString& rId);
+
+ void UpdateRow(int nIndex, const OUString& rImage, const OUString& rTitle,
+ const OUString& rSubtitle, const OUString& rApplication, const OUString& rModify,
+ const OUString& rSize, const OUString& rId);
+
+ void ReloadRows();
+
+ bool UpdateRows();
+
+ void sortColumn(const int col);
+
+ void sort();
+
+ void clearListView();
+
+ void ShowListView() { mxTreeView->show(); }
+
+ void HideListView() { mxTreeView->hide(); }
+
+ void unselect_all() { mxTreeView->unselect_all(); }
+
+ void remove(const OUString& rId);
+
+ void rename(const OUString& rId, const OUString& rTitle);
+
+ void refreshDefaultColumn();
+
+protected:
+ sal_uInt16 get_nId(int pos);
+
+ OUString get_selected_id() { return mxTreeView->get_selected_id(); }
+
+ void select_id(const OUString& sId) { mxTreeView->select_id(sId); }
+
+ int get_selected_index() { return mxTreeView->get_selected_index(); }
+
+ std::vector<int> get_selected_rows() { return mxTreeView->get_selected_rows(); }
+
+ bool IsListViewVisible() { return mxTreeView->is_visible(); }
+
+ OUString get_id(int pos) { return mxTreeView->get_id(pos); }
+
+ void set_cursor(int pos) { mxTreeView->set_cursor(pos); }
+
+ int get_cursor_index() { return mxTreeView->get_cursor_index(); }
+
+ sal_uInt16 get_cursor_nId() { return get_nId(mxTreeView->get_cursor_index()); }
+
+ void select(int pos) { mxTreeView->select(pos); }
+
+ int get_index(sal_uInt16 nId) { return mxTreeView->find_id(OUString::number(nId)); }
+
+ DECL_LINK(ColumnClickedHdl, const int, void);
+
+ DECL_LINK(QueryTooltipHdl, const weld::TreeIter&, OUString);
+
+protected:
+ std::unique_ptr<weld::TreeView> mxTreeView;
+ std::vector<std::unique_ptr<ListViewItem>> mListViewItems;
+ Link<weld::TreeView&, void> maSelectionChangedHdl;
+ int mnSortColumn;
+};
+
+struct ListViewItem
+{
+public:
+ OUString maId;
+ OUString maTitle;
+ OUString maSubtitle;
+ OUString maApplication;
+ OUString maPath;
+ bool mbDefault;
+
+ /** Last modify time in seconds since 1/1/1970. */
+ sal_uInt32 mnModify;
+ /** Size in bytes of the file. */
+ sal_uInt64 mnSize;
+
+ OUString maDisplayModify;
+ OUString maDisplaySize;
+ OUString maDisplayPath;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc
index cb627807d8c8..9927afe17e93 100644
--- a/include/sfx2/strings.hrc
+++ b/include/sfx2/strings.hrc
@@ -343,6 +343,11 @@
#define STR_CLICKHYPERLINK NC_("STR_CLICKHYPERLINK", "Click to open hyperlink: %{link}")
#define STR_STYLEUSEDBY NC_("STR_STYLEUSEDBY", "(used by: %STYLELIST)")
+
+#define STR_DOCUMENT NC_("STR_DOCUMENT", "Document")
+#define STR_SPREADSHEET NC_("STR_SPREADSHEET", "Spreadsheet")
+#define STR_PRESENTATION NC_("STR_PRESENTATION", "Presentation")
+#define STR_DRAWING NC_("STR_DRAWING", "Drawing")
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/templatedlg.hxx b/include/sfx2/templatedlg.hxx
index 76d7d98eced5..e9cf26d2cb8a 100644
--- a/include/sfx2/templatedlg.hxx
+++ b/include/sfx2/templatedlg.hxx
@@ -19,7 +19,7 @@
#include <vcl/timer.hxx>
#include <vcl/weld.hxx>
-#include <sfx2/templatelocalview.hxx>
+#include <sfx2/templatedlglocalview.hxx>
class TemplateSearchView;
class ThumbnailViewItem;
@@ -44,6 +44,8 @@ public:
virtual short run() override;
void setDocumentModel(const css::uno::Reference<css::frame::XModel>& rModel);
+ void setTemplateViewMode(TemplateViewMode eViewMode);
+ TemplateViewMode getTemplateViewMode();
protected:
void getApplicationSpecificSettings();
@@ -83,6 +85,11 @@ protected:
DECL_LINK(ImplUpdateDataHdl, Timer*, void);
DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
+ DECL_LINK(ListViewHdl, weld::Button&, void);
+ DECL_LINK(ThumbnailViewHdl, weld::Button&, void);
+ DECL_LINK(FocusRectLocalHdl, weld::Widget&, tools::Rectangle);
+ DECL_LINK(FocusRectSearchHdl, weld::Widget&, tools::Rectangle);
+
void OnTemplateImportCategory(const OUString& sCategory);
// static void OnTemplateLink ();
void OnTemplateOpen();
@@ -134,10 +141,14 @@ protected:
std::unique_ptr<weld::CheckButton> mxCBXHideDlg;
std::unique_ptr<weld::MenuButton> mxActionBar;
std::unique_ptr<TemplateSearchView> mxSearchView;
- std::unique_ptr<TemplateLocalView> mxLocalView;
+ std::unique_ptr<TemplateDlgLocalView> mxLocalView;
std::unique_ptr<weld::Menu> mxTemplateDefaultMenu;
std::unique_ptr<weld::CustomWeld> mxSearchViewWeld;
std::unique_ptr<weld::CustomWeld> mxLocalViewWeld;
+ std::unique_ptr<weld::ToggleButton> mxListViewButton;
+ std::unique_ptr<weld::ToggleButton> mxThumbnailViewButton;
+ TemplateViewMode mViewMode;
+ bool bMakeSelItemVisible;
};
// class SfxTemplateCategoryDialog -------------------------------------------------------------------
@@ -198,4 +209,4 @@ private:
#endif // INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/include/sfx2/templatedlglocalview.hxx b/include/sfx2/templatedlglocalview.hxx
new file mode 100644
index 000000000000..a8fc57e254c3
--- /dev/null
+++ b/include/sfx2/templatedlglocalview.hxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#pragma once
+
+#include <sfx2/templatelocalview.hxx>
+#include <sfx2/listview.hxx>
+
+class TemplateDlgLocalView final : public TemplateLocalView, public ListView
+{
+public:
+ TemplateDlgLocalView(std::unique_ptr<weld::ScrolledWindow> xWindow,
+ std::unique_ptr<weld::Menu> xMenu,
+ std::unique_ptr<weld::TreeView> xTreeView);
+
+ void setTemplateViewMode(TemplateViewMode eMode);
+
+ virtual void showAllTemplates() override;
+
+ void showRegion(TemplateContainerItem const* pItem);
+
+ void showRegion(const OUString& rName);
+
+ void createContextMenu(const bool bIsDefault);
+
+ virtual void Show() override;
+
+ virtual void Hide() override;
+
+ bool IsVisible();
+
+ void connect_focus_rect(const Link<weld::Widget&, tools::Rectangle>& rLink)
+ {
+ GetDrawingArea()->connect_focus_rect(rLink);
+ }
+
+ void MakeItemVisible(sal_uInt16 nId) { ThumbnailView::MakeItemVisible(nId); }
+
+private:
+ void ContextMenuSelectHdl(const OString& rIdent);
+
+ void insertFilteredItems();
+
+ void syncCursor();
+
+ void updateSelection();
+
+ DECL_LINK(RowActivatedHdl, weld::TreeView&, bool);
+
+ DECL_LINK(ListViewChangedHdl, weld::TreeView&, void);
+
+ DECL_LINK(PopupMenuHdl, const CommandEvent&, bool);
+
+ TemplateViewMode mViewMode;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */