[Compbench-devel] CompBenchmarks++/Qt-4/Plan PlanAvailable.cpp, NONE, 1.1 PlanAvailable.h, NONE, 1.
Brought to you by:
xfred
Update of /cvsroot/compbench/CompBenchmarks++/Qt-4/Plan In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv5764 Added Files: PlanAvailable.cpp PlanAvailable.h PlanAvailableBenchmark.cpp PlanAvailableBenchmark.h PlanAvailableCompiler.cpp PlanAvailableCompiler.h PlanAvailableOption.cpp PlanAvailableOption.h PlanDefine.cpp PlanDefine.h PlanDefineBatch.cpp PlanDefineBatch.h PlanDefineToolBox.cpp PlanDefineToolBox.h PlanManager.cpp PlanManager.h Log Message: First import. --- NEW FILE: PlanManager.cpp --- #include <Plan/PlanManager.h> #include <Plan/PlanAvailable.h> #include <QVBoxLayout> using namespace CQT; PlanManager::PlanManager(QWidget *parent) : QSplitter(Qt::Vertical, parent) { QVBoxLayout *lay; lay=new QVBoxLayout; available=new PlanAvailable; // lay-> addWidget(available); define=new PlanDefine; // lay-> addWidget(define); /* list=new PlanList; lay->addWidget(list); info=new PlanInfo; lay->addWidget(info); */ /* list->setSelection(0); */ /* info=new PlanInfo(); lay->addWidget(info); */ // setLayout(lay); /* connect(list, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), info, SLOT(doSelectionChanged(QListWidgetItem*, QListWidgetItem*)), Qt::QueuedConnection); connect(this, SIGNAL(sigPlansRefresh()), this, SLOT(doPlansRefresh()), Qt::QueuedConnection); */ } PlanAvailableCompilerList *PlanManager::AvailableCompiler(void) { return(available->AvailableCompiler()); } PlanAvailableBenchmarkList *PlanManager::AvailableBenchmark(void) { return(available->AvailableBenchmark()); } PlanDefine *PlanManager::Define(void) { return(define); } PlanManager::~PlanManager() { } --- NEW FILE: PlanDefineBatch.cpp --- #include <Plan/PlanDefineBatch.h> #include <main.h> using namespace CQT; PlanDefineBatchContextMenuEvent::PlanDefineBatchContextMenuEvent(Reason reason, const QPoint &globalPos) : QContextMenuEvent(reason, globalPos) { } PlanDefineBatchContextMenuEvent::~PlanDefineBatchContextMenuEvent() { } 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); } void PlanDefineBatchContextMenu::doBatchUnregister(void) { } PlanDefineBatchContextMenu::~PlanDefineBatchContextMenu() { } PlanDefineBatchListItem::PlanDefineBatchListItem(PlanItemType _type) : QTreeWidgetItem(_type), CompilerHolder(0), OptionHolder(0), BenchmarkHolder(0), PlanBatchHolder(0) { QString txt; switch(_type) { case PICompilers: txt="Compilers"; break; case PIOptionSet: txt="Options' set"; break; case PIBenchmarks: txt="Benchmarks"; break; default: txt="?"; break; } setText(0, txt); } PlanDefineBatchListItem::PlanDefineBatchListItem(CBM::PlanBatch *_batch) : QTreeWidgetItem(QStringList(_batch->Id().c_str()), PIPlanBatch), CompilerHolder(0), OptionHolder(0), BenchmarkHolder(0), PlanBatchHolder(_batch) { setFlags(Qt::ItemIsEditable | flags()); addChild(new PlanDefineBatchListItem(PICompilers)); addChild(new PlanDefineBatchListItem(PIOptionSet)); addChild(new PlanDefineBatchListItem(PIBenchmarks)); QFont fnt("helvetica", 1, QFont::Bold); fnt.setUnderline(true); setFont(0, fnt); setExpanded(true); } PlanDefineBatchListItem::PlanDefineBatchListItem(CBM::Compiler *_compiler) : QTreeWidgetItem(QStringList(_compiler->Name().c_str()), PICompiler), CompilerHolder(_compiler), OptionHolder(0), BenchmarkHolder(0), PlanBatchHolder(0) { } PlanDefineBatchListItem *PlanDefineBatchListItem::Parent(PlanItemType _which) { QTreeWidgetItem *p = parent(); while (p) { if (p->type()==_which) { return((PlanDefineBatchListItem*) p); } p=p->parent(); } return(0); } PlanDefineBatchListItem *PlanDefineBatchListItem::Nearest(PlanItemType _which) { printf("in nearest\n"); QTreeWidgetItem *P = Parent(PIPlanBatch); QTreeWidgetItem *C; int i, n; if (_which==PIPlanBatch) return((PlanDefineBatchListItem*)P); if (!P) return(0); n=P->childCount(); printf("nearest1\n"); for(i=0;i<n;i++) { C=P->child(i); printf("nearest1 i=%d/%d x=%d, t=%d\n",i,n,_which,C->type()); if (C->type()==_which) return((PlanDefineBatchListItem*)C); } printf("nearestD\n"); return(0); } PlanDefineBatchListItem::~PlanDefineBatchListItem() { } PlanDefineBatchList::PlanDefineBatchList(QWidget *parent) : QTreeWidget(parent) { connect(this, SIGNAL(sigPlanBatchRegister(CBM::PlanBatch*)), this, SLOT(doPlanBatchRegister(CBM::PlanBatch*))); connect(this, SIGNAL(sigPlanBatchUnregister(CBM::PlanBatch*)), this, SLOT(doPlanBatchUnregister(CBM::PlanBatch*))); connect(this, SIGNAL(sigPlanBatchRenamed(CBM::PlanBatch*, QString)), this, SLOT(doPlanBatchRenamed(CBM::PlanBatch*, QString))); headerItem()->setHidden(true); setContextMenuPolicy(Qt::DefaultContextMenu); setAcceptDrops(true); } void PlanDefineBatchList::doPlanBatchRegister(CBM::PlanBatch *_batch) { PlanDefineBatchListItem *R = new PlanDefineBatchListItem(_batch); addTopLevelItem(R); } void PlanDefineBatchList::doPlanBatchUnregister(CBM::PlanBatch *_batch) { } void PlanDefineBatchList::doPlanBatchRenamed(CBM::PlanBatch *_batch, QString _newname) { } void PlanDefineBatchList::planBatchRegister(CBM::PlanBatch *_batch) { emit sigPlanBatchRegister(_batch); } void PlanDefineBatchList::planBatchUnregister(CBM::PlanBatch *_batch) { emit sigPlanBatchUnregister(_batch); } void PlanDefineBatchList::planBatchRenamed(CBM::PlanBatch *_batch, QString _newname) { emit sigPlanBatchRenamed(_batch, _newname); } void PlanDefineBatchList::contextMenuEvent(QContextMenuEvent *event) { PlanDefineBatchContextMenu m((PlanDefineBatchListItem*)currentItem()); m.exec(event->globalPos()); } void PlanDefineBatchList::dragEnterEvent(QDragEnterEvent *event) { if (event->mimeData()->hasText()) { if (children().contains(event->source())) { event->setDropAction(Qt::MoveAction); event->accept(); } else { event->acceptProposedAction(); } } else { event->ignore(); } } void PlanDefineBatchList::dragMoveEvent(QDragMoveEvent *event) { if (event->mimeData()->hasText()) { if (children().contains(event->source())) { event->setDropAction(Qt::MoveAction); event->accept(); } else { event->acceptProposedAction(); } } else { event->ignore(); } } void PlanDefineBatchList::dropEvent(QDropEvent *event) { if (event->mimeData()->hasText()) { PlanDefineBatchListItem *I = dynamic_cast<PlanDefineBatchListItem*>(currentItem()); printf("I=%x\n", (unsigned int) I); if (I) { event->setDropAction(Qt::MoveAction); PlanDefineBatchListItem *C = new PlanDefineBatchListItem(App->PlanCompilerSelected()); printf("there, finding nearest\n"); PlanDefineBatchListItem *P = I->Nearest(PICompilers); printf("nearest=%x\n", (unsigned int) P); if (P) { P->setExpanded(true); P->addChild(C); } /* PlanDefineBatchListBatch *R = new PlanDefineBatchListBatch; addTopLevelItem(R);*/ event->accept(); } event->ignore(); } else { event->ignore(); } } PlanDefineBatchList::~PlanDefineBatchList() { } --- NEW FILE: PlanAvailable.h --- #ifndef H_CQT_PLANAVAILABLE #define H_CQT_PLANAVAILABLE #include <Plan/PlanAvailableCompiler.h> #include <Plan/PlanAvailableOption.h> #include <Plan/PlanAvailableBenchmark.h> #include <QGroupBox> namespace CQT { class PlanAvailable : public QGroupBox { Q_OBJECT private: PlanAvailableCompilerList *availableCompiler; PlanAvailableOptionList *availableOption; PlanAvailableBenchmarkList *availableBenchmark; protected: signals: public slots: virtual void doSelectionChanged(QListWidgetItem *current, QListWidgetItem *previous); public: PlanAvailable(QWidget *parent = 0); virtual PlanAvailableCompilerList *AvailableCompiler(void); virtual PlanAvailableOptionList *AvailableOption(void); virtual PlanAvailableBenchmarkList *AvailableBenchmark(void); virtual ~PlanAvailable(); }; } #endif --- NEW FILE: PlanDefineToolBox.cpp --- #include <Plan/PlanDefineToolBox.h> #include <QVBoxLayout> #include <QHBoxLayout> using namespace CQT; PlanDefineToolOptions::PlanDefineToolOptions(QWidget *parent) : QWidget(parent) { QVBoxLayout *lay = new QVBoxLayout; setLayout(lay); cbTestsuite=new QCheckBox("Enable testsuites"); cbTestsuite->setCheckState(Qt::Checked); cbTestsuite->setToolTip(tr("Run package's embedded testsuite before evaluating benchmarks.<br>A benchmark won't be launched if testsuite fails.")); lay->addWidget(cbTestsuite); cbCompileOnly=new QCheckBox("Compile only"); cbCompileOnly->setCheckState(Qt::Unchecked); cbCompileOnly->setToolTip(tr("Don't evaluate benchmarks, just compile packages.<br>If <i>Enable testsuites</i> is checked, available testsuite are run yet.")); lay->addWidget(cbCompileOnly); cbCompileOnly=new QCheckBox("Use knowledge-base"); cbCompileOnly->setCheckState(Qt::Checked); cbCompileOnly->setToolTip(tr("Use CompBenchmarks knowledge-base to warn about issues related to options")); lay->addWidget(cbCompileOnly); QHBoxLayout *lay2 = new QHBoxLayout; QLabel *itLabel = new QLabel(tr("Iterations :")); lay2->addWidget(itLabel); iterations=new QSpinBox; iterations->setRange(1,255); iterations->setValue(3); iterations->setToolTip(tr("Times each compiled benchmark'll be evaluated")); lay2->addWidget(iterations); lay2->insertStretch(-1, 20); lay->insertLayout(-1, lay2); lay->addStretch(); } PlanDefineToolOptions::~PlanDefineToolOptions() { } PlanDefineToolInfo::PlanDefineToolInfo(QWidget *parent) : QWidget(parent) { QVBoxLayout *lay = new QVBoxLayout; setLayout(lay); QHBoxLayout *lay2 = new QHBoxLayout; QLabel *iLabel = new QLabel(tr("Iteration :")); lay2->addWidget(iLabel); currentIteration=new QLabel("0"); lay2->addWidget(currentIteration); QLabel *sep = new QLabel(tr("/")); lay2->addWidget(sep); totalIterations=new QLabel("0"); lay2->addWidget(totalIterations); lay2->insertStretch(-1, 20); lay->insertLayout(-1, lay2); lay->addStretch(); } PlanDefineToolInfo::~PlanDefineToolInfo() { } PlanDefineToolQuick::PlanDefineToolQuick(QWidget *parent) : QWidget(parent) { QVBoxLayout *lay = new QVBoxLayout; setLayout(lay); load=new QPushButton(QIcon(":/icons/open.png"), tr("Load")); lay->addWidget(load); save=new QPushButton(QIcon(":/icons/save.png"), tr("Save")); lay->addWidget(save); start=new QPushButton(QIcon(":/icons/arrow-right.png"), tr("Run")); lay->addWidget(start); stop=new QPushButton(QIcon(":/icons/stop.png"), tr("Stop")); lay->addWidget(stop); lay->addStretch(); } PlanDefineToolQuick::~PlanDefineToolQuick() { } PlanDefineToolBox::PlanDefineToolBox(QWidget *parent) : QToolBox(parent) { defineOptions=new PlanDefineToolOptions; addItem(defineOptions, QIcon(":/icons/admin.png"), tr("Options")); defineInfo=new PlanDefineToolInfo; addItem(defineInfo, QIcon(":/icons/tip.png"), tr("Informations")); defineQuick=new PlanDefineToolQuick; addItem(defineQuick, QIcon(":/icons/downloads.png"), tr("Status")); } PlanDefineToolBox::~PlanDefineToolBox() { } --- NEW FILE: PlanDefineToolBox.h --- #ifndef H_CQT_PLANDEFINETOOLBOX #define H_CQT_PLANDEFINETOOLBOX #include <QToolBox> #include <QCheckBox> #include <QSpinBox> #include <QLabel> #include <QPushButton> namespace CQT { class PlanDefineToolOptions : public QWidget { Q_OBJECT private: QCheckBox *cbTestsuite; QCheckBox *cbCompileOnly; QCheckBox *cbKB; QSpinBox *iterations; protected: public: PlanDefineToolOptions(QWidget *parent = 0); virtual ~PlanDefineToolOptions(); }; class PlanDefineToolInfo : public QWidget { Q_OBJECT private: QLabel *currentIteration; QLabel *totalIterations; protected: public: PlanDefineToolInfo(QWidget *parent = 0); virtual ~PlanDefineToolInfo(); }; class PlanDefineToolQuick : public QWidget { Q_OBJECT private: QPushButton *start; QPushButton *stop; QPushButton *load; QPushButton *save; protected: public: PlanDefineToolQuick(QWidget *parent = 0); virtual ~PlanDefineToolQuick(); }; class PlanDefineToolBox : public QToolBox { Q_OBJECT private: PlanDefineToolOptions *defineOptions; PlanDefineToolInfo *defineInfo; PlanDefineToolQuick *defineQuick; protected: signals: public slots: public: PlanDefineToolBox(QWidget *parent = 0); virtual ~PlanDefineToolBox(); }; } #endif --- NEW FILE: PlanAvailable.cpp --- #include <Plan/PlanAvailable.h> #include <QGridLayout> #include <QLabel> using namespace CQT; PlanAvailable::PlanAvailable(QWidget *parent) : QGroupBox(parent) { QGridLayout *lay; QLabel *compilerLabel; QLabel *optionLabel; QLabel *bmLabel; lay=new QGridLayout; setLayout(lay); setTitle(tr("Available items")); availableCompiler=new PlanAvailableCompilerList; compilerLabel=new QLabel(tr("Compilers :")); lay->addWidget(compilerLabel, 0, 0); lay->addWidget(availableCompiler, 1, 0); availableOption=new PlanAvailableOptionList; optionLabel=new QLabel(tr("Options :")); lay->addWidget(optionLabel, 0, 1); lay->addWidget(availableOption, 1, 1); availableBenchmark=new PlanAvailableBenchmarkList; bmLabel=new QLabel(tr("Benchmarks :")); lay->addWidget(bmLabel, 0, 2); lay->addWidget(availableBenchmark, 1, 2); connect(availableCompiler, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(doSelectionChanged(QListWidgetItem*, QListWidgetItem*)), Qt::QueuedConnection); } void PlanAvailable::doSelectionChanged(QListWidgetItem *current, QListWidgetItem *) { PlanAvailableCompilerListItem *C = (PlanAvailableCompilerListItem*) current; if (C) availableOption->optionsRefresh(C->Compiler()); } PlanAvailableCompilerList *PlanAvailable::AvailableCompiler(void) { return(availableCompiler); } PlanAvailableOptionList *PlanAvailable::AvailableOption(void) { return(availableOption); } PlanAvailableBenchmarkList *PlanAvailable::AvailableBenchmark(void) { return(availableBenchmark); } PlanAvailable::~PlanAvailable() { } --- NEW FILE: PlanAvailableOption.cpp --- #include <QLabel> #include <main.h> #include <Compiler/CompilerList.h> #include <Compiler/Compiler-Option-Description.h> #include <System/System.h> using namespace CQT; PlanAvailableOptionListItem::PlanAvailableOptionListItem(CBM::CompilerOption *_option) : QListWidgetItem(_option->Option().c_str()), OptionHolder(_option) { /* if (Compiler()->getStatus()<CBM::Compiler::Preconfigured) setIcon(QIcon(":/icons/error.png")); else */ setIcon(QIcon(":/icons/success.png")); // setToolTip(_option->shortDescription().c_str()); } PlanAvailableOptionListItem::~PlanAvailableOptionListItem() { delete(Option()); } PlanAvailableOptionList::PlanAvailableOptionList(QWidget *parent) : QListWidget(parent) { connect(this, SIGNAL(sigOptionsRefresh(CBM::Compiler*)), this, SLOT(doOptionsRefresh(CBM::Compiler*)), Qt::QueuedConnection); } void PlanAvailableOptionList::optionsRefresh(CBM::Compiler *_compiler) { emit sigOptionsRefresh(_compiler); } void PlanAvailableOptionList::doOptionsRefresh(CBM::Compiler *_compiler) { CBM::CompilerOptionDescriptions *COD = _compiler->OptionDescriptions(); int i, n = COD->DescriptionNumber(); CBM::CompilerOptionDescription *D; clear(); for(i=0;i<n;i++) { D=COD->Description(i); addItem(new PlanAvailableOptionListItem(new CBM::CompilerOption(D->Option()))); } /* int i, n; CBM::Compiler *P; int psel = currentRow(); clear(); setContextMenuPolicy(Qt::DefaultContextMenu); n=CBM::cbmSystem->compilerNumber(); for(i=0; i<n; i++) { P=CBM::cbmSystem->Compiler(i); addItem(new PlanAvailableOptionListItem(P)); } sortItems(); setCurrentRow(psel); */ } PlanAvailableOptionList::~PlanAvailableOptionList() { } --- NEW FILE: PlanAvailableCompiler.cpp --- #include <main.h> #include <Plan/PlanAvailableCompiler.h> #include <System/System.h> using namespace CQT; PlanAvailableCompilerListItem::PlanAvailableCompilerListItem(CBM::Compiler *_compiler) : QListWidgetItem(_compiler->Name().c_str()), CompilerHolder(_compiler) { setIcon(QIcon(":/icons/success.png")); } PlanAvailableCompilerListItem::~PlanAvailableCompilerListItem() { } PlanAvailableCompilerList::PlanAvailableCompilerList(QWidget *parent) : QListWidget(parent) { connect(this, SIGNAL(sigCompilerRegister(CBM::Compiler*)), this, SLOT(doCompilerRegister(CBM::Compiler*))); connect(this, SIGNAL(sigCompilerUnregister(CBM::Compiler*)), this, SLOT(doCompilerUnregister(CBM::Compiler*))); connect(this, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(doSelectionChanged()), Qt::QueuedConnection); setToolTip(tr("Drag compilers in Benchmark definition to use them")); } void PlanAvailableCompilerList::mousePressEvent(QMouseEvent *event) { QListWidget::mousePressEvent(event); CBM::Compiler *C = compilerSelected(); if (!C) return; QString plainText = "compiler"; QMimeData *mimeData = new QMimeData; mimeData->setText(plainText); QDrag *drag = new QDrag(this); drag->setMimeData(mimeData); drag->setHotSpot(event->pos() - rect().topLeft()); Qt::DropAction dropAction = drag->start(Qt::CopyAction | Qt::MoveAction); if (dropAction == Qt::MoveAction) { close(); update(); } } void PlanAvailableCompilerList::doCompilerRegister(CBM::Compiler *_compiler) { addItem(new PlanAvailableCompilerListItem(_compiler)); } void PlanAvailableCompilerList::doCompilerUnregister(CBM::Compiler *_compiler) { int i, n = count(); PlanAvailableCompilerListItem *I; for(i=0;i<n;i++) { I=(PlanAvailableCompilerListItem*) item(i); if (I->Compiler()->Binary()==_compiler->Binary()) { I=(PlanAvailableCompilerListItem*) takeItem(i); delete(I); break; } } } void PlanAvailableCompilerList::doSelectionChanged(void) { emit App->planCompilerSelect(compilerSelected()); } void PlanAvailableCompilerList::compilerRegister(CBM::Compiler *_compiler) { emit sigCompilerRegister(_compiler); } void PlanAvailableCompilerList::compilerUnregister(CBM::Compiler *_compiler) { emit sigCompilerUnregister(_compiler); } CBM::Compiler *PlanAvailableCompilerList::compilerSelected(void) { PlanAvailableCompilerListItem *I = (PlanAvailableCompilerListItem*) currentItem(); if (!I) return(0); return(I->Compiler()); } PlanAvailableCompilerList::~PlanAvailableCompilerList() { } --- NEW FILE: PlanAvailableBenchmark.h --- #ifndef H_CQT_AVAILABLEBENCHMARK #define H_CQT_AVAILABLEBENCHMARK #include <QTreeWidget> #include <Basic/BenchmarkHolder.h> namespace CQT { class PlanAvailableBenchmarkListItem : public QTreeWidgetItem, public BenchmarkHolder { public: PlanAvailableBenchmarkListItem(CBM::Benchmark *_benchmark); virtual ~PlanAvailableBenchmarkListItem(); }; class PlanAvailableBenchmarkList : public QTreeWidget { Q_OBJECT private: protected slots: virtual void doRefreshBenchmarks(void); signals: virtual void sigRefreshBenchmarks(void); public: PlanAvailableBenchmarkList(QWidget *parent = 0); virtual void refreshBenchmarks(void); virtual ~PlanAvailableBenchmarkList(); }; } #endif --- NEW FILE: PlanManager.h --- #ifndef H_CQT_PLANMANAGER #define H_CQT_PLANMANAGER #include <QSplitter> #include <Plan/PlanAvailable.h> #include <Plan/PlanAvailableCompiler.h> #include <Plan/PlanAvailableBenchmark.h> #include <Plan/PlanDefine.h> #include <Compiler/CompilerHolder.h> // #include <Plan/PlanList.h> // #include <Plan/PlanInfo.h> namespace CQT { class PlanManager : public QSplitter { Q_OBJECT private: PlanAvailable *available; PlanDefine *define; protected: signals: public slots: public: PlanManager(QWidget *parent = 0); virtual PlanAvailableCompilerList *AvailableCompiler(void); virtual PlanAvailableBenchmarkList *AvailableBenchmark(void); virtual PlanDefine *Define(void); virtual ~PlanManager(); }; } #endif --- NEW FILE: PlanAvailableCompiler.h --- #ifndef H_CQT_AVAILABLECOMPILER #define H_CQT_AVAILABLECOMPILER #include <QListWidget> #include <Compiler/CompilerHolder.h> namespace CQT { class PlanAvailableCompilerListItem : public QListWidgetItem, public CompilerHolder { public: PlanAvailableCompilerListItem(CBM::Compiler *_compiler); virtual ~PlanAvailableCompilerListItem(); }; class PlanAvailableCompilerList : public QListWidget { Q_OBJECT private: protected: virtual void mousePressEvent(QMouseEvent *event); signals: void sigCompilerRegister(CBM::Compiler *_compiler); void sigCompilerUnregister(CBM::Compiler *_compiler); public slots: void doCompilerRegister(CBM::Compiler *_compiler); void doCompilerUnregister(CBM::Compiler *_compiler); void doSelectionChanged(void); public: PlanAvailableCompilerList(QWidget *parent = 0); virtual void compilerRegister(CBM::Compiler *_compiler); virtual void compilerUnregister(CBM::Compiler *_compiler); virtual CBM::Compiler *compilerSelected(void); virtual ~PlanAvailableCompilerList(); }; } #endif --- NEW FILE: PlanDefineBatch.h --- #ifndef H_CQT_DEFINEBATCH #define H_CQT_DEFINEBATCH #include <QTreeWidget> #include <QDragEnterEvent> #include <QContextMenuEvent> #include <QMenu> #include <Compiler/CompilerHolder.h> #include <Basic/OptionHolder.h> #include <Basic/BenchmarkHolder.h> #include <Basic/PlanBatchHolder.h> namespace CQT { typedef enum { PIPlanBatch, PICompilers, PIOptionSet, PIOptions, PIBenchmarks, PICompiler, PIOption, PIBenchmark } PlanItemType; class PlanDefineBatchContextMenuEvent : public QContextMenuEvent { public: PlanDefineBatchContextMenuEvent(Reason reason, const QPoint &globalPos); virtual ~PlanDefineBatchContextMenuEvent(); }; class PlanDefineBatchContextMenu : public QMenu { Q_OBJECT protected slots: void doBatchRegister(void); void doBatchUnregister(void); public: PlanDefineBatchContextMenu(class PlanDefineBatchListItem *item); virtual ~PlanDefineBatchContextMenu(); }; class PlanDefineBatchListItem : public QTreeWidgetItem, public CompilerHolder, public OptionHolder, public BenchmarkHolder, public PlanBatchHolder { public: PlanDefineBatchListItem(PlanItemType _type); PlanDefineBatchListItem(CBM::PlanBatch *_batch); PlanDefineBatchListItem(CBM::Compiler *_compiler); virtual PlanDefineBatchListItem *Parent(PlanItemType _which); virtual PlanDefineBatchListItem *Nearest(PlanItemType _which); virtual ~PlanDefineBatchListItem(); }; class PlanDefineBatchList : public QTreeWidget { Q_OBJECT private: protected: virtual void dragEnterEvent(QDragEnterEvent *event); virtual void dropEvent(QDropEvent *event); virtual void dragMoveEvent(QDragMoveEvent *event); virtual void contextMenuEvent(QContextMenuEvent *event); signals: void sigPlanBatchRegister(CBM::PlanBatch *_batch); void sigPlanBatchUnregister(CBM::PlanBatch *_batch); void sigPlanBatchRenamed(CBM::PlanBatch *_batch, QString _newname); protected slots: virtual void doPlanBatchRegister(CBM::PlanBatch *_batch); virtual void doPlanBatchUnregister(CBM::PlanBatch *_batch); virtual void doPlanBatchRenamed(CBM::PlanBatch *_batch, QString _newname); public: PlanDefineBatchList(QWidget *parent = 0); virtual void planBatchRegister(CBM::PlanBatch *_batch); virtual void planBatchUnregister(CBM::PlanBatch *_batch); virtual void planBatchRenamed(CBM::PlanBatch *_batch, QString _newname); virtual ~PlanDefineBatchList(); }; } #endif --- NEW FILE: PlanAvailableBenchmark.cpp --- #include <Plan/PlanAvailableBenchmark.h> #include <Benchmark/Package.h> #include <System/System.h> using namespace CQT; PlanAvailableBenchmarkListItem::PlanAvailableBenchmarkListItem(CBM::Benchmark *_benchmark) : QTreeWidgetItem(QStringList(_benchmark->Name().c_str()), 0), BenchmarkHolder(_benchmark) { } PlanAvailableBenchmarkListItem::~PlanAvailableBenchmarkListItem() { } PlanAvailableBenchmarkList::PlanAvailableBenchmarkList(QWidget *parent) : QTreeWidget(parent) { setToolTip(tr("Drag benchmarks in Benchmark definition to use them")); connect(this, SIGNAL(sigRefreshBenchmarks()), this, SLOT(doRefreshBenchmarks())); headerItem()->setHidden(true); doRefreshBenchmarks(); } void PlanAvailableBenchmarkList::doRefreshBenchmarks(void) { int pi, pn = CBM::cbmSystem->packageNumber(); int bi, bn; QTreeWidgetItem *iP; CBM::Package *P; PlanAvailableBenchmarkListItem *iB; CBM::Benchmark *B; clear(); for (pi=0; pi<pn; pi++) { P=CBM::cbmSystem->Package(pi); if (P->getStatus()<CBM::Package::Preconfigured) continue; iP=new QTreeWidgetItem(QStringList(P->Name().c_str()), 0); iP->setIcon(0, QIcon(":/icons/package.png")); addTopLevelItem(iP); bn=P->benchmarkNumber(); for(bi=0; bi<bn; bi++) { B=P->Benchmark(bi); iB=new PlanAvailableBenchmarkListItem(B); iP->addChild(iB); } } } void PlanAvailableBenchmarkList::refreshBenchmarks(void) { emit sigRefreshBenchmarks(); } PlanAvailableBenchmarkList::~PlanAvailableBenchmarkList() { } --- NEW FILE: PlanDefine.h --- #ifndef H_CQT_PLANDEFINE #define H_CQT_PLANDEFINE #include <Plan/PlanDefineToolBox.h> #include <Plan/PlanDefineBatch.h> #include <QGroupBox> namespace CQT { class PlanDefine : public QGroupBox { Q_OBJECT private: PlanDefineToolBox *defineToolBox; PlanDefineBatchList *defineBatch; protected: signals: public slots: public: PlanDefine(QWidget *parent = 0); virtual PlanDefineBatchList *Batch(void); virtual ~PlanDefine(); }; } #endif --- NEW FILE: PlanDefine.cpp --- #include <Plan/PlanDefine.h> #include <QHBoxLayout> #include <QSplitter> using namespace CQT; PlanDefine::PlanDefine(QWidget *parent) : QGroupBox(parent) { QSplitter *sp = new QSplitter; QHBoxLayout *lay = new QHBoxLayout; defineToolBox=new PlanDefineToolBox; defineBatch=new PlanDefineBatchList; /* lay->addWidget(defineToolBox); lay->addWidget(defineBatch); */ sp->addWidget(defineToolBox); sp->addWidget(defineBatch); lay->addWidget(sp); setTitle(tr("Benchmark definition")); setLayout(lay); } PlanDefineBatchList *PlanDefine::Batch(void) { return(defineBatch); } PlanDefine::~PlanDefine() { } --- NEW FILE: PlanAvailableOption.h --- #ifndef H_CQT_AVAILABLEOPTION #define H_CQT_AVAILABLEOPTION #include <QListWidget> #include <Basic/OptionHolder.h> #include <Compiler/Compiler.h> namespace CQT { class PlanAvailableOptionListItem : public QListWidgetItem, public OptionHolder { public: PlanAvailableOptionListItem(CBM::CompilerOption *_option); virtual ~PlanAvailableOptionListItem(); }; class PlanAvailableOptionList : public QListWidget { Q_OBJECT private: protected: signals: void sigOptionsRefresh(CBM::Compiler *_compiler); public slots: void doOptionsRefresh(CBM::Compiler *_compiler); public: PlanAvailableOptionList(QWidget *parent = 0); virtual void optionsRefresh(CBM::Compiler *_compiler); virtual ~PlanAvailableOptionList(); }; } #endif |