summaryrefslogtreecommitdiff
path: root/sw/source/ui/misc
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-05-01 13:59:51 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2017-05-01 17:18:46 +0200
commit1c8d6e6ec2ae3e5ee38ab343b662db30f48fc7f5 (patch)
treecdb7f65a38fc4358801d5ab6b095d72989a44a8e /sw/source/ui/misc
parent7ab811b05e72a6ede72161c3e8b429424318bd29 (diff)
AutoText: handle Delete key in the dialog
Change-Id: Ifbd0026b097ff9fbf077dda57f874cfc59da3e45 Reviewed-on: https://gerrit.libreoffice.org/37119 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sw/source/ui/misc')
-rw-r--r--sw/source/ui/misc/glossary.cxx59
1 files changed, 42 insertions, 17 deletions
diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx
index 192b407be077..a19a96e61bb4 100644
--- a/sw/source/ui/misc/glossary.cxx
+++ b/sw/source/ui/misc/glossary.cxx
@@ -230,6 +230,7 @@ SwGlossaryDlg::SwGlossaryDlg(SfxViewFrame* pViewFrame,
m_pCategoryBox->SetDoubleClickHdl(LINK(this,SwGlossaryDlg, NameDoubleClick));
m_pCategoryBox->SetSelectHdl(LINK(this,SwGlossaryDlg,GrpSelect));
+ m_pCategoryBox->SetDeleteHdl(LINK(this,SwGlossaryDlg,DeleteHdl));
m_pBibBtn->SetClickHdl(LINK(this,SwGlossaryDlg,BibHdl));
m_pInsertBtn->SetClickHdl(LINK(this,SwGlossaryDlg,InsertHdl));
@@ -522,23 +523,7 @@ IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn, bool )
}
else if (sItemIdent == "delete")
{
- ScopedVclPtrInstance< MessageDialog > aQuery(this, SW_RES(STR_QUERY_DELETE), VclMessageType::Question, VclButtonsType::YesNo);
- if (RET_YES == aQuery->Execute())
- {
- const OUString aShortName(m_pShortNameEdit->GetText());
- const OUString aTitle(m_pNameED->GetText());
- if (!aTitle.isEmpty() && pGlossaryHdl->DelGlossary(aShortName))
- {
- SvTreeListEntry* pChild = DoesBlockExist(aTitle, aShortName);
- OSL_ENSURE(pChild, "entry not found!");
- SvTreeListEntry* pParent = m_pCategoryBox->GetParent(pChild);
- m_pCategoryBox->Select(pParent);
-
- m_pCategoryBox->GetModel()->Remove(pChild);
- m_pNameED->SetText(OUString());
- NameModify(*m_pNameED);
- }
- }
+ DeleteEntry();
}
else if (sItemIdent == "macro")
{
@@ -1028,6 +1013,16 @@ void SwGlTreeListBox::ExpandedHdl()
SvTreeListBox::ExpandedHdl();
}
+void SwGlTreeListBox::KeyInput( const KeyEvent& rKEvt )
+{
+ if(m_aDeleteHdl.IsSet() && rKEvt.GetKeyCode().GetCode() == KEY_DELETE)
+ {
+ m_aDeleteHdl.Call(nullptr);
+ return;
+ }
+ SvTreeListBox::KeyInput( rKEvt );
+}
+
OUString SwGlossaryDlg::GetCurrGrpName() const
{
SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
@@ -1069,6 +1064,11 @@ IMPL_LINK_NOARG(SwGlossaryDlg, InsertHdl, Button*, void)
EndDialog(RET_OK);
}
+IMPL_LINK_NOARG(SwGlossaryDlg, DeleteHdl, SwGlTreeListBox*, void)
+{
+ DeleteEntry();
+}
+
void SwGlossaryDlg::ShowPreview()
{
//create example
@@ -1130,4 +1130,29 @@ void SwGlossaryDlg::ResumeShowAutoText()
bResume = false;
}
+void SwGlossaryDlg::DeleteEntry()
+{
+ SvTreeListEntry* pEntry = m_pCategoryBox->FirstSelected();
+
+ const OUString aTitle(m_pNameED->GetText());
+ const OUString aShortName(m_pShortNameEdit->GetText());
+ SvTreeListEntry* pChild = DoesBlockExist(aTitle, aShortName);
+ SvTreeListEntry* pParent = pChild ? m_pCategoryBox->GetParent(pChild) : nullptr;
+ const bool bExists = nullptr != pChild;
+ const bool bIsGroup = pEntry && !pParent;
+
+ ScopedVclPtrInstance< MessageDialog > aQuery(this, SW_RES(STR_QUERY_DELETE), VclMessageType::Question, VclButtonsType::YesNo);
+ if (bExists && !bIsGroup && RET_YES == aQuery->Execute())
+ {
+ if (!aTitle.isEmpty() && pGlossaryHdl->DelGlossary(aShortName))
+ {
+ OSL_ENSURE(pChild, "entry not found!");
+ m_pCategoryBox->Select(pParent);
+ m_pCategoryBox->GetModel()->Remove(pChild);
+ m_pNameED->SetText(OUString());
+ NameModify(*m_pNameED);
+ }
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */