本文整理汇总了C++中SearchData::SetRootDirs方法的典型用法代码示例。如果您正苦于以下问题:C++ SearchData::SetRootDirs方法的具体用法?C++ SearchData::SetRootDirs怎么用?C++ SearchData::SetRootDirs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchData
的用法示例。
在下文中一共展示了SearchData::SetRootDirs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoGetSearchData
SearchData FindInFilesDialog::DoGetSearchData()
{
SearchData data;
wxString findStr(m_data.GetFindString());
if(m_findString->GetValue().IsEmpty() == false) {
findStr = m_findString->GetValue();
}
data.SetFindString(findStr);
m_data.SetFlags(GetSearchFlags());
size_t flags = m_data.GetFlags();
// If the 'Skip comments' is ON, remove the
// 'colour comments' flag
if(flags & wxFRD_SKIP_COMMENTS) {
flags &= ~wxFRD_COLOUR_COMMENTS;
}
data.SetMatchCase((flags & wxFRD_MATCHCASE) != 0);
data.SetMatchWholeWord((flags & wxFRD_MATCHWHOLEWORD) != 0);
data.SetRegularExpression((flags & wxFRD_REGULAREXPRESSION) != 0);
data.SetDisplayScope((flags & wxFRD_DISPLAYSCOPE) != 0);
data.SetEncoding(m_choiceEncoding->GetStringSelection());
data.SetSkipComments(flags & wxFRD_SKIP_COMMENTS);
data.SetSkipStrings(flags & wxFRD_SKIP_STRINGS);
data.SetColourComments(flags & wxFRD_COLOUR_COMMENTS);
wxArrayString searchWhere = m_listPaths->GetStrings();
wxArrayString files;
wxArrayString rootDirs;
for(size_t i = 0; i < searchWhere.GetCount(); ++i) {
const wxString& rootDir = searchWhere.Item(i);
// Check both translations and otherwise: the history may contain either
if((rootDir == wxGetTranslation(SEARCH_IN_WORKSPACE)) || (rootDir == SEARCH_IN_WORKSPACE)) {
ManagerST::Get()->GetWorkspaceFiles(files);
} else if((rootDir == wxGetTranslation(SEARCH_IN_PROJECT)) || (rootDir == SEARCH_IN_PROJECT)) {
ManagerST::Get()->GetActiveProjectFiles(files);
} else if((rootDir == wxGetTranslation(SEARCH_IN_CURR_FILE_PROJECT)) ||
(rootDir == SEARCH_IN_CURR_FILE_PROJECT)) {
ManagerST::Get()->GetActiveFileProjectFiles(files);
} else if((rootDir == wxGetTranslation(SEARCH_IN_CURRENT_FILE)) || (rootDir == SEARCH_IN_CURRENT_FILE)) {
LEditor* editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
if(editor) {
files.Add(editor->GetFileName().GetFullPath());
}
} else if((rootDir == wxGetTranslation(SEARCH_IN_OPEN_FILES)) || (rootDir == SEARCH_IN_OPEN_FILES)) {
std::vector<LEditor*> editors;
clMainFrame::Get()->GetMainBook()->GetAllEditors(editors, MainBook::kGetAll_IncludeDetached);
for(size_t n = 0; n < editors.size(); ++n) {
LEditor* editor = dynamic_cast<LEditor*>(*(editors.begin() + n));
if(editor) {
files.Add(editor->GetFileName().GetFullPath());
}
}
} else if(wxFileName::DirExists(searchWhere.Item(i))) {
rootDirs.Add(searchWhere.Item(i));
}
}
data.SetFiles(files); // list of files
data.SetRootDirs(rootDirs); // folders
data.UseNewTab(false);
data.SetExtensions(m_fileTypes->GetValue());
return data;
}
示例2: DoGetSearchData
SearchData FindInFilesDialog::DoGetSearchData()
{
SearchData data;
wxString findStr(m_data.GetFindString());
if(!m_findString->GetValue().IsEmpty()) {
findStr = m_findString->GetValue();
}
data.SetFindString(findStr);
data.SetReplaceWith(m_replaceString->GetValue());
m_data.SetFlags(GetSearchFlags());
size_t flags = m_data.GetFlags();
// If the 'Skip comments' is ON, remove the
// 'colour comments' flag
if(flags & wxFRD_SKIP_COMMENTS) {
flags &= ~wxFRD_COLOUR_COMMENTS;
}
data.SetMatchCase((flags & wxFRD_MATCHCASE) != 0);
data.SetMatchWholeWord((flags & wxFRD_MATCHWHOLEWORD) != 0);
data.SetRegularExpression((flags & wxFRD_REGULAREXPRESSION) != 0);
data.SetDisplayScope((flags & wxFRD_DISPLAYSCOPE) != 0);
data.SetEncoding(m_choiceEncoding->GetStringSelection());
data.SetSkipComments(flags & wxFRD_SKIP_COMMENTS);
data.SetSkipStrings(flags & wxFRD_SKIP_STRINGS);
data.SetColourComments(flags & wxFRD_COLOUR_COMMENTS);
data.SetEnablePipeSupport(flags & wxFRD_ENABLE_PIPE_SUPPORT);
wxArrayString searchWhere = m_listPaths->GetStrings();
wxArrayString files;
wxArrayString rootDirs;
for(size_t i = 0; i < searchWhere.GetCount(); ++i) {
const wxString& rootDir = searchWhere.Item(i);
// Check both translations and otherwise: the history may contain either
if((rootDir == wxGetTranslation(SEARCH_IN_WORKSPACE)) || (rootDir == SEARCH_IN_WORKSPACE)) {
if(!clWorkspaceManager::Get().IsWorkspaceOpened()) continue;
clWorkspaceManager::Get().GetWorkspace()->GetWorkspaceFiles(files);
} else if((rootDir == wxGetTranslation(SEARCH_IN_PROJECT)) || (rootDir == SEARCH_IN_PROJECT)) {
if(!clWorkspaceManager::Get().IsWorkspaceOpened()) continue;
if(clWorkspaceManager::Get().GetWorkspace()->IsProjectSupported()) {
// get the active project files
clWorkspaceManager::Get().GetWorkspace()->GetProjectFiles("", files);
} else {
// search the entire workspace
clWorkspaceManager::Get().GetWorkspace()->GetWorkspaceFiles(files);
}
} else if((rootDir == wxGetTranslation(SEARCH_IN_CURR_FILE_PROJECT)) ||
(rootDir == SEARCH_IN_CURR_FILE_PROJECT)) {
if(!clWorkspaceManager::Get().IsWorkspaceOpened()) continue;
IEditor* editor = clGetManager()->GetActiveEditor();
if(!editor) continue;
if(clWorkspaceManager::Get().GetWorkspace()->IsProjectSupported()) {
wxString projectName =
clWorkspaceManager::Get().GetWorkspace()->GetProjectFromFile(editor->GetFileName());
clWorkspaceManager::Get().GetWorkspace()->GetProjectFiles(projectName, files);
} else {
// search the entire workspace
clWorkspaceManager::Get().GetWorkspace()->GetWorkspaceFiles(files);
}
} else if((rootDir == wxGetTranslation(SEARCH_IN_CURRENT_FILE)) || (rootDir == SEARCH_IN_CURRENT_FILE)) {
LEditor* editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
if(editor) {
files.Add(editor->GetFileName().GetFullPath());
}
} else if((rootDir == wxGetTranslation(SEARCH_IN_OPEN_FILES)) || (rootDir == SEARCH_IN_OPEN_FILES)) {
std::vector<LEditor*> editors;
clMainFrame::Get()->GetMainBook()->GetAllEditors(editors, MainBook::kGetAll_IncludeDetached);
for(size_t n = 0; n < editors.size(); ++n) {
LEditor* editor = dynamic_cast<LEditor*>(*(editors.begin() + n));
if(editor) {
files.Add(editor->GetFileName().GetFullPath());
}
}
} else if(wxFileName::DirExists(searchWhere.Item(i))) {
rootDirs.Add(searchWhere.Item(i));
}
}
// Remove duplicates
wxStringSet_t filesSet;
wxArrayString uniqueFiles;
std::for_each(files.begin(), files.end(), [&](const wxString& file) {
if(filesSet.count(file) == 0) {
filesSet.insert(file);
uniqueFiles.Add(file);
}
});
files.swap(uniqueFiles);
data.SetFiles(files); // list of files
data.SetRootDirs(rootDirs); // folders
//.........这里部分代码省略.........