diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-02-05 15:35:35 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-02-05 22:43:05 +0100 |
commit | 29a66fe8cde3e18bf4d1c3d7a1f2077ea54548be (patch) | |
tree | efa032d617b6771bac09a5d5867634a0e605ab6e /vcl | |
parent | 2877657777926dbc66f4844cc94e37e74fd546cd (diff) |
weld WebConnectionInfoDialog
Change-Id: Idff8a0589075c8b7c774f187f5082fd954251d77
Reviewed-on: https://gerrit.libreoffice.org/67420
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 42 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 32 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 85 |
3 files changed, 136 insertions, 23 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 823c4bb2a666..f55c6fc3b43d 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1936,6 +1936,7 @@ private: DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool); DECL_LINK(ExpandingHdl, SvTreeListBox*, bool); DECL_LINK(EndDragHdl, HeaderBar*, void); + DECL_LINK(HeaderBarClickedHdl, HeaderBar*, void); DECL_LINK(ToggleHdl, SvLBoxButtonData*, void); public: SalInstanceTreeView(SvTabListBox* pTreeView, bool bTakeOwnership) @@ -1956,6 +1957,7 @@ public: //make the last entry fill available space pHeaderBar->SetItemSize(pHeaderBar->GetItemId(pHeaderBar->GetItemCount() - 1 ), HEADERBAR_FULLSIZE); pHeaderBar->SetEndDragHdl(LINK(this, SalInstanceTreeView, EndDragHdl)); + pHeaderBar->SetSelectHdl(LINK(this, SalInstanceTreeView, HeaderBarClickedHdl)); } m_aCheckButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl)); m_aRadioButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl)); @@ -2487,7 +2489,36 @@ public: virtual void make_sorted() override { m_xTreeView->SetStyle(m_xTreeView->GetStyle() | WB_SORT); - m_xTreeView->GetModel()->Resort(); + set_sort_order(true); + } + + virtual void set_sort_order(bool bAscending) override + { + SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get()); + if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr) + { + sal_uInt16 nTextId = pHeaderBar->GetItemId(0); + HeaderBarItemBits nBits = pHeaderBar->GetItemBits(nTextId); + if (nBits & HeaderBarItemBits::CLICKABLE) + { + nBits &= ~HeaderBarItemBits::UPARROW; + nBits &= ~HeaderBarItemBits::DOWNARROW; + if (bAscending) + nBits |= HeaderBarItemBits::DOWNARROW; + else + nBits |= HeaderBarItemBits::UPARROW; + pHeaderBar->SetItemBits(nTextId, nBits); + } + } + + SvTreeList* pListModel = m_xTreeView->GetModel(); + pListModel->SetSortMode(bAscending ? SortAscending : SortDescending); + pListModel->Resort(); + } + + virtual bool get_sort_order() const override + { + return m_xTreeView->GetModel()->GetSortMode() == SortAscending; } SvTabListBox& getTreeView() @@ -2500,6 +2531,7 @@ public: SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get()); if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr) { + pHeaderBar->SetSelectHdl(Link<HeaderBar*, void>()); pHeaderBar->SetEndDragHdl(Link<HeaderBar*, void>()); } m_xTreeView->SetExpandingHdl(Link<SvTreeListBox*, bool>()); @@ -2554,6 +2586,14 @@ IMPL_LINK(SalInstanceTreeView, EndDragHdl, HeaderBar*, pHeaderBar, void) m_xTreeView->SetTabs(aTabPositions.size(), aTabPositions.data(), MapUnit::MapPixel); } +IMPL_LINK(SalInstanceTreeView, HeaderBarClickedHdl, HeaderBar*, pHeaderBar, void) +{ + sal_uInt16 nId = pHeaderBar->GetCurItemId(); + if (!(pHeaderBar->GetItemBits(nId) & HeaderBarItemBits::CLICKABLE)) + return; + signal_column_clicked(pHeaderBar->GetItemPos(nId)); +} + IMPL_LINK_NOARG(SalInstanceTreeView, ExpandingHdl, SvTreeListBox*, bool) { SvTreeListEntry* pEntry = m_xTreeView->GetHdlEntry(); diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index fe406ed94b6f..c95ed2800193 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -1123,6 +1123,30 @@ namespace return bHeadersVisible; } + bool extractSortIndicator(VclBuilder::stringmap &rMap) + { + bool bSortIndicator = false; + VclBuilder::stringmap::iterator aFind = rMap.find(OString("sort-indicator")); + if (aFind != rMap.end()) + { + bSortIndicator = toBool(aFind->second); + rMap.erase(aFind); + } + return bSortIndicator; + } + + bool extractClickable(VclBuilder::stringmap &rMap) + { + bool bClickable = false; + VclBuilder::stringmap::iterator aFind = rMap.find(OString("clickable")); + if (aFind != rMap.end()) + { + bClickable = toBool(aFind->second); + rMap.erase(aFind); + } + return bClickable; + } + void setupFromActionName(Button *pButton, VclBuilder::stringmap &rMap, const css::uno::Reference<css::frame::XFrame>& rFrame) { if (!rFrame.is()) @@ -1950,8 +1974,11 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & SvHeaderTabListBox* pTreeView = dynamic_cast<SvHeaderTabListBox*>(pParent); if (HeaderBar* pHeaderBar = pTreeView ? pTreeView->GetHeaderBar() : nullptr) { - OUString sTitle(extractTitle(rMap)); - HeaderBarItemBits nBits = HeaderBarItemBits::LEFTIMAGE | HeaderBarItemBits::CLICKABLE; + HeaderBarItemBits nBits = HeaderBarItemBits::LEFTIMAGE; + if (extractClickable(rMap)) + nBits |= HeaderBarItemBits::CLICKABLE; + if (extractSortIndicator(rMap)) + nBits |= HeaderBarItemBits::DOWNARROW; float fAlign = extractAlignment(rMap); if (fAlign == 0.0) nBits |= HeaderBarItemBits::LEFT; @@ -1960,6 +1987,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & else if (fAlign == 0.5) nBits |= HeaderBarItemBits::CENTER; auto nItemId = pHeaderBar->GetItemCount() + 1; + OUString sTitle(extractTitle(rMap)); pHeaderBar->InsertItem(nItemId, sTitle, 100, nBits); } } diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index b64cb1933a73..ca35d447fbb1 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -4956,15 +4956,19 @@ private: GtkTreeView* m_pTreeView; GtkTreeStore* m_pTreeStore; std::unique_ptr<comphelper::string::NaturalStringSorter> m_xSorter; + GList *m_pColumns; + std::vector<gulong> m_aColumnSignalIds; // map from toggle column to toggle visibility column std::map<int, int> m_aToggleVisMap; gint m_nTextCol; + gint m_nTextColHeader; gint m_nImageCol; gint m_nExpanderImageCol; gint m_nIdCol; gulong m_nChangedSignalId; gulong m_nRowActivatedSignalId; gulong m_nTestExpandRowSignalId; + GtkSortType m_eSortType; DECL_LINK(async_signal_changed, void*, void); @@ -5142,30 +5146,57 @@ private: gtk_tree_path_free(tree_path); } + void signal_column_clicked(GtkTreeViewColumn* pClickedColumn) + { + int nIndex(0); + for (GList* pEntry = g_list_first(m_pColumns); pEntry; pEntry = g_list_next(pEntry)) + { + GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(pEntry->data); + if (pColumn == pClickedColumn) + { + TreeView::signal_column_clicked(nIndex); + break; + } + ++nIndex; + } + } + + static void signalColumnClicked(GtkTreeViewColumn* pColumn, gpointer widget) + { + GtkInstanceTreeView* pThis = static_cast<GtkInstanceTreeView*>(widget); + pThis->signal_column_clicked(pColumn); + } + public: GtkInstanceTreeView(GtkTreeView* pTreeView, bool bTakeOwnership) : GtkInstanceContainer(GTK_CONTAINER(pTreeView), bTakeOwnership) , m_pTreeView(pTreeView) , m_pTreeStore(GTK_TREE_STORE(gtk_tree_view_get_model(m_pTreeView))) , m_nTextCol(-1) + , m_nTextColHeader(-1) , m_nImageCol(-1) , m_nExpanderImageCol(-1) , m_nChangedSignalId(g_signal_connect(gtk_tree_view_get_selection(pTreeView), "changed", G_CALLBACK(signalChanged), this)) , m_nRowActivatedSignalId(g_signal_connect(pTreeView, "row-activated", G_CALLBACK(signalRowActivated), this)) , m_nTestExpandRowSignalId(g_signal_connect(pTreeView, "test-expand-row", G_CALLBACK(signalTestExpandRow), this)) + , m_eSortType(GTK_SORT_ASCENDING) { - GList *pColumns = gtk_tree_view_get_columns(m_pTreeView); - int nIndex(0); - for (GList* pEntry = g_list_first(pColumns); pEntry; pEntry = g_list_next(pEntry)) + m_pColumns = gtk_tree_view_get_columns(m_pTreeView); + int nIndex(0), nHeader(0); + for (GList* pEntry = g_list_first(m_pColumns); pEntry; pEntry = g_list_next(pEntry)) { GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(pEntry->data); + m_aColumnSignalIds.push_back(g_signal_connect(pColumn, "clicked", G_CALLBACK(signalColumnClicked), this)); GList *pRenderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(pColumn)); for (GList* pRenderer = g_list_first(pRenderers); pRenderer; pRenderer = g_list_next(pRenderer)) { GtkCellRenderer* pCellRenderer = GTK_CELL_RENDERER(pRenderer->data); if (m_nTextCol == -1 && GTK_IS_CELL_RENDERER_TEXT(pCellRenderer)) + { m_nTextCol = nIndex; + m_nTextColHeader = nHeader; + } else if (GTK_IS_CELL_RENDERER_TOGGLE(pCellRenderer)) { g_object_set_data(G_OBJECT(pCellRenderer), "g-lo-CellIndex", reinterpret_cast<gpointer>(nIndex)); @@ -5183,8 +5214,8 @@ public: ++nIndex; } g_list_free(pRenderers); + ++nHeader; } - g_list_free(pColumns); m_nIdCol = nIndex++; for (auto& a : m_aToggleVisMap) { @@ -5194,8 +5225,7 @@ public: virtual void set_column_fixed_widths(const std::vector<int>& rWidths) override { - GList *pColumns = gtk_tree_view_get_columns(m_pTreeView); - GList* pEntry = g_list_first(pColumns); + GList* pEntry = g_list_first(m_pColumns); for (auto nWidth : rWidths) { assert(pEntry && "wrong count"); @@ -5203,27 +5233,22 @@ public: gtk_tree_view_column_set_fixed_width(pColumn, nWidth); pEntry = g_list_next(pEntry); } - g_list_free(pColumns); } virtual OUString get_column_title(int nColumn) const override { - GList *pColumns = gtk_tree_view_get_columns(m_pTreeView); - GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(g_list_nth_data(pColumns, nColumn)); + GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(g_list_nth_data(m_pColumns, nColumn)); assert(pColumn && "wrong count"); const gchar* pTitle = gtk_tree_view_column_get_title(pColumn); OUString sRet = OUString(pTitle, pTitle ? strlen(pTitle) : 0, RTL_TEXTENCODING_UTF8); - g_list_free(pColumns); return sRet; } virtual void set_column_title(int nColumn, const OUString& rTitle) override { - GList *pColumns = gtk_tree_view_get_columns(m_pTreeView); - GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(g_list_nth_data(pColumns, nColumn)); + GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(g_list_nth_data(m_pColumns, nColumn)); assert(pColumn && "wrong count"); gtk_tree_view_column_set_title(pColumn, OUStringToOString(rTitle, RTL_TEXTENCODING_UTF8).getStr()); - g_list_free(pColumns); } virtual void insert(weld::TreeIter* pParent, int pos, const OUString* pText, const OUString* pId, const OUString* pIconName, @@ -5310,9 +5335,23 @@ public: m_xSorter.reset(new comphelper::string::NaturalStringSorter( ::comphelper::getProcessComponentContext(), Application::GetSettings().GetUILanguageTag().getLocale())); + set_sort_order(true); + } + + virtual void set_sort_order(bool bAscending) override + { + m_eSortType = bAscending ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING; GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(m_pTreeStore); - gtk_tree_sortable_set_sort_column_id(pSortable, m_nTextCol, GTK_SORT_ASCENDING); - gtk_tree_sortable_set_sort_func(pSortable, m_nTextCol, sort_func, m_xSorter.get(), nullptr); + gtk_tree_sortable_set_sort_column_id(pSortable, m_nTextCol, m_eSortType); + GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(g_list_nth_data(m_pColumns, m_nTextColHeader)); + assert(pColumn && "wrong count"); + if (gtk_tree_view_column_get_sort_indicator(pColumn)) + gtk_tree_view_column_set_sort_order(pColumn, m_eSortType); + } + + virtual bool get_sort_order() const override + { + return m_eSortType == GTK_SORT_ASCENDING; } virtual int n_children() const override @@ -5681,7 +5720,7 @@ public: if (m_xSorter) { GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(m_pTreeStore); - gtk_tree_sortable_set_sort_column_id(pSortable, GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, GTK_SORT_ASCENDING); + gtk_tree_sortable_set_sort_column_id(pSortable, GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, m_eSortType); } enable_notify_events(); } @@ -5692,7 +5731,7 @@ public: if (m_xSorter) { GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(m_pTreeStore); - gtk_tree_sortable_set_sort_column_id(pSortable, m_nTextCol, GTK_SORT_ASCENDING); + gtk_tree_sortable_set_sort_column_id(pSortable, m_nTextCol, m_eSortType); } gtk_tree_view_set_model(m_pTreeView, GTK_TREE_MODEL(m_pTreeStore)); GtkInstanceContainer::thaw(); @@ -5703,8 +5742,7 @@ public: virtual int get_height_rows(int nRows) const override { gint nMaxRowHeight = 0; - GList *pColumns = gtk_tree_view_get_columns(m_pTreeView); - for (GList* pEntry = g_list_first(pColumns); pEntry; pEntry = g_list_next(pEntry)) + for (GList* pEntry = g_list_first(m_pColumns); pEntry; pEntry = g_list_next(pEntry)) { GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(pEntry->data); GList *pRenderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(pColumn)); @@ -5714,7 +5752,6 @@ public: nMaxRowHeight = std::max(nMaxRowHeight, nRowHeight); g_list_free(pRenderers); } - g_list_free(pColumns); gint nVerticalSeparator; gtk_widget_style_get(GTK_WIDGET(m_pTreeView), "vertical-separator", &nVerticalSeparator, nullptr); @@ -5807,6 +5844,14 @@ public: g_signal_handler_disconnect(m_pTreeView, m_nTestExpandRowSignalId); g_signal_handler_disconnect(m_pTreeView, m_nRowActivatedSignalId); g_signal_handler_disconnect(gtk_tree_view_get_selection(m_pTreeView), m_nChangedSignalId); + + for (GList* pEntry = g_list_last(m_pColumns); pEntry; pEntry = g_list_previous(pEntry)) + { + GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(pEntry->data); + g_signal_handler_disconnect(pColumn, m_aColumnSignalIds.back()); + m_aColumnSignalIds.pop_back(); + } + g_list_free(m_pColumns); } }; |