Esempio n. 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));
    }
}
Esempio n. 2
0
void FileSystemWidget::pathIndexChanged(const QModelIndex & index)
{
    FileNode *node = m_model->nodeFromIndex(index);
    if (node) {
        QFileInfo info = node->fileInfo();
        QModelIndex newIndex = index;
        if (info.isDir()) {
            newIndex = index;
        } else {
            newIndex = index.parent();
        }
        this->setStartIndex(newIndex);
    }
}
Esempio n. 3
0
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));
    }
}