Files
UnrealEngineUWP/Engine/Source/Developer/SuperSearch/Private/SuperSearchModule.cpp
Ben Marsh 20bf0eb6a1 Updating copyright notices to 2017 (copying from //Tasks/UE4/Dev-Copyright-2017).
#rb none
#lockdown Nick.Penwarden

[CL 3226823 by Ben Marsh in Main branch]
2016-12-08 08:52:44 -05:00

73 lines
1.7 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "SuperSearchModule.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Application/SlateWindowHelper.h"
#include "SSuperSearch.h"
IMPLEMENT_MODULE( FSuperSearchModule,SuperSearch );
namespace SuperSearchModule
{
static const FName FNameSuperSearchApp = FName(TEXT("SuperSearchApp"));
}
FSearchEntry * FSearchEntry::MakeCategoryEntry(const FString & InTitle)
{
FSearchEntry * SearchEntry = new FSearchEntry();
SearchEntry->Title = InTitle;
SearchEntry->bCategory = true;
return SearchEntry;
}
FSuperSearchModule::FSuperSearchModule()
: SearchEngine(ESearchEngine::Google)
{
}
void FSuperSearchModule::StartupModule()
{
}
void FSuperSearchModule::ShutdownModule()
{
}
void FSuperSearchModule::SetSearchEngine(ESearchEngine InSearchEngine)
{
SearchEngine = InSearchEngine;
for ( TWeakPtr<SSuperSearchBox>& SearchBoxPtr : SuperSearchBoxes )
{
TSharedPtr<SSuperSearchBox> SearchBox = SearchBoxPtr.Pin();
if ( SearchBox.IsValid() )
{
SearchBox->SetSearchEngine(SearchEngine);
}
}
}
TSharedRef< SWidget > FSuperSearchModule::MakeSearchBox(TSharedPtr< SEditableTextBox >& OutExposedEditableTextBox, const TOptional<const FSuperSearchStyle*> InStyle) const
{
// Remove any search box that has expired.
for ( int32 i = SuperSearchBoxes.Num() - 1; i >= 0; i-- )
{
if ( !SuperSearchBoxes[i].IsValid() )
{
SuperSearchBoxes.RemoveAtSwap(i);
}
}
TSharedRef< SSuperSearchBox > NewSearchBox =
SNew(SSuperSearchBox)
.Style(InStyle)
.SearchEngine(SearchEngine);
OutExposedEditableTextBox = NewSearchBox->GetEditableTextBox();
SuperSearchBoxes.Add(NewSearchBox);
return NewSearchBox;
}