Exemple #1
0
void FileSystemWidget::treeViewContextMenuRequested(const QPoint &pos)
{
    QMenu *contextMenu = 0;
    QModelIndex index = m_tree->indexAt(pos);
    if (index.isValid()) {
        FileNode *node = m_model->nodeFromIndex(index);
        if (node) {
            m_contextInfo = node->fileInfo();
            m_contextIndex = index;
            if (node->isDir()) {
                contextMenu = m_folderMenu;
                if (m_model->isRootPathNode(node)) {
                    m_closeFolerAct->setVisible(true);
                    m_removeFolderAct->setVisible(false);
                } else {
                    m_closeFolerAct->setVisible(false);
                    m_removeFolderAct->setVisible(true);
                }
            } else {
                contextMenu = m_fileMenu;
            }
        }
    } else {
        contextMenu = m_rootMenu;
    }
    if (contextMenu && contextMenu->actions().count() > 0) {
        contextMenu->popup(m_tree->mapToGlobal(pos));
    }
}
void FileSystemWidget::treeViewContextMenuRequested(const QPoint &pos)
{
    QModelIndex index = m_tree->indexAt(pos);
    if (!index.isValid()) {
        return;
    }
    FileNode *node = m_model->nodeFromIndex(index);
    if (!node) {
        return;
    }
    m_contextInfo = node->fileInfo();
    m_contextIndex = index;
    QMenu *contextMenu = 0;
    if (node->isDir()) {
        contextMenu = m_folderMenu;
    } else {
        contextMenu = m_fileMenu;
    }

    if (contextMenu && contextMenu->actions().count() > 0) {
        contextMenu->popup(m_tree->mapToGlobal(pos));
    }
}