Ejemplo n.º 1
0
void FileBrowser::doubleClickedTreeView(QModelIndex proxyIndex)
{
    QModelIndex index = m_proxyModel->mapToSource(proxyIndex);
    if (!index.isValid()) {
        return;
    }
    if (m_fileModel->isDir(index)) {
        return;
    }
    QString fileName = m_fileModel->filePath(index);
    if (fileName.isEmpty()) {
        return;
    }
    QFileInfo info(fileName);
    QString mimeType = m_liteApp->mimeTypeManager()->findMimeTypeByFile(fileName);
    if (mimeType.startsWith("text/")) {
        m_liteApp->fileManager()->openEditor(fileName);
        return;
    }
    QString cmd = FileUtil::lookPathInDir(info.fileName(),info.path());
    if (cmd == fileName) {        
        LiteApi::ILiteBuild *build = LiteApi::getLiteBuild(m_liteApp);
        if (build) {
            build->executeCommand(info.fileName(),QString(),info.path());
            return;
        }
    }
    m_liteApp->fileManager()->openFile(fileName);
}
Ejemplo n.º 2
0
void FileBrowser::executeFile()
{
    LiteApi::ILiteBuild *build = LiteApi::getLiteBuild(m_liteApp);
    if (build) {
        QFileInfo info = m_folderView->contextFileInfo();
        QString cmd = FileUtil::lookPathInDir(info.fileName(),info.path());
        if (!cmd.isEmpty()) {
            build->executeCommand(cmd,QString(),info.path(),true,true,false);
        }
    }
}
Ejemplo n.º 3
0
void FileSystemWidget::openPathIndex(const QModelIndex &index)
{
    FileNode *node = m_model->nodeFromIndex(index);
    if (!node) {
        return;
    }
    if (node->isFile()) {
        QFileInfo info(node->path());
        QString cmd = FileUtil::lookPathInDir(info.fileName(),LiteApi::getCurrentEnvironment(m_liteApp),info.path());
        if (cmd == node->path()) {
            LiteApi::ILiteBuild *build = LiteApi::getLiteBuild(m_liteApp);
            if (build) {
                build->executeCommand(info.fileName(),QString(),info.path());
                return;
            }
        }
        m_liteApp->fileManager()->openEditor(node->path(),true);
    }
}
Ejemplo n.º 4
0
void FileBrowser::commandReturn()
{
    QString text = m_commandEdit->text();
    if (text.isEmpty()) {
        return;
    }
    m_commandEdit->selectAll();
    QString cmd = text;
    QString args;
    int find = text.indexOf(" ");
    if (find != -1) {
        cmd = text.left(find);
        args = text.right(text.length()-find-1);
    }
    LiteApi::ILiteBuild *build = LiteApi::getLiteBuild(m_liteApp);
    if (!build) {
        return;
    }
    build->executeCommand(cmd.trimmed(),args.trimmed(),m_fileModel->rootPath());
}
Ejemplo n.º 5
0
void FileSystemWidget::openPathIndex(const QModelIndex &index)
{
    FileNode *node = m_model->nodeFromIndex(index);
    if (!node) {
        return;
    }
    if (node->isFile()) {
        QFileInfo info(node->path());
        QString mimeType = m_liteApp->mimeTypeManager()->findMimeTypeByFile(node->path());
        if (mimeType.startsWith("text/") || mimeType.startsWith("application/")) {
            m_liteApp->fileManager()->openEditor(node->path());
            return;
        }
        QString cmd = FileUtil::lookPathInDir(info.fileName(),info.path());
        if (cmd == node->path()) {
            LiteApi::ILiteBuild *build = LiteApi::getLiteBuild(m_liteApp);
            if (build) {
                build->executeCommand(info.fileName(),QString(),info.path());
                return;
            }
        }
        m_liteApp->fileManager()->openEditor(node->path(),true);
    }
}