summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-11-25 20:18:11 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-11-26 11:31:37 +0100
commitb1baf73dc671069bedec18d170f8199b0766ea60 (patch)
tree6e2007f68dbd6e12b4ba55b5b02c7b04b083c9c6
parentaaad3500b3d558836a776b162184cb0556850940 (diff)
weld SfxCmisVersionsDialog
Change-Id: I73fc8ba88021f3d1450d10a75970e1fd58f26c3f Reviewed-on: https://gerrit.libreoffice.org/64002 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sfx2/source/dialog/versdlg.cxx204
-rw-r--r--sfx2/source/inc/versdlg.hxx36
-rw-r--r--sfx2/uiconfig/ui/versionscmis.ui168
3 files changed, 153 insertions, 255 deletions
diff --git a/sfx2/source/dialog/versdlg.cxx b/sfx2/source/dialog/versdlg.cxx
index 7ceb3b7be93f..13724cf6a54c 100644
--- a/sfx2/source/dialog/versdlg.cxx
+++ b/sfx2/source/dialog/versdlg.cxx
@@ -111,105 +111,42 @@ SfxVersionInfo::SfxVersionInfo()
{
}
-void SfxVersionsTabListBox_Impl::KeyInput(const KeyEvent& rKeyEvent)
+namespace
{
- const vcl::KeyCode& rCode = rKeyEvent.GetKeyCode();
- switch (rCode.GetCode())
+ void setColSizes(weld::TreeView& rVersionBox)
{
- case KEY_RETURN :
- case KEY_ESCAPE :
- case KEY_TAB :
- {
- Dialog *pParent = GetParentDialog();
- if (pParent)
- pParent->KeyInput(rKeyEvent);
- else
- SvSimpleTable::KeyInput(rKeyEvent);
- break;
- }
- default:
- SvSimpleTable::KeyInput( rKeyEvent );
- break;
- }
-}
-
-void SfxVersionsTabListBox_Impl::setColSizes()
-{
- HeaderBar &rBar = GetTheHeaderBar();
- if (rBar.GetItemCount() < 3)
- return;
-
- // recalculate the datetime column width
- long nWidestTime(GetTextWidth(getWidestTime(Application::GetSettings().GetLocaleDataWrapper())));
- long nW1 = rBar.GetTextWidth(rBar.GetItemText(1));
+ // recalculate the datetime column width
+ int nWidestTime(rVersionBox.get_pixel_size(getWidestTime(Application::GetSettings().GetLocaleDataWrapper())).Width());
+ int nW1 = rVersionBox.get_pixel_size(rVersionBox.get_column_title(1)).Width();
- long nMax = std::max(nWidestTime, nW1) + 12; // max width + a little offset
- const long nRest = GetSizePixel().Width() - nMax;
+ int nMax = std::max(nWidestTime, nW1) + 12; // max width + a little offset
+ const int nRest = rVersionBox.get_preferred_size().Width() - nMax;
- std::set<OUString> aAuthors;
- SfxVersionInfo aInfo;
- aAuthors.insert(SvtUserOptions().GetFullName());
-
- for (SvTreeListEntry* pEntry = First(); pEntry; pEntry = Next(pEntry))
- {
- aAuthors.insert(static_cast<SfxVersionInfo*>(pEntry->GetUserData())->aAuthor);
- }
+ std::set<OUString> aAuthors;
+ SfxVersionInfo aInfo;
+ aAuthors.insert(SvtUserOptions().GetFullName());
- long nMaxAuthorWidth = nRest/4;
- for (auto const& author : aAuthors)
- {
- nMaxAuthorWidth = std::max(nMaxAuthorWidth, GetTextWidth(author));
- if (nMaxAuthorWidth > nRest/2)
+ for (int i = 0; i < rVersionBox.n_children(); ++i)
{
- nMaxAuthorWidth = nRest/2;
- break;
+ aAuthors.insert(reinterpret_cast<SfxVersionInfo*>(rVersionBox.get_id(i).toInt64())->aAuthor);
}
- }
- long aTabPositions[] = { 0, nMax, nMax + nMaxAuthorWidth };
- SvSimpleTable::SetTabs(SAL_N_ELEMENTS(aTabPositions), aTabPositions, MapUnit::MapPixel);
-}
-
-void SfxVersionsTabListBox_Impl::Resize()
-{
- SvSimpleTable::Resize();
- if (isInitialLayout(this))
- setColSizes();
-}
-
-void SfxVersionDialog::setColSizes()
-{
- // recalculate the datetime column width
- int nWidestTime(m_xVersionBox->get_pixel_size(getWidestTime(Application::GetSettings().GetLocaleDataWrapper())).Width());
- int nW1 = m_xVersionBox->get_pixel_size(m_xVersionBox->get_column_title(1)).Width();
-
- int nMax = std::max(nWidestTime, nW1) + 12; // max width + a little offset
- const int nRest = m_xVersionBox->get_preferred_size().Width() - nMax;
-
- std::set<OUString> aAuthors;
- SfxVersionInfo aInfo;
- aAuthors.insert(SvtUserOptions().GetFullName());
-
- for (int i = 0; i < m_xVersionBox->n_children(); ++i)
- {
- aAuthors.insert(reinterpret_cast<SfxVersionInfo*>(m_xVersionBox->get_id(i).toInt64())->aAuthor);
- }
-
- int nMaxAuthorWidth = nRest/4;
- for (auto const& author : aAuthors)
- {
- nMaxAuthorWidth = std::max<int>(nMaxAuthorWidth, m_xVersionBox->get_pixel_size(author).Width());
- if (nMaxAuthorWidth > nRest/2)
+ int nMaxAuthorWidth = nRest/4;
+ for (auto const& author : aAuthors)
{
- nMaxAuthorWidth = nRest/2;
- break;
+ nMaxAuthorWidth = std::max<int>(nMaxAuthorWidth, rVersionBox.get_pixel_size(author).Width());
+ if (nMaxAuthorWidth > nRest/2)
+ {
+ nMaxAuthorWidth = nRest/2;
+ break;
+ }
}
- }
- std::vector<int> aWidths;
- aWidths.push_back(nMax);
- aWidths.push_back(nMaxAuthorWidth);
- m_xVersionBox->set_column_fixed_widths(aWidths);
+ std::vector<int> aWidths;
+ aWidths.push_back(nMax);
+ aWidths.push_back(nMaxAuthorWidth);
+ rVersionBox.set_column_fixed_widths(aWidths);
+ }
}
SfxVersionDialog::SfxVersionDialog(weld::Window* pParent, SfxViewFrame* pVwFrame, bool bIsSaveVersionOnClose)
@@ -227,7 +164,7 @@ SfxVersionDialog::SfxVersionDialog(weld::Window* pParent, SfxViewFrame* pVwFrame
{
m_xVersionBox->set_size_request(m_xVersionBox->get_approximate_digit_width() * 90,
m_xVersionBox->get_height_rows(15));
- setColSizes();
+ setColSizes(*m_xVersionBox);
Link<weld::Button&,void> aClickLink = LINK( this, SfxVersionDialog, ButtonHdl_Impl );
m_xViewButton->connect_clicked( aClickLink );
@@ -438,8 +375,8 @@ IMPL_LINK(SfxVersionDialog, ButtonHdl_Impl, weld::Button&, rButton, void)
}
else if (&rButton == m_xCmisButton.get())
{
- VclPtrInstance< SfxCmisVersionsDialog > pDlg(m_pViewFrame);
- pDlg->Execute();
+ SfxCmisVersionsDialog aDlg(m_xDialog.get(), m_pViewFrame);
+ aDlg.run();
}
}
@@ -487,87 +424,48 @@ IMPL_LINK(SfxViewVersionDialog_Impl, ButtonHdl, weld::Button&, rButton, void)
m_xDialog->response(RET_OK);
}
-SfxCmisVersionsDialog::SfxCmisVersionsDialog ( SfxViewFrame* pVwFrame )
- : SfxModalDialog(nullptr, "VersionsCmisDialog", "sfx/ui/versionscmis.ui")
- , pViewFrame(pVwFrame)
+SfxCmisVersionsDialog::SfxCmisVersionsDialog(weld::Window* pParent, SfxViewFrame* pVwFrame)
+ : SfxDialogController(pParent, "sfx/ui/versionscmis.ui", "VersionsCmisDialog")
+ , m_pViewFrame(pVwFrame)
+ , m_xOpenButton(m_xBuilder->weld_button("open"))
+ , m_xViewButton(m_xBuilder->weld_button("show"))
+ , m_xDeleteButton(m_xBuilder->weld_button("delete"))
+ , m_xCompareButton(m_xBuilder->weld_button("compare"))
{
- get(m_pOpenButton, "open");
- get(m_pViewButton, "show");
- get(m_pDeleteButton, "delete");
- get(m_pCompareButton, "compare");
-
- SvSimpleTableContainer *pContainer = get<SvSimpleTableContainer>("versions");
- Size aControlSize(260, 114);
- aControlSize = pContainer->LogicToPixel(aControlSize, MapMode(MapUnit::MapAppFont));
- pContainer->set_width_request(aControlSize.Width());
- pContainer->set_height_request(aControlSize.Height());
-
- m_pVersionBox = VclPtr<SfxVersionsTabListBox_Impl>::Create(*pContainer, WB_TABSTOP);
-
- m_pVersionBox->GrabFocus();
- m_pVersionBox->SetStyle( m_pVersionBox->GetStyle() | WB_HSCROLL | WB_CLIPCHILDREN );
- m_pVersionBox->SetSelectionMode( SelectionMode::Single );
-
- long aTabPositions[] = { 0, 0, 0 };
- m_pVersionBox->SvSimpleTable::SetTabs(SAL_N_ELEMENTS(aTabPositions), aTabPositions);
- OUString sHeader1(get<FixedText>("datetime")->GetText());
- OUString sHeader2(get<FixedText>("savedby")->GetText());
- OUString sHeader3(get<FixedText>("comments")->GetText());
- OUString sHeader = sHeader1 + "\t" + sHeader2 + "\t" + sHeader3;
- m_pVersionBox->InsertHeaderEntry(sHeader);
-
- HeaderBar &rBar = m_pVersionBox->GetTheHeaderBar();
- HeaderBarItemBits nBits = rBar.GetItemBits(1) | HeaderBarItemBits::FIXEDPOS | HeaderBarItemBits::FIXED;
- nBits &= ~HeaderBarItemBits::CLICKABLE;
- rBar.SetItemBits(1, nBits);
- rBar.SetItemBits(2, nBits);
- rBar.SetItemBits(3, nBits);
-
- m_pVersionBox->Resize();
-
- OUString sText = GetText();
- sText = sText + " " + pViewFrame->GetObjectShell()->GetTitle();
- SetText( sText );
+ m_xVersionBox->set_size_request(m_xVersionBox->get_approximate_digit_width() * 90,
+ m_xVersionBox->get_height_rows(15));
+ setColSizes(*m_xVersionBox);
- LoadVersions();
+ m_xVersionBox->grab_focus();
- m_pVersionBox->setColSizes();
+ OUString sText = m_xDialog->get_title();
+ sText = sText + " " + m_pViewFrame->GetObjectShell()->GetTitle();
+ m_xDialog->set_title(sText);
+ LoadVersions();
}
SfxCmisVersionsDialog::~SfxCmisVersionsDialog()
{
- disposeOnce();
-}
-
-void SfxCmisVersionsDialog::dispose()
-{
- m_pTable.reset();
- m_pVersionBox.disposeAndClear();
- m_pOpenButton.clear();
- m_pViewButton.clear();
- m_pDeleteButton.clear();
- m_pCompareButton.clear();
- SfxModalDialog::dispose();
}
void SfxCmisVersionsDialog::LoadVersions()
{
- SfxObjectShell *pObjShell = pViewFrame->GetObjectShell();
+ SfxObjectShell *pObjShell = m_pViewFrame->GetObjectShell();
uno::Sequence < document::CmisVersion > aVersions = pObjShell->GetCmisVersions( );
m_pTable.reset(new SfxVersionTableDtor( aVersions ));
- for ( size_t n = 0; n < m_pTable->size(); ++n )
+ for (size_t n = 0; n < m_pTable->size(); ++n)
{
SfxVersionInfo *pInfo = m_pTable->at( n );
OUString aEntry = formatTime(pInfo->aCreationDate, Application::GetSettings().GetLocaleDataWrapper());
- aEntry += "\t";
- aEntry += pInfo->aAuthor;
- aEntry += "\t";
- aEntry += ConvertWhiteSpaces_Impl( pInfo->aComment );
- SvTreeListEntry *pEntry = m_pVersionBox->InsertEntry( aEntry );
- pEntry->SetUserData( pInfo );
+ m_xVersionBox->append(OUString::number(reinterpret_cast<sal_Int64>(pInfo)), aEntry);
+ auto nLastRow = m_xVersionBox->n_children() - 1;
+ m_xVersionBox->set_text(nLastRow, pInfo->aAuthor, 1);
+ m_xVersionBox->set_text(nLastRow, ConvertWhiteSpaces_Impl(pInfo->aComment), 2);
}
+ if (auto nCount = m_pTable->size())
+ m_xVersionBox->select(nCount - 1);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/inc/versdlg.hxx b/sfx2/source/inc/versdlg.hxx
index 949c0b4bd6bc..123a744f897b 100644
--- a/sfx2/source/inc/versdlg.hxx
+++ b/sfx2/source/inc/versdlg.hxx
@@ -23,26 +23,11 @@
#include <sfx2/basedlgs.hxx>
#include <svtools/simptabl.hxx>
#include <svtools/svmedit.hxx>
-#include <vcl/svtabbx.hxx>
-#include <vcl/button.hxx>
-#include <vcl/fixed.hxx>
#include <vcl/weld.hxx>
class SfxViewFrame;
struct SfxVersionInfo;
-class SfxVersionsTabListBox_Impl : public SvSimpleTable
-{
-public:
- SfxVersionsTabListBox_Impl(SvSimpleTableContainer& rParent, WinBits nBits)
- : SvSimpleTable(rParent, nBits)
- {
- }
- void setColSizes();
- virtual void Resize() override;
- virtual void KeyInput(const KeyEvent& rKeyEvent) override;
-};
-
class SfxVersionTableDtor;
class SfxVersionDialog : public SfxDialogController
{
@@ -63,7 +48,6 @@ class SfxVersionDialog : public SfxDialogController
DECL_LINK(ButtonHdl_Impl, weld::Button&, void );
void Init_Impl();
void Open_Impl();
- void setColSizes();
public:
SfxVersionDialog(weld::Window* pParent, SfxViewFrame* pFrame, bool);
@@ -89,22 +73,22 @@ public:
SfxViewVersionDialog_Impl(weld::Window *pParent, SfxVersionInfo& rInfo, bool bEdit);
};
-class SfxCmisVersionsDialog : public SfxModalDialog
+class SfxCmisVersionsDialog : public SfxDialogController
{
- VclPtr<SfxVersionsTabListBox_Impl> m_pVersionBox;
- VclPtr<PushButton> m_pOpenButton;
- VclPtr<PushButton> m_pViewButton;
- VclPtr<PushButton> m_pDeleteButton;
- VclPtr<PushButton> m_pCompareButton;
- SfxViewFrame* pViewFrame;
+ SfxViewFrame* m_pViewFrame;
std::unique_ptr<SfxVersionTableDtor> m_pTable;
+ std::unique_ptr<weld::Button> m_xOpenButton;
+ std::unique_ptr<weld::Button> m_xViewButton;
+ std::unique_ptr<weld::Button> m_xDeleteButton;
+ std::unique_ptr<weld::Button> m_xCompareButton;
+ std::unique_ptr<weld::TreeView> m_xVersionBox;
+
void LoadVersions();
public:
- SfxCmisVersionsDialog ( SfxViewFrame* pFrame );
- virtual ~SfxCmisVersionsDialog () override;
- virtual void dispose() override;
+ SfxCmisVersionsDialog(weld::Window *pParent, SfxViewFrame* pFrame);
+ virtual ~SfxCmisVersionsDialog() override;
};
#endif
diff --git a/sfx2/uiconfig/ui/versionscmis.ui b/sfx2/uiconfig/ui/versionscmis.ui
index 9b5d9532e5f6..e3db36c539ce 100644
--- a/sfx2/uiconfig/ui/versionscmis.ui
+++ b/sfx2/uiconfig/ui/versionscmis.ui
@@ -1,28 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="sfx">
<requires lib="gtk+" version="3.18"/>
- <requires lib="LibreOffice" version="1.0"/>
+ <object class="GtkTreeStore" id="liststore3">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name text2 -->
+ <column type="gchararray"/>
+ <!-- column-name text3 -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="VersionsCmisDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
- <property name="resizable">False</property>
+ <property name="modal">True</property>
<property name="type_hint">dialog</property>
+ <child>
+ <placeholder/>
+ </child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
<property name="spacing">12</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="layout_style">start</property>
+ <property name="layout_style">end</property>
<child>
- <object class="GtkButton" id="close">
- <property name="label">gtk-close</property>
+ <object class="GtkButton" id="delete">
+ <property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -32,12 +47,12 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="open">
- <property name="label">gtk-open</property>
+ <object class="GtkButton" id="compare">
+ <property name="label" translatable="yes" context="versionscmis|compare">_Compare</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="use_stock">True</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -60,12 +75,11 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="delete">
- <property name="label">gtk-delete</property>
+ <object class="GtkButton" id="close">
+ <property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -75,12 +89,12 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="compare">
- <property name="label" translatable="yes" context="versionscmis|compare">_Compare</property>
+ <object class="GtkButton" id="open">
+ <property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -141,47 +155,67 @@
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
- <object class="GtkBox" id="box1">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can_focus">True</property>
<property name="hexpand">True</property>
- <property name="spacing">12</property>
- <property name="homogeneous">True</property>
- <child>
- <object class="GtkLabel" id="datetime">
- <property name="can_focus">False</property>
- <property name="no_show_all">True</property>
- <property name="label" translatable="yes" context="versionscmis|datetime">Date and time</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="savedby">
- <property name="can_focus">False</property>
- <property name="no_show_all">True</property>
- <property name="label" translatable="yes" context="versionscmis|savedby">Saved by</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="vexpand">True</property>
+ <property name="shadow_type">in</property>
<child>
- <object class="GtkLabel" id="comments">
- <property name="can_focus">False</property>
- <property name="no_show_all">True</property>
- <property name="label" translatable="yes" context="versionscmis|comments">Comments</property>
+ <object class="GtkTreeView" id="versions">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore3</property>
+ <property name="rules_hint">True</property>
+ <property name="headers_visible">True</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="versions-selection2"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <property name="resizable">True</property>
+ <property name="spacing">6</property>
+ <property name="title" translatable="yes" context="versionscmis|datetime">Date and time</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderer1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+ <property name="resizable">True</property>
+ <property name="spacing">6</property>
+ <property name="title" translatable="yes" context="versionscmis|savedby">Saved by</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderer2"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn3">
+ <property name="resizable">True</property>
+ <property name="spacing">6</property>
+ <property name="title" translatable="yes" context="versionscmis|comments">Comments</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderer3"/>
+ <attributes>
+ <attribute name="text">2</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
</child>
</object>
<packing>
@@ -189,21 +223,6 @@
<property name="top_attach">0</property>
</packing>
</child>
- <child>
- <object class="svtlo-SvSimpleTableContainer" id="versions">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="Simple Table Container-selection1"/>
- </child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
</object>
</child>
</object>
@@ -221,12 +240,9 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">0</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
</object>
<packing>
<property name="expand">False</property>
@@ -237,11 +253,11 @@
</object>
</child>
<action-widgets>
+ <action-widget response="103">delete</action-widget>
+ <action-widget response="102">compare</action-widget>
+ <action-widget response="101">show</action-widget>
<action-widget response="-7">close</action-widget>
- <action-widget response="0">open</action-widget>
- <action-widget response="0">show</action-widget>
- <action-widget response="0">delete</action-widget>
- <action-widget response="0">compare</action-widget>
+ <action-widget response="-5">open</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
</object>