Ejemplo n.º 1
0
void GopathBrowser::pathIndexChanged(const QModelIndex & index)
{
    PathNode *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);
    }
}
Ejemplo n.º 2
0
void GopathBrowser::treeViewContextMenuRequested(const QPoint &pos)
{
    QModelIndex index = m_pathTree->indexAt(pos);
    if (!index.isValid()) {
        return;
    }
    PathNode *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_pathTree->mapToGlobal(pos));
    }
}