Kaydet (Commit) 470682b3 authored tarafından heiko tietze's avatar heiko tietze Kaydeden (comit) Michael Meeks

tdf#113831 Show number of search results

Skipped label used to show the number via resource strings

Change-Id: I6f57799565126c202041d0bf6a9f361d4e64cdfd
Reviewed-on: https://gerrit.libreoffice.org/45269Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 43dd18bf
......@@ -47,6 +47,8 @@
#define SCSTR_NO_TAB_BG_COLOR NC_("SCSTR_NO_TAB_BG_COLOR", "Default")
#define SCSTR_RENAMEOBJECT NC_("SCSTR_RENAMEOBJECT", "Name Object")
#define STR_INSERTGRAPHIC NC_("STR_INSERTGRAPHIC", "Insert Image")
#define SCSTR_TOTAL NC_("SCSTR_TOTAL", "%1 results found")
#define SCSTR_SKIPPED NC_("SCSTR_SKIPPED", "(only %1 are listed)")
// Attribute
#define SCSTR_PROTECTDOC NC_("SCSTR_PROTECTDOC", "Protect Document")
#define SCSTR_UNPROTECTDOC NC_("SCSTR_UNPROTECTDOC", "Unprotect document")
......
......@@ -25,9 +25,11 @@ namespace sc {
SearchResultsDlg::SearchResultsDlg( SfxBindings* _pBindings, vcl::Window* pParent ) :
ModelessDialog(pParent, "SearchResultsDialog", "modules/scalc/ui/searchresults.ui"),
aSkipped( ScResId( SCSTR_SKIPPED ) ),
aTotal( ScResId( SCSTR_TOTAL ) ),
mpBindings(_pBindings), mpDoc(nullptr)
{
get(mpLabel, "skipped");
get(mpSearchResults, "lbSearchResults");
SvSimpleTableContainer *pContainer = get<SvSimpleTableContainer>("results");
Size aControlSize(150, 120);
......@@ -50,23 +52,19 @@ SearchResultsDlg::~SearchResultsDlg()
void SearchResultsDlg::dispose()
{
mpList.disposeAndClear();
mpLabel.disposeAndClear();
mpSearchResults.disposeAndClear();
ModelessDialog::dispose();
}
namespace
{
class ListWrapper {
size_t mnCount;
static const size_t mnMaximum = 1000;
OUStringBuffer maName;
VclPtr<FixedText> mpLabel;
VclPtr<SvSimpleTable> mpList;
public:
ListWrapper(const VclPtr<SvSimpleTable> &pList,
const VclPtr<FixedText> &pLabel) :
mnCount(0),
mpLabel(pLabel),
size_t mnCount = 0;
static const size_t mnMaximum = 1000;
ListWrapper(const VclPtr<SvSimpleTable> &pList) :
mpList(pList)
{
mpList->Clear();
......@@ -88,33 +86,19 @@ namespace
mpList->InsertEntry(maName.makeStringAndClear());
}
}
void Update()
{
if (mnCount > mnMaximum)
{
if (mpLabel)
{
size_t nSkipped = mnCount - mnMaximum;
OUString aSkipped(mpLabel->GetText());
mpList->InsertEntry(
aSkipped.replaceFirst("$1", OUString::number(nSkipped)));
}
}
mpList->SetUpdateMode(true);
}
};
}
void SearchResultsDlg::FillResults( ScDocument* pDoc, const ScRangeList &rMatchedRanges, bool bCellNotes )
{
ListWrapper aList(mpList, mpLabel);
ListWrapper aList(mpList);
std::vector<OUString> aTabNames = pDoc->GetAllTableNames();
SCTAB nTabCount = aTabNames.size();
// tdf#92160 - too many results blow the widget's mind
size_t nMatchMax = rMatchedRanges.size();
if (nMatchMax > 1000)
nMatchMax = 1000;
if (nMatchMax > ListWrapper::mnMaximum)
nMatchMax = ListWrapper::mnMaximum;
if (bCellNotes)
{
......@@ -163,7 +147,14 @@ void SearchResultsDlg::FillResults( ScDocument* pDoc, const ScRangeList &rMatche
}
}
}
aList.Update();
OUString aSearchResults = ScGlobal::ReplaceOrAppend( aTotal, "%1", OUString::number( aList.mnCount ) );
if (aList.mnCount > ListWrapper::mnMaximum)
aSearchResults += " " + ScGlobal::ReplaceOrAppend( aSkipped, "%1", OUString::number( ListWrapper::mnMaximum ) );
mpSearchResults->SetText(aSearchResults);
mpList->SetUpdateMode(true);
mpDoc = pDoc;
}
......
......@@ -23,7 +23,9 @@ namespace sc {
class SearchResultsDlg : public ModelessDialog
{
VclPtr<SvSimpleTable> mpList;
VclPtr<FixedText> mpLabel;
VclPtr<FixedText> mpSearchResults;
OUString aSkipped;
OUString aTotal;
SfxBindings* mpBindings;
ScDocument* mpDoc;
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.1 -->
<interface domain="sc">
<!-- interface-requires LibreOffice 1.0 -->
<!-- interface-requires gtk+ 3.0 -->
<requires lib="gtk+" version="3.0"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkDialog" id="SearchResultsDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
......@@ -37,7 +38,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
<property name="position">2</property>
</packing>
</child>
<child>
......@@ -46,6 +47,9 @@
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
</object>
<packing>
<property name="expand">False</property>
......@@ -54,16 +58,25 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="skipped">
<property name="visible">False</property>
<object class="GtkLabel" id="lbSearchResults">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="searchresults|skipped">skipped $1 ...</property>
<property name="halign">start</property>
<property name="label"></property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">close</action-widget>
</action-widgets>
<child>
<placeholder/>
</child>
</object>
</interface>
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