void TeQtViewsListView::contentsDragMoveEvent(QDragMoveEvent *e) { if(pressedThemeItem_) pressedThemeItem_->setOpen(themeOpen_); if(e->source() != viewport()) { e->ignore(); e->acceptAction(false); return; } QPoint p = contentsToViewport(((QDragMoveEvent*)e)->pos()); TeQtCheckListItem *item = (TeQtCheckListItem*)itemAt(p); if (item) { if (p.x() < treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)) + itemMargin()) { e->ignore(); e->acceptAction(false); } else { if(item->getType() == TeQtCheckListItem::THEME || item->getType() == TeQtCheckListItem::VIEW) { e->accept(); e->acceptAction(); } else { e->ignore(); e->acceptAction(false); if(currentThemeItem_) { unselectAllItems(); currentThemeItem_->parent()->setSelected(true); currentThemeItem_->parent()->repaint(); currentThemeItem_->setSelected(true); repaint(); } } } } else { e->ignore(); e->acceptAction(false); } }
void ListView::contentsMouseReleaseEvent(QMouseEvent *e) { #if QT_VERSION < 300 m_mousePressPos = QPoint(0, 0); #endif QListView::contentsMouseReleaseEvent(e); if (m_pressedItem){ QListViewItem *item = m_pressedItem; m_pressedItem = NULL; item->repaint(); QListViewItem *citem = itemAt(contentsToViewport(e->pos())); if (item == citem) emit clickItem(item); } }
void DirectoryView::contentsMousePressEvent( QMouseEvent* e ) { QListView::contentsMousePressEvent(e); QPoint p( contentsToViewport( e->pos() ) ); QListViewItem *i = itemAt( p ); if ( i ) { // if the user clicked into the root decoration of the item, don't try to start a drag! if ( p.x() > header()->cellPos( header()->mapToActual( 0 ) ) + treeStepSize() * ( i->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() || p.x() < header()->cellPos( header()->mapToActual( 0 ) ) ) { presspos = e->pos(); mousePressed = TRUE; } } }
void DirectoryView::contentsDragEnterEvent( QDragEnterEvent *e ) { if ( !QUriDrag::canDecode(e) ) { e->ignore(); return; } oldCurrent = currentItem(); QListViewItem *i = itemAt( contentsToViewport(e->pos()) ); if ( i ) { dropItem = i; autoopen_timer->start( autoopenTime ); } }
bool KWalletEntryList::acceptDrag(QDropEvent* e) const { QListViewItem *i = itemAt(contentsToViewport(e->pos())); if (i) { if (e->provides("application/x-kwallet-entry") || e->provides("text/uri-list")) { return true; } } if ((e->provides("application/x-kwallet-folder") && e->source() != viewport()) || e->provides("text/uri-list")) { return true; } return false; }
//----------------------------------------------- void KFileDnDDetailView::contentsDragEnterEvent( QDragEnterEvent *e ) { kdDebug (9020) << "KFileDnDDetailView::contentsDragEnterEvent" << endl; if ( ! acceptDrag( e ) ) { e->accept( false ); return; } e->acceptAction(); QListViewItem *i = itemAt( contentsToViewport( e->pos() ) ); if ( i && m_useAutoOpenTimer ) { m_dropItem = i; m_autoOpenTimer.start( m_autoOpenTime ); } }
void ListView::contentsMousePressEvent(QMouseEvent *e) { if (e->button() == QObject::LeftButton){ m_pressedItem = itemAt(contentsToViewport(e->pos())); if (m_pressedItem && !m_pressedItem->isSelectable()) m_pressedItem = NULL; if (m_pressedItem) repaintItem(m_pressedItem); #if QT_VERSION < 300 m_mousePressPos = e->pos(); QTimer::singleShot(QApplication::startDragTime(), this, SLOT(startDrag())); #endif } QListView::contentsMousePressEvent(e); }
void DirectoryView::contentsDragMoveEvent(QDragMoveEvent *e) { if (!QUriDrag::canDecode(e)) { e->ignore(); return; } QPoint vp = contentsToViewport((reinterpret_cast<QDragMoveEvent*>(e))->pos()); QListViewItem *i = itemAt(vp); if (i) { setSelected(i, TRUE); e->accept(); if (i != dropItem) { autoopen_timer->stop(); dropItem = i; autoopen_timer->start(autoopenTime); } switch (e->action()) { case QDropEvent::Copy: break; case QDropEvent::Move: e->acceptAction(); break; case QDropEvent::Link: e->acceptAction(); break; default: break; } } else { e->ignore(); autoopen_timer->stop(); dropItem = 0; } }
void FolderListView::contentsMouseMoveEvent( QMouseEvent* e ) { if (isRenaming()) { mousePressed = FALSE; e->ignore(); return; } if ( mousePressed && ( presspos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) { mousePressed = FALSE; QListViewItem *item = itemAt( contentsToViewport(presspos) ); if ( item ) startDrag(); } }
void DirectoryView::contentsMouseMoveEvent( QMouseEvent* e ) { if ( mousePressed && ( presspos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) { mousePressed = FALSE; QListViewItem *item = itemAt( contentsToViewport(presspos) ); if ( item ) { QString source = fullPath(item); if ( QFile::exists(source) ) { QUriDrag* ud = new QUriDrag(viewport()); ud->setUnicodeUris( source ); if ( ud->drag() ) QMessageBox::information( this, "Drag source", QString("Delete ")+source, "Not implemented" ); } } } }
void K3bListView::placeEditor( K3bListViewItem* item, int col ) { ensureItemVisible( item ); QRect r = itemRect( item ); r.setX( contentsToViewport( QPoint(header()->sectionPos( col ), 0) ).x() ); r.setWidth( header()->sectionSize( col ) - 1 ); // check if the column is fully visible if( visibleWidth() < r.right() ) r.setRight(visibleWidth()); r = QRect( viewportToContents( r.topLeft() ), r.size() ); if( item->pixmap( col ) ) { r.setX( r.x() + item->pixmap(col)->width() ); } // the tree-stuff is painted in the first column if( col == 0 ) { r.setX( r.x() + item->depth() * treeStepSize() ); if( rootIsDecorated() ) r.setX( r.x() + treeStepSize() ); } if( item->needButton(col) ) { prepareButton( item, col ); m_editorButton->setFixedHeight( r.height() ); // for now we make a square button m_editorButton->setFixedWidth( m_editorButton->height() ); r.setWidth( r.width() - m_editorButton->width() ); moveChild( m_editorButton, r.right(), r.y() ); } if( QWidget* editor = prepareEditor( item, col ) ) { editor->resize( r.size() ); // editor->resize( QSize( r.width(), editor->minimumSizeHint().height() ) ); moveChild( editor, r.x(), r.y() ); } }
void KonqSidebarTree::contentsDragMoveEvent( QDragMoveEvent *e ) { QListViewItem *item = itemAt( contentsToViewport( e->pos() ) ); // Accept drops on the background, if URLs if ( !item && m_lstDropFormats.contains("text/uri-list") ) { m_dropItem = 0; e->acceptAction(); if (selectedItem()) setSelected( selectedItem(), false ); // no item selected return; } if (item && static_cast<KonqSidebarTreeItem*>(item)->acceptsDrops( m_lstDropFormats )) { d->m_dropMode = SidebarTreeMode; if ( !item->isSelectable() ) { m_dropItem = 0; m_autoOpenTimer->stop(); e->ignore(); return; } e->acceptAction(); setSelected( item, true ); if ( item != m_dropItem ) { m_autoOpenTimer->stop(); m_dropItem = item; m_autoOpenTimer->start( autoOpenTimeout ); } } else { d->m_dropMode = KListViewMode; KListView::contentsDragMoveEvent(e); } }
void KACLListView::contentsMousePressEvent(QMouseEvent *e) { QListViewItem *clickedItem = itemAt(contentsToViewport(e->pos())); if(!clickedItem) return; // if the click is on an as yet unselected item, select it first if(!clickedItem->isSelected()) KListView::contentsMousePressEvent(e); if(!currentItem()) return; int column = header()->sectionAt(e->x()); acl_perm_t perm; switch(column) { case 2: perm = ACL_READ; break; case 3: perm = ACL_WRITE; break; case 4: perm = ACL_EXECUTE; break; default: return KListView::contentsMousePressEvent(e); } KACLListViewItem *referenceItem = static_cast< KACLListViewItem * >(clickedItem); unsigned short referenceHadItSet = referenceItem->value & perm; QListViewItemIterator it(this); while(KACLListViewItem *item = static_cast< KACLListViewItem * >(it.current())) { ++it; if(!item->isSelected()) continue; // toggle those with the same value as the clicked item, leave the others if(referenceHadItSet == (item->value & perm)) item->togglePerm(perm); } }
void KFileDetailView::contentsDragEnterEvent( TQDragEnterEvent *e ) { if ( ! acceptDrag( e ) ) { // can we decode this ? e->ignore(); // No return; } e->acceptAction(); // Yes if ((dropOptions() & AutoOpenDirs) == 0) return; KFileListViewItem *item = dynamic_cast<KFileListViewItem*>(itemAt( contentsToViewport( e->pos() ) )); if ( item ) { // are we over an item ? d->dropItem = item; d->autoOpenTimer.start( autoOpenDelay() ); // restart timer } else { d->dropItem = 0; d->autoOpenTimer.stop(); } }
void LogListView::contentsMousePressEvent(QMouseEvent *e) { // Retrieve selected item const LogListViewItem* selItem = static_cast<LogListViewItem*>(itemAt(contentsToViewport(e->pos()))); if( !selItem ) return; // Retrieve revision const QString revision = selItem->text(LogListViewItem::Revision); if ( e->button() == Qt::LeftButton ) { // If the control key was pressed, then we change revision B not A if( e->modifiers() & Qt::ControlModifier ) emit revisionClicked(revision, true); else emit revisionClicked(revision, false); } else if ( e->button() == Qt::MidButton ) emit revisionClicked(revision, true); }
void toListView::contentsMouseDoubleClickEvent(QMouseEvent *e) { #if 0 // todo QPoint p = e->pos(); int col = headerItem()->sectionAt(p.x()); toTreeWidgetItem *item = itemAt(contentsToViewport(p)); toResultViewItem *resItem = dynamic_cast<toResultViewItem *>(item); toResultViewCheck *chkItem = dynamic_cast<toResultViewCheck *>(item); QClipboard *clip = qApp->clipboard(); if (resItem) clip->setText(resItem->allText(col)); else if (chkItem) clip->setText(chkItem->allText(col)); else if (item) clip->setText(item->text(col)); Q3Header *head = header(); for (int i = 0; i < columns(); i++) { QString str; if (resItem) str = resItem->allText(i); else if (chkItem) str = chkItem->allText(col); else if (item) str = item->text(i); try { toParamGet::setDefault(toCurrentConnection(this), head->label(i).lower(), toUnnull(str)); } catch (...) {} } toTreeWidget::contentsMouseDoubleClickEvent(e); #endif }
void CardView::contentsMousePressEvent( QMouseEvent *e ) { Q3ScrollView::contentsMousePressEvent( e ); QPoint pos = contentsToViewport( e->pos() ); d->mLastClickPos = e->pos(); CardViewItem *item = itemAt( e->pos() ); if ( item == 0 ) { d->mLastClickOnItem = false; if ( d->mOnSeparator) { d->mResizeAnchor = e->x() + contentsX(); d->mColspace = (2 * d->mItemSpacing); int ccw = d->mItemWidth + d->mColspace + d->mSepWidth; d->mFirst = (contentsX() + d->mSepWidth) / ccw; d->mPressed = (d->mResizeAnchor + d->mSepWidth) / ccw; d->mSpan = d->mPressed - d->mFirst; d->mFirstX = d->mFirst * ccw; if ( d->mFirstX ) d->mFirstX -= d->mSepWidth; } else { selectAll( false ); } return; } d->mLastClickOnItem = true; CardViewItem *other = d->mCurrentItem; setCurrentItem( item ); // Always emit the selection emit clicked( item ); // The RMB click if ( e->button() & Qt::RightButton ) { // select current item item->setSelected( true ); emit contextMenuRequested( item, mapToGlobal( pos ) ); return; } // Check the selection type and update accordingly if ( d->mSelectionMode == CardView::Single ) { // make sure it isn't already selected if ( item->isSelected() ) return; bool b = signalsBlocked(); blockSignals( true ); selectAll( false ); blockSignals( b ); item->setSelected( true ); item->repaintCard(); emit selectionChanged( item ); } else if ( d->mSelectionMode == CardView::Multi ) { // toggle the selection item->setSelected( !item->isSelected() ); item->repaintCard(); emit selectionChanged(); } else if ( d->mSelectionMode == CardView::Extended ) { if ( (e->button() & Qt::LeftButton) && (e->modifiers() & Qt::ShiftModifier) ) { if ( item == other ) return; bool s = !item->isSelected(); if ( s && !(e->modifiers() & Qt::ControlModifier) ) { bool b = signalsBlocked(); blockSignals( true ); selectAll( false ); blockSignals( b ); } int from, to, a, b; a = d->mItemList.findRef( item ); b = d->mItemList.findRef( other ); from = a < b ? a : b; to = a > b ? a : b; CardViewItem *aItem; for ( ; from <= to; ++from ) { aItem = d->mItemList.at( from ); aItem->setSelected( s ); repaintItem( aItem ); } emit selectionChanged(); } else if ( (e->button() & Qt::LeftButton) && (e->modifiers() & Qt::ControlModifier) ) { item->setSelected( !item->isSelected() ); item->repaintCard(); emit selectionChanged(); } else if ( e->button() & Qt::LeftButton ) { bool b = signalsBlocked(); blockSignals( true ); selectAll( false ); blockSignals( b ); item->setSelected( true ); item->repaintCard(); emit selectionChanged(); } } }
void K3bDataFileView::slotDropped( QDropEvent* e, QListViewItem*, QListViewItem* ) { // remove any highlighting if( m_dropDirItem ) { m_dropDirItem->highlightIcon( false ); m_dropDirItem = 0; } if( !e->isAccepted() ) return; // determine K3bDirItem to add the items to m_addParentDir = currentDir(); if( K3bDataDirViewItem* dirViewItem = dynamic_cast<K3bDataDirViewItem*>( itemAt(contentsToViewport(e->pos())) ) ) { // only add to a dir if we drop directly on the name if( header()->sectionAt( e->pos().x() ) == 0 ) m_addParentDir = dirViewItem->dirItem(); } if( m_addParentDir ) { // check if items have been moved if( e->source() == viewport() ) { // move all selected items QPtrList<QListViewItem> selectedViewItems = selectedItems(); QValueList<K3bDataItem*> selectedDataItems; QPtrListIterator<QListViewItem> it( selectedViewItems ); for( ; it.current(); ++it ) { K3bDataViewItem* dataViewItem = dynamic_cast<K3bDataViewItem*>( it.current() ); if( dataViewItem ) selectedDataItems.append( dataViewItem->dataItem() ); else kdDebug() << "no dataviewitem" << endl; } K3bDataUrlAddingDialog::copyMoveItems( selectedDataItems, m_addParentDir, this, e->action() == QDropEvent::Copy ); } else if( e->source() == m_treeView->viewport() ) { // move the selected dir if( K3bDataDirViewItem* dirItem = dynamic_cast<K3bDataDirViewItem*>( m_treeView->selectedItem() ) ) { QValueList<K3bDataItem*> selectedDataItems; selectedDataItems.append( dirItem->dirItem() ); K3bDataUrlAddingDialog::copyMoveItems( selectedDataItems, m_addParentDir, this, e->action() == QDropEvent::Copy ); } } else { // seems that new items have been dropped m_addUrls.clear(); if( KURLDrag::decode( e, m_addUrls ) ) { // // This is a small (not to ugly) hack to circumvent problems with the // event queues: the url adding dialog will be non-modal regardless of // the settings in case we open it directly. // QTimer::singleShot( 0, this, SLOT(slotAddUrls()) ); } } } // now grab that focus setFocus(); }
void TeQtViewsListView::contentsMousePressEvent(QMouseEvent *e) { rightMouseWasClicked_ = false;; if (e->button() == RightButton) { rightMouseWasClicked_ = true; popupMenu_->move(e->globalPos().x(), e->globalPos().y()); } else if (e->button() == LeftButton) { QPoint p( contentsToViewport( e->pos() ) ); pressedPosition_ = p; TeQtCheckListItem *item = (TeQtCheckListItem*)itemAt(p); if (item != 0) { if(item->getType() == TeQtCheckListItem::THEME) { // don?t drag, if the user clicked into the root decoration of the item int x = p.x(); int len = treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)) + itemMargin(); if (x > len) // if (p.x() > treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)) + itemMargin()) { pressedThemeItem_ = (TeQtThemeItem*)item; themeOpen_ = isOpen(item); } // Item was pressed inside the visibility box if (x > len && x < len + 10) { if (e->state() & Qt::ShiftButton) { if (refThemeItemForVis_ == 0) refThemeItemForVis_ = (TeQtThemeItem*)item; else { TeQtThemeItem *themeItem = (TeQtThemeItem*)item; if ((themeItem == refThemeItemForVis_) || (themeItem->parent() != refThemeItemForVis_->parent())) return; list<TeQtCheckListItem*> themeItemList; list<TeQtCheckListItem*>::iterator it; // find if the item pressed is below the reference item TeQtCheckListItem *itemBelow = (TeQtCheckListItem*)refThemeItemForVis_->itemBelow(); while((itemBelow != 0) && (itemBelow->getType() == TeQtCheckListItem::THEME)) { themeItemList.push_back(itemBelow); if (itemBelow == themeItem) { for (it = themeItemList.begin(); it != themeItemList.end(); ++it) { TeQtCheckListItem *thItem = *it; bool visible = refThemeItemForVis_->isOn(); setOn(thItem, visible); } refThemeItemForVis_ = 0; return; } itemBelow = (TeQtCheckListItem*)itemBelow->itemBelow(); } // find if the item pressed is above the reference item themeItemList.clear(); TeQtCheckListItem *itemAbove = (TeQtCheckListItem*)refThemeItemForVis_->itemAbove(); while((itemAbove != 0) && (itemAbove->getType() == TeQtCheckListItem::THEME)) { themeItemList.push_back(itemAbove); if (itemAbove == themeItem) { for (it = themeItemList.begin(); it != themeItemList.end(); ++it) { TeQtCheckListItem* thItem = *it; bool visible = refThemeItemForVis_->isOn(); setOn(thItem, visible); } refThemeItemForVis_ = 0; return; } itemAbove = (TeQtCheckListItem*)itemAbove->itemAbove(); } } } else refThemeItemForVis_ = 0; } } else { item->setSelected(false); item->repaint(); pressedThemeItem_ = 0; } leftButtonPressed_ = true; } } QListView::contentsMousePressEvent(e); }
void TeQtViewsListView::contentsDropEvent(QDropEvent *e) { if(e->source() != viewport()) { e->ignore(); e->acceptAction(false); pressedThemeItem_ = 0; if(currentThemeItem_) { unselectAllItems(); currentThemeItem_->parent()->setSelected(true); currentThemeItem_->parent()->repaint(); currentThemeItem_->setSelected(true); repaint(); } return; } int itemPriority; TeQtThemeItem *themeItem; bool viewChanged = false; QPoint p = contentsToViewport(((QDragMoveEvent*)e)->pos()); TeQtCheckListItem *dropItem = (TeQtCheckListItem*)itemAt(p); if (dropItem == 0) { e->ignore(); e->acceptAction(false); pressedThemeItem_ = 0; if(currentThemeItem_) { unselectAllItems(); currentThemeItem_->parent()->setSelected(true); currentThemeItem_->parent()->repaint(); currentThemeItem_->setSelected(true); repaint(); } return; } if (dropItem == pressedThemeItem_) { e->ignore(); e->acceptAction(false); pressedThemeItem_ = 0; if(currentThemeItem_) { unselectAllItems(); currentThemeItem_->parent()->setSelected(true); currentThemeItem_->parent()->repaint(); currentThemeItem_->setSelected(true); repaint(); } return; } e->accept(); e->acceptAction(); //Set the view item of the pressed item and the drop item TeQtViewItem *pressedViewItem = (TeQtViewItem*)pressedThemeItem_->parent(); TeQtViewItem *dropViewItem; if(dropItem->getType() == TeQtCheckListItem::THEME) dropViewItem = (TeQtViewItem*)dropItem->parent(); else dropViewItem = (TeQtViewItem*)dropItem; //set a flag to indicate whether there was a view change if (pressedViewItem != dropViewItem) viewChanged = true; //update the priorities and move the items accordingly if (viewChanged) { vector<QListViewItem*> themeItemVector = dropViewItem->getChildren(); for (unsigned int i = 0; i < themeItemVector.size(); ++i) { themeItem = (TeQtThemeItem*)themeItemVector[i]; if(pressedThemeItem_->text(0) == themeItem->text(0)) { emit dragDropItems(0, 0, 0); pressedThemeItem_ = 0; return; } } if (dropItem->getType() == TeQtCheckListItem::THEME) { TeQtThemeItem *dropThemeItem = (TeQtThemeItem*)dropItem; itemPriority = dropThemeItem->order(); pressedThemeItem_->order(itemPriority); themeItem = dropThemeItem; } else { itemPriority = 0; pressedThemeItem_->order(itemPriority); themeItem = (TeQtThemeItem*)dropViewItem->firstChild(); } while (themeItem) { themeItem->order(++itemPriority); themeItem = (TeQtThemeItem*)themeItem->nextSibling(); } pressedViewItem->takeItem(pressedThemeItem_); dropViewItem->insertItem(pressedThemeItem_); } else { if (dropItem->getType() == TeQtCheckListItem::THEME) { TeQtThemeItem *dropThemeItem = (TeQtThemeItem*)dropItem; int pressedItemPriority = pressedThemeItem_->order(); int droppedItemPriority = dropThemeItem->order(); if (pressedItemPriority < droppedItemPriority) { itemPriority = pressedItemPriority; pressedThemeItem_->order(droppedItemPriority); themeItem = (TeQtThemeItem*)pressedThemeItem_->nextSibling(); while (themeItem != dropThemeItem) { themeItem->order(itemPriority++); themeItem = (TeQtThemeItem*)themeItem->nextSibling(); } dropThemeItem->order(itemPriority); } else { itemPriority = droppedItemPriority; pressedThemeItem_->order(itemPriority); themeItem = (TeQtThemeItem*)dropThemeItem; while (themeItem != pressedThemeItem_) { themeItem->order(++itemPriority); themeItem = (TeQtThemeItem*)themeItem->nextSibling(); } } pressedThemeItem_->moveItem(dropThemeItem); } else { itemPriority = 0; pressedThemeItem_->order(itemPriority); themeItem = (TeQtThemeItem*)dropItem->firstChild(); while (themeItem != pressedThemeItem_) { themeItem->order(++itemPriority); themeItem = (TeQtThemeItem*)themeItem->nextSibling(); } pressedViewItem->takeItem(pressedThemeItem_); pressedViewItem->insertItem(pressedThemeItem_); dropViewItem->setOpen(true); } } if (pressedViewItem != dropViewItem) { // the drag and drop theme items belong to different views if (pressedThemeItem_ == currentThemeItem_) { currentViewItem_ = dropViewItem; clicked(pressedThemeItem_); } } // emit dragDropItems(pressedViewItem, dropViewItem); emit dragDropItems(pressedThemeItem_, pressedViewItem, dropViewItem); pressedThemeItem_->setOpen(themeOpen_); pressedThemeItem_ = 0; if(currentThemeItem_) { unselectAllItems(); currentThemeItem_->parent()->setSelected(true); currentThemeItem_->parent()->repaint(); currentThemeItem_->setSelected(true); repaint(); } }