示例#1
0
    void ExplorerTreeModel::setDefaultDb(IServer* server, DataBaseInfoSPtr db)
    {
        ExplorerServerItem *parent = findServerItem(server);
        DCHECK(parent);
        if(!parent){
            return;
        }

        int child_count = parent->childrenCount();
        for(int i = 0; i < child_count ; ++i){
            ExplorerDatabaseItem *item = dynamic_cast<ExplorerDatabaseItem*>(parent->child(i));
            DCHECK(item);
            if(!item){
                continue;
            }

            DataBaseInfoSPtr info = item->info();
            if(info->isDefault()){
                if(info->name() != db->name()){
                    info->setIsDefault(false);
                    updateItem(createIndex(i,0,parent), createIndex(i,0,parent));
                }
            }
            else{
                if(info->name() == db->name()){
                    info->setIsDefault(true);
                    updateItem(createIndex(i,0,parent), createIndex(i,0,parent));
                }
            }
        }
    }
示例#2
0
 IDatabase::IDatabase(IServerSPtr server, DataBaseInfoSPtr info)
     : info_(info), server_(server)
 {
     DCHECK(server);
     DCHECK(info);
     DCHECK(server->type() == info->type());
 }
 MemcachedDatabase::MemcachedDatabase(IServerSPtr server, DataBaseInfoSPtr info)
     : IDatabase(server, info)
 {
     DCHECK(server);
     DCHECK(info);
     DCHECK(server->type() == MEMCACHED);
     DCHECK(info->type() == MEMCACHED);
 }
示例#4
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();
    }