本文整理汇总了C++中ItemData类的典型用法代码示例。如果您正苦于以下问题:C++ ItemData类的具体用法?C++ ItemData怎么用?C++ ItemData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ItemData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoGetItemData
bool PHPWorkspaceView::IsFolderItem(const wxTreeItemId& item)
{
ItemData* data = DoGetItemData(item);
if(!data) return false;
return data->IsFolder();
}
示例2: wxUnusedVar
void PHPWorkspaceView::OnNewFolder(wxCommandEvent& e)
{
wxUnusedVar(e);
wxString name = wxGetTextFromUser(_("New Folder Name:"), _("New Folder"));
if(name.IsEmpty()) return;
wxString project = DoGetSelectedProject();
if(project.IsEmpty()) return;
wxTreeItemId parent = m_treeCtrlView->GetSelection();
CHECK_ITEM_RET(parent);
ItemData* itemData = DoGetItemData(parent);
CHECK_PTR_RET(itemData);
if(!itemData->IsFolder() && !itemData->IsProject()) return;
PHPProject::Ptr_t proj = PHPWorkspace::Get()->GetProject(project);
CHECK_PTR_RET(proj);
wxString folder;
if(itemData->IsFolder()) {
folder << itemData->GetFolderPath() << "/" << name;
} else {
folder << name;
}
PHPFolder::Ptr_t pFolder = proj->AddFolder(folder);
proj->Save();
// Update the UI
DoAddFolder(parent, pFolder, proj);
}
示例3: CHECK_PTR_RET
void PHPWorkspaceView::DoAddFolderFiles(const wxString& project,
const wxString& folder,
const wxTreeItemId& folderTreeItemId,
wxStringSet_t* filesAdded)
{
PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(project);
CHECK_PTR_RET(pProject);
PHPFolder::Ptr_t pFolder = pProject->Folder(folder);
CHECK_PTR_RET(pFolder);
wxArrayString files;
pFolder->GetFiles(files, pProject->GetFilename().GetPath());
files.Sort();
for(size_t i = 0; i < files.GetCount(); ++i) {
wxFileName fn(files.Item(i));
// create the user data
ItemData* itemData = new ItemData(ItemData::Kind_File);
itemData->SetFile(fn.GetFullPath());
itemData->SetFolderPath(folder);
itemData->SetProjectName(project);
int imgId = DoGetItemImgIdx(fn.GetFullName());
m_treeCtrlView->AppendItem(folderTreeItemId, fn.GetFullName(), imgId, imgId, itemData);
if(filesAdded) {
filesAdded->insert(fn.GetFullPath());
}
}
}
示例4: UpdateProvinceItem
void DialogProvinceDetails::UpdateProvinceItem( ProvinceItem * val )
{
if( val == nullptr )
{
return;
}
int rowCount = ui.listWidget->rowCount();
for( int i=0; i < rowCount; i++ )
{
QString valueName = ui.listWidget->item(i,0)->text();
ItemData toUpdate = val->FindItem(valueName);
if( toUpdate.IsNull() == true )
{
continue;
}
if( toUpdate.GetData().type() == QVariant::StringList )
{
QStringList list = ui.listWidget->item(i,1)->text().split(",",QString::SkipEmptyParts);
val->SetItem(valueName,list);
}
else
{
QString value = ui.listWidget->item(i,1)->text();
val->SetItem(valueName,value);
}
}
}
示例5: findItemByData
wxTreeItemId luProjTree::findItemByData(const wxTreeItemId& parent, const wxString& data)
{
if (!parent.IsOk()) return parent;
ItemData* item = dynamic_cast<ItemData*>(GetItemData(parent));
if (item && item->GetName() == data)
return parent;
if (item) gkPrintf("%s", (const char*)item->GetName());
if (HasChildren(parent))
{
wxTreeItemIdValue cookie;
wxTreeItemId item = GetFirstChild(parent, cookie);
while (item.IsOk())
{
wxTreeItemId find = findItemByData(item, data); //find is item self or children.
if (find.IsOk()) return find;
item = GetNextChild(item, cookie);
}
}
return wxTreeItemId(); //not found
}
示例6: DoGetSingleSelection
void PHPWorkspaceView::OnNewClass(wxCommandEvent& e)
{
wxTreeItemId folderId = DoGetSingleSelection();
ItemData* data = DoGetItemData(folderId);
if(!data || !data->IsFolder()) {
return;
}
PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(data->GetProjectName());
CHECK_PTR_RET(pProject);
PHPFolder::Ptr_t pFolder = pProject->Folder(data->GetFolderPath());
CHECK_PTR_RET(pFolder);
NewPHPClass dlg(wxTheApp->GetTopWindow(), pFolder->GetFullPath(pProject->GetFilename().GetPath(), false));
if(dlg.ShowModal() == wxID_OK) {
PHPClassDetails pcd = dlg.GetDetails();
pFolder = pProject->AddFolder(PHPFolder::GetFolderPathFromFileFullPath(pcd.GetFilepath().GetFullPath(),
pProject->GetFilename().GetPath()));
CHECK_PTR_RET(pFolder);
folderId = EnsureFolderExists(
DoGetProjectItem(pProject->GetName()), pFolder->GetPathRelativeToProject(), pProject->GetName());
DoAddFileWithContent(
folderId, pcd.GetFilepath(), pcd.ToString(EditorConfigST::Get()->GetOptions()->GetEOLAsString(), " "));
}
}
示例7: wxASSERT_MSG
wxTreeItemId
PHPWorkspaceView::EnsureFolderExists(const wxTreeItemId& projectItem, const wxString& path, const wxString& project)
{
PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(project);
wxASSERT_MSG(pProject, wxString::Format("Could not locate project %s", project));
int imgId = m_mgr->GetStdIcons()->GetMimeImageId(FileExtManager::TypeFolder);
wxString curpath;
wxTreeItemId parent = projectItem;
wxArrayString parts = ::wxStringTokenize(path, "/", wxTOKEN_STRTOK);
for(size_t i = 0; i < parts.GetCount(); ++i) {
if(!curpath.IsEmpty()) {
curpath << "/";
}
curpath << parts.Item(i);
if(!HasFolderWithName(parent, parts.Item(i), parent)) {
ItemData* itemData = new ItemData(ItemData::Kind_Folder);
itemData->SetFolderPath(curpath);
itemData->SetProjectName(project);
itemData->SetFolderName(parts.Item(i));
parent =
m_treeCtrlView->AppendItem(parent,
parts.Item(i) == "." ? pProject->GetFilename().GetPath() : parts.Item(i),
imgId,
imgId,
itemData);
}
}
m_treeCtrlView->SortChildren(projectItem);
return parent;
}
示例8: notifyStartDrop
void DemoKeeper::notifyStartDrop(wraps::BaseLayout* _sender, wraps::DDItemInfo _info, bool& _result)
{
if (_info.sender_index != MyGUI::ITEM_NONE)
{
ItemData* data = *static_cast<ItemBox*>(_info.sender)->getItemDataAt<ItemData*>(_info.sender_index);
_result = !data->isEmpty();
}
}
示例9: OnItemActivated
void luProjTree::OnItemActivated(wxTreeEvent& event)
{
wxTreeItemId itemId = event.GetItem();
ItemData* item = (ItemData*)GetItemData(itemId);
luMainFrame* frame = getLuMainFrame();
if (!item || !frame) return;
int data = item->GetData();
wxString name = item->GetName();
}
示例10: ItemData
void PHPWorkspaceView::DoAddFilesToTreeView(const wxTreeItemId& folderId, PHPProject::Ptr_t pProject, PHPFolder::Ptr_t pFolder, const wxArrayString& files)
{
for(size_t i=0; i<files.GetCount(); ++i) {
ItemData *itemData = new ItemData(ItemData::Kind_File);
itemData->SetFile( files.Item(i) );
itemData->SetProjectName( pProject->GetName() );
itemData->SetFolderPath( pFolder->GetPathRelativeToProject() );
int imgId = DoGetItemImgIdx(files.Item(i));
m_treeCtrlView->AppendItem(folderId, wxFileName(files.Item(i)).GetFullName(), imgId, imgId, itemData);
}
m_treeCtrlView->SortChildren( folderId );
}
示例11: ItemData
void PHPWorkspaceView::DoAddFolder(const wxTreeItemId& parent, PHPFolder::Ptr_t folder, PHPProject::Ptr_t project)
{
// add the folder itself
ItemData* itemData = new ItemData(ItemData::Kind_Folder);
itemData->SetFolderPath(folder->GetPathRelativeToProject());
itemData->SetProjectName(project->GetName());
itemData->SetFolderName(folder->GetName()); // display name
wxTreeItemId folderItem = EnsureFolderExists(
DoGetProjectItem(project->GetName()), folder->GetPathRelativeToProject(), project->GetName());
// Get list of folders
const PHPFolder::List_t& children = folder->GetChildren();
PHPFolder::List_t::const_iterator iter = children.begin();
for(; iter != children.end(); ++iter) {
DoAddFolder(folderItem, *iter, project);
}
wxArrayString folderFiles;
folder->GetFiles(folderFiles, project->GetFilename().GetPath(), 0);
// Add the files
for(size_t i = 0; i < folderFiles.GetCount(); ++i) {
ItemData* itemData = new ItemData(ItemData::Kind_File);
itemData->SetFile(folderFiles.Item(i));
itemData->SetProjectName(project->GetName());
itemData->SetFolderPath(folder->GetPathRelativeToProject());
int imgId = DoGetItemImgIdx(folderFiles.Item(i));
m_treeCtrlView->AppendItem(folderItem, wxFileName(folderFiles.Item(i)).GetFullName(), imgId, imgId, itemData);
}
}
示例12: sourceModel
/** Maps to what groups the source row belongs by returning the data of those groups.
*
* @returns a list of data for the rows the argument belongs to. In common cases this list will
* contain only one entry. An empty list means that the source item will be placed in the root of
* this proxyModel. There is no support for hiding source items.
*
* Group data can be pre-loaded in the return value so it's added to the cache maintained by this
* class. This is required if you want to have data that is not present in the source model.
*/
QList<RowData>
QtGroupingProxy::belongsTo( const QModelIndex &idx )
{
//qDebug() << __FILE__ << __FUNCTION__;
QList<RowData> rowDataList;
//get all the data for this index from the model
ItemData itemData = sourceModel()->itemData( idx );
QMapIterator<int, QVariant> i( itemData );
while( i.hasNext() )
{
i.next();
int role = i.key();
QVariant variant = i.value();
// qDebug() << "role " << role << " : (" << variant.typeName() << ") : "<< variant;
if( variant.type() == QVariant::List )
{
//a list of variants get's expanded to multiple rows
QVariantList list = variant.toList();
for( int i = 0; i < list.length(); i++ )
{
//take an existing row data or create a new one
RowData rowData = (rowDataList.count() > i) ? rowDataList.takeAt( i )
: RowData();
//we only gather data for the first column
ItemData indexData = rowData.contains( 0 ) ? rowData.take( 0 ) : ItemData();
indexData.insert( role, list.value( i ) );
rowData.insert( 0, indexData );
//for the grouped column the data should not be gathered from the children
//this will allow filtering on the content of this column with a
//QSortFilterProxyModel
rowData.insert( m_groupedColumn, indexData );
rowDataList.insert( i, rowData );
}
}
else if( !variant.isNull() )
{
//it's just a normal item. Copy all the data and break this loop.
RowData rowData;
rowData.insert( 0, itemData );
rowDataList << rowData;
break;
}
}
return rowDataList;
}
示例13: DoGetItemData
void PHPWorkspaceView::OnDeleteProject(wxCommandEvent& e)
{
// Prompt user
wxTreeItemId selection = m_treeCtrlView->GetSelection();
if(selection.IsOk()) {
ItemData* itemData = DoGetItemData(selection);
if ( itemData && itemData->IsProject() ) {
if(wxMessageBox(wxString() << _("Are you sure you want to delete\nproject '") << itemData->GetProjectName() << "'?",
_("CodeLite"),
wxYES_NO| wxCANCEL,
wxTheApp->GetTopWindow()) == wxYES) {
PHPWorkspace::Get()->DeleteProject(itemData->GetProjectName());
m_treeCtrlView->Delete( selection );
}
}
}
}
示例14: DoGetSelectedProject
void PHPWorkspaceView::OnSetProjectActive(wxCommandEvent& e)
{
wxString project = DoGetSelectedProject();
if(project.IsEmpty()) return;
PHPWorkspace::Get()->SetProjectActive(project);
wxTreeItemIdValue cookie;
wxTreeItemId child = m_treeCtrlView->GetFirstChild(m_treeCtrlView->GetRootItem(), cookie);
while(child.IsOk()) {
ItemData* id = DoGetItemData(child);
if(id && id->IsProject()) {
id->SetActive(id->GetProjectName() == project);
m_treeCtrlView->SetItemBold(child, id->IsActive());
}
child = m_treeCtrlView->GetNextChild(m_treeCtrlView->GetRootItem(), cookie);
}
}
示例15: DoGetSingleSelection
void PHPWorkspaceView::OnRenameFile(wxCommandEvent& e)
{
wxTreeItemId item = DoGetSingleSelection();
CHECK_ITEM_RET(item);
ItemData *data = DoGetItemData(item);
CHECK_PTR_RET(data);
CHECK_ID_FILE(data);
wxFileName old_file_name = data->GetFile();
wxString new_name = ::wxGetTextFromUser(_("New file name:"), _("Rename file"), old_file_name.GetFullName() );
if ( new_name.IsEmpty() )
return;
if ( new_name == old_file_name.GetFullName() )
return;
// Check to see if we got a file with the old path opened
bool reopenFile = false;
IEditor *editor = m_mgr->FindEditor(old_file_name.GetFullPath());
if ( editor ) {
m_mgr->ClosePage( editor->GetFileName().GetFullName() );
reopenFile = true;
editor = NULL;
}
PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(DoGetSelectedProject());
CHECK_PTR_RET(pProject);
if ( pProject->RenameFile(old_file_name.GetFullPath(), new_name) ) {
// Locate the folder
pProject->Save();
m_treeCtrlView->SetItemText(item, new_name);
// Update the item data
old_file_name.SetFullName(new_name);
data->SetFile( old_file_name.GetFullPath() );
// Open the file if it was opened earlier
// old_file_name now contains the new full path to the new file
if ( reopenFile ) {
m_mgr->OpenFile( old_file_name.GetFullPath() );
}
}
}