示例#1
0
void ProjectManager::ifNoCurrentProject(const QString &projectName)
{
	if (currentProject.isEmpty()) {
		if (!projectName.isEmpty()) {
			setCurrentProject(projectName);
		} else if (openedProjectList.count() > 0) {
			setCurrentProject(openedProjectList.at(0));
		}
	}
}
示例#2
0
DelProject::DelProject(QWidget *parent) :
		QDialog(parent),
		m_ui(new Ui::DelProject)
{
	m_ui->setupUi(this);

	connect(m_ui->listView, SIGNAL(clicked(QModelIndex)),
			this, SLOT(showDcpt(QModelIndex)));
	connect(m_ui->listView, SIGNAL(doubleClicked(QModelIndex)),
			this, SLOT(setCurrentProject()));
	connect(m_ui->delButton, SIGNAL(clicked()),
			this, SLOT(delPro()));
	connect(m_ui->currentButton, SIGNAL(clicked()),
			this, SLOT(setCurrentProject()));
}
示例#3
0
TrayIcon::TrayIcon()
  : QSystemTrayIcon(),
    menu(NULL),
    offIcon(":/gfx/off.png"),
    onIcon(":/gfx/on.png"),
    currentProject(NULL),
    runningSince(QDateTime::currentDateTime().toString(Qt::SystemLocaleLongDate))
{
  setIcon(offIcon);
  setVisible(true);

  setupActions();
  setupConnections();
  setupProjects();
  // commented out because it's handled by a signal
  //setupMenu();

  setCurrentProject(NULL);
}
示例#4
0
文件: Server.cpp 项目: qyqx/rtags
bool Server::init(const Options &options)
{
    {
        List<Path> plugins = Rct::executablePath().parentDir().files(Path::File);
        for (int i=0; i<plugins.size(); ++i) {
            if (mPluginFactory.addPlugin(plugins.at(i))) {
                error() << "Loaded plugin" << plugins.at(i);
            }
        }
    }
    RTags::initMessages();

    mIndexerThreadPool = new ThreadPool(options.threadCount, options.clangStackSize);

    mOptions = options;
    if (options.options & NoBuiltinIncludes) {
        mOptions.defaultArguments.append("-nobuiltininc");
        mOptions.defaultArguments.append("-nostdinc++");
    } else {
        Path clangPath = Path::resolved(CLANG_INCLUDEPATH);
        clangPath.prepend("-I");
        mOptions.defaultArguments.append(clangPath);
    }

    if (options.options & UnlimitedErrors)
        mOptions.defaultArguments.append("-ferror-limit=0");
    if (options.options & Wall)
        mOptions.defaultArguments.append("-Wall");
    if (options.options & SpellChecking)
        mOptions.defaultArguments << "-fspell-checking";
    error() << "using args:" << String::join(mOptions.defaultArguments, " ");

    if (mOptions.options & ClearProjects) {
        clearProjects();
    }

    for (int i=0; i<10; ++i) {
        mServer = new SocketServer;
        if (mServer->listenUnix(mOptions.socketFile)) {
            break;
        }
        delete mServer;
        mServer = 0;
        if (!i) {
            enum { Timeout = 1000 };
            Client client;
            if (client.connectToServer(mOptions.socketFile, Timeout)) {
                QueryMessage msg(QueryMessage::Shutdown);
                client.send(&msg, Timeout);
            }
        }
        sleep(1);
        Path::rm(mOptions.socketFile);
    }
    if (!mServer) {
        error("Unable to listen on %s", mOptions.socketFile.constData());
        return false;
    }

    restoreFileIds();
    mServer->clientConnected().connect(this, &Server::onNewConnection);
    reloadProjects();
    if (!(mOptions.options & NoStartupCurrentProject)) {
        Path current = Path(mOptions.dataDir + ".currentProject").readAll(1024);
        if (current.size() > 1) {
            current.chop(1);
            if (!setCurrentProject(current)) {
                error() << "Can't restore project" << current;
                unlink((mOptions.dataDir + ".currentProject").constData());
            }
        }
    }

    return true;
}
示例#5
0
文件: Server.cpp 项目: jsyjr/rtags
bool Server::init(const Options &options)
{
    {
        Path dir(RTAGS_BIN);
        dir.resolve();
        List<Path> plugins = dir.files(Path::File);
        Path executableDir = Rct::executablePath().resolved().parentDir();
        if (dir != executableDir)
            plugins += executableDir.files(Path::File);
        for (int i=0; i<plugins.size(); ++i) {
            if (mPluginFactory.addPlugin(plugins.at(i))) {
                error() << "Loaded plugin" << plugins.at(i);
            }
        }
    }
    RTags::initMessages();

    mIndexerThreadPool = new ThreadPool(options.threadCount);
    mQueryThreadPool = new ThreadPool(2);

    mOptions = options;
    if (options.options & NoBuiltinIncludes) {
        mOptions.defaultArguments.append("-nobuiltininc");
        mOptions.defaultArguments.append("-nostdinc++");
    } else {
        Path clangPath = Path::resolved(CLANG_INCLUDEPATH);
        clangPath.prepend("-I");
        mOptions.defaultArguments.append(clangPath);
    }

    if (options.options & UnlimitedErrors)
        mOptions.defaultArguments.append("-ferror-limit=0");
    if (options.options & Wall)
        mOptions.defaultArguments.append("-Wall");
    if (options.options & SpellChecking)
        mOptions.defaultArguments << "-fspell-checking";
    error() << "using args:" << String::join(mOptions.defaultArguments, " ");

    if (mOptions.options & ClearProjects) {
        clearProjects();
    }

    for (int i=0; i<10; ++i) {
        mServer.reset(new SocketServer);
        if (mServer->listen(mOptions.socketFile)) {
            break;
        }
        mServer.reset();
        if (!i) {
            enum { Timeout = 1000 };
            Connection connection;
            if (connection.connectToServer(mOptions.socketFile, Timeout)) {
                connection.send(QueryMessage(QueryMessage::Shutdown));
                connection.disconnected().connect(std::bind([](){ EventLoop::eventLoop()->quit(); }));
                connection.finished().connect(std::bind([](){ EventLoop::eventLoop()->quit(); }));
                EventLoop::eventLoop()->exec(Timeout);
            }
        }
        sleep(1);
        Path::rm(mOptions.socketFile);
    }
    if (!mServer) {
        error("Unable to listen on %s", mOptions.socketFile.constData());
        return false;
    }

    restoreFileIds();
    mServer->newConnection().connect(std::bind(&Server::onNewConnection, this));
    reloadProjects();
    if (!(mOptions.options & NoStartupCurrentProject)) {
        Path current = Path(mOptions.dataDir + ".currentProject").readAll(1024);
        if (current.size() > 1) {
            current.chop(1);
            if (!setCurrentProject(current)) {
                error() << "Can't restore project" << current;
                unlink((mOptions.dataDir + ".currentProject").constData());
            }
        }
    }

    if (mOptions.clearCompletionCacheInterval && mOptions.completionCacheSize) {
        clearCompletionCache();
    }

    return true;
}
示例#6
0
文件: Server.cpp 项目: rosrad/rtags
bool Server::init(const Options &options)
{
    RTags::initMessages();

    mOptions = options;
    mSuspended = (options.options & StartSuspended);
    Path clangPath = Path::resolved(CLANG_INCLUDEPATH_STR);
    mOptions.includePaths.append(clangPath);
#ifdef OS_Darwin
    if (clangPath.exists()) {
        Path cppClangPath = clangPath + "../../../c++/v1/";
        cppClangPath.resolve();
        if (cppClangPath.isDir()) {
            mOptions.includePaths.append(cppClangPath);
        } else {
            cppClangPath = clangPath + "../../../../include/c++/v1/";
            cppClangPath.resolve();
            if (cppClangPath.isDir()) {
                mOptions.includePaths.append(cppClangPath);
            } else {
                error("Unable to find libc++ include path (.../c++/v1) near " CLANG_INCLUDEPATH_STR );
                return false;
            }
        }
        // this seems to be the only way we get things like cstdint
    }
#endif

    if (!(options.options & NoUnlimitedErrors))
        mOptions.defaultArguments << "-ferror-limit=0";
    if (options.options & Wall)
        mOptions.defaultArguments << "-Wall";
    if (options.options & SpellChecking)
        mOptions.defaultArguments << "-fspell-checking";
    if (!(options.options & NoNoUnknownWarningsOption))
        mOptions.defaultArguments.append("-Wno-unknown-warning-option");
    Log l(Error);
    l << "Running with" << mOptions.jobCount << "jobs, using args:"
      << String::join(mOptions.defaultArguments, ' ') << '\n';
    l << "Includepaths:" << String::join(mOptions.includePaths, ' ');

    if (mOptions.options & ClearProjects) {
        clearProjects();
    }

    for (int i=0; i<10; ++i) {
        mUnixServer.reset(new SocketServer);
        if (mUnixServer->listen(mOptions.socketFile)) {
            break;
        }
        mUnixServer.reset();
        if (!i) {
            enum { Timeout = 1000 };
            Connection connection;
            if (connection.connectUnix(mOptions.socketFile, Timeout)) {
                connection.send(QueryMessage(QueryMessage::Shutdown));
                connection.disconnected().connect(std::bind([](){ EventLoop::eventLoop()->quit(); }));
                connection.finished().connect(std::bind([](){ EventLoop::eventLoop()->quit(); }));
                EventLoop::eventLoop()->exec(Timeout);
            }
        } else {
            sleep(1);
        }
        Path::rm(mOptions.socketFile);
    }
    if (!mUnixServer) {
        error("Unable to listen on %s", mOptions.socketFile.constData());
        return false;
    }

    restoreFileIds();
    mUnixServer->newConnection().connect(std::bind(&Server::onNewConnection, this, std::placeholders::_1));
    reloadProjects();
    if (!(mOptions.options & NoStartupCurrentProject)) {
        Path current = Path(mOptions.dataDir + ".currentProject").readAll(1024);
        if (current.size() > 1) {
            current.chop(1);
            const auto project = mProjects.value(current);
            if (!project) {
                error() << "Can't restore project" << current;
                unlink((mOptions.dataDir + ".currentProject").constData());
            } else {
                setCurrentProject(project);
            }
        }
    }

    return true;
}