weld rows menu
Change-Id: I0dd56e2c236b15b057ddd0f2d93019b783d457d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111218 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
@@ -29,8 +29,6 @@
|
||||
|
||||
#define HID_BROWSER_COLUMNFORMAT "DBACCESS_HID_BROWSER_COLUMNFORMAT"
|
||||
#define HID_BROWSER_COLUMNWIDTH "DBACCESS_HID_BROWSER_COLUMNWIDTH"
|
||||
#define HID_BROWSER_TABLEFORMAT "DBACCESS_HID_BROWSER_TABLEFORMAT"
|
||||
#define HID_BROWSER_ROWHEIGHT "DBACCESS_HID_BROWSER_ROWHEIGHT"
|
||||
|
||||
#define HID_CTL_QRYSQLEDIT "DBACCESS_HID_CTL_QRYSQLEDIT"
|
||||
|
||||
|
||||
@@ -666,7 +666,7 @@ CellController* SbaGridControl::GetController(sal_Int32 nRow, sal_uInt16 nCol)
|
||||
return FmGridControl::GetController(nRow, nCol);
|
||||
}
|
||||
|
||||
void SbaGridControl::PreExecuteRowContextMenu(PopupMenu& rMenu)
|
||||
void SbaGridControl::PreExecuteRowContextMenu(weld::Menu& rMenu)
|
||||
{
|
||||
FmGridControl::PreExecuteRowContextMenu(rMenu);
|
||||
|
||||
@@ -674,18 +674,18 @@ void SbaGridControl::PreExecuteRowContextMenu(PopupMenu& rMenu)
|
||||
|
||||
if (!IsReadOnlyDB())
|
||||
{
|
||||
rMenu.InsertItem(ID_BROWSER_TABLEATTR, DBA_RES(RID_STR_TABLE_FORMAT), MenuItemBits::NONE, OString(), nPos++);
|
||||
rMenu.SetHelpId(ID_BROWSER_TABLEATTR, HID_BROWSER_TABLEFORMAT);
|
||||
|
||||
rMenu.InsertItem(ID_BROWSER_ROWHEIGHT, DBA_RES(RID_STR_ROW_HEIGHT), MenuItemBits::NONE, OString(), nPos++);
|
||||
rMenu.SetHelpId(ID_BROWSER_ROWHEIGHT, HID_BROWSER_ROWHEIGHT);
|
||||
rMenu.InsertSeparator(OString(), nPos++);
|
||||
rMenu.insert(nPos++, "tableattr", DBA_RES(RID_STR_TABLE_FORMAT),
|
||||
nullptr, nullptr, nullptr, TRISTATE_INDET);
|
||||
rMenu.insert(nPos++, "rowheight", DBA_RES(RID_STR_ROW_HEIGHT),
|
||||
nullptr, nullptr, nullptr, TRISTATE_INDET);
|
||||
rMenu.insert_separator(nPos++, "separator1");
|
||||
}
|
||||
|
||||
if ( GetSelectRowCount() > 0 )
|
||||
{
|
||||
rMenu.InsertItem(ID_BROWSER_COPY, DBA_RES(RID_STR_COPY), MenuItemBits::NONE, OString(), nPos++);
|
||||
rMenu.InsertSeparator(OString(), nPos++);
|
||||
rMenu.insert(nPos++, "copy", DBA_RES(RID_STR_COPY),
|
||||
nullptr, nullptr, nullptr, TRISTATE_INDET);
|
||||
rMenu.insert_separator(nPos++, "separator2");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -821,24 +821,16 @@ void SbaGridControl::SetBrowserAttrs()
|
||||
}
|
||||
}
|
||||
|
||||
void SbaGridControl::PostExecuteRowContextMenu(const PopupMenu& rMenu, sal_uInt16 nExecutionResult)
|
||||
void SbaGridControl::PostExecuteRowContextMenu(const OString& rExecutionResult)
|
||||
{
|
||||
switch (nExecutionResult)
|
||||
{
|
||||
case ID_BROWSER_TABLEATTR:
|
||||
SetBrowserAttrs();
|
||||
break;
|
||||
case ID_BROWSER_ROWHEIGHT:
|
||||
SetRowHeight();
|
||||
break;
|
||||
case ID_BROWSER_COPY:
|
||||
CopySelectedRowsToClipboard();
|
||||
break;
|
||||
|
||||
default:
|
||||
FmGridControl::PostExecuteRowContextMenu(rMenu, nExecutionResult);
|
||||
break;
|
||||
}
|
||||
if (rExecutionResult == "tableattr")
|
||||
SetBrowserAttrs();
|
||||
else if (rExecutionResult == "rowheight")
|
||||
SetRowHeight();
|
||||
else if (rExecutionResult == "copy")
|
||||
CopySelectedRowsToClipboard();
|
||||
else
|
||||
FmGridControl::PostExecuteRowContextMenu(rExecutionResult);
|
||||
}
|
||||
|
||||
void SbaGridControl::Select()
|
||||
|
||||
@@ -252,8 +252,8 @@ namespace dbaui
|
||||
virtual ::svt::CellController* GetController(sal_Int32 nRow, sal_uInt16 nCol) override;
|
||||
|
||||
// DbGridControl overridables
|
||||
virtual void PreExecuteRowContextMenu(PopupMenu& rMenu) override;
|
||||
virtual void PostExecuteRowContextMenu(const PopupMenu& rMenu, sal_uInt16 nExecutionResult) override;
|
||||
virtual void PreExecuteRowContextMenu(weld::Menu& rMenu) override;
|
||||
virtual void PostExecuteRowContextMenu(const OString& rExecutionResult) override;
|
||||
|
||||
// DbGridControl overridables
|
||||
virtual void onRowChange() override;
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace com::sun::star::beans { class XPropertySet; }
|
||||
namespace com::sun::star::container { class XIndexContainer; }
|
||||
namespace com::sun::star::container { class XNameAccess; }
|
||||
|
||||
class PopupMenu;
|
||||
|
||||
// FmGridHeader
|
||||
|
||||
struct FmGridHeaderData;
|
||||
|
||||
@@ -37,9 +37,9 @@ namespace com::sun::star::sdbc { class XRowSet; }
|
||||
namespace com::sun::star::sdb { class XRowsChangeListener; }
|
||||
namespace com::sun::star::uno { class XComponentContext; }
|
||||
namespace com::sun::star::util { class XNumberFormatter; }
|
||||
namespace weld { class Menu; }
|
||||
|
||||
class CursorWrapper;
|
||||
class PopupMenu;
|
||||
|
||||
bool CompareBookmark(const css::uno::Any& aLeft, const css::uno::Any& aRight);
|
||||
|
||||
@@ -345,10 +345,10 @@ protected:
|
||||
All disabled entries will be removed before executing the menu, so be careful with separators
|
||||
near entries you probably wish to disable ...
|
||||
*/
|
||||
virtual void PreExecuteRowContextMenu(PopupMenu& rMenu);
|
||||
virtual void PreExecuteRowContextMenu(weld::Menu& rMenu);
|
||||
/** After executing the context menu for a row this method is called.
|
||||
*/
|
||||
virtual void PostExecuteRowContextMenu(const PopupMenu& rMenu, sal_uInt16 nExecutionResult);
|
||||
virtual void PostExecuteRowContextMenu(const OString& rExecutionResult);
|
||||
|
||||
/// @throws css::uno::RuntimeException
|
||||
void DataSourcePropertyChanged(const css::beans::PropertyChangeEvent& evt);
|
||||
|
||||
@@ -43,11 +43,11 @@
|
||||
#include <com/sun/star/container/XIndexAccess.hpp>
|
||||
#include <tools/diagnose_ex.h>
|
||||
#include <tools/debug.hxx>
|
||||
#include <vcl/builder.hxx>
|
||||
#include <vcl/menu.hxx>
|
||||
#include <vcl/settings.hxx>
|
||||
#include <vcl/commandevent.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
#include <vcl/weld.hxx>
|
||||
#include <vcl/weldutils.hxx>
|
||||
|
||||
#include <svx/strings.hrc>
|
||||
|
||||
@@ -2408,14 +2408,14 @@ sal_uInt32 DbGridControl::GetTotalCellWidth(sal_Int32 nRow, sal_uInt16 nColId)
|
||||
return 30; // FIXME magic number for default cell width
|
||||
}
|
||||
|
||||
void DbGridControl::PreExecuteRowContextMenu(PopupMenu& rMenu)
|
||||
void DbGridControl::PreExecuteRowContextMenu(weld::Menu& rMenu)
|
||||
{
|
||||
bool bDelete = (m_nOptions & DbGridControlOptions::Delete) && GetSelectRowCount() && !IsCurrentAppending();
|
||||
// if only a blank row is selected then do not delete
|
||||
bDelete = bDelete && !((m_nOptions & DbGridControlOptions::Insert) && GetSelectRowCount() == 1 && IsRowSelected(GetRowCount() - 1));
|
||||
|
||||
rMenu.EnableItem(rMenu.GetItemId("delete"), bDelete);
|
||||
rMenu.EnableItem(rMenu.GetItemId("save"), IsModified());
|
||||
rMenu.set_visible("delete", bDelete);
|
||||
rMenu.set_visible("save", IsModified());
|
||||
|
||||
// the undo is more difficult
|
||||
bool bCanUndo = IsModified();
|
||||
@@ -2424,21 +2424,21 @@ void DbGridControl::PreExecuteRowContextMenu(PopupMenu& rMenu)
|
||||
nState = m_aMasterStateProvider.Call(DbGridControlNavigationBarState::Undo);
|
||||
bCanUndo &= ( 0 != nState );
|
||||
|
||||
rMenu.EnableItem(rMenu.GetItemId("undo"), bCanUndo);
|
||||
rMenu.set_visible("undo", bCanUndo);
|
||||
}
|
||||
|
||||
void DbGridControl::PostExecuteRowContextMenu(const PopupMenu& rMenu, sal_uInt16 nExecutionResult)
|
||||
void DbGridControl::PostExecuteRowContextMenu(const OString& rExecutionResult)
|
||||
{
|
||||
if (nExecutionResult == rMenu.GetItemId("delete"))
|
||||
if (rExecutionResult == "delete")
|
||||
{
|
||||
// delete asynchronously
|
||||
if (m_nDeleteEvent)
|
||||
Application::RemoveUserEvent(m_nDeleteEvent);
|
||||
m_nDeleteEvent = Application::PostUserEvent(LINK(this,DbGridControl,OnDelete), nullptr, true);
|
||||
}
|
||||
else if (nExecutionResult == rMenu.GetItemId("undo"))
|
||||
else if (rExecutionResult == "undo")
|
||||
Undo();
|
||||
else if (nExecutionResult == rMenu.GetItemId("save"))
|
||||
else if (rExecutionResult == "save")
|
||||
SaveRow();
|
||||
}
|
||||
|
||||
@@ -2531,12 +2531,14 @@ void DbGridControl::copyCellText(sal_Int32 _nRow, sal_uInt16 _nColId)
|
||||
|
||||
void DbGridControl::executeRowContextMenu(const Point& _rPreferredPos)
|
||||
{
|
||||
VclBuilder aBuilder(nullptr, AllSettings::GetUIRootDir(), "svx/ui/rowsmenu.ui", "");
|
||||
VclPtr<PopupMenu> aContextMenu(aBuilder.get_menu("menu"));
|
||||
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "svx/ui/rowsmenu.ui"));
|
||||
std::unique_ptr<weld::Menu> xContextMenu(xBuilder->weld_menu("menu"));
|
||||
|
||||
PreExecuteRowContextMenu(*aContextMenu );
|
||||
aContextMenu->RemoveDisabledEntries( true, true );
|
||||
PostExecuteRowContextMenu(*aContextMenu, aContextMenu->Execute(this, _rPreferredPos));
|
||||
tools::Rectangle aRect(_rPreferredPos, Size(1,1));
|
||||
weld::Window* pParent = weld::GetPopupParent(*this, aRect);
|
||||
|
||||
PreExecuteRowContextMenu(*xContextMenu);
|
||||
PostExecuteRowContextMenu(xContextMenu->popup_at_rect(pParent, aRect));
|
||||
}
|
||||
|
||||
void DbGridControl::Command(const CommandEvent& rEvt)
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <vcl/event.hxx>
|
||||
#include <vcl/fieldvalues.hxx>
|
||||
#include <vcl/status.hxx>
|
||||
#include <vcl/menu.hxx>
|
||||
#include <vcl/image.hxx>
|
||||
#include <vcl/settings.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
|
||||
@@ -1,65 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.20.0 -->
|
||||
<!-- Generated with glade 3.38.2 -->
|
||||
<interface domain="svx">
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkMenu" id="menu">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkCheckMenuItem" id="avg">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="functionmenu|avg">Average</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckMenuItem" id="counta">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="functionmenu|counta">CountA</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckMenuItem" id="count">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="functionmenu|count">Count</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckMenuItem" id="max">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="functionmenu|max">Maximum</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckMenuItem" id="min">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="functionmenu|min">Minimum</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckMenuItem" id="sum">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="functionmenu|sum">Sum</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckMenuItem" id="selection">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="functionmenu|selection">Selection count</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckMenuItem" id="none">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="functionmenu|none">None</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
@@ -1,29 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.20.0 -->
|
||||
<!-- Generated with glade 3.38.2 -->
|
||||
<interface domain="svx">
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkMenu" id="menu">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="delete">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="rowsmenu|delete">Delete Rows</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="save">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="rowsmenu|save">Save Record</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="undo">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="rowsmenu|undo">Undo: Data entry</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
Reference in New Issue
Block a user