void CscopeTab::BuildTable(CScopeResultTable_t *table) { if ( !table ) { return; } if (m_table) { // Free the old table FreeTable(); } m_table = table; m_dataviewModel->Clear(); wxStringSet_t insertedItems; CScopeResultTable_t::iterator iter = m_table->begin(); for (; iter != m_table->end(); ++iter ) { wxString file = iter->first; wxVector<wxVariant> cols; cols.push_back( CScoptViewResultsModel::CreateIconTextVariant(file, GetBitmap(file)) ); cols.push_back(wxString()); cols.push_back(wxString()); wxDataViewItem fileItem = m_dataviewModel->AppendItem( wxDataViewItem(0), cols, NULL); // Add the entries for this file CScopeEntryDataVec_t* vec = iter->second; for ( size_t i=0; i<vec->size(); ++i ) { CscopeEntryData entry = vec->at(i); // Dont insert duplicate entries to the match view wxString display_string; display_string << _("Line: ") << entry.GetLine() << wxT(", ") << entry.GetScope() << wxT(", ") << entry.GetPattern(); if(insertedItems.find(display_string) == insertedItems.end()) { insertedItems.insert(display_string); cols.clear(); cols.push_back( CScoptViewResultsModel::CreateIconTextVariant(entry.GetScope(), wxNullBitmap) ); cols.push_back( (wxString() << entry.GetLine()) ); cols.push_back( (wxString() << entry.GetPattern()) ); m_dataviewModel->AppendItem( fileItem, cols, new CscopeTabClientData(entry) ); } } } FreeTable(); }
void CscopeTab::CopyContentsToClipboard(bool selectionOnly) { if ( !m_table ) return; CscopeEntryData data; int state = wxLIST_STATE_DONTCARE; if ( m_pListCtrl->GetSelectedItemCount() && selectionOnly) state = wxLIST_STATE_SELECTED; wxString str; long item = -1; for ( ;; ) { item = m_pListCtrl->GetNextItem(item, wxLIST_NEXT_ALL, state); if ( item == -1 ) break; data = m_table->at(item); str += data.GetFile() + _T('|') + wxString::Format(_T("%d|"), data.GetLine()) + data.GetScope() + _T('|') + data.GetPattern() + _T("|\n"); } if (wxTheClipboard->Open()) { wxTheClipboard->SetData(new wxTextDataObject(str)); wxTheClipboard->Close(); } }