summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-10-04 12:11:21 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-10-04 21:15:03 +0200
commit3022dc22ceae5da4e8c8d6b287c03619e03fc123 (patch)
treedb305783b49a974a0191df1f261f20b23eecb785 /dbaccess
parent6e2a7571e8ee4960f54610ba790394202c4d7aed (diff)
weld OCollectionView
Change-Id: I3aac2b42442ec3f61c2d18369eae061ae44880a5 Reviewed-on: https://gerrit.libreoffice.org/80205 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/inc/bitmaps.hlst2
-rw-r--r--dbaccess/source/ui/dlg/CollectionView.cxx146
-rw-r--r--dbaccess/source/ui/inc/CollectionView.hxx42
-rw-r--r--dbaccess/source/ui/uno/dbinteraction.cxx6
-rw-r--r--dbaccess/uiconfig/ui/collectionviewdialog.ui60
5 files changed, 165 insertions, 91 deletions
diff --git a/dbaccess/inc/bitmaps.hlst b/dbaccess/inc/bitmaps.hlst
index b12d7c681a9f..fb9c4567bb87 100644
--- a/dbaccess/inc/bitmaps.hlst
+++ b/dbaccess/inc/bitmaps.hlst
@@ -24,8 +24,6 @@
#define FORMFOLDER_TREE_ICON "dbaccess/res/forms_16.png"
#define REPORT_TREE_ICON "dbaccess/res/report_16.png"
#define REPORTFOLDER_TREE_ICON "dbaccess/res/reports_16.png"
-#define BMP_NAVIGATION_BTN_UP_SC "res/fp010.png"
-#define BMP_NAVIGATION_CREATEFOLDER_SC "res/fp015.png"
#define BMP_PRIMARY_KEY "dbaccess/res/jo01.png"
#define BMP_PKEYICON "dbaccess/res/pkey.png"
#define BMP_UP "dbaccess/res/sortup.png"
diff --git a/dbaccess/source/ui/dlg/CollectionView.cxx b/dbaccess/source/ui/dlg/CollectionView.cxx
index 8838514e130d..14f942902e9d 100644
--- a/dbaccess/source/ui/dlg/CollectionView.cxx
+++ b/dbaccess/source/ui/dlg/CollectionView.cxx
@@ -39,10 +39,16 @@
#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
#include <com/sun/star/ucb/IOErrorCode.hpp>
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#include <com/sun/star/ucb/XDynamicResultSet.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/task/InteractionHandler.hpp>
#include <com/sun/star/task/InteractionClassification.hpp>
#include <com/sun/star/sdbc/SQLException.hpp>
#include <com/sun/star/awt/XWindow.hpp>
+#include <comphelper/processfactory.hxx>
+#include <ucbhelper/commandenvironment.hxx>
+#include <ucbhelper/content.hxx>
#include <unotools/viewoptions.hxx>
#include <osl/thread.h>
#include <connectivity/dbexception.hxx>
@@ -58,61 +64,49 @@ using namespace ::com::sun::star::container;
using namespace ::com::sun::star::task;
using namespace ::com::sun::star::sdbc;
using namespace comphelper;
-OCollectionView::OCollectionView( vcl::Window * pParent
- ,const Reference< XContent>& _xContent
- ,const OUString& _sDefaultName
- ,const css::uno::Reference< css::uno::XComponentContext >& _rxContext)
- : ModalDialog( pParent, "CollectionView", "dbaccess/ui/collectionviewdialog.ui")
+
+OCollectionView::OCollectionView(weld::Window* pParent,
+ const Reference< XContent>& _xContent,
+ const OUString& _sDefaultName,
+ const css::uno::Reference< css::uno::XComponentContext >& _rxContext)
+ : GenericDialogController(pParent, "dbaccess/ui/collectionviewdialog.ui", "CollectionView")
, m_xContent(_xContent)
, m_xContext(_rxContext)
, m_bCreateForm(true)
+ , m_xFTCurrentPath(m_xBuilder->weld_label("currentPathLabel"))
+ , m_xNewFolder(m_xBuilder->weld_button("newFolderButton"))
+ , m_xUp(m_xBuilder->weld_button("upButton"))
+ , m_xView(m_xBuilder->weld_tree_view("viewTreeview"))
+ , m_xName(m_xBuilder->weld_entry("fileNameEntry"))
+ , m_xPB_OK(m_xBuilder->weld_button("ok"))
{
- get(m_pFTCurrentPath, "currentPathLabel");
- get(m_pNewFolder, "newFolderButton");
- get(m_pUp, "upButton");
- get(m_pView, "viewTreeview");
- get(m_pName, "fileNameEntry");
- get(m_pPB_OK, "ok");
+ Reference<XInteractionHandler2> xHandler(
+ InteractionHandler::createWithParent(m_xContext, m_xDialog->GetXWindow()));
+ m_xCmdEnv = new ::ucbhelper::CommandEnvironment(xHandler, nullptr);
OSL_ENSURE(m_xContent.is(),"No valid content!");
- m_pView->Initialize(m_xContent);
- m_pFTCurrentPath->SetStyle( m_pFTCurrentPath->GetStyle() | WB_PATHELLIPSIS );
+ m_xView->set_size_request(m_xView->get_approximate_digit_width() * 60, m_xView->get_height_rows(8));
+ m_xView->make_sorted();
+ Initialize();
initCurrentPath();
- m_pName->SetText(_sDefaultName);
- m_pName->GrabFocus();
-
- m_pUp->SetModeImage(Image(StockImage::Yes, BMP_NAVIGATION_BTN_UP_SC));
- m_pNewFolder->SetModeImage(Image(StockImage::Yes, BMP_NAVIGATION_CREATEFOLDER_SC));
+ m_xName->set_text(_sDefaultName);
+ m_xName->grab_focus();
- m_pView->SetDoubleClickHdl( LINK( this, OCollectionView, Dbl_Click_FileView ) );
- m_pView->EnableAutoResize();
- m_pView->EnableDelete(true);
- m_pUp->SetClickHdl( LINK( this, OCollectionView, Up_Click ) );
- m_pNewFolder->SetClickHdl( LINK( this, OCollectionView, NewFolder_Click ) );
- m_pPB_OK->SetClickHdl( LINK( this, OCollectionView, Save_Click ) );
+ m_xView->connect_row_activated( LINK( this, OCollectionView, Dbl_Click_FileView ) );
+ m_xUp->connect_clicked( LINK( this, OCollectionView, Up_Click ) );
+ m_xNewFolder->connect_clicked( LINK( this, OCollectionView, NewFolder_Click ) );
+ m_xPB_OK->connect_clicked( LINK( this, OCollectionView, Save_Click ) );
}
OCollectionView::~OCollectionView()
{
- disposeOnce();
-}
-
-void OCollectionView::dispose()
-{
- m_pFTCurrentPath.clear();
- m_pNewFolder.clear();
- m_pUp.clear();
- m_pView.clear();
- m_pName.clear();
- m_pPB_OK.clear();
- ModalDialog::dispose();
}
-IMPL_LINK_NOARG(OCollectionView, Save_Click, Button*, void)
+IMPL_LINK_NOARG(OCollectionView, Save_Click, weld::Button&, void)
{
- OUString sName = m_pName->GetText();
- if ( sName.isEmpty() )
+ OUString sName = m_xName->get_text();
+ if (sName.isEmpty())
return;
try
{
@@ -132,7 +126,7 @@ IMPL_LINK_NOARG(OCollectionView, Save_Click, Button*, void)
xChild.set(m_xContent,UNO_QUERY);
}
}
- m_pView->Initialize(m_xContent);
+ Initialize();
initCurrentPath();
}
OUString sSubFolder = sName.copy(0,nIndex-1);
@@ -157,7 +151,7 @@ IMPL_LINK_NOARG(OCollectionView, Save_Click, Button*, void)
IOErrorCode_NOT_EXISTING_PATH,aValues);
Reference<XInteractionHandler2> xHandler(
- InteractionHandler::createWithParent(m_xContext, VCLUnoHelper::GetInterface( this )));
+ InteractionHandler::createWithParent(m_xContext, m_xDialog->GetXWindow()));
OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aException));
Reference< XInteractionRequest > xRequest(pRequest);
@@ -174,14 +168,14 @@ IMPL_LINK_NOARG(OCollectionView, Save_Click, Button*, void)
{
if ( xNameContainer->hasByName(sName) )
{
- std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Question, VclButtonsType::YesNo,
DBA_RES(STR_ALREADYEXISTOVERWRITE)));
if (xQueryBox->run() != RET_YES)
return;
}
- m_pName->SetText(sName);
- EndDialog( RET_OK );
+ m_xName->set_text(sName);
+ m_xDialog->response(RET_OK);
}
}
catch( const Exception& )
@@ -190,17 +184,17 @@ IMPL_LINK_NOARG(OCollectionView, Save_Click, Button*, void)
}
}
-IMPL_LINK_NOARG(OCollectionView, NewFolder_Click, Button*, void)
+IMPL_LINK_NOARG(OCollectionView, NewFolder_Click, weld::Button&, void)
{
try
{
Reference<XHierarchicalNameContainer> xNameContainer(m_xContent,UNO_QUERY);
- if ( dbaui::insertHierachyElement(GetFrameWeld(),m_xContext,xNameContainer,OUString(),m_bCreateForm) )
- m_pView->Initialize(m_xContent);
+ if ( dbaui::insertHierachyElement(m_xDialog.get(),m_xContext,xNameContainer,OUString(),m_bCreateForm) )
+ Initialize();
}
catch( const SQLException& )
{
- showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ), VCLUnoHelper::GetInterface(this), m_xContext );
+ showError(::dbtools::SQLExceptionInfo(::cppu::getCaughtException()), m_xDialog->GetXWindow(), m_xContext);
}
catch( const Exception& )
{
@@ -208,7 +202,7 @@ IMPL_LINK_NOARG(OCollectionView, NewFolder_Click, Button*, void)
}
}
-IMPL_LINK_NOARG(OCollectionView, Up_Click, Button*, void)
+IMPL_LINK_NOARG(OCollectionView, Up_Click, weld::Button&, void)
{
try
{
@@ -219,11 +213,11 @@ IMPL_LINK_NOARG(OCollectionView, Up_Click, Button*, void)
if ( xNameAccess.is() )
{
m_xContent.set(xNameAccess,UNO_QUERY);
- m_pView->Initialize(m_xContent);
+ Initialize();
initCurrentPath();
}
else
- m_pUp->Disable();
+ m_xUp->set_sensitive(false);
}
}
catch( const Exception& )
@@ -232,16 +226,15 @@ IMPL_LINK_NOARG(OCollectionView, Up_Click, Button*, void)
}
}
-IMPL_LINK_NOARG(OCollectionView, Dbl_Click_FileView, SvTreeListBox*, bool)
+IMPL_LINK_NOARG(OCollectionView, Dbl_Click_FileView, weld::TreeView&, void)
{
try
{
Reference<XNameAccess> xNameAccess(m_xContent,UNO_QUERY);
if ( xNameAccess.is() )
{
- OUString sSubFolder = m_pView->GetCurrentURL();
- sSubFolder = sSubFolder.copy(sSubFolder.lastIndexOf('/') + 1);
- if ( !sSubFolder.isEmpty() )
+ OUString sSubFolder = m_xView->get_selected_text();
+ if (!sSubFolder.isEmpty())
{
Reference< XContent> xContent;
if ( xNameAccess->hasByName(sSubFolder) )
@@ -249,7 +242,7 @@ IMPL_LINK_NOARG(OCollectionView, Dbl_Click_FileView, SvTreeListBox*, bool)
if ( xContent.is() )
{
m_xContent = xContent;
- m_pView->Initialize(m_xContent);
+ Initialize();
initCurrentPath();
}
}
@@ -259,7 +252,6 @@ IMPL_LINK_NOARG(OCollectionView, Dbl_Click_FileView, SvTreeListBox*, bool)
{
DBG_UNHANDLED_EXCEPTION("dbaccess");
}
- return false;
}
void OCollectionView::initCurrentPath()
@@ -279,7 +271,7 @@ void OCollectionView::initCurrentPath()
else if ( !m_bCreateForm && sCID.getLength() != static_cast<sal_Int32>(strlen(s_sReportsCID)) )
sPath = sCID.copy(strlen(s_sReportsCID) - 2);
- m_pFTCurrentPath->SetText(sPath);
+ m_xFTCurrentPath->set_label(sPath);
Reference<XChild> xChild(m_xContent,UNO_QUERY);
bEnable = xChild.is() && Reference<XNameAccess>(xChild->getParent(),UNO_QUERY).is();
}
@@ -288,12 +280,46 @@ void OCollectionView::initCurrentPath()
{
DBG_UNHANDLED_EXCEPTION("dbaccess");
}
- m_pUp->Enable(bEnable);
+ m_xUp->set_sensitive(bEnable);
}
OUString OCollectionView::getName() const
{
- return m_pName->GetText();
+ return m_xName->get_text();
+}
+
+#define ROW_TITLE 1
+#define ROW_IS_FOLDER 2
+
+void OCollectionView::Initialize()
+{
+ weld::WaitObject aWaitCursor(m_xDialog.get());
+
+ m_xView->clear();
+
+ try
+ {
+ ::ucbhelper::Content aContent(m_xContent, m_xCmdEnv, comphelper::getProcessComponentContext());
+ Sequence<OUString> aProps(2);
+ aProps[0] = "Title";
+ aProps[1] = "IsFolder";
+ auto xDynResultSet = aContent.createDynamicCursor(aProps, ucbhelper::INCLUDE_FOLDERS_ONLY);
+ if (!xDynResultSet.is())
+ return;
+
+ Reference<XResultSet> xResultSet = xDynResultSet->getStaticResultSet();
+ Reference<XRow> xRow(xResultSet, UNO_QUERY);
+ while (xResultSet->next())
+ {
+ if (!xRow->getBoolean(ROW_IS_FOLDER))
+ continue;
+ m_xView->append_text(xRow->getString(ROW_TITLE));
+ }
+ }
+ catch (const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("dbaccess");
+ }
}
} // namespace dbaui
diff --git a/dbaccess/source/ui/inc/CollectionView.hxx b/dbaccess/source/ui/inc/CollectionView.hxx
index 2036032cd7be..949e60b749ec 100644
--- a/dbaccess/source/ui/inc/CollectionView.hxx
+++ b/dbaccess/source/ui/inc/CollectionView.hxx
@@ -20,12 +20,9 @@
#ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_COLLECTIONVIEW_HXX
#define INCLUDED_DBACCESS_SOURCE_UI_INC_COLLECTIONVIEW_HXX
-#include <svtools/fileview.hxx>
-#include <vcl/button.hxx>
-#include <vcl/edit.hxx>
-#include <vcl/fixed.hxx>
-#include <vcl/dialog.hxx>
+#include <vcl/weld.hxx>
#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
@@ -33,32 +30,35 @@ namespace dbaui
{
/* this class allows to browse through the collection of forms and reports
*/
- class OCollectionView : public ModalDialog
+ class OCollectionView : public weld::GenericDialogController
{
- VclPtr<FixedText> m_pFTCurrentPath;
- VclPtr<PushButton> m_pNewFolder;
- VclPtr<PushButton> m_pUp;
- VclPtr<SvtFileView> m_pView;
- VclPtr<Edit> m_pName;
- VclPtr<PushButton> m_pPB_OK;
css::uno::Reference< css::ucb::XContent> m_xContent;
css::uno::Reference< css::uno::XComponentContext > m_xContext;
+ css::uno::Reference< css::ucb::XCommandEnvironment > m_xCmdEnv;
bool m_bCreateForm;
- DECL_LINK(Up_Click, Button*, void);
- DECL_LINK(NewFolder_Click, Button*, void);
- DECL_LINK(Save_Click, Button*, void);
- DECL_LINK(Dbl_Click_FileView, SvTreeListBox*, bool);
+ std::unique_ptr<weld::Label> m_xFTCurrentPath;
+ std::unique_ptr<weld::Button> m_xNewFolder;
+ std::unique_ptr<weld::Button> m_xUp;
+ std::unique_ptr<weld::TreeView> m_xView;
+ std::unique_ptr<weld::Entry> m_xName;
+ std::unique_ptr<weld::Button> m_xPB_OK;
+
+ DECL_LINK(Up_Click, weld::Button&, void);
+ DECL_LINK(NewFolder_Click, weld::Button&, void);
+ DECL_LINK(Save_Click, weld::Button&, void);
+ DECL_LINK(Dbl_Click_FileView, weld::TreeView&, void);
/// sets the fixedtext to the right content
void initCurrentPath();
+
+ void Initialize();
public:
- OCollectionView( vcl::Window * pParent
- ,const css::uno::Reference< css::ucb::XContent>& _xContent
- ,const OUString& _sDefaultName
- ,const css::uno::Reference< css::uno::XComponentContext >& _rxContext);
+ OCollectionView(weld::Window * pParent,
+ const css::uno::Reference< css::ucb::XContent>& _xContent,
+ const OUString& _sDefaultName,
+ const css::uno::Reference< css::uno::XComponentContext >& _rxContext);
virtual ~OCollectionView() override;
- virtual void dispose() override;
const css::uno::Reference< css::ucb::XContent>& getSelectedFolder() const { return m_xContent;}
OUString getName() const;
};
diff --git a/dbaccess/source/ui/uno/dbinteraction.cxx b/dbaccess/source/ui/uno/dbinteraction.cxx
index 1bd4f34e28e6..7824298889fa 100644
--- a/dbaccess/source/ui/uno/dbinteraction.cxx
+++ b/dbaccess/source/ui/uno/dbinteraction.cxx
@@ -261,8 +261,8 @@ namespace dbaui
Reference< XInteractionDocumentSave > xCallback(_rContinuations[nDocuPos], UNO_QUERY);
OSL_ENSURE(xCallback.is(), "BasicInteractionHandler::implHandle(DocumentSaveRequest): can't save document without an appropriate interaction handler!s");
- ScopedVclPtrInstance< OCollectionView > aDlg(nullptr, _rDocuRequest.Content, _rDocuRequest.Name, m_xContext);
- sal_Int16 nResult = aDlg->Execute();
+ OCollectionView aDlg(Application::GetFrameWeld(m_xParentWindow), _rDocuRequest.Content, _rDocuRequest.Name, m_xContext);
+ sal_Int16 nResult = aDlg.run();
try
{
switch (nResult)
@@ -270,7 +270,7 @@ namespace dbaui
case RET_OK:
if (xCallback.is())
{
- xCallback->setName(aDlg->getName(), aDlg->getSelectedFolder());
+ xCallback->setName(aDlg.getName(), aDlg.getSelectedFolder());
xCallback->select();
}
break;
diff --git a/dbaccess/uiconfig/ui/collectionviewdialog.ui b/dbaccess/uiconfig/ui/collectionviewdialog.ui
index a89de8eb8648..0ffb48584773 100644
--- a/dbaccess/uiconfig/ui/collectionviewdialog.ui
+++ b/dbaccess/uiconfig/ui/collectionviewdialog.ui
@@ -2,13 +2,33 @@
<!-- Generated with glade 3.22.1 -->
<interface domain="dba">
<requires lib="gtk+" version="3.18"/>
- <requires lib="LibreOffice" version="1.0"/>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">res/fp015.png</property>
+ </object>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">res/fp010.png</property>
+ </object>
+ <object class="GtkTreeStore" id="liststore1">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="CollectionView">
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="collectionviewdialog|CollectionView">Save</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>
<placeholder/>
@@ -93,6 +113,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
+ <property name="spacing">3</property>
<child>
<object class="GtkLabel" id="currentPathLabel">
<property name="visible">True</property>
@@ -100,6 +121,7 @@
<property name="halign">start</property>
<property name="valign">start</property>
<property name="hexpand">True</property>
+ <property name="ellipsize">middle</property>
</object>
<packing>
<property name="expand">False</property>
@@ -116,6 +138,8 @@
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes" context="collectionviewdialog|newFolderButton|tooltip_text">Create New Directory</property>
+ <property name="image">image1</property>
+ <property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -131,6 +155,8 @@
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes" context="collectionviewdialog|upButton|tooltip_text">Up One Level</property>
+ <property name="image">image2</property>
+ <property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -146,13 +172,37 @@
</packing>
</child>
<child>
- <object class="svtlo-SvtFileView" id="viewTreeview">
+ <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="viewTreeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore1</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">1</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="Macro Library List-selection2"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn5">
+ <property name="resizable">True</property>
+ <property name="title" translatable="yes" context="collectionviewdialog|columntitle">Folder Name</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderer4"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
<packing>