News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Doubt in projectmanager.cpp

Started by puneet_m, September 06, 2007, 09:47:34 PM

Previous topic - Next topic

puneet_m

In Codeblock GUI, am trying to do drag and drop from Open files List panel to Project panel. But it is not working. Below is the code for drag and drop in projectmanager.cpp. What could be error? (I am using the code for version 4360).


void ProjectManager::OnTreeBeginDrag(wxTreeEvent& event)
{
//    wxString text = m_pTree->GetItemText(event.GetItem());
//    DBGLOG(_T("BeginDrag: %s"), text.c_str());

    // what item do we start dragging?
    wxTreeItemId id = event.GetItem();
    if (!id.IsOk())
        return;

    // if no data associated with it, disallow
    FileTreeData* ftd = (FileTreeData*)m_pTree->GetItemData(id);
    if (!ftd)
        return;

    // if no project, disallow
    cbProject* prj = ftd->GetProject();
    if (!prj)
        return;

    // allow only if the project approves
    if (!prj->CanDragNode(m_pTree, id))
        return;

    // allowed
    m_DraggingItem = id;
    event.Allow();
}

void ProjectManager::OnTreeEndDrag(wxTreeEvent& event)
{
//    wxString text = m_pTree->GetItemText(event.GetItem());
//    wxString oldtext = m_pTree->GetItemText(m_DraggingItem);
//    DBGLOG(_T("EndDrag: %s to %s"), oldtext.c_str(), text.c_str());

    wxTreeItemId from = m_DraggingItem;
    wxTreeItemId to = event.GetItem();
    m_DraggingItem.Unset();

    // are both items valid?
    if (!from.IsOk() || !to.IsOk())
        return;

    // if no data associated with any of them, disallow
    FileTreeData* ftd1 = (FileTreeData*)m_pTree->GetItemData(from);
    FileTreeData* ftd2 = (FileTreeData*)m_pTree->GetItemData(to);
    if (!ftd1 || !ftd2)
        return;

    // if no project or different projects, disallow
    cbProject* prj1 = ftd1->GetProject();
    cbProject* prj2 = ftd2->GetProject();
    if (!prj1 || prj1 != prj2)
        return;

    // allow only if the project approves
    if (!prj1->NodeDragged(m_pTree, from, to))
        return;

    event.Allow();
}