Kaydet (Commit) 215d1cea authored tarafından Caolán McNamara's avatar Caolán McNamara

weld ScDPShowDetailDlg

Change-Id: Ifbb93a71ac891f4a5621edcd1c3f004a278a088d
Reviewed-on: https://gerrit.libreoffice.org/54577Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 99343e63
......@@ -492,7 +492,7 @@ public:
sal_Int32 nDatePart,
const Date& rNullDate ) = 0;
virtual VclPtr<AbstractScDPShowDetailDlg> CreateScDPShowDetailDlg( vcl::Window* pParent,
virtual VclPtr<AbstractScDPShowDetailDlg> CreateScDPShowDetailDlg(weld::Window* pParent,
ScDPObject& rDPObj,
css::sheet::DataPilotFieldOrientation nOrient ) = 0;
......
......@@ -160,7 +160,12 @@ IMPL_ABSTDLG_BASE(AbstractScDPFunctionDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScDPSubtotalDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScDPNumGroupDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScDPDateGroupDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractScDPShowDetailDlg_Impl);
short AbstractScDPShowDetailDlg_Impl::Execute()
{
return m_xDlg->execute();
}
IMPL_ABSTDLG_BASE(AbstractScNewScenarioDlg_Impl);
short AbstractScShowTabDlg_Impl::Execute()
......@@ -602,7 +607,7 @@ sal_Int32 AbstractScDPDateGroupDlg_Impl::GetDatePart() const
OUString AbstractScDPShowDetailDlg_Impl::GetDimensionName() const
{
return pDlg->GetDimensionName();
return m_xDlg->GetDimensionName();
}
void AbstractScNewScenarioDlg_Impl::SetScenarioData(
......@@ -867,9 +872,9 @@ VclPtr<AbstractScDPDateGroupDlg> ScAbstractDialogFactory_Impl::CreateScDPDateGro
}
VclPtr<AbstractScDPShowDetailDlg> ScAbstractDialogFactory_Impl::CreateScDPShowDetailDlg (
vcl::Window* pParent, ScDPObject& rDPObj, css::sheet::DataPilotFieldOrientation nOrient )
weld::Window* pParent, ScDPObject& rDPObj, css::sheet::DataPilotFieldOrientation nOrient )
{
return VclPtr<AbstractScDPShowDetailDlg_Impl>::Create( VclPtr<ScDPShowDetailDlg>::Create( pParent, rDPObj, nOrient ) );
return VclPtr<AbstractScDPShowDetailDlg_Impl>::Create(new ScDPShowDetailDlg(pParent, rDPObj, nOrient));
}
VclPtr<AbstractScNewScenarioDlg> ScAbstractDialogFactory_Impl::CreateScNewScenarioDlg(vcl::Window* pParent, const OUString& rName,
......
......@@ -407,7 +407,14 @@ class AbstractScDPDateGroupDlg_Impl : public AbstractScDPDateGroupDlg
class AbstractScDPShowDetailDlg_Impl : public AbstractScDPShowDetailDlg
{
DECL_ABSTDLG_BASE( AbstractScDPShowDetailDlg_Impl, ScDPShowDetailDlg)
protected:
std::shared_ptr<ScDPShowDetailDlg> m_xDlg;
public:
explicit AbstractScDPShowDetailDlg_Impl(ScDPShowDetailDlg* p)
: m_xDlg(p)
{
}
virtual short Execute() override;
virtual OUString GetDimensionName() const override;
};
......@@ -597,9 +604,9 @@ public:
sal_Int32 nDatePart,
const Date& rNullDate ) override;
virtual VclPtr<AbstractScDPShowDetailDlg> CreateScDPShowDetailDlg( vcl::Window* pParent,
virtual VclPtr<AbstractScDPShowDetailDlg> CreateScDPShowDetailDlg(weld::Window* pParent,
ScDPObject& rDPObj,
css::sheet::DataPilotFieldOrientation nOrient ) override;
css::sheet::DataPilotFieldOrientation nOrient) override;
virtual VclPtr<AbstractScNewScenarioDlg> CreateScNewScenarioDlg ( vcl::Window* pParent, const OUString& rName,
bool bEdit, bool bSheetProtected ) override;
......
......@@ -812,13 +812,11 @@ IMPL_LINK( ScDPSubtotalOptDlg, SelectHdl, ListBox&, rLBox, void )
}
}
ScDPShowDetailDlg::ScDPShowDetailDlg( vcl::Window* pParent, ScDPObject& rDPObj, css::sheet::DataPilotFieldOrientation nOrient ) :
ModalDialog ( pParent, "ShowDetail", "modules/scalc/ui/showdetaildialog.ui" ),
mrDPObj(rDPObj)
ScDPShowDetailDlg::ScDPShowDetailDlg(weld::Window* pParent, ScDPObject& rDPObj, css::sheet::DataPilotFieldOrientation nOrient)
: GenericDialogController(pParent, "modules/scalc/ui/showdetaildialog.ui", "ShowDetail")
, mrDPObj(rDPObj)
, mxLbDims(m_xBuilder->weld_tree_view("dimsTreeview"))
{
get(mpLbDims, "dimsTreeview");
get(mpBtnOk, "ok");
ScDPSaveData* pSaveData = rDPObj.GetSaveData();
long nDimCount = rDPObj.GetDimCount();
for (long nDim=0; nDim<nDimCount; nDim++)
......@@ -837,39 +835,31 @@ ScDPShowDetailDlg::ScDPShowDetailDlg( vcl::Window* pParent, ScDPObject& rDPObj,
if (pLayoutName)
aName = *pLayoutName;
}
mpLbDims->InsertEntry( aName );
mxLbDims->append_text(aName);
maNameIndexMap.emplace(aName, nDim);
}
}
}
if( mpLbDims->GetEntryCount() )
mpLbDims->SelectEntryPos( 0 );
if (mxLbDims->n_children())
mxLbDims->select(0);
mpLbDims->SetDoubleClickHdl( LINK( this, ScDPShowDetailDlg, DblClickHdl ) );
mxLbDims->connect_row_activated(LINK(this, ScDPShowDetailDlg, DblClickHdl));
}
ScDPShowDetailDlg::~ScDPShowDetailDlg()
{
disposeOnce();
}
void ScDPShowDetailDlg::dispose()
{
mpLbDims.clear();
mpBtnOk.clear();
ModalDialog::dispose();
}
short ScDPShowDetailDlg::Execute()
short ScDPShowDetailDlg::execute()
{
return mpLbDims->GetEntryCount() ? ModalDialog::Execute() : static_cast<short>(RET_CANCEL);
return mxLbDims->n_children() ? m_xDialog->run() : static_cast<short>(RET_CANCEL);
}
OUString ScDPShowDetailDlg::GetDimensionName() const
{
// Look up the internal dimension name which may be different from the
// displayed field name.
OUString aSelectedName = mpLbDims->GetSelectedEntry();
OUString aSelectedName = mxLbDims->get_selected_text();
DimNameIndexMap::const_iterator itr = maNameIndexMap.find(aSelectedName);
if (itr == maNameIndexMap.end())
// This should never happen!
......@@ -880,10 +870,9 @@ OUString ScDPShowDetailDlg::GetDimensionName() const
return mrDPObj.GetDimName(nDim, bIsDataLayout);
}
IMPL_LINK( ScDPShowDetailDlg, DblClickHdl, ListBox&, rLBox, void )
IMPL_LINK_NOARG(ScDPShowDetailDlg, DblClickHdl, weld::TreeView&, void)
{
if( &rLBox == mpLbDims )
mpBtnOk->Click();
m_xDialog->response(RET_OK);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -31,6 +31,7 @@
#include <vcl/button.hxx>
#include <vcl/morebtn.hxx>
#include <vcl/field.hxx>
#include <vcl/weld.hxx>
#include <svx/checklbx.hxx>
#include <sfx2/itemconnect.hxx>
#include <pivot.hxx>
......@@ -186,14 +187,14 @@ private:
NameMapType maDataFieldNameMap; /// Cache for displayed name to field name mapping.
};
class ScDPShowDetailDlg : public ModalDialog
class ScDPShowDetailDlg : public weld::GenericDialogController
{
public:
explicit ScDPShowDetailDlg( vcl::Window* pParent, ScDPObject& rDPObj,
css::sheet::DataPilotFieldOrientation nOrient );
virtual ~ScDPShowDetailDlg() override;
virtual void dispose() override;
virtual short Execute() override;
explicit ScDPShowDetailDlg(weld::Window* pParent, ScDPObject& rDPObj,
css::sheet::DataPilotFieldOrientation nOrient);
virtual ~ScDPShowDetailDlg() override;
short execute();
/**
* @return String internal name of the selected field. Note that this may
......@@ -203,15 +204,14 @@ public:
OUString GetDimensionName() const;
private:
DECL_LINK( DblClickHdl, ListBox&, void );
DECL_LINK(DblClickHdl, weld::TreeView&, void);
private:
VclPtr<ListBox> mpLbDims;
VclPtr<OKButton> mpBtnOk;
typedef std::unordered_map<OUString, long> DimNameIndexMap;
DimNameIndexMap maNameIndexMap;
ScDPObject& mrDPObj;
std::unique_ptr<weld::TreeView> mxLbDims;
};
#endif
......
......@@ -1083,11 +1083,10 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
if ( pTabViewShell->HasSelectionForDrillDown( nOrientation ) )
{
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
assert(pFact && "ScAbstractFactory create fail!");
ScopedVclPtr<AbstractScDPShowDetailDlg> pDlg( pFact->CreateScDPShowDetailDlg(
pTabViewShell->GetDialogParent(), *pDPObj, nOrientation ) );
OSL_ENSURE(pDlg, "Dialog create fail!");
pTabViewShell->GetFrameWeld(), *pDPObj, nOrientation ) );
assert(pDlg && "Dialog create fail!");
if ( pDlg->Execute() == RET_OK )
{
OUString aNewDimName( pDlg->GetDimensionName() );
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.19.0 -->
<!-- Generated with glade 3.20.4 -->
<interface domain="sc">
<requires lib="gtk+" version="3.18"/>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="ShowDetail">
<property name="can_focus">False</property>
<property name="hexpand">True</property>
......@@ -9,17 +17,20 @@
<property name="border_width">6</property>
<property name="title" translatable="yes" context="showdetaildialog|ShowDetail">Show Detail</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</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>
<child>
<object class="GtkButton" id="ok">
......@@ -66,6 +77,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="secondary">True</property>
</packing>
</child>
</object>
......@@ -88,12 +100,12 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="showdetaildialog|label1">_Choose the field containing the detail you want to show</property>
<property name="use_underline">True</property>
<property name="wrap">True</property>
<property name="mnemonic_widget">dimsTreeview</property>
<property name="max_width_chars">50</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -102,13 +114,37 @@
</packing>
</child>
<child>
<object class="GtkTreeView" id="dimsTreeview">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="dimsTreeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore1</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
......@@ -131,5 +167,8 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
<child>
<placeholder/>
</child>
</object>
</interface>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment