Example #1
0
 void ServersManager::clear()
 {
     for(size_t i = 0; i < servers_.size(); ++i){
         IServerSPtr ser = servers_[i];
         ser->driver()->stop();
     }
     servers_.clear();
 }
Example #2
0
    connectionTypes QueryWidget::connectionType() const
    {
        IServerSPtr ser = shellWidget_->server();
        if(!ser){
            return DBUNKNOWN;
        }

        return ser->type();
    }
Example #3
0
 IServerSPtr ServersManager::findServerBySetting(const IConnectionSettingsBaseSPtr &settings) const
 {
     for(size_t i = 0; i < servers_.size(); ++i){
         IServerSPtr drp = servers_[i];
         IDriverSPtr curDr = drp->driver();
         if(curDr->settings() == settings){
             return drp;
         }
     }
     return IServerSPtr();
 }
Example #4
0
    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;
    }
Example #5
0
 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;
 }
Example #6
0
    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();
    }
Example #8
0
 IDatabase::IDatabase(IServerSPtr server, DataBaseInfoSPtr info)
     : info_(info), server_(server)
 {
     DCHECK(server);
     DCHECK(info);
     DCHECK(server->type() == info->type());
 }
Example #9
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);
    }
SsdbDatabase::SsdbDatabase(IServerSPtr server, IDataBaseInfoSPtr info)
  : IDatabase(server, info) {
  DCHECK(server);
  DCHECK(info);
  DCHECK(server->type() == SSDB);
  DCHECK(info->type() == SSDB);
}
 MemcachedDatabase::MemcachedDatabase(IServerSPtr server, DataBaseInfoSPtr info)
     : IDatabase(server, info)
 {
     DCHECK(server);
     DCHECK(info);
     DCHECK(server->type() == MEMCACHED);
     DCHECK(info->type() == MEMCACHED);
 }
    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();
    }
    void ExplorerTreeView::importServer()
    {
        QModelIndex sel = selectedIndex();
        if(!sel.isValid()){
            return;
        }

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

        IServerSPtr server = node->server();

        using namespace translations;
        QString filepath = QFileDialog::getOpenFileName(this, trImport, QString(), trfilterForRdb);
        if (filepath.isEmpty() && server) {
            server->exportFromPath(filepath);
        }
    }
Example #14
0
    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);
        }
    }
Example #15
0
    void ServersManager::closeServer(IServerSPtr server)
    {
        for(size_t i = 0; i < servers_.size(); ++i){
            IServerSPtr ser = servers_[i];
            if(ser == server){
                if(ser->isSuperServer()){
                    IDriverSPtr drv = ser->driver();
                    for(size_t j = 0; j < servers_.size(); ++j){
                        IServerSPtr servj = servers_[j];
                        if(servj->driver() == drv){
                            servj->isSuperServer_ = true;
                            break;
                        }
                    }
                }

                servers_.erase(servers_.begin()+i);
                refreshSyncServers();
                break;
            }
        }
    }
Example #16
0
 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());
                     }
                 }
             }
         }
     }
 }
    void ExplorerTreeView::shutdownServer()
    {
        QModelIndex sel = selectedIndex();
        if(!sel.isValid()){
            return;
        }

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

        IServerSPtr server = node->server();
        if(server && server->isConnected()){
            // Ask user
            int answer = QMessageBox::question(this, "Shutdown", QString("Really shutdown \"%1\" server?").arg(server->name()), QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton);

            if (answer != QMessageBox::Yes){
                return;
            }

            server->shutDown();
        }
    }
    void ExplorerTreeView::openMaxClientSetDialog()
    {
        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;
        }

        bool ok;
        int maxcl = QInputDialog::getInt(this, tr("Set max connection on %1 server").arg(server->name()),
                                             tr("Maximum connection:"), 10000, 1, INT32_MAX, 100, &ok);
        if(ok){
            server->setMaxConnection(maxcl);
        }
    }
    void ExplorerTreeView::connectDisconnectToServer()
    {
        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;
        }

        if(server->isConnected()){
            server->disconnect();
        }
        else{
            server->connect();
        }
    }
    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);
    }
Example #21
0
    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);
    }
Example #23
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;
    }
    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();
    }
Example #25
0
    QVariant ExplorerTreeModel::data(const QModelIndex& index, int role) const
    {
        if (!index.isValid()){
            return QVariant();
        }

        IExplorerTreeItem* node = common::utils_qt::item<IExplorerTreeItem*>(index);

        if (!node){
            return QVariant();
        }

        int col = index.column();

        IExplorerTreeItem::eType t = node->type();

        if(role == Qt::ToolTipRole){
            IServerSPtr serv = node->server();
            if(t == IExplorerTreeItem::eServer && serv){
                ServerDiscoveryInfoSPtr disc = serv->discoveryInfo();
                if(disc){
                    QString dname = common::convertFromString<QString>(disc->name());
                    QString dtype = common::convertFromString<QString>(common::convertToString(disc->type()));
                    QString dhost = common::convertFromString<QString>(common::convertToString(disc->host()));
                    return QString("<b>Name:</b> %1<br/>"
                                   "<b>Type:</b> %2<br/>"
                                   "<b>Host:</b> %3<br/>").arg(dname).arg(dtype).arg(dhost);
                }
            }
            else if(t == IExplorerTreeItem::eDatabase){
                ExplorerDatabaseItem* db = dynamic_cast<ExplorerDatabaseItem*>(node);
                if(db && db->isDefault()){
                    return QString("<b>Db size:</b> %1 keys<br/>").arg(db->size());
                }
            }
        }

        if(role == Qt::DecorationRole && col == ExplorerServerItem::eName ){
            if(t == IExplorerTreeItem::eCluster){
                return GuiFactory::instance().clusterIcon();
            }
            else if(t == IExplorerTreeItem::eServer){
                return GuiFactory::instance().icon(node->server()->type());
            }
            else if(t == IExplorerTreeItem::eKey){
                return GuiFactory::instance().keyIcon();
            }
            else if(t == IExplorerTreeItem::eDatabase){
                return GuiFactory::instance().databaseIcon();
            }
            else{
                NOTREACHED();
            }
        }

        if (role == Qt::DisplayRole) {
            if (col == IExplorerTreeItem::eName) {
                if(t == IExplorerTreeItem::eKey){
                    return node->name();
                }
                else{
                    return QString("%1 (%2)").arg(node->name()).arg(node->childrenCount());
                }
            }
        }

        if(role == Qt::ForegroundRole){
            if(t == IExplorerTreeItem::eDatabase){
                ExplorerDatabaseItem* db = dynamic_cast<ExplorerDatabaseItem*>(node);
                if(db && db->isDefault()){
                    return QVariant( QColor( Qt::red ) );
                }
            }
        }

        return QVariant();
    }
    void ExplorerTreeView::showContextMenu(const QPoint& point)
    {
        QPoint menuPoint = mapToGlobal(point);
        menuPoint.setY(menuPoint.y() + header()->height());

        QModelIndex sel = selectedIndex();
        if(sel.isValid()){            
            IExplorerTreeItem *node = common::utils_qt::item<IExplorerTreeItem*>(sel);
            DCHECK(node);
            if(!node){
                return;
            }

            if(node->type() == IExplorerTreeItem::eCluster){
                QMenu menu(this);
                closeClusterAction_->setEnabled(true);
                menu.addAction(closeClusterAction_);
                menu.exec(menuPoint);
            }
            else if(node->type() == IExplorerTreeItem::eServer){
                QMenu menu(this);                
                menu.addAction(connectAction_);
                menu.addAction(openConsoleAction_);

                IServerSPtr server = node->server();
                bool isCon = server->isConnected();
                bool isAuth = server->isAuthenticated();

                bool isClusterMember = dynamic_cast<ExplorerClusterItem*>(node->parent()) != NULL;

                loadDatabaseAction_->setEnabled(isAuth);
                menu.addAction(loadDatabaseAction_);
                infoServerAction_->setEnabled(isAuth);
                menu.addAction(infoServerAction_);
                propertyServerAction_->setEnabled(isAuth);
                menu.addAction(propertyServerAction_);

                setServerPassword_->setEnabled(isAuth);
                menu.addAction(setServerPassword_);

                setMaxClientConnection_->setEnabled(isAuth);
                menu.addAction(setMaxClientConnection_);

                menu.addAction(historyServerAction_);
                closeServerAction_->setEnabled(!isClusterMember);
                menu.addAction(closeServerAction_);

                bool isLocal = server->isLocalHost();

                importAction_->setEnabled(!isCon && isLocal);
                menu.addAction(importAction_);                
                backupAction_->setEnabled(isCon && isLocal);
                menu.addAction(backupAction_);
                shutdownAction_->setEnabled(isAuth);
                menu.addAction(shutdownAction_);

                menu.exec(menuPoint);
            }
            else if(node->type() == IExplorerTreeItem::eDatabase){
                ExplorerDatabaseItem *db = dynamic_cast<ExplorerDatabaseItem*>(node);
                QMenu menu(this);
                menu.addAction(loadContentAction_);
                bool isDefault = db && db->isDefault();
                loadContentAction_->setEnabled(isDefault);

                menu.addAction(createKeyAction_);
                createKeyAction_->setEnabled(isDefault);

                if(isDefault){
                    menu.addAction(viewKeysAction_);
                }

                menu.addAction(setDefaultDbAction_);
                setDefaultDbAction_->setEnabled(!isDefault);
                menu.exec(menuPoint);
            }
            else if(node->type() == IExplorerTreeItem::eKey){
                QMenu menu(this);
                menu.addAction(getValueAction_);
                menu.addAction(deleteKeyAction_);
                menu.exec(menuPoint);
            }
        }
    }
Example #27
0
    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();
    }