本文整理汇总了C++中EventCommandExec类的典型用法代码示例。如果您正苦于以下问题:C++ EventCommandExec类的具体用法?C++ EventCommandExec怎么用?C++ EventCommandExec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventCommandExec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processEvent
bool WinDockPlugin::processEvent(Event *e)
{
if (e->type() == eEventCommandExec){
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
CommandDef *cmd = ece->cmd();
if (cmd->id == CmdAutoHide){
dock->setAutoHide((cmd->flags & COMMAND_CHECKED) != 0);
bAutoHideVisible = true;
setBarState();
enableAutoHide(getAutoHide());
return true;
}
} else
if (e->type() == eEventCheckCommandState){
EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
CommandDef *cmd = ecs->cmd();
if ((cmd->id == CmdAutoHide) && (dock->getState() != ABE_FLOAT)){
cmd->flags &= ~COMMAND_CHECKED;
if (dock->getAutoHide())
cmd->flags |= COMMAND_CHECKED;
return true;
}
} else
if ((e->type() == eEventInit) && !m_bInit)
init();
if (e->type() == eEventInTaskManager){
EventInTaskManager *eitm = static_cast<EventInTaskManager*>(e);
if ((dock->getState() != ABE_FLOAT) && eitm->showInTaskmanager()){
EventInTaskManager(false).process();
return true;
}
}
return false;
}
示例2: switch
bool MsgJournal::processEvent(Event *e)
{
if (e->type() == eEventCheckCommandState){
EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
CommandDef *cmd = ecs->cmd();
if (cmd->param == m_edit){
unsigned id = cmd->bar_grp;
if ((id >= MIN_INPUT_BAR_ID) && (id < MAX_INPUT_BAR_ID)){
cmd->flags |= BTN_HIDE;
if ((cmd->id == CmdDeleteJournalMessage + CmdReceived) && m_ID)
cmd->flags &= ~BTN_HIDE;
return true;
}
switch (cmd->id){
case CmdSend:
case CmdSendClose:
e->process(this);
cmd->flags &= ~BTN_HIDE;
return true;
case CmdTranslit:
case CmdSmile:
case CmdNextMessage:
case CmdMsgAnswer:
e->process(this);
cmd->flags |= BTN_HIDE;
return true;
}
}
} else
if (e->type() == eEventCommandExec){
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
CommandDef *cmd = ece->cmd();
if (cmd->param == m_edit){
if (cmd->id == CmdSend){
QString msgText = m_edit->m_edit->text();
if (!msgText.isEmpty())
send(msgText);
return true;
}
if (cmd->id == CmdDeleteJournalMessage + CmdReceived){
QWidget *w = m_edit->m_bar;
Command cmd;
cmd->id = CmdDeleteJournalMessage + CmdReceived;
cmd->param = m_edit;
EventCommandWidget eWidget(cmd);
eWidget.process();
QWidget *btnRemove = eWidget.widget();
if (btnRemove)
w = btnRemove;
BalloonMsg::ask(NULL, i18n("Remove record from journal?"), w, SLOT(removeRecord(void*)), NULL, NULL, this);
return true;
}
return false;
}
示例3: switch
bool MsgContacts::processEvent(Event *e)
{
if (e->type() == eEventCheckCommandState){
EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
CommandDef *cmd = ecs->cmd();
if (cmd->param == m_edit){
unsigned id = cmd->bar_grp;
if ((id >= MIN_INPUT_BAR_ID) && (id < MAX_INPUT_BAR_ID)){
cmd->flags |= BTN_HIDE;
return true;
}
switch (cmd->id){
case CmdSend:
case CmdSendClose:
e->process(this);
cmd->flags &= ~BTN_HIDE;
return true;
case CmdTranslit:
case CmdSmile:
case CmdNextMessage:
case CmdMsgAnswer:
e->process(this);
cmd->flags |= BTN_HIDE;
return true;
}
}
} else
if (e->type() == eEventCommandExec){
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
CommandDef *cmd = ece->cmd();
if ((cmd->id == CmdSend) && (cmd->param == m_edit)){
QString msgText = m_edit->m_edit->text();
QString contacts;
for (list<unsigned>::iterator it = m_list->selected.begin(); it != m_list->selected.end(); ++it){
Contact *contact = getContacts()->contact(*it);
if (contact){
if (!contacts.isEmpty())
contacts += ';';
contacts += QString("sim:%1,%2") .arg(*it) .arg(contact->getName());
}
}
if (!contacts.isEmpty()){
ContactsMessage *msg = new ContactsMessage;
msg->setContact(m_edit->m_userWnd->id());
msg->setContacts(contacts);
msg->setClient(m_client);
m_edit->sendMessage(msg);
}
return true;
}
}
return false;
}
示例4: switch
bool MsgGen::processEvent(Event *e)
{
if (e->type() == eEventCheckCommandState){
EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
CommandDef *cmd = ecs->cmd();
if (cmd->param == m_edit){
unsigned id = cmd->bar_grp;
if ((id >= MIN_INPUT_BAR_ID) && (id < MAX_INPUT_BAR_ID)){
cmd->flags |= BTN_HIDE;
return true;
}
switch (cmd->id){
case CmdTranslit:
case CmdSmile:
case CmdSend:
case CmdSendClose:
e->process(this);
cmd->flags &= ~BTN_HIDE;
return true;
case CmdNextMessage:
case CmdMsgAnswer:
e->process(this);
cmd->flags |= BTN_HIDE;
return true;
}
}
} else
if (e->type() == eEventCommandExec){
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
CommandDef *cmd = ece->cmd();
if ((cmd->id == CmdSend) && (cmd->param == m_edit)){
QString msgText = m_edit->m_edit->text();
if (!msgText.isEmpty()){
log(L_DEBUG, "Send: %s", msgText.local8Bit().data());
Message *msg = new Message;
msg->setText(msgText);
msg->setContact(m_edit->m_userWnd->id());
msg->setClient(m_client);
msg->setFlags(MESSAGE_RICHTEXT);
msg->setForeground(m_edit->m_edit->foreground().rgb() & 0xFFFFFF);
msg->setBackground(m_edit->m_edit->background().rgb() & 0xFFFFFF);
msg->setFont(CorePlugin::m_plugin->getEditFont());
m_edit->sendMessage(msg);
}
return true;
}
}
return false;
}
示例5: processEvent
bool ListView::processEvent(Event *e)
{
if (e->type() == eEventCommandExec){
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
CommandDef *cmd = ece->cmd();
if ((cmd->id == CmdListDelete) && (cmd->menu_id == MenuListView)){
ListViewItem *item = (ListViewItem*)(cmd->param);
if (item->listView() == this){
emit deleteItem(item);
return true;
}
}
}
return false;
}
示例6: processEvent
bool NetmonitorPlugin::processEvent(Event *e)
{
if (e->type() == eEventCommandExec){
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
CommandDef *cmd = ece->cmd();
if (cmd->id == CmdNetMonitor){
showMonitor();
return true;
}
}
else if(e->type() == eEventPluginLoadConfig)
{
PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("netmonitor");
if(!hub.isNull())
setPropertyHub(hub);
}
return false;
}
示例7: switch
bool MsgAuth::processEvent(Event *e)
{
if (e->type() == eEventCheckCommandState){
EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
CommandDef *cmd = ecs->cmd();
if (cmd->param == m_edit){
unsigned id = cmd->bar_grp;
if ((id >= MIN_INPUT_BAR_ID) && (id < MAX_INPUT_BAR_ID)){
cmd->flags |= BTN_HIDE;
return true;
}
switch (cmd->id){
case CmdTranslit:
case CmdSmile:
case CmdSend:
case CmdSendClose:
e->process(this);
cmd->flags &= ~BTN_HIDE;
return true;
case CmdNextMessage:
case CmdMsgAnswer:
e->process(this);
cmd->flags |= BTN_HIDE;
return true;
}
}
} else
if (e->type() == eEventCommandExec){
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
CommandDef *cmd = ece->cmd();
if ((cmd->id == CmdSend) && (cmd->param == m_edit)){
QString msgText = m_edit->m_edit->text();
AuthMessage *msg = new AuthMessage(m_type);
msg->setText(msgText);
msg->setContact(m_edit->m_userWnd->id());
msg->setClient(m_client);
m_edit->sendMessage(msg);
return true;
}
}
return false;
}
示例8: processEvent
bool AboutPlugin::processEvent(Event *e)
{
if (e->type() == eEventCommandExec){
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
CommandDef *cmd = ece->cmd();
if (cmd->id == CmdBugReport){
QString s = "http://developer.berlios.de/bugs/?group_id=4482";
EventGoURL eURL(s);
eURL.process();
}
if (cmd->id == CmdAbout){
if (about == NULL)
{
KAboutData *about_data = getAboutData();
about_data->setTranslator(
I18N_NOOP("_: NAME OF TRANSLATORS\nYour names"),
I18N_NOOP("_: EMAIL OF TRANSLATORS\nYour emails"));
about = new KAboutApplication( about_data, NULL, "about", false );
connect(about, SIGNAL(finished()), this, SLOT(aboutDestroyed()));
}
raiseWindow(about);
}
#ifdef USE_KDE
if (cmd->id == CmdAboutKDE){
if (about_kde == NULL)
{
about_kde = new KAboutKDE( NULL, "aboutkde", false);
connect(about_kde, SIGNAL(finished()), this, SLOT(aboutDestroyed()));
}
raiseWindow(about_kde);
}
#endif
}
return false;
}
示例9: switch
bool DockPlugin::processEvent(Event *e)
{
switch (e->type()){
case eEventInit:
init();
break;
case eEventQuit:
if (m_dock){
delete m_dock;
m_dock = NULL;
}
break;
case eEventRaiseWindow: {
EventRaiseWindow *w = static_cast<EventRaiseWindow*>(e);
if (w->widget() == getMainWindow()){
if (m_dock == NULL)
init();
if (!getShowMain())
return (void*)1;
}
break;
}
case eEventCommandCreate: {
EventCommandCreate *ecc = static_cast<EventCommandCreate*>(e);
CommandDef *def = ecc->cmd();
if (def->menu_id == MenuMain){
CommandDef d = *def;
if (def->flags & COMMAND_IMPORTANT){
if (d.menu_grp == 0)
d.menu_grp = 0x1001;
}else{
d.menu_grp = 0;
}
d.menu_id = DockMenu;
d.bar_id = 0;
EventCommandCreate(&d).process();
}
break;
}
case eEventCheckCommandState: {
EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
CommandDef *def = ecs->cmd();
if (def->id == CmdToggle){
def->flags &= ~COMMAND_CHECKED;
def->text = isMainShow() ?
I18N_NOOP("Hide main window") :
I18N_NOOP("Show main window");
return (void*)1;
}
break;
}
case eEventCommandExec: {
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
CommandDef *def = ece->cmd();
if (def->id == CmdToggle){
QWidget *main = getMainWindow();
if(!main)
return false;
if (isMainShow()){
setShowMain(false);
main->hide();
}else{
m_inactiveTime = 0;
setShowMain(true);
raiseWindow(main,getDesktop());
}
return (void*)1;
}
if (def->id == CmdCustomize){
EventMenu(DockMenu, EventMenu::eCustomize).process();
return (void*)1;
}
if (def->id == CmdQuit)
m_bQuit = true;
break;
}
default:
break;
}
return false;
}
示例10: switch
//.........这里部分代码省略.........
contactChanged(contact);
break;
}
case EventContact::eStatus: {
unsigned style = 0;
QString wrkIcons;
QString statusIcon;
contact->contactInfo(style, statusIcon, &wrkIcons);
bool bTyping = false;
while (!wrkIcons.isEmpty()){
if (getToken(wrkIcons, ',') == "typing"){
bTyping = true;
break;
}
}
if (userWnd->m_bTyping != bTyping){
userWnd->m_bTyping = bTyping;
if (bTyping){
userWnd->setStatus(g_i18n("%1 is typing", contact) .arg(contact->getName()));
}else{
userWnd->setStatus("");
}
userWnd = m_tabBar->currentWnd();
if (userWnd && (contact->id() == userWnd->id()))
m_status->message(userWnd->status());
}
}
default:
break;
}
break;
}
case eEventClientsChanged:
setupAccel();
break;
case eEventContactClient: {
EventContactClient *ecc = static_cast<EventContactClient*>(e);
contactChanged(ecc->contact());
break;
}
case eEventInit:
init();
break;
case eEventCommandExec: {
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
CommandDef *cmd = ece->cmd();
UserWnd *userWnd = m_tabBar->currentWnd();
if (userWnd && ((unsigned long)(cmd->param) == userWnd->id())){
if (cmd->menu_id == MenuContainerContact){
m_tabBar->raiseTab(cmd->id);
return true;
}
if (cmd->id == CmdClose){
delete userWnd;
return true;
}
if (cmd->id == CmdInfo && cmd->menu_id != MenuContact){
CommandDef c = *cmd;
c.menu_id = MenuContact;
c.param = (void*)userWnd->id();
EventCommandExec(&c).process();
return true;
}
}
break;
}
case eEventCheckCommandState: {
EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
CommandDef *cmd = ecs->cmd();
UserWnd *userWnd = m_tabBar->currentWnd();
if (userWnd && ((unsigned long)(cmd->param) == userWnd->id()) &&
(cmd->menu_id == MenuContainerContact) &&
(cmd->id == CmdContainerContacts)){
list<UserWnd*> userWnds = m_tabBar->windows();
CommandDef *cmds = new CommandDef[userWnds.size() + 1];
unsigned n = 0;
for (list<UserWnd*>::iterator it = userWnds.begin(); it != userWnds.end(); ++it){
cmds[n].id = (*it)->id();
cmds[n].flags = COMMAND_DEFAULT;
cmds[n].text_wrk = (*it)->getName();
cmds[n].icon = (*it)->getIcon();
cmds[n].text = "_";
cmds[n].menu_id = n + 1;
if (n < sizeof(accels) / sizeof(const char*))
cmds[n].accel = accels[n];
if (*it == m_tabBar->currentWnd())
cmds[n].flags |= COMMAND_CHECKED;
n++;
}
cmd->param = cmds;
cmd->flags |= COMMAND_RECURSIVE;
return true;
}
break;
}
default:
break;
}
return false;
}
示例11: switch
bool HistoryWindow::processEvent(Event *e)
{
switch(e->type()) {
case eEventContact:
{
EventContact *ec = static_cast<EventContact*>(e);
Contact *contact = ec->contact();
if (contact->id() != m_id)
break;
switch(ec->action())
{
case EventContact::eDeleted:
QTimer::singleShot(0, this, SLOT(close()));
break;
case EventContact::eChanged:
setName();
break;
default:
break;
}
break;
}
case eEventCheckCommandState:
{
EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
CommandDef *cmd = ecs->cmd();
if (cmd->id == CmdHistoryDirection && (unsigned long)(cmd->param) == m_id)
{
cmd->flags &= ~COMMAND_CHECKED;
if (m_bDirection)
cmd->flags |= COMMAND_CHECKED;
return true;
}
if (cmd->id != CmdDeleteMessage && cmd->id != CmdCutHistory || cmd->param != m_view || !m_view->currentMessage())
return false;
cmd->flags &= ~COMMAND_CHECKED;
return true;
}
case eEventCommandExec:
{
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
CommandDef *cmd = ece->cmd();
if ((unsigned long)(cmd->param) != m_id)
return false;
if (cmd->id == CmdHistoryDirection)
{
bool bDirection = ((cmd->flags & COMMAND_CHECKED) != 0);
CorePlugin::instance()->setValue("HistoryDirection", bDirection);
if (bDirection != m_bDirection)
{
m_bDirection = bDirection;
m_page = 0;
m_states.clear();
fill();
}
return true;
}
if (cmd->id == CmdHistoryNext)
{
if (m_page + 1 < m_states.size())
{
m_page++;
fill();
}
return true;
}
if (cmd->id == CmdHistoryPrev)
{
if (m_page > 0)
{
m_page--;
fill();
}
return true;
}
if (cmd->id == CmdHistorySave)
{
QString str = QFileDialog::getSaveFileName(this, QString::null, QString::null, i18n("Textfile (*.txt)"));
if(!str.isEmpty())
{
bool res = true;
if (QFile::exists(str))
{
QMessageBox mb(i18n("Error"), i18n("File already exists. Overwrite?"),
QMessageBox::Warning,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No,
QMessageBox::Cancel | QMessageBox::Escape);
mb.setButtonText(QMessageBox::Yes, i18n("&Overwrite"));
mb.setButtonText(QMessageBox::No, i18n("&Append"));
switch (mb.exec())
{
case QMessageBox::Yes:
res = History::save(m_id, str, false);
break;
case QMessageBox::No:
res = History::save(m_id, str, true);
break;
case QMessageBox::Cancel:
//.........这里部分代码省略.........
示例12: switch
bool FilterPlugin::processEvent(Event *e)
{
switch (e->type()) {
case eEventContact: {
EventContact *ec = static_cast<EventContact*>(e);
if(ec->action() != EventContact::eChanged)
break;
Contact *contact = ec->contact();
if (contact->getGroup()){
Command cmd;
cmd->id = CmdIgnore;
cmd->flags = BTN_HIDE;
cmd->param = (void*)(contact->id());
EventCommandShow(cmd).process();
}
break;
}
case eEventPluginLoadConfig:
{
setPropertyHub( ProfileManager::instance()->getPropertyHub("filter") );
break;
}
case eEventMessageReceived: {
EventMessage *em = static_cast<EventMessage*>(e);
Message *msg = em->msg();
if (!msg || (msg->type() == MessageStatus))
return false;
Contact *contact = getContacts()->contact(msg->contact());
PropertyHubPtr data = contact->getUserData("filter");
// check if we accept only from users on the list
if (((contact == NULL) || contact->getFlags() & CONTACT_TEMPORARY) &&
((value("FromList").toBool() &&
msg->type() != MessageAuthRequest &&
msg->type() != MessageAuthGranted &&
msg->type() != MessageAuthRefused) ||
(value("AuthFromList").toBool() && msg->type() <= MessageContacts))) {
delete msg;
delete contact;
return msg;
}
if (!contact)
return false;
// check if the user is a ignored user
if (contact->getIgnore()){
delete msg;
return true;
}
// get filter-data
if (data && !data->value("SpamList").toString().isEmpty() && (!contact || (contact->getFlags() & CONTACT_TEMPORARY) )) {
if (checkSpam(msg->getPlainText(), data->value("SpamList").toString())){
delete msg;
return true;
}
}
break;
}
case eEventCheckCommandState: {
EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
CommandDef *cmd = ecs->cmd();
if (cmd->id == CmdIgnore){
cmd->flags &= ~BTN_HIDE;
Contact *contact = getContacts()->contact((unsigned long)(cmd->param));
if (contact && contact->getGroup())
cmd->flags |= BTN_HIDE;
return true;
}
if (cmd->id == CmdIgnoreText){
cmd->flags &= ~COMMAND_CHECKED;
if (cmd->menu_id == MenuMsgView){
MsgViewBase *edit = (MsgViewBase*)(cmd->param);
if (edit->textCursor().hasSelection())
return true;
} else
/*if (cmd->menu_id == MenuTextEdit){
TextEdit *edit = ((MsgEdit*)(cmd->param))->m_edit;
if (edit->textCursor().hasSelection())
return true;
}*/ //Fixme Block (crashing on rightclick in msgedit from container)
return false;
}
if (cmd->menu_id == MenuContactGroup){
if (cmd->id == CmdIgnoreList){
Contact *contact = getContacts()->contact((unsigned long)(cmd->param));
if (contact == NULL)
return false;
cmd->flags &= COMMAND_CHECKED;
if (contact->getIgnore())
cmd->flags |= COMMAND_CHECKED;
return true;
}
}
break;
}
case eEventCommandExec: {
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
CommandDef *cmd = ece->cmd();
if (cmd->id == CmdIgnore){
Contact *contact = getContacts()->contact((unsigned long)(cmd->param));
if (contact){
//.........这里部分代码省略.........
示例13: switch
bool TextEdit::processEvent(Event *e)
{
if (m_param == NULL)
return false;
if (e->type() == eEventCheckCommandState){
EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
CommandDef *cmd = ecs->cmd();
if (cmd->param != m_param)
return false;
switch (cmd->id){
case CmdBgColor:
case CmdFgColor:
case CmdBold:
case CmdItalic:
case CmdUnderline:
case CmdFont:
if (!isReadOnly()){
cmd->flags &= ~BTN_HIDE;
}else{
cmd->flags |= BTN_HIDE;
}
return true;
default:
break;
}
} else
if (e->type() == eEventCommandExec){
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
CommandDef *cmd = ece->cmd();
if (cmd->param != m_param)
return false;
switch (cmd->id){
case CmdBgColor:{
EventCommandWidget eWidget(cmd);
eWidget.process();
CToolButton *btnBg = dynamic_cast<CToolButton*>(eWidget.widget());
if (btnBg){
ColorPopup *popup = new ColorPopup(this, background());
popup->move(CToolButton::popupPos(btnBg, popup));
connect(popup, SIGNAL(colorChanged(QColor)), this, SLOT(bgColorChanged(QColor)));
popup->show();
}
return true;
}
case CmdFgColor:{
EventCommandWidget eWidget(cmd);
eWidget.process();
CToolButton *btnFg = dynamic_cast<CToolButton*>(eWidget.widget());
if (btnFg){
ColorPopup *popup = new ColorPopup(this, foreground());
popup->move(CToolButton::popupPos(btnFg, popup));
connect(popup, SIGNAL(colorChanged(QColor)), this, SLOT(fgColorChanged(QColor)));
popup->show();
}
return true;
}
case CmdBold:
if (!m_bChanged){
m_bSelected = true;
setFontWeight((cmd->flags & COMMAND_CHECKED) != 0 ? QFont::Bold : QFont::Normal);
}
return true;
case CmdItalic:
if (!m_bChanged){
m_bSelected = true;
setFontItalic((cmd->flags & COMMAND_CHECKED) != 0);
}
return true;
case CmdUnderline:
if (!m_bChanged){
m_bSelected = true;
setFontUnderline((cmd->flags & COMMAND_CHECKED) != 0);
}
return true;
case CmdFont:{
#ifdef USE_KDE
QFont f = font();
if (KFontDialog::getFont(f, false, topLevelWidget()) != KFontDialog::Accepted)
break;
#else
bool ok = false;
QFont f = QFontDialog::getFont(&ok, font(), topLevelWidget());
if (!ok)
break;
#endif
m_bSelected = true;
setCurrentFont(f);
break;
}
default:
return false;
}
}
return false;
}
示例14: textEdit
//.........这里部分代码省略.........
m_curWord = QString::null;
while (!m_fonts.empty())
m_fonts.pop();
m_bCheck = true;
parse(textEdit()->text(m_paragraph));
flushText();
m_curText = QString::null;
m_bCheck = false; */
// if (!m_bInError)
// return false;
if (m_plugin->checkWord(word)) return false;
m_word = word;
m_start_word = from;
m_sug = m_plugin->suggestions(m_word);
// SIM::CommandDef *cmds = new SIM::CommandDef[m_sug.count() + 3]; // +3 instead of +1 were for Add and Ignore commands
SIM::CommandDef *cmds = new SIM::CommandDef[m_sug.count() + 1];
unsigned i = 0;
for (QStringList::Iterator it = m_sug.begin(); it != m_sug.end(); ++it, i++){
cmds[i].id = m_plugin->CmdSpell + i /*+ 2*/; // +2 were for Add and Ignore commands
cmds[i].text = "_";
cmds[i].text_wrk = (*it);
if (i >= 10){
i++;
break;
}
}
cmds[i].text = QString::null; // Empty text marks end of command list for COMMAND::RECURSIVE
// Add and Ignore seems never really worked, at least do not saves this to config file (shaplov):
/* cmds[i].id = m_plugin->CmdSpell;
cmds[i].text = "_";
cmds[i].text_wrk = i18n("Add '%1'").arg(m_word);*/
/* i++;
cmds[i].id = m_plugin->CmdSpell + 1;
cmds[i].text = "_";
cmds[i].text_wrk = i18n("Ignore '%1'").arg(m_word); */
cmd->param = cmds;
cmd->flags |= SIM::COMMAND_RECURSIVE;
return true;
}
} else
if (e->type() == eEventCommandExec){
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
CommandDef *cmd = ece->cmd();
if (cmd->id == CmdSend){
if (((MsgEdit*)(cmd->param))->m_edit == textEdit()){
// m_bDisable = true;
// rehighlight();
// QTimer::singleShot(50, this, SLOT(restore()));
removeHighlight();
}
}
if ((cmd->id >= m_plugin->CmdSpell) && (cmd->id < m_plugin->CmdSpell + m_sug.count() + 1)){
MsgEdit *m_edit = (MsgEdit*)(cmd->param);
if (m_edit->m_edit != textEdit())
return false;
if (0 && cmd->id == m_plugin->CmdSpell){
// Interlas of Add command.
/* m_plugin->add(m_word);
MAP_BOOL::iterator it = m_words.find(SIM::my_string(m_word));
if (it == m_words.end()){
m_words.insert(MAP_BOOL::value_type(SIM::my_string(m_word), true));
}else{
if ((*it).second)
return false;
(*it).second = true;
}
// m_bDirty = true;
// QTimer::singleShot(300, this, SLOT(reformat()));
*/
}else if (0 && cmd->id == m_plugin->CmdSpell + 1){
// Internals of Ignore command
/* MAP_BOOL::iterator it = m_plugin->m_ignore.find(SIM::my_string(m_word));
if (it == m_plugin->m_ignore.end())
m_plugin->m_ignore.insert(MAP_BOOL::value_type(SIM::my_string(m_word), true));
it = m_words.find(SIM::my_string(m_word));
if (it == m_words.end()){
m_words.insert(MAP_BOOL::value_type(SIM::my_string(m_word), true));
}else{
if ((*it).second)
return false;
(*it).second = true;
}
// m_bDirty = true;
// QTimer::singleShot(300, this, SLOT(reformat()));
*/
}else{
unsigned n = cmd->id - m_plugin->CmdSpell /*- 2*/; // -2 were because of Add and Ignore commands
QString word = m_sug[n];
textEdit()->setSelection(m_parag, m_start_word, m_parag, m_start_word + m_word.length(), 0);
textEdit()->insert(word, true, true, true);
}
}
}
return false;
}
示例15: switch
bool MsgEdit::processEvent(Event *e)
{
switch (e->type()) {
case eEventContact: {
EventContact *ec = static_cast<EventContact*>(e);
if (ec->contact()->id() != m_userWnd->m_id)
break;
adjustType();
break;
}
case eEventClientChanged: {
adjustType();
break;
}
case eEventMessageReceived: {
EventMessage *em = static_cast<EventMessage*>(e);
Message *msg = em->msg();
if (msg->getFlags() & MESSAGE_NOVIEW)
return false;
if ((msg->contact() == m_userWnd->id()) && (msg->type() != MessageStatus)){
if (CorePlugin::instance()->getContainerMode()){
bool bSetFocus = false;
if (topLevelWidget() && topLevelWidget()->inherits("Container")){
Container *container = static_cast<Container*>(topLevelWidget());
if (container->wnd() == m_userWnd)
bSetFocus = true;
}
setMessage(msg, bSetFocus);
}else{
if (m_edit->isReadOnly())
QTimer::singleShot(0, this, SLOT(setupNext()));
}
}
break;
}
case eEventRealSendMessage: {
EventRealSendMessage *ersm = static_cast<EventRealSendMessage*>(e);
if (ersm->edit() == this){
sendMessage(ersm->msg());
return true;
}
break;
}
case eEventCheckCommandState: {
EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e);
CommandDef *cmd = ecs->cmd();
if ((cmd->param == (TextEdit*)m_edit) && (cmd->id == CmdTranslit)){
Contact *contact = getContacts()->contact(m_userWnd->id());
if (contact){
SIM::PropertyHubPtr data = contact->getUserData("translit");
if(!data.isNull()) {
cmd->flags &= ~COMMAND_CHECKED;
if (data->value("Translit").toBool())
cmd->flags |= COMMAND_CHECKED;
// FIXME: return true; missing here?
}
}
return false;
}
if ((cmd->menu_id != MenuTextEdit) || (cmd->param != (TextEdit*)m_edit))
return false;
cmd->flags &= ~(COMMAND_CHECKED | COMMAND_DISABLED);
switch (cmd->id){
case CmdUndo:
if (m_edit->isReadOnly())
return false;
if (!m_edit->document()->isUndoAvailable())
cmd->flags |= COMMAND_DISABLED;
return true;
case CmdRedo:
if (m_edit->isReadOnly())
return false;
if (!m_edit->document()->isRedoAvailable())
cmd->flags |= COMMAND_DISABLED;
return true;
case CmdCut:
if (m_edit->isReadOnly())
return false;
case CmdCopy:
if (m_edit->textCursor().selectedText().isEmpty())
cmd->flags |= COMMAND_DISABLED;
return true;
case CmdPaste:
if (m_edit->isReadOnly())
return false;
if (QApplication::clipboard()->text().isEmpty())
cmd->flags |= COMMAND_DISABLED;
return true;
case CmdClear:
if (m_edit->isReadOnly())
return false;
case CmdSelectAll:
if (m_edit->toPlainText().isEmpty())
cmd->flags |= COMMAND_DISABLED;
return true;
}
break;
}
case eEventCommandExec: {
EventCommandExec *ece = static_cast<EventCommandExec*>(e);
//.........这里部分代码省略.........