Changeset 372 for trunk/tools/designer/src/lib/shared
- Timestamp:
- Dec 2, 2009, 4:30:02 AM (16 years ago)
- Location:
- trunk/tools/designer/src/lib/shared
- Files:
-
- 10 edited
- 1 copied
-
actionrepository.cpp (modified) (11 diffs)
-
formwindowbase_p.h (modified) (1 diff)
-
orderdialog.cpp (modified) (1 diff)
-
orderdialog_nodnd.ui (copied) (copied from trunk/tools/designer/src/lib/shared/orderdialog.ui ) (1 diff)
-
qdesigner_dnditem.cpp (modified) (7 diffs)
-
qdesigner_menu.cpp (modified) (6 diffs)
-
qdesigner_menubar.cpp (modified) (6 diffs)
-
qdesigner_tabwidget.cpp (modified) (5 diffs)
-
qdesigner_toolbar.cpp (modified) (6 diffs)
-
qtresourceview.cpp (modified) (4 diffs)
-
shared.pri (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/designer/src/lib/shared/actionrepository.cpp
r2 r372 291 291 static bool handleImageDragEnterMoveEvent(QDropEvent *event) 292 292 { 293 293 294 QtResourceView::ResourceType type; 294 295 const bool rc = QtResourceView::decodeMimeData(event->mimeData(), &type) && type == QtResourceView::ResourceImage; … … 298 299 event->ignore(); 299 300 return rc; 301 302 303 300 304 } 301 305 302 306 static void handleImageDropEvent(const QAbstractItemView *iv, QDropEvent *event, ActionModel *am) 303 307 { 308 304 309 const QModelIndex index = iv->indexAt(event->pos()); 305 310 if (!index.isValid()) { … … 307 312 return; 308 313 } 314 309 315 310 316 if (!handleImageDragEnterMoveEvent(event)) 311 317 return; 312 318 319 313 320 am->dropMimeData(event->mimeData(), event->proposedAction(), index.row(), 0, iv->rootIndex()); 321 314 322 } 315 323 … … 322 330 return; 323 331 332 324 333 QDrag *drag = new QDrag(dragParent); 325 334 QMimeData *data = model->mimeData(indexes); … … 329 338 330 339 drag->start(supportedActions); 340 331 341 } 332 342 … … 336 346 m_model(model) 337 347 { 348 338 349 setDragEnabled(true); 339 350 setAcceptDrops(true); 340 351 setDropIndicatorShown(true); 341 352 setDragDropMode(DragDrop); 353 342 354 setModel(model); 343 355 setRootIsDecorated(false); … … 368 380 void ActionTreeView::dragEnterEvent(QDragEnterEvent *event) 369 381 { 382 370 383 handleImageDragEnterMoveEvent(event); 384 371 385 } 372 386 373 387 void ActionTreeView::dragMoveEvent(QDragMoveEvent *event) 374 388 { 389 375 390 handleImageDragEnterMoveEvent(event); 391 376 392 } 377 393 378 394 void ActionTreeView::dropEvent(QDropEvent *event) 379 395 { 396 380 397 handleImageDropEvent(this, event, m_model); 398 381 399 } 382 400 … … 414 432 m_model(model) 415 433 { 434 416 435 setDragEnabled(true); 417 436 setAcceptDrops(true); 418 437 setDropIndicatorShown(true); 419 438 setDragDropMode(DragDrop); 439 420 440 setModel(model); 421 441 setTextElideMode(Qt::ElideMiddle); … … 449 469 void ActionListView::dragEnterEvent(QDragEnterEvent *event) 450 470 { 471 451 472 handleImageDragEnterMoveEvent(event); 473 452 474 } 453 475 454 476 void ActionListView::dragMoveEvent(QDragMoveEvent *event) 455 477 { 478 456 479 handleImageDragEnterMoveEvent(event); 480 457 481 } 458 482 459 483 void ActionListView::dropEvent(QDropEvent *event) 460 484 { 485 461 486 handleImageDropEvent(this, event, m_model); 487 462 488 } 463 489 … … 647 673 void ActionRepositoryMimeData::accept(QDragMoveEvent *event) const 648 674 { 675 649 676 if (event->proposedAction() == m_dropAction) { 650 677 event->acceptProposedAction(); … … 653 680 event->accept(); 654 681 } 682 655 683 } 656 684 -
trunk/tools/designer/src/lib/shared/formwindowbase_p.h
r2 r372 170 170 CRLFLineTerminator, 171 171 NativeLineTerminator = 172 #if defined (Q_OS_WIN) 172 #if defined (Q_OS_WIN) 173 173 CRLFLineTerminator 174 174 #else -
trunk/tools/designer/src/lib/shared/orderdialog.cpp
r2 r372 46 46 #include "orderdialog_p.h" 47 47 #include "iconloader_p.h" 48 #include "ui_orderdialog.h" 48 #ifndef QT_NO_DRAGANDDROP 49 # include "ui_orderdialog.h" 50 #else 51 # include "ui_orderdialog_nodnd.h" 52 #endif 49 53 50 54 #include <QtDesigner/QExtensionManager> -
trunk/tools/designer/src/lib/shared/orderdialog_nodnd.ui
r362 r372 82 82 <height>0</height> 83 83 </size> 84 </property>85 <property name="dragDropMode" >86 <enum>QAbstractItemView::InternalMove</enum>87 84 </property> 88 85 <property name="selectionMode" > -
trunk/tools/designer/src/lib/shared/qdesigner_dnditem.cpp
r2 r372 154 154 drag->setPixmap(QPixmap::fromImage(image)); 155 155 #else 156 156 157 drag->setPixmap(widgetPixmap); 158 157 159 #endif 158 160 } … … 189 191 QPixmap pixmap = QPixmap::fromImage(image); 190 192 pixmap.setMask(mask); 193 191 194 drag->setPixmap(pixmap); 195 192 196 } 193 197 break; … … 197 201 m_globalStartPos = m_items.first()->decoration()->pos() + m_items.first()->hotSpot(); 198 202 m_hotSpot = m_globalStartPos - decorationTopLeft; 203 199 204 drag->setHotSpot(m_hotSpot); 200 205 201 206 drag->setMimeData(this); 207 202 208 } 203 209 … … 219 225 return Qt::IgnoreAction; 220 226 227 221 228 QDrag *drag = new QDrag(dragSource); 222 229 QDesignerMimeData *mimeData = new QDesignerMimeData(items, drag); … … 237 244 238 245 return executedAction; 246 247 248 239 249 } 240 250 … … 270 280 void QDesignerMimeData::acceptEventWithAction(Qt::DropAction desiredAction, QDropEvent *e) 271 281 { 282 272 283 if (e->proposedAction() == desiredAction) { 273 284 e->acceptProposedAction(); … … 276 287 e->accept(); 277 288 } 289 278 290 } 279 291 -
trunk/tools/designer/src/lib/shared/qdesigner_menu.cpp
r2 r372 165 165 } 166 166 167 167 168 QDrag *drag = new QDrag(this); 168 169 drag->setPixmap(ActionRepositoryMimeData::actionDragPixmap(action)); 169 170 drag->setMimeData(new ActionRepositoryMimeData(action, dropAction)); 171 170 172 171 173 const int old_index = m_currentIndex; 172 174 m_currentIndex = -1; 173 175 176 174 177 if (drag->start(dropAction) == Qt::IgnoreAction) { 178 179 180 175 181 if (dropAction == Qt::MoveAction) { 176 182 QAction *previous = safeActionAt(index); … … 712 718 void QDesignerMenu::dragEnterEvent(QDragEnterEvent *event) 713 719 { 720 714 721 const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData()); 715 722 if (!d || d->actionList().empty()) { … … 734 741 break; 735 742 } 743 736 744 } 737 745 738 746 void QDesignerMenu::dragMoveEvent(QDragMoveEvent *event) 739 747 { 748 740 749 if (actionGeometry(m_addSeparator).contains(event->pos())) { 741 750 event->ignore(); … … 773 782 break; 774 783 } 784 775 785 } 776 786 … … 784 794 void QDesignerMenu::dropEvent(QDropEvent *event) 785 795 { 796 786 797 m_showSubMenuTimer->stop(); 787 798 hideSubMenu(); … … 820 831 event->ignore(); 821 832 } 833 822 834 adjustIndicator(QPoint(-1, -1)); 823 835 } -
trunk/tools/designer/src/lib/shared/qdesigner_menubar.cpp
r2 r372 328 328 hideMenu(index); 329 329 330 330 331 QDrag *drag = new QDrag(this); 331 332 drag->setPixmap(ActionRepositoryMimeData::actionDragPixmap(action)); 332 333 drag->setMimeData(new ActionRepositoryMimeData(action, Qt::MoveAction)); 334 333 335 334 336 const int old_index = m_currentIndex; 335 337 m_currentIndex = -1; 336 338 339 337 340 if (drag->start(Qt::MoveAction) == Qt::IgnoreAction) { 341 342 343 338 344 InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw); 339 345 cmd->init(this, action, safeActionAt(index)); … … 629 635 void QDesignerMenuBar::dragEnterEvent(QDragEnterEvent *event) 630 636 { 637 631 638 const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData()); 632 639 if (!d || d->actionList().empty()) { … … 650 657 break; 651 658 } 659 652 660 } 653 661 654 662 void QDesignerMenuBar::dragMoveEvent(QDragMoveEvent *event) 655 663 { 664 656 665 const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData()); 657 666 if (!d || d->actionList().empty()) { … … 674 683 break; 675 684 } 685 676 686 } 677 687 … … 687 697 m_dragging = false; 688 698 699 689 700 if (const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData())) { 690 701 … … 707 718 } 708 719 event->ignore(); 720 709 721 } 710 722 -
trunk/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp
r2 r372 215 215 216 216 m_mousePressed = false; 217 217 218 QDrag *drg = new QDrag(m_tabWidget); 218 219 drg->setMimeData(new qdesigner_internal::MyMimeData(m_tabWidget)); 220 219 221 220 222 m_dragIndex = index; … … 225 227 QLabel *label = new QLabel(m_dragLabel); 226 228 label->adjustSize(); 229 227 230 drg->setPixmap(QPixmap::grabWidget(label)); 231 228 232 label->deleteLater(); 229 233 } else { 234 230 235 drg->setPixmap(m_dragIcon.pixmap(22, 22)); 236 231 237 } 232 238 233 239 m_tabWidget->removeTab(m_dragIndex); 234 240 241 235 242 const Qt::DropActions dropAction = drg->start(Qt::MoveAction); 243 244 245 236 246 237 247 if (dropAction == Qt::IgnoreAction) { … … 253 263 case QEvent::DragEnter: 254 264 case QEvent::DragMove: { 265 255 266 QDragMoveEvent *de = static_cast<QDragMoveEvent*>(e); 256 267 if (!qdesigner_internal::MyMimeData::fromMyTab(de->mimeData(), m_tabWidget)) … … 282 293 m_dropIndicator->setGeometry(pos.x(), pos.y() , 3, rect.height()); 283 294 m_dropIndicator->show(); 295 296 297 298 284 299 } break; 285 300 286 301 case QEvent::Drop: { 302 287 303 QDropEvent *de = static_cast<QDropEvent*>(e); 288 304 if (!qdesigner_internal::MyMimeData::fromMyTab(de->mimeData(), m_tabWidget)) … … 298 314 cmd->init(m_tabWidget, m_dragPage, m_dragIcon, m_dragLabel, m_dragIndex, newIndex); 299 315 fw->commandHistory()->push(cmd); 316 317 318 300 319 } break; 301 320 -
trunk/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
r2 r372 122 122 case QEvent::ContextMenu: 123 123 return handleContextMenuEvent(static_cast<QContextMenuEvent*>(event)); 124 124 125 case QEvent::DragEnter: 125 126 case QEvent::DragMove: … … 129 130 case QEvent::Drop: 130 131 return handleDropEvent(static_cast<QDropEvent *>(event)); 132 131 133 case QEvent::MouseButtonPress: 132 134 return handleMousePressEvent(static_cast<QMouseEvent*>(event)); … … 327 329 } 328 330 331 329 332 bool ToolBarEventFilter::handleDragEnterMoveEvent(QDragMoveEvent *event) 330 333 { … … 400 403 return true; 401 404 } 405 402 406 403 407 void ToolBarEventFilter::startDrag(const QPoint &pos, Qt::KeyboardModifiers modifiers) … … 420 424 } 421 425 426 422 427 QDrag *drag = new QDrag(m_toolBar); 423 428 drag->setPixmap(ActionRepositoryMimeData::actionDragPixmap( action)); … … 425 430 426 431 if (drag->start(dropAction) == Qt::IgnoreAction) { 432 433 434 427 435 hideDragIndicator(); 428 436 if (dropAction == Qt::MoveAction) { -
trunk/tools/designer/src/lib/shared/qtresourceview.cpp
r2 r372 94 94 QListWidget(parent) 95 95 { 96 96 97 setDragEnabled(true); 98 97 99 } 98 100 … … 106 108 return; 107 109 110 108 111 const QString filePath = item->data(Qt::UserRole).toString(); 109 112 const QIcon icon = item->icon(); … … 122 125 drag->setMimeData(mimeData); 123 126 drag->exec(Qt::CopyAction); 127 124 128 } 125 129 … … 605 609 void QtResourceView::setDragEnabled(bool dragEnabled) 606 610 { 611 607 612 d_ptr->m_listWidget->setDragEnabled(dragEnabled); 613 608 614 } 609 615 610 616 bool QtResourceView::dragEnabled() const 611 617 { 618 612 619 return d_ptr->m_listWidget->dragEnabled(); 620 613 621 } 614 622 -
trunk/tools/designer/src/lib/shared/shared.pri
r2 r372 188 188 189 189 RESOURCES += $$PWD/shared.qrc 190 191 192 193 194
Note:
See TracChangeset
for help on using the changeset viewer.
