void KstViewWidget::dropEvent(QDropEvent *e) { if (e->source() != this && e->provides(PlotMimeSource::mimeType())) { // FIXME: support both copy and move KstViewObjectPtr vo = findChildFor(e->pos()); if (vo) { if (vo->paste(e)) { e->acceptAction(true); KstApp::inst()->updateViewManager(true); _view->paint(KstPainter::P_PAINT); } } else { if (viewObject()->paste(e)) { e->acceptAction(true); KstApp::inst()->updateViewManager(true); _view->paint(KstPainter::P_PAINT); } } } else if (_view->viewMode() != KstTopLevelView::LayoutMode) { KstViewObjectPtr vo = findChildFor(e->pos()); if (vo) { vo->dropEvent(this, e); return; } QWidget::dropEvent(e); } }
ObjectTree::ObjectTree(QWidget *parent) : QVBox(parent) { copying = false; cutting = false; referencing = false; list = new ObjectListView(this); list->addColumn("Objects"); list->addColumn("Value"); list->addColumn("Def"); list->setRootIsDecorated(true); list->setItemMargin(3); list->setTreeStepSize(15); list->setAcceptDrops(true); menu = new QMenu(list); menu->addAction(QIcon(QPixmap("icons/add.png")), "Add", this, SLOT(addAttribute())); menu->addAction(QIcon(QPixmap("icons/remove.png")), "Delete", this, SLOT(deleteObject())); menu->addAction(QIcon(QPixmap("icons/object.png")), "View", this, SLOT(viewObject())); menu->addAction(QIcon(QPixmap("icons/filesaveobj.png")), "Save...", this, SLOT(saveObject())); menu->addSeparator(); menu->addAction(QIcon(QPixmap("icons/editcut.png")), "Cut", this, SLOT(objcut())); menu->addAction(QIcon(QPixmap("icons/editcopy.png")), "Copy", this, SLOT(objcopy())); menu->addAction(QIcon(QPixmap("icons/definition.png")), "Reference", this, SLOT(objref())); menu->addSeparator(); menu->addAction(QIcon(QPixmap("icons/trace.png")), "Trace", this, SLOT(traceObject())); menu->addAction(QIcon(QPixmap("icons/monitor.png")), "Monitor"); menu->addAction(QIcon(QPixmap("icons/edit.png")), "Edit", this, SLOT(editObject())); icon_array = new QPixmap[NUM_OBJTYPES]; for (int i=0; i<NUM_OBJTYPES; i++) { icon_array[i] = QPixmap(icon_files[i]); } icon_def = new QPixmap(icon_deffile); new ObjectItem(list, Null, Null, core::root, "root", false); //new ObjectItem(list, Null, Null, doste::Current, "current", false); //aname = new AttribNameDialog(); connect(list, SIGNAL(expanded(QTreeWidgetItem*)), this, SLOT(expanded(QTreeWidgetItem*))); connect(list, SIGNAL(collapsed(QTreeWidgetItem*)), this, SLOT(collapsed(QTreeWidgetItem*))); connect(list, SIGNAL(itemRenamed(QTreeWidgetItem *, int, const QString&)), this, SLOT(itemRenamed(QTreeWidgetItem*, int, const QString&))); connect(list, SIGNAL(rightButtonClicked(QTreeWidgetItem *, const QPoint&, int)), this, SLOT(rightButtonClicked(QTreeWidgetItem*, const QPoint&, int))); connect(list, SIGNAL(onItem(QTreeWidgetItem*)), this, SLOT(onItem(QTreeWidgetItem*))); connect(list, SIGNAL(clicked(QTreeWidgetItem*)), this, SLOT(itemClicked(QTreeWidgetItem*))); }