TextSearch: Add "Clear history" menu item
Sometimes it's good to go back to a clean slate… Change-Id: I6252b42c948b1fa9cbe786104a191fb0d4e629c0 Reviewed-on: https://review.haiku-os.org/c/haiku/+/9306 Reviewed-by: waddlesplash <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
@@ -208,6 +208,13 @@ void GrepWindow::FrameMoved(BPoint origin)
|
||||
void GrepWindow::MenusBeginning()
|
||||
{
|
||||
fModel->FillHistoryMenu(fHistoryMenu);
|
||||
|
||||
if (fHistoryMenu->CountItems() > 0) {
|
||||
fHistoryMenu->AddSeparatorItem();
|
||||
BMessage* message = new BMessage(MSG_CLEAR_HISTORY);
|
||||
fHistoryMenu->AddItem(new BMenuItem(B_TRANSLATE("Clear history"), message));
|
||||
}
|
||||
|
||||
BWindow::MenusBeginning();
|
||||
}
|
||||
|
||||
@@ -329,6 +336,11 @@ void GrepWindow::MessageReceived(BMessage* message)
|
||||
_OnSearchText();
|
||||
break;
|
||||
}
|
||||
|
||||
case MSG_CLEAR_HISTORY:
|
||||
fModel->ClearHistory();
|
||||
break;
|
||||
|
||||
case MSG_START_CANCEL:
|
||||
_OnStartCancel();
|
||||
break;
|
||||
|
||||
@@ -207,6 +207,20 @@ Model::AddToHistory(const char* text)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Model::ClearHistory()
|
||||
{
|
||||
BList items;
|
||||
if (!_LoadHistory(items))
|
||||
return;
|
||||
|
||||
items.RemoveItems(0, items.CountItems());
|
||||
|
||||
_SaveHistory(items);
|
||||
_FreeHistory(items);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Model::FillHistoryMenu(BMenu* menu) const
|
||||
{
|
||||
|
||||
@@ -33,6 +33,7 @@ enum {
|
||||
MSG_SELECT_HISTORY,
|
||||
MSG_PREV_HISTORY,
|
||||
MSG_NEXT_HISTORY,
|
||||
MSG_CLEAR_HISTORY,
|
||||
MSG_NODE_MONITOR_PULSE,
|
||||
MSG_START_NODE_MONITORING,
|
||||
|
||||
@@ -70,6 +71,7 @@ public:
|
||||
status_t SavePrefs();
|
||||
|
||||
void AddToHistory(const char* text);
|
||||
void ClearHistory();
|
||||
void FillHistoryMenu(BMenu* menu) const;
|
||||
BString GetHistoryItem(int32 index);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user