1 /** @file selectEvalExecutions.cpp
2 @package snark14Display
3 @author Bruno M. Carvalho and Deniz Sarioz
4 licensed under (open-source) QPL v1.0
5 which accompanies this distribution in the file QPL
8 #include "variables.hpp"
9 #include "selectEvalExecutions.hpp"
10 #include "chooseYVar.hpp"
11 #include "SnarkDisplay.hpp"
14 #include <qapplication.h>
16 #include <q3listbox.h>
17 #include <qpushbutton.h>
21 #include <qwhatsthis.h>
23 // extern displaywindow **displaywindowset;
26 * Constructs a selectEvalExecutionsWindow which is a child of 'parent', with the
27 * name 'name' and widget flags set to 'f'
29 * The dialog will by default be modeless, unless you set 'modal' to
30 * TRUE to construct a modal dialog.
33 selectEvalExecutionsWindow::selectEvalExecutionsWindow( QWidget* parent, const char* name, bool modal, WFlags fl , int x , int y )
34 : QDialog( parent, name, modal, fl )
40 const int WINWIDTH = 760;
41 const int WINHEIGHT = 350;
43 setName( "selectEvalExecutionsWindow" );
44 resize( WINWIDTH, WINHEIGHT );
45 setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, sizePolicy().hasHeightForWidth() ) );
46 setMinimumSize( QSize( WINWIDTH, WINHEIGHT ) );
47 setMaximumSize( QSize( WINWIDTH, WINHEIGHT ) );
48 setCaption( tr( "Select Evaluate Executions to be plotted" ) );
55 const int BUTTONWIDTH = 140; // for (most) buttons
56 const int BUTTONHEIGHT = 40;
57 const int LRPADDING = 10; // left-to-right padding
58 openbutton = new QPushButton( this, "openbutton" );
59 openbutton->setGeometry( QRect( LRPADDING, 15, BUTTONWIDTH, BUTTONHEIGHT ) );
60 openbutton->setText( tr( "Proceed" ) ); // makes more sense than "open"
61 QObject::connect(openbutton,SIGNAL(clicked()),this,SLOT(openEvalExecutions()));
63 selectbutton = new QPushButton( this, "selectbutton" );
64 selectbutton->setGeometry( QRect( LRPADDING, 65, BUTTONWIDTH, BUTTONHEIGHT ) );
65 selectbutton->setText( tr( "Select All" ) );
66 QObject::connect(selectbutton,SIGNAL(clicked()),this,SLOT(selectAll()));
68 clearselectbutton = new QPushButton( this, "clearselectbutton" );
69 clearselectbutton->setGeometry( QRect( LRPADDING, 115, BUTTONWIDTH, BUTTONHEIGHT ) );
70 clearselectbutton->setText( tr( "Clear Selected" ) );
71 QObject::connect(clearselectbutton,SIGNAL(clicked()),this,SLOT(clearSelected()));
73 evalExecutionsListBox = new QListBox( this, "evalExecutionsListBox" );
74 evalExecutionsListBox->setSelectionMode(QListBox::Multi);
75 QFont f = QFont("courier",10,25,false);
76 f.setFixedPitch(true);
77 evalExecutionsListBox->setFont(f);
79 for(unsigned i=0; i < myEES.num_eval_execs(); i++) {
80 /// QString s = QString("Execution %1" ) . arg(i);
81 QString s(static_cast<char*>(myEES.getExecName(i)));
82 evalExecutionsListBox->insertItem(s);
84 int tmpi = BUTTONWIDTH + LRPADDING*2;
85 evalExecutionsListBox->setGeometry( QRect( tmpi, 15, WINWIDTH - tmpi - LRPADDING , 250 ) );
87 Line6 = new QFrame( this, "Line6" );
88 Line6->setGeometry( QRect( 0, 280, WINWIDTH, 16 ) );
89 Line6->setFrameStyle( QFrame::HLine | QFrame::Sunken );
91 closebutton = new QPushButton( this, "closebutton" );
92 closebutton->setGeometry( QRect( 380, 300, 100, 40 ) );
93 closebutton->setText( tr( "Close" ) );
94 QObject::connect(closebutton,SIGNAL(clicked()),this,SLOT(reject()));
98 * Destroys the object and frees any allocated resources
100 selectEvalExecutionsWindow::~selectEvalExecutionsWindow()
102 // no need to delete child widgets, Qt does it all for us
105 void selectEvalExecutionsWindow::openEvalExecutions()
107 if(std::verbose >= 2) std::cout << "in selectEvalExecutionsWindow::openEvalExecutions()" << std::endl;
114 for(unsigned i=0; i < myEES.num_eval_execs(); i++) {
115 if(evalExecutionsListBox->isSelected(i)) {
116 myEES.select_exec(i);
118 myEES.deselect_exec(i);
122 /// myEES.show_selected();
125 // if stmts have necessary side effects
126 if(hasG = myEES.selectionHasGlobal()) {
127 // if(std::verbose >=1) std::cout << "The selection has global." << std::endl;
129 if(hasP = myEES.selectionHasPBP()) {
130 // if(std::verbose >=1) std::cout << "The selection has PBP." << std::endl;
132 if(!(hasG || hasP)) {
133 std::cout << "Selection has neither global nor PBP! Nothing to plot!" << std::endl;
135 // do something like open a brand new window... onward!
137 topleft = this->pos();
138 // chooseYVarWindow* w;
139 /// if(myYVarWinP) delete myYVarWinP;
140 // myYVarWinP = new chooseYVarWindow(this, "blah", true, topleft.x(), topleft.y() );
141 chooseYVarWindow* myYVarWinP;
142 myYVarWinP = new chooseYVarWindow(desk, "Eval::chooseYVarWindow", false, 0, (this->pos()).x() + 30, (this->pos()).y() + 50 );
143 // w = new chooseYVarWindow(this, "Please choose the Y-variable to be plotted.", false, topleft.x() - 10, topleft.y() - 10);
147 } // --selectEvalExecutionsWindow::openEvalExecutions()
149 void selectEvalExecutionsWindow::selectAll()
151 evalExecutionsListBox->selectAll(true);
154 void selectEvalExecutionsWindow::clearSelected()
156 evalExecutionsListBox->selectAll(false);