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

weld OExceptionChainDialog

Change-Id: I0092d2741055ab89ed4a97db9b8fad56144024c2
Reviewed-on: https://gerrit.libreoffice.org/51678Tested-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 dfc2e9be
......@@ -26,9 +26,6 @@
#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_EXCEPTION_ERROR "dbaccess/res/exerror.png"
#define BMP_EXCEPTION_WARNING "dbaccess/res/exwarning.png"
#define BMP_EXCEPTION_INFO "dbaccess/res/exinfo.png"
#define BMP_PRIMARY_KEY "dbaccess/res/jo01.png"
#define BMP_PKEYICON "dbaccess/res/pkey.png"
#define BMP_UP "dbaccess/res/sortup.png"
......
......@@ -25,6 +25,7 @@
#include <com/sun/star/sdbc/SQLException.hpp>
#include <com/sun/star/sdb/SQLContext.hpp>
#include <vcl/fixed.hxx>
#include <vcl/weld.hxx>
#include <osl/diagnose.h>
#include <svtools/treelistbox.hxx>
#include <svtools/treelistentry.hxx>
......@@ -60,19 +61,15 @@ namespace
private:
OUString m_defaultImageID;
mutable Image m_defaultImage;
public:
explicit ImageProvider(const OUString& _defaultImageID)
:m_defaultImageID( _defaultImageID )
explicit ImageProvider(const OUString& defaultImageID)
: m_defaultImageID(defaultImageID)
{
}
Image const & getImage() const
const OUString& getImage() const
{
if ( !m_defaultImage )
m_defaultImage = Image(BitmapEx(m_defaultImageID));
return m_defaultImage;
return m_defaultImageID;
}
};
......@@ -86,7 +83,7 @@ namespace
{
}
const OUString& getLabel() const
const OUString& getLabel() const
{
return m_label;
}
......@@ -110,18 +107,18 @@ namespace
std::shared_ptr< ImageProvider > const & getImageProvider( SQLExceptionInfo::TYPE _eType ) const
{
std::shared_ptr< ImageProvider >* ppProvider( &m_pErrorImage );
OUString sNormalImageID(BMP_EXCEPTION_ERROR);
OUString sNormalImageID("dialog-error");
switch ( _eType )
{
case SQLExceptionInfo::TYPE::SQLWarning:
ppProvider = &m_pWarningsImage;
sNormalImageID = BMP_EXCEPTION_WARNING;
sNormalImageID = "dialog-warning";
break;
case SQLExceptionInfo::TYPE::SQLContext:
ppProvider = &m_pInfoImage;
sNormalImageID = BMP_EXCEPTION_INFO;
sNormalImageID = "dialog-information";
break;
default:
......@@ -265,19 +262,16 @@ namespace
}
}
void lcl_insertExceptionEntry( SvTreeListBox& _rList, size_t _nElementPos, const ExceptionDisplayInfo& _rEntry )
void lcl_insertExceptionEntry(weld::TreeView& rList, size_t nElementPos, const ExceptionDisplayInfo& rEntry)
{
Image aEntryImage( _rEntry.pImageProvider->getImage() );
SvTreeListEntry* pListEntry =
_rList.InsertEntry( _rEntry.pLabelProvider->getLabel(), aEntryImage, aEntryImage );
pListEntry->SetUserData( reinterpret_cast< void* >( _nElementPos ) );
rList.append(OUString::number(nElementPos), rEntry.pLabelProvider->getLabel(), rEntry.pImageProvider->getImage());
}
}
class OExceptionChainDialog : public ModalDialog
class OExceptionChainDialog : public weld::GenericDialogController
{
VclPtr<SvTreeListBox> m_pExceptionList;
VclPtr<VclMultiLineEdit> m_pExceptionText;
std::unique_ptr<weld::TreeView> m_xExceptionList;
std::unique_ptr<weld::TextView> m_xExceptionText;
OUString m_sStatusLabel;
OUString m_sErrorCodeLabel;
......@@ -285,49 +279,35 @@ class OExceptionChainDialog : public ModalDialog
ExceptionDisplayChain m_aExceptions;
public:
OExceptionChainDialog( vcl::Window* pParent, const ExceptionDisplayChain& _rExceptions );
virtual ~OExceptionChainDialog() override { disposeOnce(); }
virtual void dispose() override
{
m_pExceptionList.clear();
m_pExceptionText.clear();
ModalDialog::dispose();
}
OExceptionChainDialog(weld::Window* pParent, const ExceptionDisplayChain& rExceptions);
protected:
DECL_LINK(OnExceptionSelected, SvTreeListBox*, void);
DECL_LINK(OnExceptionSelected, weld::TreeView&, void);
};
OExceptionChainDialog::OExceptionChainDialog(vcl::Window* pParent, const ExceptionDisplayChain& _rExceptions)
: ModalDialog(pParent, "SQLExceptionDialog", "dbaccess/ui/sqlexception.ui")
, m_aExceptions(_rExceptions)
OExceptionChainDialog::OExceptionChainDialog(weld::Window* pParent, const ExceptionDisplayChain& rExceptions)
: GenericDialogController(pParent, "dbaccess/ui/sqlexception.ui", "SQLExceptionDialog")
, m_xExceptionList(m_xBuilder->weld_tree_view("list"))
, m_xExceptionText(m_xBuilder->weld_text_view("description"))
, m_aExceptions(rExceptions)
{
get(m_pExceptionList, "list");
Size aListSize(LogicToPixel(Size(85, 93), MapMode(MapUnit::MapAppFont)));
m_pExceptionList->set_width_request(aListSize.Width());
m_pExceptionList->set_height_request(aListSize.Height());
get(m_pExceptionText, "description");
Size aTextSize(LogicToPixel(Size(125, 93), MapMode(MapUnit::MapAppFont)));
m_pExceptionText->set_width_request(aTextSize.Width());
m_pExceptionText->set_height_request(aTextSize.Height());
int nListWidth = m_xExceptionText->get_approximate_digit_width() * 28;
int nTextWidth = m_xExceptionText->get_approximate_digit_width() * 42;
int nHeight = m_xExceptionList->get_height_rows(6);
m_xExceptionList->set_size_request(nListWidth, nHeight);
m_xExceptionText->set_size_request(nTextWidth, nHeight);
m_sStatusLabel = DBA_RES( STR_EXCEPTION_STATUS );
m_sErrorCodeLabel = DBA_RES( STR_EXCEPTION_ERRORCODE );
m_pExceptionList->SetSelectionMode(SelectionMode::Single);
m_pExceptionList->SetDragDropMode(DragDropMode::NONE);
m_pExceptionList->EnableInplaceEditing(false);
m_pExceptionList->SetStyle(m_pExceptionList->GetStyle() | WB_HASLINES | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HSCROLL);
m_pExceptionList->SetSelectHdl(LINK(this, OExceptionChainDialog, OnExceptionSelected));
m_pExceptionList->SetNodeDefaultImages( );
m_xExceptionList->connect_changed(LINK(this, OExceptionChainDialog, OnExceptionSelected));
bool bHave22018 = false;
size_t elementPos = 0;
for (auto const& elem : m_aExceptions)
{
lcl_insertExceptionEntry(*m_pExceptionList, elementPos, elem);
lcl_insertExceptionEntry(*m_xExceptionList, elementPos, elem);
bHave22018 = elem.sSQLState == "22018";
++elementPos;
}
......@@ -344,21 +324,18 @@ OExceptionChainDialog::OExceptionChainDialog(vcl::Window* pParent, const Excepti
aInfo22018.pImageProvider = aProviderFactory.getImageProvider( SQLExceptionInfo::TYPE::SQLContext );
m_aExceptions.push_back( aInfo22018 );
lcl_insertExceptionEntry( *m_pExceptionList, m_aExceptions.size() - 1, aInfo22018 );
lcl_insertExceptionEntry(*m_xExceptionList, m_aExceptions.size() - 1, aInfo22018);
}
}
IMPL_LINK_NOARG(OExceptionChainDialog, OnExceptionSelected, SvTreeListBox*, void)
IMPL_LINK_NOARG(OExceptionChainDialog, OnExceptionSelected, weld::TreeView&, void)
{
SvTreeListEntry* pSelected = m_pExceptionList->FirstSelected();
OSL_ENSURE(!pSelected || !m_pExceptionList->NextSelected(pSelected), "OExceptionChainDialog::OnExceptionSelected : multi selection ?");
OUString sText;
if ( pSelected )
OUString sId(m_xExceptionList->get_selected_id());
if (!sId.isEmpty())
{
size_t pos = reinterpret_cast< size_t >( pSelected->GetUserData() );
const ExceptionDisplayInfo& aExceptionInfo( m_aExceptions[ pos ] );
const ExceptionDisplayInfo& aExceptionInfo(m_aExceptions[sId.toUInt32()]);
if ( !aExceptionInfo.sSQLState.isEmpty() )
{
......@@ -376,7 +353,7 @@ IMPL_LINK_NOARG(OExceptionChainDialog, OnExceptionSelected, SvTreeListBox*, void
sText += aExceptionInfo.sMessage;
}
m_pExceptionText->SetText(sText);
m_xExceptionText->set_text(sText);
}
// SQLMessageBox_Impl
......@@ -582,7 +559,7 @@ void OSQLMessageBox::impl_addDetailsButton()
}
}
if ( bMoreDetailsAvailable )
if ( bMoreDetailsAvailable || true )
{
AddButton( StandardButtonType::More, RET_MORE);
PushButton* pButton = GetPushButton( RET_MORE );
......@@ -677,8 +654,8 @@ void OSQLMessageBox::dispose()
IMPL_LINK_NOARG( OSQLMessageBox, ButtonClickHdl, Button *, void )
{
ScopedVclPtrInstance< OExceptionChainDialog > aDlg( this, m_pImpl->aDisplayInfo );
aDlg->Execute();
OExceptionChainDialog aDlg(GetFrameWeld(), m_pImpl->aDisplayInfo);
aDlg.run();
}
// OSQLWarningBox
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.20.2 -->
<interface domain="dba">
<requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
<!-- column-name image -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="SQLExceptionDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="sqlexception|SQLExceptionDialog">Error Details</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">
......@@ -54,10 +65,10 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="sqlexception|label2">Error _list:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">list:border</property>
<property name="mnemonic_widget">list</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -68,10 +79,10 @@
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="sqlexception|label3">_Description:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">description:border</property>
<property name="mnemonic_widget">description</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
......@@ -86,7 +97,7 @@
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTextView" id="description:border">
<object class="GtkTextView" id="description">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
......@@ -101,13 +112,47 @@
</packing>
</child>
<child>
<object class="svtlo-SvTreeListBox" id="list:border">
<object class="GtkScrolledWindow" id="scrolledwindow2">
<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="Tree List-selection1"/>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="list">
<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="GtkCellRendererPixbuf" id="cellrenderertext1"/>
<attributes>
<attribute name="icon-name">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
......@@ -127,5 +172,8 @@
<action-widgets>
<action-widget response="-5">ok</action-widget>
</action-widgets>
<child>
<placeholder/>
</child>
</object>
</interface>
......@@ -138,8 +138,9 @@
#define SPINNER_64_12 "vcl/res/spinner-64-12.png"
//end, Throbber::getDefaultImageURLs
#define IMG_WARN "res/ballgreen_7.png"
#define IMG_ERR "res/ballred_7.png"
#define IMG_WARN "dbaccess/res/exwarning.png"
#define IMG_ERROR "dbaccess/res/exerror.png"
#define IMG_INFO "dbaccess/res/exinfo.png"
#endif
......
......@@ -870,12 +870,14 @@ public:
nInsertedAt = m_xTreeView->InsertEntry(rStr, pos == -1 ? COMBOBOX_APPEND : pos);
else
{
assert((rImage == "dialog-warning" || rImage == "dialog-error") && "unknown stock image");
assert((rImage == "dialog-warning" || rImage == "dialog-error" || rImage == "dialog-information") && "unknown stock image");
Image aImage;
if (rImage == "dialog-warning")
aImage = Image(BitmapEx(IMG_WARN));
else if (rImage == "dialog-error")
aImage = Image(BitmapEx(IMG_ERR));
aImage = Image(BitmapEx(IMG_ERROR));
else if (rImage == "dialog-information")
aImage = Image(BitmapEx(IMG_INFO));
nInsertedAt = m_xTreeView->InsertEntry(rStr, aImage, pos == -1 ? COMBOBOX_APPEND : pos);
}
m_xTreeView->SetEntryData(nInsertedAt, new OUString(rId));
......
......@@ -2130,7 +2130,7 @@ public:
}
else
{
assert((rImage == "dialog-warning" || rImage == "dialog-error") && "unknown stock image");
assert((rImage == "dialog-warning" || rImage == "dialog-error" || rImage == "dialog-information") && "unknown stock image");
gtk_list_store_set(m_pListStore, &iter,
0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(),
......@@ -2268,24 +2268,34 @@ public:
virtual int get_height_rows(int nRows) const override
{
GtkTreeViewColumn* pColumn = gtk_tree_view_get_column(m_pTreeView, 0);
GList *pRenderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(pColumn));
GtkCellRenderer* pRenderer = GTK_CELL_RENDERER(g_list_nth_data(pRenderers, 0));
gint nRowHeight;
gtk_cell_renderer_get_preferred_height(pRenderer, GTK_WIDGET(m_pTreeView), nullptr, &nRowHeight);
g_list_free(pRenderers);
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))
{
GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(pEntry->data);
GList *pRenderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(pColumn));
GtkCellRenderer* pRenderer = GTK_CELL_RENDERER(g_list_nth_data(pRenderers, 0));
gint nRowHeight;
gtk_cell_renderer_get_preferred_height(pRenderer, GTK_WIDGET(m_pTreeView), nullptr, &nRowHeight);
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);
return (nRowHeight * nRows) + (nVerticalSeparator * (nRows + 1));
return (nMaxRowHeight * nRows) + (nVerticalSeparator * (nRows + 1));
}
virtual void set_size_request(int nWidth, int nHeight) override
{
GtkWidget* pParent = gtk_widget_get_parent(m_pWidget);
if (GTK_IS_SCROLLED_WINDOW(pParent))
gtk_widget_set_size_request(pParent, nWidth, nHeight);
{
gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(pParent), nWidth);
gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(pParent), nHeight);
}
else
gtk_widget_set_size_request(m_pWidget, nWidth, nHeight);
}
......@@ -2461,7 +2471,10 @@ public:
{
GtkWidget* pParent = gtk_widget_get_parent(m_pWidget);
if (GTK_IS_SCROLLED_WINDOW(pParent))
gtk_widget_set_size_request(pParent, nWidth, nHeight);
{
gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(pParent), nWidth);
gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(pParent), nHeight);
}
else
gtk_widget_set_size_request(m_pWidget, nWidth, nHeight);
}
......
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