summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-02-16 11:42:35 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-02-16 17:58:30 +0100
commit1607033e581ee1fc4aab5564cbf8fa89d7094ec7 (patch)
tree88695a26b9da00e466c46b5dfa4f4dd15a3f7d35 /dbaccess
parent2c8ffa41ec8e1ab2af95d5e033a445c17d29cf5a (diff)
convert m_aTypeImage to weld::Image and move inside OTableWindowTitle
Change-Id: Ib3370a2a44761b2f4f5c6d0ade86d2f640c9fc48 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110989 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/ui/inc/TableWindow.hxx4
-rw-r--r--dbaccess/source/ui/inc/TableWindowTitle.hxx2
-rw-r--r--dbaccess/source/ui/inc/imageprovider.hxx14
-rw-r--r--dbaccess/source/ui/misc/imageprovider.cxx27
-rw-r--r--dbaccess/source/ui/querydesign/TableWindow.cxx28
-rw-r--r--dbaccess/source/ui/querydesign/TableWindowTitle.cxx2
6 files changed, 14 insertions, 63 deletions
diff --git a/dbaccess/source/ui/inc/TableWindow.hxx b/dbaccess/source/ui/inc/TableWindow.hxx
index cb8a210f527a..c3bed06c75b8 100644
--- a/dbaccess/source/ui/inc/TableWindow.hxx
+++ b/dbaccess/source/ui/inc/TableWindow.hxx
@@ -25,7 +25,6 @@
#include "TableWindowData.hxx"
#include "TableWindowListBox.hxx"
#include <vector>
-#include <vcl/fixed.hxx>
#include <vcl/window.hxx>
#include <comphelper/containermultiplexer.hxx>
@@ -59,7 +58,6 @@ namespace dbaui
friend class OTableWindowListBox;
protected:
// and the table itself (needed for me as I want to lock it as long as the window is alive)
- VclPtr<FixedImage> m_aTypeImage;
VclPtr<OTableWindowTitle> m_xTitle;
VclPtr<OTableWindowListBox> m_xListBox;
@@ -110,7 +108,7 @@ namespace dbaui
css::beans::XPropertySet>& _xColumn,
bool _bPrimaryKey);
- /** updates m_aTypeImage
+ /** updates image
*/
void impl_updateImage();
diff --git a/dbaccess/source/ui/inc/TableWindowTitle.hxx b/dbaccess/source/ui/inc/TableWindowTitle.hxx
index 04e612de58ad..0a3779bd8873 100644
--- a/dbaccess/source/ui/inc/TableWindowTitle.hxx
+++ b/dbaccess/source/ui/inc/TableWindowTitle.hxx
@@ -27,6 +27,7 @@ namespace dbaui
{
VclPtr<OTableWindow> m_pTabWin;
std::unique_ptr<weld::Label> m_xLabel;
+ std::unique_ptr<weld::Image> m_xImage;
DECL_LINK(MousePressHdl, const MouseEvent&, bool);
@@ -36,6 +37,7 @@ namespace dbaui
virtual void dispose() override;
weld::Label& GetLabel() { return *m_xLabel; }
+ weld::Image& GetImage() { return *m_xImage; }
};
}
diff --git a/dbaccess/source/ui/inc/imageprovider.hxx b/dbaccess/source/ui/inc/imageprovider.hxx
index e022647a7090..8841a49361a9 100644
--- a/dbaccess/source/ui/inc/imageprovider.hxx
+++ b/dbaccess/source/ui/inc/imageprovider.hxx
@@ -65,17 +65,9 @@ namespace dbaui
constants.
@param _rName
the name of the object
- @param _out_rImage
- the normal image to use for the object
@return
- the image to be used for the object.
+ the name of the image to be used for the object.
*/
- void getImages(
- const OUString& _rName,
- const sal_Int32 _nDatabaseObjectType,
- Image& _out_rImage
- );
-
OUString getImageId(
const OUString& _rName,
const sal_Int32 _nDatabaseObjectType
@@ -87,7 +79,7 @@ namespace dbaui
/** returns the default image to be used for a database object
- In opposite to getImages, this method does not check the concrete object
+ In opposite to getImageId, this method does not check the concrete object
for its image, but returns a default image to be used for all objects of the given
type.
@@ -103,7 +95,7 @@ namespace dbaui
/** returns the resource ID for the default image to be used for a database object
- In opposite to getImages, this method does not check the concrete object
+ In opposite to getImageId, this method does not check the concrete object
for its image, but returns a default image to be used for all objects of the given
type.
diff --git a/dbaccess/source/ui/misc/imageprovider.cxx b/dbaccess/source/ui/misc/imageprovider.cxx
index 585b87bc9294..20a294f83785 100644
--- a/dbaccess/source/ui/misc/imageprovider.cxx
+++ b/dbaccess/source/ui/misc/imageprovider.cxx
@@ -116,33 +116,6 @@ namespace dbaui
}
}
- void ImageProvider::getImages( const OUString& _rName, const sal_Int32 _nDatabaseObjectType, Image& _out_rImage )
- {
- if ( _nDatabaseObjectType != DatabaseObject::TABLE )
- {
- // for types other than tables, the icon does not depend on the concrete object
- _out_rImage = getDefaultImage( _nDatabaseObjectType );
- }
- else
- {
- // check whether the connection can give us an icon
- Reference< XGraphic > xGraphic;
- lcl_getConnectionProvidedTableIcon_nothrow( *m_pData, _rName, xGraphic );
- if ( xGraphic.is() )
- _out_rImage = Image( xGraphic );
-
- if ( !_out_rImage )
- {
- // no -> determine by type
- OUString sImageResourceID;
- lcl_getTableImageResourceID_nothrow( *m_pData, _rName, sImageResourceID );
-
- if (!sImageResourceID.isEmpty() && !_out_rImage)
- _out_rImage = Image(StockImage::Yes, sImageResourceID);
- }
- }
- }
-
OUString ImageProvider::getImageId(const OUString& _rName, const sal_Int32 _nDatabaseObjectType)
{
if (_nDatabaseObjectType != DatabaseObject::TABLE)
diff --git a/dbaccess/source/ui/querydesign/TableWindow.cxx b/dbaccess/source/ui/querydesign/TableWindow.cxx
index db0119ce89da..8a523b467e5f 100644
--- a/dbaccess/source/ui/querydesign/TableWindow.cxx
+++ b/dbaccess/source/ui/querydesign/TableWindow.cxx
@@ -89,7 +89,6 @@ void Draw3DBorder(vcl::RenderContext& rRenderContext, const tools::Rectangle& rR
OTableWindow::OTableWindow( vcl::Window* pParent, const TTableWindowData::value_type& pTabWinData )
: ::comphelper::OContainerListener(m_aMutex)
, Window( pParent, WB_3DLOOK|WB_MOVEABLE )
- , m_aTypeImage( VclPtr<FixedImage>::Create(this) )
, m_xTitle( VclPtr<OTableWindowTitle>::Create(this) )
, m_pData( pTabWinData )
, m_nMoveCount(0)
@@ -128,7 +127,6 @@ void OTableWindow::dispose()
if ( m_pContainerListener.is() )
m_pContainerListener->dispose();
- m_aTypeImage.disposeAndClear();
m_xTitle.disposeAndClear();
vcl::Window::dispose();
}
@@ -267,19 +265,10 @@ void OTableWindow::clearListBox()
void OTableWindow::impl_updateImage()
{
+ weld::Image& rImage = m_xTitle->GetImage();
ImageProvider aImageProvider( getDesignView()->getController().getConnection() );
-
- Image aImage;
- aImageProvider.getImages( GetComposedName(), m_pData->isQuery() ? DatabaseObject::QUERY : DatabaseObject::TABLE, aImage );
-
- if ( !aImage )
- {
- OSL_FAIL( "OTableWindow::impl_updateImage: no images!" );
- return;
- }
-
- m_aTypeImage->SetModeImage( aImage );
- m_aTypeImage->Show();
+ rImage.set_from_icon_name(aImageProvider.getImageId(GetComposedName(), m_pData->isQuery() ? DatabaseObject::QUERY : DatabaseObject::TABLE));
+ rImage.show();
}
bool OTableWindow::Init()
@@ -437,15 +426,10 @@ void OTableWindow::Resize()
tools::Long nPositionX = n5Pos;
tools::Long nPositionY = n5Pos;
- // position the image which indicates the type
- m_aTypeImage->SetPosPixel( Point( nPositionX, nPositionY ) );
- Size aImageSize( m_aTypeImage->GetImage().GetSizePixel() );
- m_aTypeImage->SetSizePixel( aImageSize );
-
- if ( nTitleHeight < aImageSize.Height() )
- nTitleHeight = aImageSize.Height();
+ Size aPreferredSize = m_xTitle->get_preferred_size();
+ if (nTitleHeight < aPreferredSize.Height())
+ nTitleHeight = aPreferredSize.Height();
- nPositionX += aImageSize.Width() + CalcZoom( 2 );
m_xTitle->SetPosSizePixel( Point( nPositionX, nPositionY ), Size( aOutSize.Width() - nPositionX - n5Pos, nTitleHeight ) );
tools::Long nTitleToList = CalcZoom( 3 );
diff --git a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx
index a2a569fc8679..3d625b8bb777 100644
--- a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx
+++ b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx
@@ -35,6 +35,7 @@ OTableWindowTitle::OTableWindowTitle(OTableWindow* pParent)
: InterimItemWindow(pParent, "dbaccess/ui/tabletitle.ui", "TableTitle")
, m_pTabWin( pParent )
, m_xLabel(m_xBuilder->weld_label("label"))
+ , m_xImage(m_xBuilder->weld_image("image"))
{
m_xLabel->connect_mouse_press(LINK(this, OTableWindowTitle, MousePressHdl));
}
@@ -46,6 +47,7 @@ OTableWindowTitle::~OTableWindowTitle()
void OTableWindowTitle::dispose()
{
+ m_xImage.reset();
m_xLabel.reset();
m_pTabWin.clear();
InterimItemWindow::dispose();