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