本文整理汇总了C++中QDropEvent类的典型用法代码示例。如果您正苦于以下问题:C++ QDropEvent类的具体用法?C++ QDropEvent怎么用?C++ QDropEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDropEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rect
bool QLineEdit::event( QEvent * e )
{
#if 0 // it works, but we'll wait with enabling it.
if ( !e )
return QWidget::event( e );
if ( e->type() == Event_DragEnter ) {
if ( ((QDragEnterEvent *) e)->provides( "text/plain" ) ) {
((QDragEnterEvent *) e)->accept( rect() );
return TRUE;
}
} else if ( e->type() == Event_DragLeave ) {
return TRUE;
} else if ( e->type() == Event_Drop ) {
QDropEvent * de = (QDropEvent *) e;
QString str;
if ( QTextDrag::decode( de, str ) ) {
if ( !hasMarkedText() ) {
int margin = frame() ? 2 : 0;
setCursorPosition( xPosToCursorPos( &tbuf[(int)offset],
fontMetrics(),
de->pos().x() - margin,
width() - 2*margin ) );
}
insert( str );
de->accept();
} else {
de->ignore();
}
return TRUE;
}
#endif
return QWidget::event( e );
}
示例2: switch
bool DockedMdiArea::event(QEvent *event)
{
// Listen for desktop file manager drop and emit a signal once a file is
// dropped.
switch (event->type()) {
case QEvent::DragEnter: {
QDragEnterEvent *e = static_cast<QDragEnterEvent*>(event);
if (!uiFiles(e->mimeData()).empty()) {
e->acceptProposedAction();
return true;
}
}
break;
case QEvent::Drop: {
QDropEvent *e = static_cast<QDropEvent*>(event);
const QStringList files = uiFiles(e->mimeData());
const QStringList::const_iterator cend = files.constEnd();
for (QStringList::const_iterator it = files.constBegin(); it != cend; ++it) {
emit fileDropped(*it);
}
e->acceptProposedAction();
return true;
}
break;
default:
break;
}
return QMdiArea::event(event);
}
示例3: if
bool FormFile::eventFilter(QObject *watched, QEvent *event)
{
if(watched == ui->lvServer)
{
if(event->type() == QEvent::DragEnter)
{
QDragEnterEvent* dee = dynamic_cast<QDragEnterEvent*>(event);
dee->acceptProposedAction();
return true;
}
else if(event->type() == QEvent::Drop)
{
QDropEvent* de = dynamic_cast<QDropEvent*>(event);
QList<QUrl>urls = de->mimeData()->urls();
if(urls.isEmpty())
{
return true;
}
QString path = urls.first().toLocalFile();
//上传文件
updateFile(path, path.split("/").last());
return true;
}
}
return QWidget::eventFilter(watched, event);
}
示例4: eventFilter
// Eventfilter: Only needed under Windows.
// Without this, files dropped in the line edit have URL-encoding.
// This eventfilter decodes the filenames as needed by KDiff3.
bool OpenDialog::eventFilter(QObject* o, QEvent* e)
{
if ( e->type()==QEvent::DragEnter )
{
QDragEnterEvent* d = static_cast<QDragEnterEvent*>(e);
d->setAccepted( d->mimeData()->hasUrls() );
return true;
}
if (e->type()==QEvent::Drop)
{
QDropEvent* d = static_cast<QDropEvent*>(e);
if ( !d->mimeData()->hasUrls() )
return false;
QList<QUrl> lst = d->mimeData()->urls();
if ( lst.count() > 0 )
{
static_cast<QLineEdit*>(o)->setText( QDir::toNativeSeparators( lst[0].toLocalFile() ) );
static_cast<QLineEdit*>(o)->setFocus();
}
return true;
}
return false;
}
示例5: msgEventAccepted
static QString msgEventAccepted(const QDropEvent &e)
{
QString message;
QTextStream str(&message);
str << "Event at " << e.pos().x() << ',' << e.pos().y() << ' ' << (e.isAccepted() ? "accepted" : "ignored");
return message;
}
示例6: if
bool DropFilter::eventFilter(QObject *obj, QEvent *event)
{
if( event->type() == QEvent::DragEnter)
{
QDragEnterEvent *dragEvent=dynamic_cast< QDragEnterEvent* >(event);
if (dragEvent->mimeData()->hasFormat("text/plain"))
{
QString data = dragEvent->mimeData()->text();
dragEvent->acceptProposedAction();
}
}
else if (event->type() == QEvent::Drop )
{
QDropEvent* dropEvent = dynamic_cast< QDropEvent* >(event);
QString data = dropEvent->mimeData()->text();
::fwServices::ObjectMsg::sptr message = ::fwServices::ObjectMsg::New();
message->addEvent("DROPPED_UUID", ::fwData::String::New(data.toStdString()));
::fwServices::IService::sptr service = m_service.lock();
::fwServices::IEditionService::notify( service, service->getObject< ::fwData::Object >(), message );
} else {
// standard event processing
return QObject::eventFilter(obj, event);
}
return true;
}
示例7: QWidget
//.........这里部分代码省略.........
emit layerSelected(layer->layerId, layer->name);
}
//****************************************************************************/
void QtLayerWidget::mouseClickHandler(QMouseEvent* event)
{
switch ((int) event->button())
{
case Qt::LeftButton:
{
// TODO
}
break;
case Qt::RightButton:
{
QPoint pos;
pos.setX(event->screenPos().x());
pos.setY(event->screenPos().y());
mContextMenu->popup(pos);
}
break;
}
}
//****************************************************************************/
void QtLayerWidget::mouseDblClickHandler(QMouseEvent* event)
{
switch ((int) event->button())
{
case Qt::LeftButton:
{
if (mTable->currentColumn() == TOOL_LAYER_COLUMN_NAME)
{
QTableWidgetItem* item = mTable->currentItem();
if (item->column() == TOOL_LAYER_COLUMN_NAME)
{
// Its the name; edit it
mTable->editItem(item);
}
}
}
break;
}
}
//****************************************************************************/
void QtLayerWidget::dropHandler(QObject* object, QEvent* event)
{
event->accept();
if (!mListenToDropEvents)
return;
if (!mListenToSceneViewWidget)
return;
// Determine whether the data was from an abstractitem modellist
QDropEvent* dropEvent = static_cast<QDropEvent*>(event);
const QMimeData* mimeData = dropEvent->mimeData();
QString mimeType("application/x-qabstractitemmodeldatalist");
if (!mimeData->hasFormat(mimeType))
return;
// Do not use the mimeData to retrieve the sceneview tree item, because a standard model is used,
// which does not return the data that is needed.
// Use the data of the selected item in the sceneview (mListenToSceneId) as an alternative.
if (mTable->rowCount() > 0 && mSceneViewWidget)
{
// Get the dropped item (this is the currently selected item of mListenToSceneId in widget mListenToSceneViewWidget)
QTreeWidgetItem* item = mListenToSceneViewWidget->getCurrentItem(mListenToSceneId);
if (item)
{
// The layerId of the selected layer = the sceneId of the visible sceneview tree in mSceneViewWidget
// The currently selected group in the mListenToSceneViewWidget = the destination group of mSceneViewWidget
int layerId = getCurrentLayerId();
int groupId = mListenToSceneViewWidget->getCurrentGroupId(item);
// 1. Add the group; this is ignored if the group is already available
QtAssetGroup assetGroupInfo = mListenToSceneViewWidget->getGroupInfo(groupId);
mSceneViewWidget->addGroupToSceneView(layerId,
assetGroupInfo.groupIcon,
groupId,
assetGroupInfo.groupName,
false);
// 2. Determine the item type and add either the asset or all assets in a group
if (mListenToSceneViewWidget->itemIsGroup(item))
{
// The dropped item is a GROUP
// Add all the items of the source group to the destination group
QVector<QTreeWidgetItem*> assetVec = mListenToSceneViewWidget->getAssetItemsOfGroup(mListenToSceneId, groupId);
foreach (QTreeWidgetItem* assetItem, assetVec)
{
mSceneViewWidget->addAssetToSceneView(layerId,
groupId,
mSceneViewWidget->getAssetIdOfAssetItem(assetItem),
assetItem->text(0));
}
}
示例8: if
bool CloudView::eventFilter(QObject *obj, QEvent *event)
{
if (obj == mHeader) {
static QPoint oldPos;
if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent *ev = (QMouseEvent *)event;
oldPos = ev->globalPos();
return true;
} else if (event->type() == QEvent::MouseMove) {
QMouseEvent *ev = (QMouseEvent *)event;
const QPoint delta = ev->globalPos() - oldPos;
MainWindow *win = seafApplet->mainWindow();
win->move(win->x() + delta.x(), win->y() + delta.y());
oldPos = ev->globalPos();
return true;
}
} else if (obj == mDropArea) {
if (event->type() == QEvent::DragEnter) {
QDragEnterEvent *ev = (QDragEnterEvent *)event;
if (ev->mimeData()->hasUrls() && ev->mimeData()->urls().size() == 1) {
const QUrl url = ev->mimeData()->urls().at(0);
if (url.scheme() == "file") {
QString path = url.toLocalFile();
#if defined(Q_OS_MAC) && (QT_VERSION <= QT_VERSION_CHECK(5, 4, 0))
path = utils::mac::fix_file_id_url(path);
#endif
if (QFileInfo(path).isDir()) {
ev->acceptProposedAction();
}
}
}
return true;
} else if (event->type() == QEvent::Drop) {
QDropEvent *ev = (QDropEvent *)event;
const QUrl url = ev->mimeData()->urls().at(0);
QString path = url.toLocalFile();
#if defined(Q_OS_MAC) && (QT_VERSION <= QT_VERSION_CHECK(5, 4, 0))
path = utils::mac::fix_file_id_url(path);
#endif
ev->setDropAction(Qt::CopyAction);
ev->accept();
showCreateRepoDialog(path);
return true;
}
}
return QWidget::eventFilter(obj, event);
}
示例9: eventFilter
bool RegisterP12::eventFilter( QObject *o, QEvent *e )
{
if( o == d->p12Cert && e->type() == QEvent::Drop )
{
QDropEvent *drop = static_cast<QDropEvent*>(e);
if( drop->mimeData()->hasUrls() )
{
d->p12Cert->setText( drop->mimeData()->urls().value( 0 ).toLocalFile() );
return true;
}
}
return QWidget::eventFilter( o, e );
}
示例10: eventFilter
bool SettingsDialog::eventFilter( QObject *o, QEvent *e )
{
if( o == d->p12Cert && e->type() == QEvent::Drop )
{
QDropEvent *d = static_cast<QDropEvent*>(e);
if( d->mimeData()->hasUrls() )
{
setP12Cert( d->mimeData()->urls().value( 0 ).toLocalFile() );
return true;
}
}
return QWidget::eventFilter( o, e );
}
示例11: switch
bool ContextHelp::eventFilter( QObject * watched, QEvent * e )
{
// kDebug() << k_funcinfo << "watched="<<watched<<endl;
if ( (watched != m_pEditor) && (watched != m_pEditor->editorViewport()) )
return false;
switch ( e->type() )
{
case QEvent::DragEnter:
{
QDragEnterEvent * dragEnter = static_cast<QDragEnterEvent*>(e);
if ( !QString( dragEnter->format() ).startsWith("ktechlab/") )
break;
dragEnter->acceptAction();
return true;
}
case QEvent::Drop:
{
QDropEvent * dropEvent = static_cast<QDropEvent*>(e);
if ( !QString( dropEvent->format() ).startsWith("ktechlab/") )
break;
dropEvent->accept();
QString type;
QDataStream stream( dropEvent->encodedData( dropEvent->format() ) /*, IO_ReadOnly */ );
stream >> type;
LibraryItem * li = itemLibrary()->libraryItem( type );
if ( !li )
return true;
m_pEditor->insertURL( "ktechlab-help:///" + type, li->name() );
return true;
}
default:
break;
}
return false;
}
示例12: painter
bool AlgorithmRunner::eventFilter(QObject *obj, QEvent *ev) {
bool draggableObject = obj == _ui->favoritesBox->widget() ||
_favorites.contains(dynamic_cast<AlgorithmRunnerItem *>(obj));
if (ev->type() == QEvent::Paint) {
if (obj == _ui->favoritesBox->widget() && _favorites.empty()) {
QPainter painter(_ui->favoritesBox->widget());
QPixmap px((_ui->favoritesBox->_droppingFavorite
? ":/tulip/graphperspective/icons/32/favorite.png"
: ":/tulip/graphperspective/icons/32/favorite-empty.png"));
painter.drawPixmap(_ui->favoritesBox->widget()->width() - px.width() - 8, 8, px);
QFont f;
f.setItalic(true);
painter.setFont(f);
painter.setBrush(QColor(107, 107, 107));
painter.setPen(QColor(107, 107, 107));
painter.drawText(0, 8 + (px.height() - 12) / 2, _ui->favoritesBox->widget()->width(), 65535,
/*Qt::AlignHCenter | Qt::AlignTop |*/ Qt::TextWordWrap,
"Put your favorite algorithms here");
}
} else if ((ev->type() == QEvent::DragEnter || ev->type() == QEvent::DragMove) &&
draggableObject) {
QDropEvent *dropEv = static_cast<QDropEvent *>(ev);
if (dynamic_cast<const AlgorithmMimeType *>(dropEv->mimeData()) != nullptr) {
_ui->favoritesBox->_droppingFavorite = true;
ev->accept();
_ui->favoritesBox->repaint();
}
return true;
} else if (ev->type() == QEvent::DragLeave && draggableObject) {
_ui->favoritesBox->_droppingFavorite = false;
_ui->favoritesBox->repaint();
} else if (ev->type() == QEvent::Drop && draggableObject) {
QDropEvent *dropEv = static_cast<QDropEvent *>(ev);
const AlgorithmMimeType *mime = dynamic_cast<const AlgorithmMimeType *>(dropEv->mimeData());
if (mime != nullptr)
addFavorite(mime->algorithm(), mime->params());
_ui->favoritesBox->_droppingFavorite = false;
_ui->favoritesBox->repaint();
}
return false;
}
示例13: if
/** Redefined to forward events to children. */
bool TabPlaylist::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::DragEnter) {
event->accept();
return true;
} else if (event->type() == QEvent::Drop) {
QDropEvent *de = static_cast<QDropEvent*>(event);
if (de->source() == NULL) {
// Drag & Drop comes from another application but has landed in the playlist area
de->ignore();
QDropEvent *d = new QDropEvent(de->pos(), de->possibleActions(), de->mimeData(), de->mouseButtons(), de->keyboardModifiers());
_mainWindow->dispatchDrop(d);
return true;
} else {
if (obj == cornerWidget()) {
auto p = this->addPlaylist();
p->forceDrop(de);
} else {
currentPlayList()->forceDrop(de);
}
return true;
}
}
return QTabWidget::eventFilter(obj, event);
}
示例14: if
bool CloudView::eventFilter(QObject *obj, QEvent *event)
{
if (obj == mHeader) {
static QPoint oldPos;
if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent *ev = (QMouseEvent *)event;
oldPos = ev->globalPos();
return true;
} else if (event->type() == QEvent::MouseMove) {
QMouseEvent *ev = (QMouseEvent *)event;
const QPoint delta = ev->globalPos() - oldPos;
MainWindow *win = seafApplet->mainWindow();
win->move(win->x() + delta.x(), win->y() + delta.y());
oldPos = ev->globalPos();
return true;
}
} else if (obj == mDropArea) {
if (event->type() == QEvent::DragEnter) {
QDragEnterEvent *ev = (QDragEnterEvent *)event;
if (ev->mimeData()->hasUrls() && ev->mimeData()->urls().size() == 1) {
const QUrl url = ev->mimeData()->urls().at(0);
if (url.isLocalFile()) {
QString path = url.toLocalFile();
if (QFileInfo(path).isDir()) {
ev->acceptProposedAction();
}
}
}
return true;
} else if (event->type() == QEvent::Drop) {
QDropEvent *ev = (QDropEvent *)event;
const QUrl url = ev->mimeData()->urls().at(0);
QString path = url.toLocalFile();
showCreateRepoDialog(path);
return true;
}
}
return QWidget::eventFilter(obj, event);
}
示例15: sipConvertFromNewType
static PyObject *meth_QDropEvent_pos(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QDropEvent *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QDropEvent, &sipCpp))
{
QPoint *sipRes;
Py_BEGIN_ALLOW_THREADS
sipRes = new QPoint(sipCpp->pos());
Py_END_ALLOW_THREADS
return sipConvertFromNewType(sipRes,sipType_QPoint,NULL);
}
}