bool ContactDropFilter::eventFilter (QObject*, QEvent *e) { if (e->type () != QEvent::Drop) return false; HandleDrop (static_cast<QDropEvent*> (e)->mimeData ()); return true; }
void tcContainerGui::OnLButtonUp(wxMouseEvent& event) { isLButtonDown = false; windowDragOn = false; ReleaseMouse(); wxPoint point = event.GetPosition(); if (draggingSelectionBox) { for (size_t k=0; k<slots.size(); k++) { slots[k].SetSelected(false); } std::vector<size_t> selectedSlots = SlotsInDragBox(); for (size_t k=0; k<selectedSlots.size(); k++) { slots[selectedSlots[k]].SetSelected(true); } draggingSelectionBox = false; return; } size_t selectedSlot; bool foundSlot = SlotContainingPoint(point, selectedSlot); dragIsArmed = false; tcDragStatus* dragStatus = tcDragStatus::Get(); if (dragStatus->IsDragging()) { std::vector<tcContainerItem*> containerItems = dragStatus->GetDraggedItems(); if (containerItems.size() > 0) { /* check if cursor is over an empty slot, if so ** handle drag (drop) */ if (foundSlot) { wxASSERT(selectedSlot < slots.size()); containerItems[0]->SetQuantity(dragStatus->GetQuantity()); HandleDrop(selectedSlot, containerItems); } else { containerItems[0]->SetQuantity(dragStatus->GetQuantity()); HandleDropWindow(containerItems); } } // clear drag dragStatus->StopDrag(); } else if (event.ControlDown()) // check for de-selecting a slot on left button up with CTRL pressed { if (foundSlot && (slots[selectedSlot].IsSelected()) && (selectedSlot != protectDeselectIdx)) { slots[selectedSlot].SetSelected(false); } } }
filter_result ClientAgentInputFilter::Filter(BMessage* msg, BHandler** target) { filter_result result(B_DISPATCH_MESSAGE); switch (msg->what) { case B_MOUSE_MOVED: break; case B_COPY: { int32 start, finish; fWindow->fInput->TextView()->GetSelection(&start, &finish); if (start == finish) *target = fWindow->fText; } break; case B_SELECT_ALL: { if (fWindow->fInput->TextView()->TextLength() == 0) *target = fWindow->fText; } break; case B_KEY_DOWN: { result = HandleKeys(msg); } break; case B_MOUSE_UP: { if (fHandledDrop) { fHandledDrop = false; result = B_SKIP_MESSAGE; } } break; case B_MIME_TYPE: { if (msg->HasData("text/plain", B_MIME_TYPE)) { const char* buffer; ssize_t size; msg->FindData("text/plain", B_MIME_TYPE, 0, reinterpret_cast<const void**>(&buffer), &size); // We copy it, because B_MIME_TYPE // might not be \0 terminated BString string; string.Append(buffer, size); HandleDrop(string.String()); fHandledDrop = true; result = B_SKIP_MESSAGE; } } break; case B_SIMPLE_DATA: { if (msg->HasRef("refs")) { for (int32 i = 0; msg->HasRef("refs", i); ++i) { entry_ref ref; msg->FindRef("refs", &ref); char mime[B_MIME_TYPE_LENGTH]; BFile file(&ref, B_READ_ONLY); BNodeInfo info(&file); off_t size; if (file.InitCheck() == B_NO_ERROR && file.GetSize(&size) == B_NO_ERROR && info.InitCheck() == B_NO_ERROR && info.GetType(mime) == B_NO_ERROR && strncasecmp(mime, "text/", 5) == 0) { char* buffer(new char[size + 1]); if (buffer) { // Oh baby! file.Read(buffer, size); buffer[size] = 0; HandleDrop(buffer); delete[] buffer; break; } } } // Give the fWindow a chance to handle non // text files. If it's a message window, it'll // kick off a dcc send fWindow->DroppedFile(msg); } } break; case B_PASTE: { // we have our own pasting code so we can catch multiple lines BClipboard clipboard("system"); const char* fText; ssize_t textLen; BMessage* clip((BMessage*)NULL); if (clipboard.Lock()) { if ((clip = clipboard.Data())) if (clip->FindData("text/plain", B_MIME_TYPE, (const void**)&fText, &textLen) != B_OK) { clipboard.Unlock(); break; } } clipboard.Unlock(); BString data(fText, textLen); HandleDrop(data.String()); result = B_SKIP_MESSAGE; } break; case B_MOUSE_WHEEL_CHANGED: { // pass this msg to IRCView fWindow->fText->MessageReceived(msg); result = B_SKIP_MESSAGE; } break; default: { // printf ("FILTER UNHANDLED: "); // msg->PrintToStream(); } break; } return result; }