void ExplorerTreeView::openPropertyServerDialog()
    {
        QModelIndex sel = selectedIndex();
        if(!sel.isValid()){
            return;
        }

        ExplorerServerItem *node = common::utils_qt::item<ExplorerServerItem*>(sel);
        if(!node){
            return;
        }

        IServerSPtr server = node->server();
        if(!server){
            return;
        }

        PropertyServerDialog infDialog(QString("%1 properties").arg(server->name()), server->type(), this);
        VERIFY(connect(server.get(), &IServer::startedLoadServerProperty, &infDialog, &PropertyServerDialog::startServerProperty));
        VERIFY(connect(server.get(), &IServer::finishedLoadServerProperty, &infDialog, &PropertyServerDialog::finishServerProperty));
        VERIFY(connect(server.get(), &IServer::startedChangeServerProperty, &infDialog, &PropertyServerDialog::startServerChangeProperty));
        VERIFY(connect(server.get(), &IServer::finishedChangeServerProperty, &infDialog, &PropertyServerDialog::finishServerChangeProperty));
        VERIFY(connect(&infDialog, &PropertyServerDialog::changedProperty, server.get(), &IServer::changeProperty));
        VERIFY(connect(&infDialog, &PropertyServerDialog::showed, server.get(), &IServer::serverProperty));
        infDialog.exec();
    }
    OutputWidget::OutputWidget(IServerSPtr server, QWidget* parent)
        : QWidget(parent)
    {
        commonModel_ = new FastoCommonModel(this);
        VERIFY(connect(commonModel_, &FastoCommonModel::changedValue, server.get(), &IServer::changeValue, Qt::DirectConnection));
        VERIFY(connect(server.get(), &IServer::startedChangeDbValue, this, &OutputWidget::startChangeDbValue, Qt::DirectConnection));
        VERIFY(connect(server.get(), &IServer::finishedChangeDbValue, this, &OutputWidget::finishChangeDbValue, Qt::DirectConnection));

        treeView_ = new FastoTreeView;
        treeView_->setModel(commonModel_);

        tableView_ = new FastoTableView;
        tableView_->setModel(commonModel_);

        textView_ = new FastoTextView(server->outputDelemitr());
        textView_->setModel(commonModel_);
        textView_->setReadOnly(true);

        timeLabel_ = new fasto::qt::gui::IconLabel(GuiFactory::instance().timeIcon(), "0", QSize(32, 32));

        QVBoxLayout* mainL = new QVBoxLayout;
        QHBoxLayout* topL = new QHBoxLayout;
        QSplitter* splitter = new QSplitter;
        splitter->setOrientation(Qt::Horizontal);
        splitter->setHandleWidth(1);
        splitter->setContentsMargins(0, 0, 0, 0);

        treeButton_ = new QPushButton;
        tableButton_ = new QPushButton;
        textButton_ = new QPushButton;
        treeButton_->setIcon(GuiFactory::instance().treeIcon());
        VERIFY(connect(treeButton_, SIGNAL(clicked()), this, SLOT(setTreeView())));
        tableButton_->setIcon(GuiFactory::instance().tableIcon());
        VERIFY(connect(tableButton_, SIGNAL(clicked()), this, SLOT(setTableView())));
        textButton_->setIcon(GuiFactory::instance().textIcon());
        VERIFY(connect(textButton_, SIGNAL(clicked()), this, SLOT(setTextView())));

        topL->addWidget(treeButton_);
        topL->addWidget(tableButton_);
        topL->addWidget(textButton_);
        topL->addWidget(splitter);
        topL->addWidget(timeLabel_);

        mainL->addLayout(topL);
        mainL->addWidget(treeView_);
        mainL->addWidget(tableView_);
        mainL->addWidget(textView_);
        setLayout(mainL);
        syncWithSettings();
    }
    ServerHistoryDialog::ServerHistoryDialog(IServerSPtr server, QWidget* parent)
        : QDialog(parent, Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint ), server_(server)
    {
        using namespace translations;
        CHECK(server_);

        setWindowIcon(GuiFactory::instance().icon(server_->type()));

        graphWidget_ = new fasto::qt::gui::GraphWidget;
        settingsGraph_ = new QWidget;
        QHBoxLayout *mainL = new QHBoxLayout;

        QSplitter *splitter = new QSplitter;
        splitter->setOrientation(Qt::Horizontal);
        splitter->setHandleWidth(1);

        mainL->addWidget(splitter);
        splitter->addWidget(settingsGraph_);

        clearHistory_ = new QPushButton;
        VERIFY(connect(clearHistory_, &QPushButton::clicked, this, &ServerHistoryDialog::clearHistory));
        serverInfoGroupsNames_ = new QComboBox;
        serverInfoFields_ = new QComboBox;

        typedef void (QComboBox::*curc)(int);
        VERIFY(connect(serverInfoGroupsNames_, static_cast<curc>(&QComboBox::currentIndexChanged), this, &ServerHistoryDialog::refreshInfoFields ));
        VERIFY(connect(serverInfoFields_, static_cast<curc>(&QComboBox::currentIndexChanged), this, &ServerHistoryDialog::refreshGraph ));

        const std::vector<std::string> headers = infoHeadersFromType(server_->type());
        for(int i = 0; i < headers.size(); ++i){
            serverInfoGroupsNames_->addItem(common::convertFromString<QString>(headers[i]));
        }
        QVBoxLayout *setingsLayout = new QVBoxLayout;
        setingsLayout->addWidget(clearHistory_);
        setingsLayout->addWidget(serverInfoGroupsNames_);
        setingsLayout->addWidget(serverInfoFields_);
        settingsGraph_->setLayout(setingsLayout);

        splitter->addWidget(graphWidget_);
        setLayout(mainL);

        glassWidget_ = new fasto::qt::gui::GlassWidget(GuiFactory::instance().pathToLoadingGif(), trLoading, 0.5, QColor(111, 111, 100), this);
        VERIFY(connect(server.get(), &IServer::startedLoadServerHistoryInfo, this, &ServerHistoryDialog::startLoadServerHistoryInfo));
        VERIFY(connect(server.get(), &IServer::finishedLoadServerHistoryInfo, this, &ServerHistoryDialog::finishLoadServerHistoryInfo));
        VERIFY(connect(server.get(), &IServer::startedClearServerHistory, this, &ServerHistoryDialog::startClearServerHistory));
        VERIFY(connect(server.get(), &IServer::finishedClearServerHistory, this, &ServerHistoryDialog::finishClearServerHistory));
        VERIFY(connect(server.get(), &IServer::serverInfoSnapShoot, this, &ServerHistoryDialog::snapShotAdd));
        retranslateUi();
    }
Exemple #4
0
    QueryWidget::QueryWidget(IServerSPtr server, QWidget* parent)
        : QWidget(parent)
    {
        shellWidget_ = new BaseShellWidget(server);
        outputWidget_ = new OutputWidget(server.get());

        VERIFY(connect(shellWidget_, &BaseShellWidget::rootCreated, outputWidget_, &OutputWidget::rootCreate));
        VERIFY(connect(shellWidget_, &BaseShellWidget::rootCompleated, outputWidget_, &OutputWidget::rootCompleate));

        VERIFY(connect(shellWidget_, &BaseShellWidget::addedChild, outputWidget_, &OutputWidget::addChild));
        VERIFY(connect(shellWidget_, &BaseShellWidget::itemUpdated, outputWidget_, &OutputWidget::itemUpdate));

        QSplitter* splitter = new QSplitter;
#ifdef OS_WIN
        splitter->setStyleSheet("QSplitter::handle { background-color: gray }");
#endif
        splitter->setOrientation(Qt::Vertical);
        splitter->setHandleWidth(1);
        splitter->setContentsMargins(0, 0, 0, 0);

        QVBoxLayout *mainLayout = new QVBoxLayout;
        mainLayout->setSpacing(0);
        splitter->addWidget(shellWidget_);
        splitter->addWidget(outputWidget_);
        splitter->setStretchFactor(0, 0);
        splitter->setStretchFactor(1, 1);
        mainLayout->addWidget(splitter);

        setLayout(mainLayout);
    }
 void ServersManager::refreshSyncServers()
 {
     for(size_t i = 0; i < servers_.size(); ++i){
         IServerSPtr servi = servers_[i];
         if(servi->isSuperServer()){
             for(size_t j = 0; j < servers_.size(); ++j){
                 IServerSPtr servj = servers_[j];
                 if(servj != servi && servj->driver() == servi->driver()){
                     if(syncServers_){
                         servj->syncWithServer(servi.get());
                     }
                     else{
                         servj->unSyncFromServer(servi.get());
                     }
                 }
             }
         }
     }
 }
    IServerSPtr ServersManager::createServer(IConnectionSettingsBaseSPtr settings)
    {
        DCHECK(settings);

        IServerSPtr result;
        connectionTypes conT = settings->connectionType();
        IServerSPtr ser = findServerBySetting(settings);
        if(conT == REDIS){
            RedisServer *newRed = NULL;
            if(!ser){
                IDriverSPtr dr(new RedisDriver(settings));
                dr->start();
                newRed = new RedisServer(dr, true);
            }
            else{
                newRed = new RedisServer(ser->driver(), false);
            }
            result.reset(newRed);
            servers_.push_back(result);
        }
        else if(conT == MEMCACHED){
            MemcachedServer *newMem = NULL;
            if(!ser){
                IDriverSPtr dr(new MemcachedDriver(settings));
                dr->start();
                newMem = new MemcachedServer(dr, true);
            }
            else{
                newMem = new MemcachedServer(ser->driver(), false);
            }
            result.reset(newMem);
            servers_.push_back(result);
        }
        else if(conT == SSDB){
            SsdbServer *newSsdb = NULL;
            if(!ser){
                IDriverSPtr dr(new SsdbDriver(settings));
                dr->start();
                newSsdb = new SsdbServer(dr, true);
            }
            else{
                newSsdb = new SsdbServer(ser->driver(), false);
            }
            result.reset(newSsdb);
            servers_.push_back(result);
        }

        DCHECK(result);
        if(ser && syncServers_){
            result->syncWithServer(ser.get());
        }

        return result;
    }
 std::vector<QObject *> ServersManager::findAllListeners(const IDriverSPtr &drv) const
 {
     std::vector<QObject *> result;
     for(size_t j = 0; j < servers_.size(); ++j){
         IServerSPtr ser = servers_[j];
         if(ser->driver() == drv){
             result.push_back(ser.get());
         }
     }
     return result;
 }
    void ExplorerTreeModel::removeServer(IServerSPtr server)
    {
        fasto::qt::gui::TreeItem *par = dynamic_cast<fasto::qt::gui::TreeItem*>(root_);
        DCHECK(par);
        if(!par){
            return;
        }

        ExplorerServerItem *serverItem = findServerItem(server.get());
        if(serverItem){
            removeItem(QModelIndex(), serverItem);
        }
    }
    void ExplorerTreeView::openHistoryServerDialog()
    {
        QModelIndex sel = selectedIndex();
        if(!sel.isValid()){
            return;
        }

        ExplorerServerItem *node = common::utils_qt::item<ExplorerServerItem*>(sel);
        if(!node){
            return;
        }

        IServerSPtr server = node->server();
        if(!server){
            return;
        }

        ServerHistoryDialog histDialog(QString("%1 history").arg(server->name()), server->type(), this);
        VERIFY(connect(server.get(), &IServer::startedLoadServerHistoryInfo, &histDialog, &ServerHistoryDialog::startLoadServerHistoryInfo));
        VERIFY(connect(server.get(), &IServer::finishedLoadServerHistoryInfo, &histDialog, &ServerHistoryDialog::finishLoadServerHistoryInfo));
        VERIFY(connect(server.get(), &IServer::serverInfoSnapShoot, &histDialog, &ServerHistoryDialog::snapShotAdd));
        VERIFY(connect(&histDialog, &ServerHistoryDialog::showed, server.get(), &IServer::requestHistoryInfo));
        histDialog.exec();
    }
    void ExplorerTreeView::addServer(IServerSPtr server)
    {
        DCHECK(server);
        if(!server){
            return;
        }

        ExplorerTreeModel *mod = static_cast<ExplorerTreeModel*>(model());
        DCHECK(mod);
        if(!mod){
            return;
        }

        syncWithServer(server.get());

        mod->addServer(server);
    }
    void ExplorerTreeModel::addServer(IServerSPtr server)
    {
        if(!server){
            return;
        }

        ExplorerServerItem *serv = findServerItem(server.get());
        if(!serv){
            fasto::qt::gui::TreeItem *parent = dynamic_cast<fasto::qt::gui::TreeItem*>(root_);
            DCHECK(parent);
            if(!parent){
                return;
            }

            ExplorerServerItem *item = new ExplorerServerItem(server, parent);
            insertItem(QModelIndex(), item);
        }
    }
    void ExplorerTreeView::removeServer(IServerSPtr server)
    {
        DCHECK(server);
        if(!server){
            return;
        }

        ExplorerTreeModel *mod = static_cast<ExplorerTreeModel*>(model());
        DCHECK(mod);
        if(!mod){
            return;
        }

        unsyncWithServer(server.get());

        mod->removeServer(server);
        emit closeServer(server);
    }
Exemple #13
0
    IServerSPtr ServersManager::createServer(IConnectionSettingsBaseSPtr settings)
    {
        DCHECK(settings);

        IServerSPtr result;
        connectionTypes conT = settings->connectionType();
        IServerSPtr ser = findServerBySetting(settings);
#ifdef BUILD_WITH_REDIS
        if(conT == REDIS){
            result.reset(make_server<RedisServer, RedisDriver>(ser, settings));
        }
#endif
#ifdef BUILD_WITH_MEMCACHED
        if(conT == MEMCACHED){
            result.reset(make_server<MemcachedServer, MemcachedDriver>(ser, settings));
        }
#endif
#ifdef BUILD_WITH_SSDB
        if(conT == SSDB){
            result.reset(make_server<SsdbServer, SsdbDriver>(ser, settings));
        }
#endif
#ifdef BUILD_WITH_LEVELDB
        if(conT == LEVELDB){
            result.reset(make_server<LeveldbServer, LeveldbDriver>(ser, settings));
        }
#endif

        DCHECK(result);
        if(result){
            servers_.push_back(result);
            if(ser && syncServers_){
                result->syncWithServer(ser.get());
            }
        }

        return result;
    }
    ViewKeysDialog::ViewKeysDialog(const QString &title, IDatabaseSPtr db, QWidget* parent)
        : QDialog(parent), db_(db), cursorStack_(), curPos_(0)
    {
        DCHECK(db_);
        if(db_){
            IServerSPtr serv = db_->server();
            VERIFY(connect(serv.get(), &IServer::startedLoadDataBaseContent, this, &ViewKeysDialog::startLoadDatabaseContent));
            VERIFY(connect(serv.get(), &IServer::finishedLoadDatabaseContent, this, &ViewKeysDialog::finishLoadDatabaseContent));
        }

        setWindowTitle(title);

        // main layout
        QVBoxLayout *mainlayout = new QVBoxLayout;

        QHBoxLayout* searchLayout = new QHBoxLayout;
        searchBox_ = new QLineEdit;
        searchBox_->setText("*");
        VERIFY(connect(searchBox_, &QLineEdit::textChanged, this, &ViewKeysDialog::searchLineChanged));
        searchLayout->addWidget(searchBox_);

        countSpinEdit_ = new QSpinBox;
        countSpinEdit_->setRange(min_key_on_page, max_key_on_page);
        countSpinEdit_->setSingleStep(step_keys_on_page);
        countSpinEdit_->setValue(defaults_key);

        keyCountLabel_ = new QLabel;

        searchLayout->addWidget(keyCountLabel_);
        searchLayout->addWidget(countSpinEdit_);

        searchButton_ = new QPushButton;
        VERIFY(connect(searchButton_, &QPushButton::clicked, this, &ViewKeysDialog::rightPageClicked));
        searchLayout->addWidget(searchButton_);

        keysModel_ = new KeysTableModel(this);
        keysTable_ = new FastoTableView;
        keysTable_->setModel(keysModel_);

        QDialogButtonBox* buttonBox = new QDialogButtonBox;
        buttonBox->setOrientation(Qt::Horizontal);
        buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
        VERIFY(connect(buttonBox, &QDialogButtonBox::accepted, this, &ViewKeysDialog::accept));
        VERIFY(connect(buttonBox, &QDialogButtonBox::rejected, this, &ViewKeysDialog::reject));
        mainlayout->addLayout(searchLayout);
        mainlayout->addWidget(keysTable_);

        leftButtonList_ = createButtonWithIcon(GuiFactory::instance().leftIcon());
        rightButtonList_ = createButtonWithIcon(GuiFactory::instance().rightIcon());
        VERIFY(connect(leftButtonList_, &QPushButton::clicked, this, &ViewKeysDialog::leftPageClicked));
        VERIFY(connect(rightButtonList_, &QPushButton::clicked, this, &ViewKeysDialog::rightPageClicked));
        QHBoxLayout* pagingLayout = new QHBoxLayout;
        pagingLayout->addWidget(leftButtonList_);
        DataBaseInfoSPtr inf = db_->info();
        size_t sizeKey = inf->size();
        currentKey_ = new QSpinBox;
        currentKey_->setEnabled(false);
        currentKey_->setValue(0);
        currentKey_->setMinimum(0);
        currentKey_->setMaximum(sizeKey);
        countKey_ = new QSpinBox;
        countKey_->setEnabled(false);
        countKey_->setValue(sizeKey);
        pagingLayout->addWidget(new QSplitter(Qt::Horizontal));
        pagingLayout->addWidget(currentKey_);
        pagingLayout->addWidget(countKey_);
        pagingLayout->addWidget(new QSplitter(Qt::Horizontal));
        pagingLayout->addWidget(rightButtonList_);

        mainlayout->addLayout(pagingLayout);
        mainlayout->addWidget(buttonBox);

        setMinimumSize(QSize(min_width, min_height));
        setLayout(mainlayout);

        updateControls();
        retranslateUi();
    }