本文整理汇总了C++中QDropEvent::mimeData方法的典型用法代码示例。如果您正苦于以下问题:C++ QDropEvent::mimeData方法的具体用法?C++ QDropEvent::mimeData怎么用?C++ QDropEvent::mimeData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDropEvent
的用法示例。
在下文中一共展示了QDropEvent::mimeData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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 );
}
示例3: 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 );
}
示例4: eventFilter
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;
}
示例5: eventFilter
//.........这里部分代码省略.........
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));
}
}
示例6: eventFilter
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);
}
示例7: eventFilter
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);
}
示例8: event
bool SessionListWidget::event(QEvent *event)
{
#ifndef QUTIM_MOBILE_UI
if (event->type() == QEvent::ToolTip) {
if (QHelpEvent *help = static_cast<QHelpEvent*>(event)) {
int index = indexAt(help->pos()).row();
if (index != -1) {
ChatUnit *unit = session(index)->getUnit();
ToolTip::instance()->showText(help->globalPos(), unit, this);
return true;
}
}
} else if (event->type() == QEvent::DragEnter) {
QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent*>(event);
if (const MimeObjectData *data = qobject_cast<const MimeObjectData*>(dragEvent->mimeData())) {
ChatUnit *u = qobject_cast<ChatUnit*>(data->object());
if (u)
dragEvent->acceptProposedAction();
}
return true;
} else if (event->type() == QEvent::Drop) {
QDropEvent *dropEvent = static_cast<QDropEvent*>(event);
if (const MimeObjectData *mimeData
= qobject_cast<const MimeObjectData*>(dropEvent->mimeData())) {
if (ChatUnit *u = qobject_cast<ChatUnit*>(mimeData->object())) {
ChatLayerImpl::get(u,true)->activate();
dropEvent->setDropAction(Qt::CopyAction);
dropEvent->accept();
return true;
}
}
} else
#endif
if (event->type() == QEvent::ContextMenu) {
QContextMenuEvent *ev = static_cast<QContextMenuEvent*>(event);
ChatSessionImpl *s = session(row(itemAt(ev->pos())));
if(s) {
s->unit()->showMenu(ev->globalPos());
return true;
}
}
return QListWidget::event(event);
}
示例9: eventFilter
bool AssemblyBrowser::eventFilter(QObject* o, QEvent* e) {
if(o == ui) {
if (e->type() == QEvent::DragEnter || e->type() == QEvent::Drop) {
QDropEvent* de = (QDropEvent*)e;
const QMimeData* md = de->mimeData();
const GObjectMimeData* gomd = qobject_cast<const GObjectMimeData*>(md);
if (gomd != NULL) {
if (e->type() == QEvent::DragEnter) {
de->acceptProposedAction();
} else {
QApplication::changeOverrideCursor(Qt::ArrowCursor);//setting arrow cursor on Linux
QString err = tryAddObject(gomd->objPtr.data());
if(!err.isEmpty()) {
QMessageBox::critical(ui, tr("Error!"), err);
}
}
}
}
}
return false;
}
示例10: eventFilter
bool ArticleViewPrivate::eventFilter(QObject * obj, QEvent * event)
{
//qDebug() << "eventFilter" << obj << event;
const AbstractBibliographicModel * model = qobject_cast< const AbstractBibliographicModel * >(view ? origin(view->model()) : 0);
// Only filter the view's events
if (model && obj == view->viewport()) {
switch (event->type()) {
case QEvent::DragMove:
case QEvent::DragEnter: {
QDropEvent * e = static_cast< QDropEvent * >(event);
if ((dropping = model->acceptsDrop(e->mimeData()))) {
view->viewport()->update();
e->accept();
} else {
e->ignore();
}
//qDebug() << "---" << dropping;
return true;
break;
}
case QEvent::DragLeave:
dropping = false;
view->viewport()->update();
break;
case QEvent::Drop:
dropping = false;
view->viewport()->update();
break;
default:
break;
}
}
return QObject::eventFilter(obj, event);
}
示例11: eventFilter
//.........这里部分代码省略.........
s = 1.0;
s = qMax<qreal>(s, 0.0);
player->setSpeed(s);
return true;
}
if (ao && ao->isAvailable()) {
qreal v = player->audio()->volume();
if (v > 0.5)
v -= 0.1;
else if (v > 0.1)
v -= 0.05;
else
v -= 0.025;
player->audio()->setVolume(v);
qDebug("vol = %.3f", player->audio()->volume());
}
}
break;
case Qt::Key_O: {
if (modifiers == Qt::ControlModifier) {
//TODO: emit a signal so we can use custome dialogs?
openLocalFile();
} else/* if (m == Qt::NoModifier) */{
emit showNextOSD();
}
}
break;
case Qt::Key_Left:
qDebug("<-");
player->seekBackward();
break;
case Qt::Key_Right:
qDebug("->");
player->seekForward();
break;
case Qt::Key_M:
if (player->audio()) {
player->audio()->setMute(!player->audio()->isMute());
}
break;
case Qt::Key_R: {
VideoRenderer* renderer = player->renderer();
VideoRenderer::OutAspectRatioMode r = renderer->outAspectRatioMode();
renderer->setOutAspectRatioMode(VideoRenderer::OutAspectRatioMode(((int)r+1)%2));
}
break;
case Qt::Key_T: {
QWidget *w = qApp->activeWindow();
if (!w)
return false;
Qt::WindowFlags wf = w->windowFlags();
if (wf & Qt::WindowStaysOnTopHint) {
qDebug("Window not stays on top");
w->setWindowFlags(wf & ~Qt::WindowStaysOnTopHint);
} else {
qDebug("Window stays on top");
w->setWindowFlags(wf | Qt::WindowStaysOnTopHint);
}
//call setParent() when changing the flags, causing the widget to be hidden
w->show();
}
break;
case Qt::Key_F1:
help();
break;
default:
return false;
}
break;
}
case QEvent::DragEnter:
case QEvent::DragMove: {
QDropEvent *e = static_cast<QDropEvent*>(event);
e->acceptProposedAction();
}
break;
case QEvent::Drop: {
QDropEvent *e = static_cast<QDropEvent*>(event);
QString path = e->mimeData()->urls().first().toLocalFile();
player->stop();
player->load(path);
player->play();
e->acceptProposedAction();
}
break;
case QEvent::GraphicsSceneContextMenu: {
QGraphicsSceneContextMenuEvent *e = static_cast<QGraphicsSceneContextMenuEvent*>(event);
showMenu(e->screenPos());
}
break;
case QEvent::ContextMenu: {
QContextMenuEvent *e = static_cast<QContextMenuEvent*>(event);
showMenu(e->globalPos());
}
break;
default:
return false;
}
return true; //false: for text input
}
示例12: eventFilter
// TODO *** drop improvements ***
// open submenus on drop interactions
bool KBookmarkBar::eventFilter( QObject *, QEvent *e )
{
if (d->m_filteredToolbar)
return false; // todo: make this limit the actions
if ( e->type() == QEvent::DragLeave )
{
removeTempSep();
}
else if ( e->type() == QEvent::Drop )
{
removeTempSep();
QDropEvent *dev = static_cast<QDropEvent*>( e );
QDomDocument doc;
QList<KBookmark> list = KBookmark::List::fromMimeData( dev->mimeData(), doc );
if ( list.isEmpty() )
return false;
if (list.count() > 1)
kWarning(7043) << "Sorry, currently you can only drop one address "
"onto the bookmark bar!";
KBookmark toInsert = list.first();
KBookmarkGroup parentBookmark = getToolbar();
if(d->m_sepIndex == 0)
{
KBookmark newBookmark = parentBookmark.addBookmark(toInsert.fullText(), toInsert.url() );
parentBookmark.moveBookmark( newBookmark, KBookmark() );
m_pManager->emitChanged( parentBookmark );
return true;
}
else
{
KBookmark after = parentBookmark.first();
for(int i=0; i < d->m_sepIndex - 1 ; ++i)
after = parentBookmark.next(after);
KBookmark newBookmark = parentBookmark.addBookmark(toInsert.fullText(), toInsert.url() );
parentBookmark.moveBookmark( newBookmark, after );
m_pManager->emitChanged( parentBookmark );
return true;
}
}
else if ( e->type() == QEvent::DragMove || e->type() == QEvent::DragEnter )
{
QDragMoveEvent *dme = static_cast<QDragMoveEvent*>( e );
if (!KBookmark::List::canDecode( dme->mimeData() ))
return false;
//cache text, save positions (inserting the temporary widget changes the positions)
if(e->type() == QEvent::DragEnter)
{
QDomDocument doc;
const QList<KBookmark> list = KBookmark::List::fromMimeData( dme->mimeData(), doc );
if ( list.isEmpty() )
return false;
d->tempLabel = list.first().url().pathOrUrl();
d->widgetPositions.clear();
for (int i = 0; i < m_toolBar->actions().count(); ++i)
if (QWidget* button = m_toolBar->widgetForAction(m_toolBar->actions()[i])) {
if(m_toolBar->orientation() == Qt::Horizontal) {
if(QApplication::isLeftToRight()) {
d->widgetPositions.push_back(button->geometry().right());
} else {
d->widgetPositions.push_back(button->geometry().left());
}
} else {
d->widgetPositions.push_back(button->geometry().bottom());
}
}
}
bool accept = handleToolbarDragMoveEvent(dme->pos(), d->m_actions, d->tempLabel);
if (accept)
{
dme->accept();
return true; //Really?
}
}
return false;
}
示例13: eventFilter
bool ClassSpaceChecker::eventFilter(QObject *object, QEvent *evt)
{
if(evt->type() == QEvent::FocusOut)
{
if(object == ui.tableWidgetResult)
{
ui.lineEdit_Result->setText(prevTotalResultStr_);
}
return QMainWindow::eventFilter(object, evt);
}
if(object == ui.comboBox_JarFile
|| object == ui.lineEdit_MapFile
)
{
if(evt->type() == QEvent::DragEnter)
{
QDragEnterEvent *e = (QDragEnterEvent*)evt;
const QMimeData *mimeData = e->mimeData();
if (mimeData->hasUrls())
{
int cnt = 0;
QList<QUrl> urlList = mimeData->urls();
for (int i = 0; i < urlList.size(); ++i)
{
QString path = urlList.at(i).toLocalFile();
if( !QFileInfo(path).isFile() )
continue;
if(path.indexOf(".jar", 0, Qt::CaseInsensitive) < 0
&& path.indexOf(".zip", 0, Qt::CaseInsensitive) < 0
&& path.indexOf(".txt", 0, Qt::CaseInsensitive) < 0
)
continue;
if(urlList.size() == 1)
{
if(object == ui.comboBox_JarFile)
{
if(path.indexOf(".jar", 0, Qt::CaseInsensitive) < 0
&& path.indexOf(".zip", 0, Qt::CaseInsensitive) < 0
)
continue;
}
else if(object == ui.lineEdit_MapFile)
{
if(path.indexOf(".txt", 0, Qt::CaseInsensitive) < 0)
continue;
}
}
cnt++;
}
if( cnt > 0 )
e->acceptProposedAction();
}
qDebug() << evt << mimeData->text();
}
else if(evt->type() == QEvent::DragLeave)
{
QDragLeaveEvent *e = (QDragLeaveEvent*)evt;
e->accept();
}
else if(evt->type() == QEvent::DragMove)
{
QDragMoveEvent *e = (QDragMoveEvent*)evt;
e->acceptProposedAction();
}
else if(evt->type() == QEvent::Drop)
{
QDropEvent *e = (QDropEvent*)evt;
const QMimeData* mimeData = e->mimeData();
if (mimeData->hasUrls())
{
QList<QUrl> urlList = mimeData->urls();
for (int i = 0; i < urlList.size(); ++i)
{
QString path = urlList.at(i).toLocalFile();
if(path.indexOf(".txt", 0, Qt::CaseInsensitive) >= 0)
ui.lineEdit_MapFile->setText(path);
if(path.indexOf(".jar", 0, Qt::CaseInsensitive) >= 0 || path.indexOf(".zip", 0, Qt::CaseInsensitive) >= 0)
{
checkAndJarFilePreset(path);
}
}
}
}
}
return QMainWindow::eventFilter(object, evt);
}
示例14: app
bool
PlayerWidget::eventFilter(QObject *object, QEvent *event)
{
if(object == m_layeredWidget) {
if(event->type() == QEvent::DragEnter) {
QDragEnterEvent *dragEnterEvent = static_cast<QDragEnterEvent *>(event);
KUrl::List urls = KUrl::List::fromMimeData(dragEnterEvent->mimeData());
if(!urls.isEmpty())
dragEnterEvent->accept();
else
dragEnterEvent->ignore();
return true;
} else if(event->type() == QEvent::DragMove) {
return true; // eat event
} else if(event->type() == QEvent::Drop) {
QDropEvent *dropEvent = static_cast<QDropEvent *>(event);
KUrl::List urls = KUrl::List::fromMimeData(dropEvent->mimeData());
if(!urls.isEmpty()) {
for(KUrl::List::ConstIterator it = urls.begin(), end = urls.end(); it != end; ++it) {
const KUrl &url = *it;
if(url.protocol() != "file")
continue;
app()->openVideo(url);
break;
}
}
return true; // eat event
} else if(event->type() == QEvent::KeyPress) {
// NOTE: when on full screen mode, the keyboard input is received but
// for some reason it doesn't trigger the correct actions automatically
// so we process the event and handle the issue ourselves.
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
return app()->triggerAction(QKeySequence((keyEvent->modifiers() & ~Qt::KeypadModifier) + keyEvent->key()));
} else if(event->type() == QEvent::MouseMove) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
if(mouseEvent->globalPos() != m_currentCursorPos) {
m_currentCursorPos = mouseEvent->globalPos();
if(m_layeredWidget->cursor().shape() == Qt::BlankCursor)
m_layeredWidget->unsetCursor();
if(m_fullScreenControls->isAttached())
m_fullScreenControls->toggleVisible(true);
}
}
} else if(object == m_infoControlsGroupBox || object->parent() == m_infoControlsGroupBox) {
if(event->type() != QEvent::MouseButtonRelease)
return QWidget::eventFilter(object, event);
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
if(mouseEvent->button() != Qt::RightButton)
return QWidget::eventFilter(object, event);
KMenu menu;
QAction *action = menu.addAction(i18n("Show editable position control"));
action->setCheckable(true);
action->setChecked(app()->playerConfig()->showPositionTimeEdit());
if(menu.exec(mouseEvent->globalPos()) == action)
app()->playerConfig()->toggleShowPositionTimeEdit();
return true; // eat event
}
return QWidget::eventFilter(object, event);
}
示例15: event
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);
}