Пример #1
0
void DatabaseList::slotContextMenu(const QPoint& pos)
{
    m_cell = indexAt(pos);
    // Make sure the right click occured on a cell!
    if (m_cell.isValid())
    {
        QMenu menu(this);
        bool bIsFavorite = m_filterModel->data(m_filterModel->index(m_cell.row(),DBLV_FAVORITE), Qt::ToolTipRole).toString() == tr("Favorite");
        bool bIsNotFavorite = m_filterModel->data(m_filterModel->index(m_cell.row(),DBLV_FAVORITE), Qt::ToolTipRole).toString().isEmpty();
        bool bHasPath = !m_filterModel->data(m_filterModel->index(m_cell.row(),DBLV_PATH), Qt::ToolTipRole).toString().isEmpty();
        bool bIsOpen = m_filterModel->data(m_filterModel->index(m_cell.row(),DBLV_OPEN), Qt::ToolTipRole).toString() == tr("Open");
        menu.addAction(bIsOpen ? tr("Activate") : tr("Open"), this, SLOT(dbOpen()));

        QAction* action = menu.addAction(tr("UTF8"), this, SLOT(dbToggleUTF8()));
        action->setCheckable(true);
        QString utf8 = m_filterModel->data(m_filterModel->index(m_cell.row(),DBLV_UTF8)).toString();
        bool bUtf8 = (utf8.compare("UTF8")==0);
        action->setChecked(bUtf8);

        menu.addAction(tr("Close"), this, SLOT(dbClose()))->setEnabled(bIsOpen && bHasPath);
        menu.addSeparator();
        menu.addAction(tr("Add to favorites"), this, SLOT(dbAddToFavorites()))->setEnabled(bIsNotFavorite);
        menu.addAction(tr("Remove from Favorites"), this, SLOT(dbRemoveFromFavorites()))->setEnabled(bIsFavorite);
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
        menu.addSeparator();
        menu.addAction(tr("Show in Finder"), this, SLOT(slotShowInFinder()))->setEnabled(bHasPath);
#endif
        menu.exec(mapToGlobal(pos));
    }
}
Пример #2
0
void DbService::init()
{
    BfDebug(__FUNCTION__);
    g_sm->checkCurrentOn(ServiceMgr::DB);

    // init env
    leveldb::Env::Default();
    leveldb::BytewiseComparator();

    // dbOpen
    dbOpen();

    // dbInit
    dbInit();
}
Пример #3
0
void DbService::init()
{
    BfDebug(__FUNCTION__);
    g_sm->checkCurrentOn(ServiceMgr::DB);

    // init env
    leveldb::Env::Default();
    leveldb::BytewiseComparator();

    // dbOpen
    dbOpen();

    // ctpmgr
    QObject::connect(g_sm->ctpMgr(), &CtpMgr::gotTick, this, &DbService::onGotTick);
    QObject::connect(g_sm->ctpMgr(), &CtpMgr::gotContracts, this, &DbService::onGotContracts);
    QObject::connect(g_sm->ctpMgr(), &CtpMgr::tradeWillBegin, this, &DbService::onTradeWillBegin);
}
Пример #4
0
DB_CURSOR *ltDbOpenSql0(ltDbConn *pConn,char *pSmt,int iSumBind,va_list ap)
{
    DB_CURSOR *lCursor;
    int iReturn,iStatus,status;
    if(pSmt == NULL) {
        return NULL;
    }
    lCursor=NULL;
    lCursor = dbOpen(pConn);
    if(lCursor == NULL) {
        return NULL;
    }
    iReturn = dbParse(lCursor, pSmt);
    if(iReturn == 0) {
	 if(lCursor){
         	dbClose(lCursor);
	 }
         return NULL;
    }else {
        if(iSumBind > 0) {
            status = _ltDbSetBindValue_o(pConn,lCursor,iSumBind,&ap);
            if(status != OCI_SUCCESS) {
               status = ltDbErrorCode(pConn);
               if(lCursor){
         		dbClose(lCursor);
	       }
               return NULL;
            }
        }
        iReturn = dbExec(lCursor);
        if(iReturn == 0) {
            if(lCursor){
         		dbClose(lCursor);
	     }
            return NULL;
        }
        else {
            return lCursor;
        }
    }
}
Пример #5
0
int umOpen()
{
    if (++umOpenCount != 1) {
        return didUM;
    }
    /*
     *	Do not initialize if intialization has already taken place
     */
    if (didUM == -1) {
        didUM = dbOpen(UM_USER_TABLENAME, UM_DB_FILENAME, NULL, 0);
        dbRegisterDBSchema(&userTable);
        dbRegisterDBSchema(&groupTable);
        dbRegisterDBSchema(&accessTable);
    }

    if (saveFilename == NULL) {
        saveFilename = bstrdup(B_L, UM_TXT_FILENAME);
    }

    return didUM;
}
Пример #6
0
void DbService::init()
{
    BfLog(__FUNCTION__);
    g_sm->checkCurrentOn(ServiceMgr::DB);

    // init env
    leveldb::Env::Default();
    leveldb::BytewiseComparator();

    // dbOpen
    dbOpen();

    // dbInit
    dbInit();

    // start timer
    this->pingTimer_ = new QTimer(this);
    this->pingTimer_->setInterval(5 * 1000);
    QObject::connect(this->pingTimer_, &QTimer::timeout, this, &DbService::onPing);
    this->pingTimer_->start();
}
Пример #7
0
/* 执行 SQL语句  */
int ltDbExecSql0(ltDbConn *pConn,char *pSmt,int iSumBind,...)
{
    DB_CURSOR *psCur;
    int status;
    va_list ap;
    psCur = dbOpen(pConn);
    if(psCur == NULL) {
        return -1;
    }
    status = OCIStmtPrepare(psCur->pStmt, psCur->pConn->pErr, pSmt,
        (ub4)strlen(pSmt),
        (ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT);
    if(status != OCI_SUCCESS) {
        status = ltDbErrorCode(pConn);
        dbClose(psCur);
        return status;
    }
    va_start(ap,iSumBind);
    status = _ltDbSetBindValue_o(pConn,psCur,iSumBind,&ap);
    va_end(ap);
    if(status != 0) {
        status = ltDbErrorCode(pConn);
        dbClose(psCur);
        return status;
    }
    
    status = OCIStmtExecute(psCur->pConn->pSvc, psCur->pStmt, psCur->pConn->pErr,
        1, (ub4)0, (OCISnapshot*)0, (OCISnapshot*)0, OCI_DEFAULT);
    if(status == OCI_SUCCESS) {
    /* 网文件中写日志  */
       
        dbClose(psCur);
        return 0;
    }
    else {
        status = ltDbErrorCode(pConn);
        dbClose(psCur);
        return status;
    }
}