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

test
Marc Zinnschlag 10 years ago
parent 2ef8103cc7
commit dab650a3d5

@ -220,7 +220,10 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
"Characters after search string"); "Characters after search string");
after->setDefaultValue (10); after->setDefaultValue (10);
after->setRange (0, 1000); after->setRange (0, 1000);
after->setToolTip ("Maximum number of character to display in search result after the searched text"); 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/search.hpp"
#include "../../model/tools/reportmodel.hpp" #include "../../model/tools/reportmodel.hpp"
#include "../../model/world/idtablebase.hpp" #include "../../model/world/idtablebase.hpp"
#include "../../model/settings/usersettings.hpp"
#include "reporttable.hpp" #include "reporttable.hpp"
#include "searchbox.hpp" #include "searchbox.hpp"
@ -22,7 +23,10 @@ void CSVTools::SearchSubView::replace (bool selection)
const CSMTools::ReportModel& model = const CSMTools::ReportModel& model =
dynamic_cast<const CSMTools::ReportModel&> (*mTable->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 // We are running through the indices in reverse order to avoid messing up multiple results
// in a single string. // in a single string.
for (std::vector<int>::const_reverse_iterator iter (indices.rbegin()); iter!=indices.rend(); ++iter) 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); mSearch.replace (mDocument, table, id, hint, replace);
mTable->flagAsReplaced (*iter); mTable->flagAsReplaced (*iter);
if (autoDelete)
mTable->model()->removeRows (*iter, 1);
} }
} }

Loading…
Cancel
Save