[Compbench-devel] CompBenchmarks++/Qt-4/Plan PlanDefineBatch.cpp, 1.3, 1.4 PlanDefineBatch.h, 1.3,
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-05-21 16:36:05
|
Update of /cvsroot/compbench/CompBenchmarks++/Qt-4/Plan In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv21301 Modified Files: PlanDefineBatch.cpp PlanDefineBatch.h Log Message: Batch's can be removed from a plan. Dropping a compiler on a "batch-less" plan doesn't SEGFAULT anymore. Index: PlanDefineBatch.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/Qt-4/Plan/PlanDefineBatch.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PlanDefineBatch.cpp 20 May 2007 17:11:34 -0000 1.3 --- PlanDefineBatch.cpp 21 May 2007 16:36:01 -0000 1.4 *************** *** 1,7 **** --- 1,12 ---- #include <Plan/PlanDefineBatch.h> + #include <Plan/Plan.h> + #include <System/System.h> + #include <main.h> using namespace CQT; + int new_plan_idx = 0; + PlanDefineBatchContextMenuEvent::PlanDefineBatchContextMenuEvent(Reason reason, const QPoint &globalPos) *************** *** 14,31 **** } ! PlanDefineBatchContextMenu::PlanDefineBatchContextMenu(PlanDefineBatchListItem *item) : QMenu("Batch management") { addAction(QIcon(":/icons/add.png"), tr("Add batch"), this, SLOT(doBatchRegister())); ! if ((item) && (item->type()==PIPlanBatch)) addAction(QIcon(":/icons/remove.png"), tr("Remove batch"), this, SLOT(doBatchUnregister())); } void PlanDefineBatchContextMenu::doBatchRegister(void) { ! CBM::PlanBatch *P = new CBM::PlanBatch("noname"); App->planBatchRegister(P); } --- 19,50 ---- } ! PlanDefineBatchContextMenu::PlanDefineBatchContextMenu(PlanDefineBatchListItem *_item) : QMenu("Batch management") { + item=_item; addAction(QIcon(":/icons/add.png"), tr("Add batch"), this, SLOT(doBatchRegister())); ! if (!item) ! return; ! ! if (item->type()==PIPlanBatch) addAction(QIcon(":/icons/remove.png"), tr("Remove batch"), this, SLOT(doBatchUnregister())); + + if (item->type()==PICompiler) { + addAction(QIcon(":/icons/remove.png"), tr("Remove compiler"), + this, SLOT(doCompilerRemove())); + } } void PlanDefineBatchContextMenu::doBatchRegister(void) { ! std::string n; ! char c[16]; ! sprintf(c, "%d", ++new_plan_idx); ! n+="Batch "; ! n+=c; ! CBM::PlanBatch *P = new CBM::PlanBatch(n); App->planBatchRegister(P); } *************** *** 33,36 **** --- 52,62 ---- void PlanDefineBatchContextMenu::doBatchUnregister(void) { + App->planBatchUnregister(item->Batch()); + } + + void PlanDefineBatchContextMenu::doCompilerRemove(void) + { + CBM::Compiler *C = item->Compiler(); + App->planCompilerRemove(item->Parent(PIPlanBatch)->Batch(), C); } *************** *** 97,100 **** --- 123,129 ---- PlanDefineBatchListItem *PlanDefineBatchListItem::Parent(PlanItemType _which) { + if (type()==_which) + return(this); + QTreeWidgetItem *p = parent(); *************** *** 159,162 **** --- 188,195 ---- this, SLOT(doCompilerUnregister(CBM::Compiler*)), Qt::QueuedConnection); + + connect(this, SIGNAL(sigCompilerRemove(CBM::PlanBatch*, CBM::Compiler*)), + this, SLOT(doCompilerRemove(CBM::PlanBatch*, CBM::Compiler*)), + Qt::QueuedConnection); *************** *** 167,170 **** --- 200,219 ---- } + PlanDefineBatchListItem *PlanDefineBatchList::Item(CBM::PlanBatch *_batch) + { + PlanDefineBatchListItem *R = (PlanDefineBatchListItem*) invisibleRootItem(); + PlanDefineBatchListItem *C; + int i, n = R->childCount(); + + for(i=0; i<n; i++) { + C=(PlanDefineBatchListItem*) R->child(i); + if (C->type()==PIPlanBatch) { + if (C->Batch()==_batch) + return(C); + } + } + return(0); + } + void PlanDefineBatchList::dragUpdateSelection(int x, int y) { *************** *** 175,184 **** --- 224,252 ---- void PlanDefineBatchList::doPlanBatchRegister(CBM::PlanBatch *_batch) { + CBM::Plan *P = CBM::cbmSystem->Plan(); + PlanDefineBatchListItem *R = new PlanDefineBatchListItem(_batch); addTopLevelItem(R); + + P->addBatch(_batch); } void PlanDefineBatchList::doPlanBatchUnregister(CBM::PlanBatch *_batch) { + CBM::Plan *P = CBM::cbmSystem->Plan(); + PlanDefineBatchListItem *I = Item(_batch); + PlanDefineBatchListItem *R; + + if (!I) + return; + + R=I->Nearest(PIPlanBatch); + + if (!R) + return; + + delete(invisibleRootItem()->takeChild(invisibleRootItem()->indexOfChild(I))); + P->removeBatch(_batch); + delete(_batch); } *************** *** 186,189 **** --- 254,261 ---- QString _newname) { + PlanDefineBatchListItem *I = Item(_batch); + + if (I) + I->Batch()->setId(_newname.toStdString()); } *************** *** 216,219 **** --- 288,297 ---- } + void PlanDefineBatchList::compilerRemove(CBM::PlanBatch *_batch, + CBM::Compiler *_compiler) + { + emit sigCompilerRemove(_batch, _compiler); + } + void PlanDefineBatchList::contextMenuEvent(QContextMenuEvent *event) *************** *** 230,233 **** --- 308,312 ---- QTreeWidgetItem *c; PlanDefineBatchListItem *I; + PlanDefineBatchListItem *PlanItem; for(i=0;i<_from->childCount();i++) { *************** *** 238,243 **** if (I->type()==PICompiler) { if (I->Compiler()==_compiler) { ! I=(PlanDefineBatchListItem*) _from->takeChild(i); ! delete(I); } } else --- 317,325 ---- if (I->type()==PICompiler) { if (I->Compiler()==_compiler) { ! PlanItem=I->Parent(PIPlanBatch); ! if (PlanItem->Batch()->remove(_compiler)) { ! I=(PlanDefineBatchListItem*) _from->takeChild(i); ! delete(I); ! } } } else *************** *** 246,250 **** --- 328,356 ---- doCompilerUnregister(_compiler, c); } + } + void PlanDefineBatchList::doCompilerRemove(CBM::PlanBatch *_batch, + CBM::Compiler *_compiler) + { + PlanDefineBatchListItem *P = Item(_batch); + PlanDefineBatchListItem *CS; + + PlanDefineBatchListItem *C; + + int i, n; + + if (!P) + return; + + CS=P->Nearest(PICompilers); + + n=CS->childCount(); + for(i=0; i<n; i++) { + C=(PlanDefineBatchListItem*) CS->child(i); + if (C->Compiler()==_compiler) { + CS->takeChild(i); + P->Batch()->remove(C->Compiler()); + } + } } *************** *** 283,308 **** void PlanDefineBatchList::dropEvent(QDropEvent *event) { if (event->mimeData()->hasText()) { ! dragUpdateSelection(event->pos().x(), event->pos().y()); PlanDefineBatchListItem *I = dynamic_cast<PlanDefineBatchListItem*>(currentItem()); if (I) { event->setDropAction(Qt::MoveAction); ! PlanDefineBatchListItem *C = new PlanDefineBatchListItem(App->PlanCompilerSelected()); PlanDefineBatchListItem *P = I->Nearest(PICompilers); if (P) { P->setExpanded(true); ! P->addChild(C); ! } ! ! /* PlanDefineBatchListBatch *R = new PlanDefineBatchListBatch; ! addTopLevelItem(R);*/ ! ! event->accept(); ! } ! event->ignore(); } else { event->ignore(); --- 389,415 ---- void PlanDefineBatchList::dropEvent(QDropEvent *event) { + if (event->mimeData()->hasText()) { ! dragUpdateSelection(event->pos().x(), event->pos().y()); PlanDefineBatchListItem *I = dynamic_cast<PlanDefineBatchListItem*>(currentItem()); if (I) { + PlanDefineBatchListItem *PlanItem = I->Parent(PIPlanBatch); event->setDropAction(Qt::MoveAction); ! CBM::Compiler *C = App->PlanCompilerSelected(); PlanDefineBatchListItem *P = I->Nearest(PICompilers); if (P) { P->setExpanded(true); ! if (PlanItem->Batch()->add(C)) { ! PlanDefineBatchListItem *CI = new PlanDefineBatchListItem(C); ! P->addChild(CI); ! } ! } else ! event->accept(); ! } else ! event->ignore(); } else { event->ignore(); Index: PlanDefineBatch.h =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/Qt-4/Plan/PlanDefineBatch.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PlanDefineBatch.h 20 May 2007 17:11:34 -0000 1.3 --- PlanDefineBatch.h 21 May 2007 16:36:01 -0000 1.4 *************** *** 31,41 **** { Q_OBJECT ! protected slots: void doBatchRegister(void); void doBatchUnregister(void); public: ! PlanDefineBatchContextMenu(class PlanDefineBatchListItem *item); virtual ~PlanDefineBatchContextMenu(); --- 31,44 ---- { Q_OBJECT ! private: ! class PlanDefineBatchListItem *item; protected slots: void doBatchRegister(void); void doBatchUnregister(void); + void doCompilerRemove(void); + public: ! PlanDefineBatchContextMenu(class PlanDefineBatchListItem *_item); virtual ~PlanDefineBatchContextMenu(); *************** *** 66,69 **** --- 69,73 ---- private: protected: + virtual PlanDefineBatchListItem *Item(CBM::PlanBatch *_batch); virtual void dragUpdateSelection(int x, int y); *************** *** 76,81 **** virtual void doCompilerUnregister(CBM::Compiler *_compiler, QTreeWidgetItem *_from); - - signals: --- 80,83 ---- *************** *** 87,90 **** --- 89,95 ---- void sigCompilerUnregister(CBM::Compiler *_compiler); + void sigCompilerRemove(CBM::PlanBatch *_batch, + CBM::Compiler *_compiler); + protected slots: virtual void doPlanBatchRegister(CBM::PlanBatch *_batch); *************** *** 94,97 **** --- 99,104 ---- void doCompilerUnregister(CBM::Compiler *_compiler); + void doCompilerRemove(CBM::PlanBatch *_batch, + CBM::Compiler *_compiler); public: *************** *** 105,108 **** --- 112,118 ---- virtual void compilerUnregister(CBM::Compiler *_compiler); + virtual void compilerRemove(CBM::PlanBatch *_batch, + CBM::Compiler *_compiler); + virtual ~PlanDefineBatchList(); }; |