remove rows from result table after a successful replace (configurable via user settings)

test
Marc Zinnschlag 10 years ago
parent 2ef8103cc7
commit dab650a3d5

@ -221,6 +221,9 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
after->setDefaultValue (10);
after->setRange (0, 1000);
after->setToolTip ("Maximum number of character to display in search result after the searched text");
Setting *autoDelete = createSetting (Type_CheckBox, "auto-delete", "Delete row from result table after a successful replace");
autoDelete->setDefaultValue ("true");
}
{

@ -7,6 +7,7 @@
#include "../../model/tools/search.hpp"
#include "../../model/tools/reportmodel.hpp"
#include "../../model/world/idtablebase.hpp"
#include "../../model/settings/usersettings.hpp"
#include "reporttable.hpp"
#include "searchbox.hpp"
@ -23,6 +24,9 @@ void CSVTools::SearchSubView::replace (bool selection)
const CSMTools::ReportModel& model =
dynamic_cast<const CSMTools::ReportModel&> (*mTable->model());
bool autoDelete = CSMSettings::UserSettings::instance().setting (
"search/auto-delete", QString ("true"))=="true";
// We are running through the indices in reverse order to avoid messing up multiple results
// in a single string.
for (std::vector<int>::const_reverse_iterator iter (indices.rbegin()); iter!=indices.rend(); ++iter)
@ -38,6 +42,9 @@ void CSVTools::SearchSubView::replace (bool selection)
mSearch.replace (mDocument, table, id, hint, replace);
mTable->flagAsReplaced (*iter);
if (autoDelete)
mTable->model()->removeRows (*iter, 1);
}
}

Loading…
Cancel
Save