コード例 #1
0
ExplorerReplicaSetTreeItem::ExplorerReplicaSetTreeItem(QTreeWidgetItem *parent, MongoServer *const server,
        const mongo::HostAndPort& repMemberHostAndPort, const bool isPrimary, const bool isUp)
    : BaseClass(parent),
      _repMemberHostAndPort(repMemberHostAndPort),
      _isPrimary(isPrimary),
      _isUp(isUp),
      _server(server),
      _connSettings(server->connectionRecord()->clone()),
      _bus(AppRegistry::instance().bus())
{
    // Set connection settings of this replica member
    _connSettings->setConnectionName(_repMemberHostAndPort.toString() + " [member of " + _connSettings->connectionName() + "]");
    _connSettings->setServerHost(_repMemberHostAndPort.host());
    _connSettings->setServerPort(_repMemberHostAndPort.port());
    _connSettings->setReplicaSet(false);
    _connSettings->replicaSetSettings()->setMembers(std::vector<std::string>()); // todo: replicaSetSettings->clear()

    // Add Actions
    auto openShellAction = new QAction("Open Shell", this);
    openShellAction->setIcon(GuiRegistry::instance().mongodbIcon());
    VERIFY(connect(openShellAction, SIGNAL(triggered()), SLOT(ui_openShell())));

    auto openDirectConnection = new QAction("Open Direct Connection", this);
    VERIFY(connect(openDirectConnection, SIGNAL(triggered()), SLOT(ui_openDirectConnection())));

    auto serverStatus = new QAction("Server Status", this);
    VERIFY(connect(serverStatus, SIGNAL(triggered()), SLOT(ui_serverStatus())));

    auto serverVersion = new QAction("MongoDB Version", this);
    VERIFY(connect(serverVersion, SIGNAL(triggered()), SLOT(ui_serverVersion())));

    auto serverHostInfo = new QAction("Host Info", this);
    VERIFY(connect(serverHostInfo, SIGNAL(triggered()), SLOT(ui_serverHostInfo())));

    auto showLog = new QAction("Show Log", this);
    VERIFY(connect(showLog, SIGNAL(triggered()), SLOT(ui_showLog())));

    BaseClass::_contextMenu->addAction(openShellAction);
    BaseClass::_contextMenu->addAction(openDirectConnection);
    BaseClass::_contextMenu->addSeparator();
    BaseClass::_contextMenu->addAction(serverStatus);
    BaseClass::_contextMenu->addAction(serverHostInfo);
    BaseClass::_contextMenu->addAction(serverVersion);
    BaseClass::_contextMenu->addSeparator();
    BaseClass::_contextMenu->addAction(showLog);

    //BaseClass::_contextMenu->setHidden(!_isUp);

    // Todo: remove ?
    //_bus->subscribe(this, DatabaseListLoadedEvent::Type, _server);
    //_bus->subscribe(this, MongoServerLoadingDatabasesEvent::Type, _server);

    updateState(_isUp, _isPrimary);

    setExpanded(true);
    setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator);
}
コード例 #2
0
    ExplorerServerTreeItem::ExplorerServerTreeItem(QTreeWidget *view,MongoServer *const server) : BaseClass(view),
        _server(server),
        _bus(AppRegistry::instance().bus())
    { 
        QAction *openShellAction = new QAction("Open Shell", this);
        openShellAction->setIcon(GuiRegistry::instance().mongodbIcon());
        VERIFY(connect(openShellAction, SIGNAL(triggered()), SLOT(ui_openShell())));

        QAction *refreshServer = new QAction("Refresh", this);
        VERIFY(connect(refreshServer, SIGNAL(triggered()), SLOT(ui_refreshServer())));

        QAction *createDatabase = new QAction("Create Database", this);
        VERIFY(connect(createDatabase, SIGNAL(triggered()), SLOT(ui_createDatabase())));

        QAction *serverStatus = new QAction("Server Status", this);
        VERIFY(connect(serverStatus, SIGNAL(triggered()), SLOT(ui_serverStatus())));

        QAction *serverVersion = new QAction("MongoDB Version", this);
        VERIFY(connect(serverVersion, SIGNAL(triggered()), SLOT(ui_serverVersion())));

        QAction *serverHostInfo = new QAction("Host Info", this);
        VERIFY(connect(serverHostInfo, SIGNAL(triggered()), SLOT(ui_serverHostInfo())));        

        QAction *showLog = new QAction("Show Log", this);
        VERIFY(connect(showLog, SIGNAL(triggered()), SLOT(ui_showLog()))); 

        QAction *disconnectAction = new QAction("Disconnect", this);
        disconnectAction->setIconText("Disconnect");
        VERIFY(connect(disconnectAction, SIGNAL(triggered()), SLOT(ui_disconnectServer())));

        BaseClass::_contextMenu->addAction(openShellAction);
        BaseClass::_contextMenu->addAction(refreshServer);
        BaseClass::_contextMenu->addSeparator();
        BaseClass::_contextMenu->addAction(createDatabase);
        BaseClass::_contextMenu->addAction(serverStatus);
        BaseClass::_contextMenu->addAction(serverHostInfo);
        BaseClass::_contextMenu->addAction(serverVersion);
        BaseClass::_contextMenu->addSeparator();
        BaseClass::_contextMenu->addAction(showLog);
        BaseClass::_contextMenu->addAction(disconnectAction);

        _bus->subscribe(this, DatabaseListLoadedEvent::Type, _server);
        _bus->subscribe(this, MongoServerLoadingDatabasesEvent::Type, _server);

        setText(0, buildServerName());
        setIcon(0, GuiRegistry::instance().serverIcon());
        setExpanded(false);
        setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
    }