Skip to content

Commit

Permalink
SearchResultTab: small style fixes, sort headers
Browse files Browse the repository at this point in the history
  • Loading branch information
jackburton79 committed Dec 2, 2024
1 parent d1346e9 commit e8c7041
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 42 deletions.
80 changes: 43 additions & 37 deletions src/ui/SearchResultTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@


#include "SearchResultTab.h"
#include "SearchResultPanel.h"
#include <LayoutBuilder.h>

#include <Catalog.h>
#include <Button.h>
#include <LayoutBuilder.h>

#include "ActionManager.h"
#include "ConfigManager.h"
#include "GenioWindow.h"
#include "GenioWindowMessages.h"
#include "ProjectBrowser.h"
#include "SearchResultPanel.h"
#include "TextUtils.h"
#include "ConfigManager.h"
#include "ToolBar.h"
#include "ActionManager.h"


extern ConfigManager gCFG;
Expand All @@ -31,10 +33,11 @@ static constexpr uint32 kSelectProject ='PRJX';


SearchResultTab::SearchResultTab(BTabView* tabView)
: BGroupView(B_VERTICAL, 0.0f)
, fSearchResultPanel(nullptr)
, fTabView(tabView)
, fSelectedProject(nullptr)
:
BGroupView(B_VERTICAL, 0.0f),
fSearchResultPanel(nullptr),
fTabView(tabView),
fSelectedProject(nullptr)
{
fProjectMenu = new OptionList<ProjectFolder *>("ProjectMenu",
B_TRANSLATE("Project:"),
Expand Down Expand Up @@ -78,32 +81,35 @@ SearchResultTab::SearchResultTab(BTabView* tabView)
void
SearchResultTab::MessageReceived(BMessage *message)
{
switch (message->what) {
case kSelectProject: {
fSelectedProject = const_cast<ProjectFolder*>(
reinterpret_cast<const ProjectFolder*>(message->GetPointer("value")));
}
switch (message->what) {
case kSelectProject:
{
fSelectedProject = const_cast<ProjectFolder*>(
reinterpret_cast<const ProjectFolder*>(message->GetPointer("value")));
break;
}
case MSG_FIND_IN_FILES:
_StartSearch(fFindTextControl->Text(), (bool)fFindWholeWordCheck->Value(),
(bool)fFindCaseSensitiveCheck->Value(), fSelectedProject);
break;
case MSG_FIND_IN_FILES:
_StartSearch(fFindTextControl->Text(), (bool) fFindWholeWordCheck->Value(),
(bool) fFindCaseSensitiveCheck->Value(), fSelectedProject);
case B_OBSERVER_NOTICE_CHANGE:
{
int32 code;
if (message->FindInt32(B_OBSERVE_WHAT_CHANGE, &code) != B_OK)
break;
case B_OBSERVER_NOTICE_CHANGE: {
int32 code;
message->FindInt32(B_OBSERVE_WHAT_CHANGE, &code);
switch (code) {
case MSG_NOTIFY_PROJECT_LIST_CHANGED:
{
_UpdateProjectList(gMainWindow->GetProjectBrowser()->GetProjectList());
break;
}
default:
switch (code) {
case MSG_NOTIFY_PROJECT_LIST_CHANGED:
{
_UpdateProjectList(gMainWindow->GetProjectBrowser()->GetProjectList());
break;
}
default:
break;
}
break;
default:
BGroupView::MessageReceived(message);
}
default:
BGroupView::MessageReceived(message);
break;
}
}
Expand Down Expand Up @@ -144,7 +150,6 @@ SearchResultTab::_UpdateProjectList(const BObjectList<ProjectFolder>* list)
ProjectFolder* activeProject = gMainWindow->GetActiveProject();
ProjectFolder* selectedProject = fSelectedProject;


fProjectMenu->AddList(list,
kSelectProject,
[&active = activeProject](auto item)
Expand Down Expand Up @@ -175,21 +180,20 @@ SearchResultTab::~SearchResultTab()
void
SearchResultTab::SetAndStartSearch(BString text, bool wholeWord, bool caseSensitive, ProjectFolder* project)
{
if (!project)
if (project == nullptr)
return;

if (text.IsEmpty())
return;

BMenu* menu = fProjectMenu->Menu();

if (!menu)
if (menu == nullptr)
return;

if (project != fSelectedProject) {
for (int32 i=0;i<menu->CountItems();i++) {
for (int32 i = 0; i < menu->CountItems(); i++) {
BMessage* msg = menu->ItemAt(i)->Message();
if (msg && msg->GetPointer("value", nullptr) == project) {
if (msg != nullptr && msg->GetPointer("value", nullptr) == project) {
fSelectedProject = project;
menu->ItemAt(i)->SetMarked(true);
break;
Expand All @@ -206,10 +210,11 @@ SearchResultTab::SetAndStartSearch(BString text, bool wholeWord, bool caseSensit
_StartSearch(text, wholeWord, caseSensitive, project);
}


void
SearchResultTab::_StartSearch(BString text, bool wholeWord, bool caseSensitive, ProjectFolder* project)
{
if (!project)
if (project == nullptr)
return;

if (text.IsEmpty())
Expand All @@ -219,7 +224,7 @@ SearchResultTab::_StartSearch(BString text, bool wholeWord, bool caseSensitive,
if (wholeWord)
extraParameters += "w";

if (caseSensitive == false)
if (!caseSensitive)
extraParameters += "i";

text.CharacterEscape("\\\n\"", '\\');
Expand All @@ -244,10 +249,11 @@ SearchResultTab::_StartSearch(BString text, bool wholeWord, bool caseSensitive,
fSearchResultPanel->StartSearch(grepCommand, project->Path());
}


bool
SearchResultTab::_IsProjectInList(const BObjectList<ProjectFolder>* list, ProjectFolder* proj)
{
//Is the current selected project still in the new list?
// Is the current selected project still in the new list?
auto count = list->CountItems();
for (int index = 0; index < count; index++) {
ProjectFolder* element = list->ItemAt(index);
Expand Down
7 changes: 2 additions & 5 deletions src/ui/SearchResultTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
*/
#pragma once

#include <SupportDefs.h>
#include <CheckBox.h>
#include <GroupView.h>
#include <TabView.h>
#include <TextControl.h>
#include <CheckBox.h>

#include "SearchResultPanel.h"
#include "OptionList.h"
#include "ProjectFolder.h"
#include "SearchResultPanel.h"

class ToolBar;

Expand Down Expand Up @@ -40,5 +39,3 @@ class SearchResultTab : public BGroupView {
BCheckBox* fFindCaseSensitiveCheck;
BCheckBox* fFindWholeWordCheck;
};


0 comments on commit e8c7041

Please sign in to comment.