Пример #1
0
void GopathBrowser::openPathIndex(const QModelIndex &index)
{
    PathNode *node = m_model->nodeFromIndex(index);
    if (!node) {
        return;
    }
    if (node->isDir()) {
        this->setStartIndex(index);
    } else if (node->isFile()) {
        if (m_syncProject->isChecked()) {
            this->setStartIndex(index.parent());
        }
        m_liteApp->fileManager()->openEditor(node->path(),true);
    }
}
Пример #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));
    }
}