void OpenResourceDialog::DoPopulateTags()
{
    bool gotExactMatch(false);

    // Next, add the tags
    TagEntryPtrVector_t tags;
    if(m_userFilters.IsEmpty()) return;

    m_manager->GetTagsManager()->GetTagsByPartialName(m_userFilters.Item(0), tags);

    for(size_t i = 0; i < tags.size(); i++) {
        TagEntryPtr tag = tags.at(i);

        // Filter out non relevanting entries
        if(!m_filters.IsEmpty() && m_filters.Index(tag->GetKind()) == wxNOT_FOUND) continue;

        if(!MatchesFilter(tag->GetName())) continue;

        wxString name(tag->GetName());

        // keep the fullpath
        wxDataViewItem item;
        wxString fullname;
        if(tag->GetKind() == wxT("function") || tag->GetKind() == wxT("prototype")) {
            fullname = wxString::Format(
                wxT("%s::%s%s"), tag->GetScope().c_str(), tag->GetName().c_str(), tag->GetSignature().c_str());
            item = DoAppendLine(tag->GetName(),
                                fullname,
                                (tag->GetKind() == wxT("function")),
                                new OpenResourceDialogItemData(
                                    tag->GetFile(), tag->GetLine(), tag->GetPattern(), tag->GetName(), tag->GetScope()),
                                DoGetTagImg(tag));
        } else {

            fullname = wxString::Format(wxT("%s::%s"), tag->GetScope().c_str(), tag->GetName().c_str());
            item = DoAppendLine(tag->GetName(),
                                fullname,
                                false,
                                new OpenResourceDialogItemData(
                                    tag->GetFile(), tag->GetLine(), tag->GetPattern(), tag->GetName(), tag->GetScope()),
                                DoGetTagImg(tag));
        }

        if((m_userFilters.GetCount() == 1) && (m_userFilters.Item(0).CmpNoCase(name) == 0) && !gotExactMatch) {
            gotExactMatch = true;
            DoSelectItem(item);
        }
    }
}
Ejemplo n.º 2
0
void OpenResourceDialog::DoPopulateWorkspaceFile()
{
	wxArrayString tmpArr;
	wxString curSel = m_textCtrlResourceName->GetValue();
	if (!curSel.Trim().Trim(false).IsEmpty()) {

		curSel = curSel.MakeLower().Trim().Trim(false);

		for (size_t i=0; i<m_files.GetCount(); i++) {
			wxString fileName(m_files.Item(i));
			wxString fileNameOnly(wxFileName(fileName).GetFullName());

			fileNameOnly.MakeLower();

			//append wildcard at the end
			if (!curSel.EndsWith(wxT("*"))) {
				curSel << wxT("*");
			}

			// FR# [2008133]
			if (m_checkBoxUsePartialMatching->IsChecked() && !curSel.StartsWith(wxT("*"))) {
				curSel.Prepend(wxT("*"));
			}

			if (wxMatchWild(curSel, fileNameOnly)) {
				// keep the fullpath
				tmpArr.Add(m_files.Item(i));
			}
		}
	}

	// Change was done, update the file list
	for (size_t i=0; i<tmpArr.GetCount(); i++) {
		wxFileName fn(tmpArr.Item(i));
		DoAppendLine(fn.GetFullName(), fn.GetFullPath(), wxT(""), false, new OpenResourceDialogItemData(tmpArr.Item(i), -1, wxT(""), OpenResourceDialog::TYPE_WORKSPACE_FILE, wxT(""), wxT("")));
		
		if( i == 150 ) {
			m_staticTextErrorMessage->SetLabel(wxT("Too many matches, please narrow down your search"));
			break;
		}
	}

	if (m_listOptions->GetItemCount() > 0) {
		DoSelectItem(0);
	}
}
Ejemplo n.º 3
0
void OpenResourceDialog::DoPopulateWorkspaceFile()
{
    // do we need to include files?
    if(!m_filters.IsEmpty() && m_filters.Index(KIND_FILE) == wxNOT_FOUND) return;

    if(!m_userFilters.IsEmpty()) {

        std::unordered_multimap<wxString, wxString>::iterator iter = m_files.begin();
        const int maxFileSize = 100;
        int counter = 0;
        for(; (iter != m_files.end()) && (counter < maxFileSize); iter++) {
            const wxString& fullpath = iter->second;
            if(!MatchesFilter(fullpath)) continue;

            wxFileName fn(iter->second);
            FileExtManager::FileType type = FileExtManager::GetType(fn.GetFullName());
            wxBitmap imgId = m_tagImgMap[wxT("text")];
            switch(type) {
            case FileExtManager::TypeSourceC:
                imgId = m_tagImgMap[wxT("c")];
                break;

            case FileExtManager::TypeSourceCpp:
                imgId = m_tagImgMap[wxT("cpp")];
                break;
            case FileExtManager::TypeHeader:
                imgId = m_tagImgMap[wxT("h")];
                break;
            case FileExtManager::TypeFormbuilder:
                imgId = m_tagImgMap[wxT("wxfb")];
                break;
            case FileExtManager::TypeWxCrafter:
                imgId = m_tagImgMap[wxT("wxcp")];
                break;
            default:
                break;
            }
            DoAppendLine(fn.GetFullName(), fn.GetFullPath(), false,
                         new OpenResourceDialogItemData(fn.GetFullPath(), -1, wxT(""), fn.GetFullName(), wxT("")),
                         imgId);
            ++counter;
        }
    }
}
Ejemplo n.º 4
0
void OpenResourceDialog::DoPopulateTags()
{
	if (m_tags.empty())
		return;

	bool gotExactMatch(false);

	wxArrayString tmpArr;
	wxString curSel = m_textCtrlResourceName->GetValue();
	wxString curSelNoStar;
	if (!curSel.Trim().Trim(false).IsEmpty()) {

		curSel = curSel.MakeLower().Trim().Trim(false);
		curSelNoStar = curSel.c_str();

		for (size_t i=0; i<m_tags.size(); i++) {
			TagEntryPtr tag = m_tags.at(i);
			wxString    name(tag->GetName());

			name.MakeLower();

			//append wildcard at the end
			if (!curSel.EndsWith(wxT("*"))) {
				curSel << wxT("*");
			}

			// FR# [2008133]
			if (m_checkBoxUsePartialMatching->IsChecked() && !curSel.StartsWith(wxT("*"))) {
				curSel.Prepend(wxT("*"));
			}

			if (wxMatchWild(curSel, name)) {
				
				// keep the fullpath
				int index(0);
				if(tag->GetKind() == wxT("function") || tag->GetKind() == wxT("prototype"))
					index = DoAppendLine(tag->GetName(), 
										 tag->GetSignature(), 
										 tag->GetScope(), 
										 tag->GetKind() == wxT("function"),
										 new OpenResourceDialogItemData(tag->GetFile(), tag->GetLine(), tag->GetPattern(), m_type, tag->GetName(), tag->GetScope()));
				else 
					index = DoAppendLine(tag->GetName(), 
										 tag->GetScope(), 
										 wxT(""), 
										 false,
										 new OpenResourceDialogItemData(tag->GetFile(), tag->GetLine(), tag->GetPattern(), m_type, tag->GetName(), tag->GetScope()));
										 
				if (curSelNoStar == name && !gotExactMatch) {
					gotExactMatch = true;
					DoSelectItem(index);
				}
			}
		}
	}

	if (m_listOptions->GetItemCount() == 150) {
		m_staticTextErrorMessage->SetLabel(wxT("Too many matches, please narrow down your search"));
	}

	if (!gotExactMatch && m_listOptions->GetItemCount()) {
		DoSelectItem(0);
	}
}