本文整理汇总了C++中DS函数的典型用法代码示例。如果您正苦于以下问题:C++ DS函数的具体用法?C++ DS怎么用?C++ DS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: connect
void SettingsWindow::connectSlots()
{
connect (m_ok, SIGNAL (clicked()), this, SLOT (apply()));
connect (m_reset, SIGNAL (clicked()), this, SLOT (reset()));
connect (m_cancel, SIGNAL (clicked()), this, SLOT (cancel()));
connect (DS(), SIGNAL (teamChanged (int)), this, SLOT (updateTeam (int)));
connect (DS(), SIGNAL (protocolChanged()), this, SLOT (readSettings()));
connect (m_useCustomAddress, SIGNAL (toggled (bool)),
m_robotAddress, SLOT (setEnabled (bool)));
connect (m_baseButton, SIGNAL (clicked()),
this, SLOT (onSelectorClicked()));
connect (m_highlightButton, SIGNAL (clicked()),
this, SLOT (onSelectorClicked()));
connect (m_backgroundButton, SIGNAL (clicked()),
this, SLOT (onSelectorClicked()));
connect (m_foregroundButton, SIGNAL (clicked()),
this, SLOT (onSelectorClicked()));
connect (m_baseEdit, SIGNAL (textChanged (QString)),
this, SLOT (onColorChanged (QString)));
connect (m_highlightEdit, SIGNAL (textChanged (QString)),
this, SLOT (onColorChanged (QString)));
connect (m_backgroundEdit, SIGNAL (textChanged (QString)),
this, SLOT (onColorChanged (QString)));
connect (m_foregroundEdit, SIGNAL (textChanged (QString)),
this, SLOT (onColorChanged (QString)));
}
示例2: DS
void SettingsWindow::applySettings()
{
/* Set the team number to be sure the address placeholder is good */
DS()->setTeamNumber (Settings::get ("Team", 0).toInt());
/* Only use a custom robot address if the checkbox is checked */
QString ip = m_useCustomAddress->isChecked() ? m_robotAddress->text() : "";
Settings::set ("Robot Address", ip);
/* Apply the robot address */
DS()->setRobotAddress (ip);
m_robotAddress->setText (ip);
m_robotAddress->setPlaceholderText (DS()->defaultRobotAddress());
/* Apply other settings */
Settings::set ("Auto Updater", m_autoUpdater->isChecked());
Settings::set ("UI Sounds", m_soundEffects->isChecked());
Settings::set ("Prompt on Quit", m_promptOnQuit->isChecked());
/* Create and apply a theme from UI values */
AppTheme::Theme theme;
theme.base = m_baseEdit->text();
theme.highlight = m_highlightEdit->text();
theme.background = m_backgroundEdit->text();
theme.foreground = m_foregroundEdit->text();
AppTheme::apply (theme);
}
示例3: FileXferDone
BOOL CTwain::FileXfer(void)
{
TW_SETUPFILEXFER twsfx;
if (!DS(DG_CONTROL, DAT_SETUPFILEXFER, MSG_GET, &twsfx)) {
return FALSE;
}
int nFF = twsfx.Format;
if (!FileXferReady(nFF, twsfx.FileName)) {
// application aborted transfer
return FALSE;
}
twsfx.Format = (TW_UINT16)nFF;
if (!DS(DG_CONTROL, DAT_SETUPFILEXFER, MSG_SET, &twsfx)) {
FileXferDone(NULL, 0);
return FALSE;
}
if (!DS(DG_IMAGE, DAT_IMAGEFILEXFER, MSG_GET, NULL)) {
FileXferDone(NULL, 0);
return FALSE;
}
ATLASSERT(nState >= TRANSFER_READY);
EndXfer(); // acknowledge & end transfer
ATLASSERT(nState == TRANSFER_READY || nState == SOURCE_ENABLED);
FlushMessageQueue();
FileXferDone(twsfx.FileName, 255);
return TRUE;
}
示例4: buttons_waiting
static QState buttons_waiting(struct Buttons *me)
{
switch (Q_SIG(me)) {
case Q_ENTRY_SIG:
SERIALSTR("<+bw>");
DS(button1, BUTTON_RELEASED_SIGNAL);
DS(button2, BUTTON_RELEASED_SIGNAL);
DS(button3, BUTTON_RELEASED_SIGNAL);
me->up_counter = 3;
return Q_HANDLED();
case BUTTONS_SIGNAL:
if ((uint16_t)(Q_PAR(me)) == 0) {
me->up_counter --;
if (me->up_counter) {
return Q_HANDLED();
} else {
SERIALSTR("@");
return Q_TRAN(buttons_state);
}
} else {
me->up_counter = 3;
return Q_HANDLED();
}
case Q_EXIT_SIG:
SERIALSTR("<-bw>");
return Q_HANDLED();
}
return Q_SUPER(buttons_state);
}
示例5: ATLASSERT
BOOL CTwain::MemoryXfer(void)
{
ATLASSERT(nState == TRANSFER_READY);
TW_IMAGEINFO info;
TW_SETUPMEMXFER twsx;
TW_IMAGEMEMXFER mx;
if (!DS(DG_CONTROL, DAT_SETUPMEMXFER, MSG_GET, &twsx)) {
return FALSE;
}
// Get actual image info
if (!DS(DG_IMAGE, DAT_IMAGEINFO, MSG_GET, &info)) {
return FALSE;
}
ATLASSERT(nState == TRANSFER_READY);
if (!MemXferReady(info)) {
// application aborted transfer
return FALSE;
}
if (!MemXferAlloc(twsx, mx.Memory)) {
MemXferDone(FALSE);
return FALSE;
}
int iRow = 0;
while (DS(DG_IMAGE, DAT_IMAGEMEMXFER, MSG_GET, &mx)) {
// We got a buffer - make sure DS doesn't
// feed us rows past the end of the image:
mx.Rows = min(mx.Rows, (unsigned)(info.ImageLength - iRow));
// Don't call the buffer-handler with 0 rows
if (mx.Rows != 0) {
if (!MemXferBuffer(iRow, mx)) {
// Buffer callback says to abort
break;
}
iRow += mx.Rows;
}
if (ResultCode() == TWRC_XFERDONE) {
// DS says that was the last buffer:
iRow = info.ImageLength; // no matter what, we're done
break;
}
}
MemXferFree(mx.Memory);
ATLASSERT(nState >= TRANSFER_READY);
EndXfer(); // acknowledge & end transfer
ATLASSERT(nState == TRANSFER_READY || nState == SOURCE_ENABLED);
FlushMessageQueue();
MemXferDone(iRow == info.ImageLength);
return TRUE;
}
示例6: sql_change_passwd
/* change passwd */
int sql_change_passwd(cs_request_t *req, sqlite3 *db, buf_t *wbuf)
{
if (req == NULL || req->name == NULL || req->passwd == NULL ||
db == NULL || wbuf == NULL || wbuf->data == NULL) {
E("parameter error.");
return -1;
}
char *query_line = (char *)cs_malloc(sizeof(char) * QUERY_LEN_MAX);
if (query_line == NULL) {
E("cs_malloc() failed.");
DPSTR(wbuf);
return -1;
}
/* check identify */
sprintf(query_line, "select * from users where name='%s' and passwd='%s'",
req->name, req->passwd);
DS(query_line);
int sql_select_num = 0;
int ret = sqlite3_exec(db, query_line, sql_check_identity_cb,
&sql_select_num, NULL);
if (ret != SQLITE_OK || sql_select_num != 1) {
/* no this user & passwd */
E("sqlite3_exec() failed.");
DD(sql_select_num);
cs_free(&query_line);
strncpy(wbuf->data, "err", 3);
wbuf->len = 3;
return -1;
}
/* update user info in users table */
memset(query_line, '\0', QUERY_LEN_MAX);
sprintf(query_line, "update users set passwd='%s' where name='%s'", req->content, req->name);
DS(query_line);
ret = sqlite3_exec(db, query_line, NULL, NULL, NULL);
if (ret != SQLITE_OK) {
E("sqlite3_exec() failed.");
cs_free(&query_line);
strncpy(wbuf->data, "err", 3);
wbuf->len = 3;
return -1;
}
strncpy(wbuf->data, "ok", 2);
wbuf->len = 2;
cs_free(&query_line);
D(GREEN"user %s change passwd success.", req->name);
return 0;
}
示例7: sql_del_log
/* del log */
int sql_del_log(cs_request_t *req, sqlite3 *db, buf_t *wbuf)
{
if (req == NULL || req->name == NULL || req->buddy_name == NULL ||
db == NULL || wbuf == NULL || wbuf->data == NULL) {
E("parameter error.");
return -1;
}
char *query_line = (char *)cs_malloc(sizeof(char) * QUERY_LEN_MAX);
if (query_line == NULL) {
E("cs_malloc() failed.");
DPSTR(wbuf);
return -1;
}
/* check log_type */
sprintf(query_line, "select * from %s where name='%s'", req->name, req->buddy_name);
DS(query_line);
int log_type = -1;
int ret = sqlite3_exec(db, query_line, sql_log_type_cb, &log_type, NULL);
if (ret != SQLITE_OK) {
E("sqlite3_exec() failed.");
DD(log_type);
cs_free(&query_line);
return -1;
}
/* empty offline table message */
memset(query_line, '\0', QUERY_LEN_MAX);
if (log_type == 0)
sprintf(query_line, "delete from %s_%s", req->name, req->buddy_name);
else if (log_type == 1)
sprintf(query_line, "delete from %s_%s", req->buddy_name, req->name);
else
DD(log_type);
DS(query_line);
ret = sqlite3_exec(db, query_line, NULL, NULL, NULL);
if (ret != SQLITE_OK) {
E("sqlite3_exec() failed.");
cs_free(&query_line);
return -1;
}
strncpy(wbuf->data, "ok", 2);
wbuf->len = 2;
cs_free(&query_line);
D(GREEN"clear log with %s success.", req->buddy_name);
return 0;
}
示例8: buttons_state
static QState buttons_state(struct Buttons *me)
{
switch (Q_SIG(me)) {
case Q_ENTRY_SIG:
SERIALSTR("(b2)");
return Q_HANDLED();
case BUTTONS_WAIT_SIGNAL:
return Q_TRAN(buttons_waiting);
case BUTTONS_SIGNAL:
if ((uint16_t)(Q_PAR(me)) & 0b0001) {
DS(button1, BUTTON_PRESSED_SIGNAL);
} else {
DS(button1, BUTTON_RELEASED_SIGNAL);
}
if ((uint16_t)(Q_PAR(me)) & 0b0010) {
DS(button2, BUTTON_PRESSED_SIGNAL);
} else {
DS(button2, BUTTON_RELEASED_SIGNAL);
}
if ((uint16_t)(Q_PAR(me)) & 0b0100) {
DS(button3, BUTTON_PRESSED_SIGNAL);
} else {
DS(button3, BUTTON_RELEASED_SIGNAL);
}
if ((uint16_t)(Q_PAR(me)) & 0b1000) {
DS(button4, BUTTON_PRESSED_SIGNAL);
} else {
DS(button4, BUTTON_RELEASED_SIGNAL);
}
return Q_HANDLED();
}
return Q_SUPER(QHsm_top);
}
示例9: sql_logout
int sql_logout(cs_request_t *req, sqlite3 *db, buf_t *wbuf)
{
if (req == NULL || db == NULL || wbuf == NULL || wbuf->data == NULL) {
E("parameter error.");
return -1;
}
char *query_line = (char *)cs_malloc(sizeof(char) * QUERY_LEN_MAX);
if (query_line == NULL) {
E("cs_malloc() failed.");
DPSTR(wbuf);
return -1;
}
/* update user info in users table */
sprintf(query_line, "update users set fd=-1 where name='%s'", req->name);
DS(query_line);
int ret = sqlite3_exec(db, query_line, NULL, NULL, NULL);
if (ret != SQLITE_OK) {
E("sqlite3_exec() failed.");
cs_free(&query_line);
return -1;
}
/* notice all buddy */
memset(query_line, '\0', QUERY_LEN_MAX);
sprintf(query_line, "select %s.name, users.fd from %s,users where %s.name=users.name", req->name, req->name, req->name);
DS(query_line);
ret = sqlite3_exec(db, query_line, sql_notice_buddy_cb, req->name, NULL);
if (ret != SQLITE_OK) {
E("sqlite3_exec() failed.");
cs_free(&query_line);
return -1;
}
strncpy(wbuf->data, "ok", 2);
wbuf->len = 2;
cs_free(&query_line);
/*
* find mine fd, fd_clr and close fd.
* free mine wrbuf
* on L171 cs_server.c where n == 0
*/
return 0;
}
示例10: DS
void TextEditorRemoteNode::processIncomingPacket( const QByteArray &B )
{
QDataStream DS( B );
quint16 PacketType = PACKET_UNKNOWN;
DS >> PacketType;
switch( PacketType )
{
case PACKET_UNKNOWN:
break;
case PACKET_TEXT:
receiveTextPacket( DS );
break;
case PACKET_HIGHLIGHTER:
receiveHighlighter( DS );
break;
case PACKET_ERRORS:
receiveErrors( DS );
break;
}
}
示例11: QLabel
void Preferences::createWidgets()
{
m_protocolLabel = new QLabel (tr ("Protocol"), this);
m_dashboardLabel = new QLabel (tr ("Dashboard"), this);
m_teamNumberLabel = new QLabel (tr ("Team Number"), this);
m_teamNumber = new QSpinBox (this);
m_protocols = new QComboBox (this);
m_dashboards = new QComboBox (this);
m_practiceTimings = new QGroupBox (tr ("Practice Timings"), this);
m_delayLabel = new QLabel (tr ("Delay"));
m_teleopLabel = new QLabel (tr ("Teleop"));
m_endGameLabel = new QLabel (tr ("End game"));
m_countdownLabel = new QLabel (tr ("Countdown"));
m_autonomousLabel = new QLabel (tr ("Autonomous"));
m_delay = new QSpinBox (this);
m_teleop = new QSpinBox (this);
m_endGame = new QSpinBox (this);
m_countdown = new QSpinBox (this);
m_autonomous = new QSpinBox (this);
m_delay->setRange (0, 500);
m_teleop->setRange (0, 500);
m_endGame->setRange (0, 500);
m_countdown->setRange (0, 500);
m_autonomous->setRange (0, 500);
m_teamNumber->setRange (0, 9999);
m_protocols->addItems (DS()->protocols());
m_dashboards->addItems (Dashboards::getInstance()->dashboardList());
m_dashboards->setCurrentIndex (Settings::get ("Dashboard", 0).toInt());
}
示例12: sql_find_buddy_fd
int sql_find_buddy_fd(cs_request_t *req, sqlite3 *db)
{
if (req == NULL || req->name == NULL ||
req->buddy_name == NULL || db == NULL) {
E("parameter error.");
return -1;
}
char *query_line = (char *)cs_malloc(sizeof(char) * QUERY_LEN_MAX);
if (query_line == NULL) {
E("cs_malloc() failed.");
return -1;
}
sprintf(query_line, "select * from users where name='%s'",
req->buddy_name);
DS(query_line);
int fd = 0;
int ret = sqlite3_exec(db, query_line, sql_buddy_fd_cb, &fd, NULL);
if (ret != SQLITE_OK || fd < 0) {
E("sqlite3_exec() failed.");
DD(fd);
cs_free(&query_line);
return -1;
}
cs_free(&query_line);
D(GREEN"user %s fd is %d.", req->buddy_name, fd);
return fd;
}
示例13: ATLTRACE_ERROR
int CTwain::SetCapOneValue(unsigned Cap, unsigned ItemType, TW_UINT32 ItemVal)
{
TW_CAPABILITY cap;
pTW_ONEVALUE pv;
BOOL bSuccess;
if (nState != SOURCE_OPEN) {
ATLTRACE_ERROR(TWERR_NOT_4);
return FALSE;
}
cap.Cap = (TW_UINT16)Cap; // capability id
cap.ConType = TWON_ONEVALUE; // container type
do
{
cap.hContainer = GlobalAlloc(GHND, sizeof (TW_ONEVALUE));
if (!cap.hContainer)
{
if (IDCANCEL == MessageBox(NULL, _T("Internal error while preparing for TWAIN acquire."), _T("ImageWalker"), MB_RETRYCANCEL | MB_ICONEXCLAMATION))
{
return FALSE;
}
}
} while (!cap.hContainer);
pv = (pTW_ONEVALUE)GlobalLock(cap.hContainer);
pv->ItemType = (TW_UINT16)ItemType;
pv->Item = ItemVal;
GlobalUnlock(cap.hContainer);
bSuccess = DS(DG_CONTROL, DAT_CAPABILITY, MSG_SET, (TW_MEMREF)&cap);
GlobalFree(cap.hContainer);
return bSuccess;
} // SetCapOneValue
示例14: sql_view_info
int sql_view_info(cs_request_t *req, sqlite3 *db, buf_t *wbuf)
{
if (req == NULL || req->buddy_name == NULL ||
db == NULL || wbuf == NULL || wbuf->data == NULL) {
E("parameter error.");
return -1;
}
/* check log_type */
char *query_line = (char *)cs_malloc(sizeof(char) * QUERY_LEN_MAX);
if (query_line == NULL) {
E("cs_malloc() failed.");
DPSTR(wbuf);
return -1;
}
sprintf(query_line, "select * from users where name='%s'", req->buddy_name);
DS(query_line);
int ret = sqlite3_exec(db, query_line, sql_get_info_cb, wbuf, NULL);
if (ret != SQLITE_OK) {
E("sqlite3_exec() failed.");
cs_free(&query_line);
return -1;
}
cs_free(&query_line);
D(GREEN"view %s info success.", req->buddy_name);
return 0;
}
示例15: DS
int CTwain::TwainMessageHook(LPMSG lpmsg)
// returns TRUE if message processed by TWAIN
// FALSE otherwise
{
int bProcessed = FALSE;
if (nState >= SOURCE_ENABLED) {
// source enabled
TW_EVENT twEvent;
twEvent.pEvent = (TW_MEMREF)lpmsg;
twEvent.TWMessage = MSG_NULL;
// relay message to source in case it wants it
DS(DG_CONTROL, DAT_EVENT, MSG_PROCESSEVENT, &twEvent);
bProcessed = (rc == TWRC_DSEVENT);
switch (twEvent.TWMessage) {
case MSG_XFERREADY:
// notify by callback
// default callback does transfers
XferReady(lpmsg);
break;
case MSG_CLOSEDSREQ:
// notify by callback
// default callback closes the source
CloseDsRequest();
break;
case MSG_NULL:
// no message returned from DS
break;
} // switch
}
return bProcessed;
} // TwainMessageHook