void ItemView::contentsMousePressEvent(QMouseEvent *e) { if (!e) return; e->accept(); if (!p_itemDocument) return; EventInfo eventInfo(this, e); if (eventInfo.isRightClick && m_pDragItem) { // We are dragging an item, and the user has right clicked. // Therefore, we want to rotate the item. /// @todo we should implement a virtual method in item for "rotating the item by one" /// - whatever that one may be (e.g. by 90 degrees, or changing the pin layout for /// flowparts, or nothing if the item isn't rotatable). if (Component * c = dynamic_cast<Component*>(m_pDragItem)) c->setAngleDegrees(c->angleDegrees() + 90); return; } p_itemDocument->canvas()->setMessage(QString::null); p_itemDocument->m_cmManager->mousePressEvent(eventInfo); }
void ItemView::contentsMouseMoveEvent(QMouseEvent *e) { // kdDebug() << k_funcinfo << "state = " << e->state() << endl; if (!e || !p_itemDocument) return; e->accept(); EventInfo eventInfo(this, e); p_itemDocument->m_cmManager->mouseMoveEvent(eventInfo); if (!m_pUpdateStatusTmr->isActive()) startUpdatingStatus(); }
// /// Notifies the views of the current document and the views of any child documents /// of a change. In contrast to QueryViews, NotifyViews sends notification of an /// event to all views and returns true if all views returned a true result. The /// event, EV_OWLNOTIFY, is sent with an event code, which is private to the /// particular document and view class, and a long argument, which can be cast /// appropriately to the actual type passed in the argument of the response /// function. // bool TDocument::NotifyViews(int event, long item, TView* exclude) { bool answer = true; TDocument* pdoc = 0; while ((pdoc = ChildDoc.Next(pdoc)) != 0) answer = (answer && pdoc->NotifyViews(event, item, exclude)); TEventHandler::TEventInfo eventInfo(WM_OWLNOTIFY, event); for (TView* view = ViewList; view != 0; view = view->NextView) if (view != exclude && view->Find(eventInfo)) answer = (answer && (view->Dispatch(eventInfo, 0, item) != 0)); return answer; }
void ItemView::contentsWheelEvent(QWheelEvent *e) { if (!e) return; e->accept(); EventInfo eventInfo(this, e); if (eventInfo.ctrlPressed) { // Zooming in or out if (eventInfo.scrollDelta > 0) zoomIn(eventInfo.pos); else zoomOut(eventInfo.pos); return; } p_itemDocument->m_cmManager->wheelEvent(eventInfo); }
// /// Queries the views of the current document and the views of any child documents /// about a specified event, but stops at the first view that returns true. In /// contrast to NotifyViews(), QueryViews returns a pointer to the first view that /// responded to an event with a true result. The event, EV_OWLNOTIFY, is sent with /// an event code (which is private to the particular document and view class) and a /// long argument (which can be cast appropriately to the actual type passed in the /// argument of the response function). // TView* TDocument::QueryViews(int event, long item, TView* exclude) { TView* view; TDocument* pdoc = 0; while ((pdoc = ChildDoc.Next(pdoc)) != 0) if ((view = pdoc->QueryViews(event, item, exclude)) != 0) return view; TEventHandler::TEventInfo eventInfo(WM_OWLNOTIFY, event); for (view = ViewList; view != 0; view = view->NextView) { if (view != exclude) { if (view->Find(eventInfo)) { if (view->Dispatch(eventInfo, 0, item)) { return view; // Return first acknowledger } } } } return 0; }
ChatEventInfoSptr ChatEventInfo::Make(const core::coll_helper &info, const bool isOutgoing, const QString &myAimid) { assert(!myAimid.isEmpty()); const auto type = info.get_value_as_enum<chat_event_type>("type"); ChatEventInfoSptr eventInfo(new ChatEventInfo( type, isOutgoing, myAimid )); const auto isGeneric = (type == core::chat_event_type::generic); if (isGeneric) { assert(!info.is_value_exist("sender_friendly")); eventInfo->setGenericText( info.get<QString>("generic") ); return eventInfo; } const auto isBuddyReg = (type == core::chat_event_type::buddy_reg); const auto isBuddyFound = (type == core::chat_event_type::buddy_found); const auto isBirthday = (type == core::chat_event_type::birthday); if (isBuddyReg || isBuddyFound || isBirthday) { assert(!info.is_value_exist("sender_friendly")); return eventInfo; } eventInfo->setSenderFriendly ( info.get<QString>("sender_friendly") ); const auto isAddedToBuddyList = (type == core::chat_event_type::added_to_buddy_list); const auto isAvatarModified = (type == core::chat_event_type::avatar_modified); if (isAddedToBuddyList || isAvatarModified) { return eventInfo; } const auto isChatNameModified = (type == core::chat_event_type::chat_name_modified); if (isChatNameModified) { const auto newChatName = info.get<QString>("chat/new_name"); assert(!newChatName.isEmpty()); eventInfo->setNewName(newChatName); return eventInfo; } const auto isChatDescriptionModified = (type == core::chat_event_type::chat_description_modified); if (isChatDescriptionModified) { const auto newDescription = info.get<QString>("chat/new_description"); eventInfo->setNewDescription(newDescription); return eventInfo; } const auto isMchatAddMembers = (type == core::chat_event_type::mchat_add_members); const auto isMchatInvite = (type == core::chat_event_type::mchat_invite); const auto isMchatLeave = (type == core::chat_event_type::mchat_leave); const auto isMchatDelMembers = (type == core::chat_event_type::mchat_del_members); const auto isMchatKicked = (type == core::chat_event_type::mchat_kicked); const auto hasMchatMembers = (isMchatAddMembers || isMchatInvite || isMchatLeave || isMchatDelMembers || isMchatKicked); if (hasMchatMembers) { const auto membersArray = info.get_value_as_array("mchat/members"); assert(membersArray); eventInfo->setMchatMembers(*membersArray); return eventInfo; } assert(!"unexpected event type"); return eventInfo; }