46 QHBoxLayout* layout =
new QHBoxLayout(
this);
51 layout->addWidget(mLabel);
56 layout->addWidget(mTimerWidget);
58 mProgressBar =
new QProgressBar;
60 layout->addWidget(mProgressBar);
65 std::set<cx::TimedAlgorithmPtr>::iterator iter;
66 for(iter=threads.begin(); iter!=threads.end(); ++iter)
72 std::set<cx::TimedAlgorithmPtr>::iterator iter;
73 for(iter=threads.begin(); iter!=threads.end(); ++iter)
79 if (mAlgorithm.count(algorithm))
84 connect(algorithm.get(), SIGNAL(started(
int)),
this, SLOT(algorithmStartedSlot(
int)));
85 connect(algorithm.get(), SIGNAL(finished()),
this, SLOT(algorithmFinishedSlot()));
86 connect(algorithm.get(), SIGNAL(productChanged()),
this, SLOT(productChangedSlot()));
89 mAlgorithm.insert(algorithm);
94 if (!mAlgorithm.count(algorithm))
99 disconnect(algorithm.get(), SIGNAL(started(
int)),
this, SLOT(algorithmStartedSlot(
int)));
100 disconnect(algorithm.get(), SIGNAL(finished()),
this, SLOT(algorithmFinishedSlot()));
101 disconnect(algorithm.get(), SIGNAL(productChanged()),
this, SLOT(productChangedSlot()));
102 this->algorithmFinished(algorithm.get());
105 mAlgorithm.erase(algorithm);
108 void TimedAlgorithmProgressBar::productChangedSlot()
111 QString product =
"algorithm";
115 mLabel->setText(product);
121 if (mLabel->isVisible())
122 mLabel->setVisible(on);
125 void TimedAlgorithmProgressBar::algorithmStartedSlot(
int maxSteps)
128 QString product =
"algorithm";
132 mLabel->setText(product);
133 mLabel->setVisible(mShowTextLabel);
134 mStartedAlgos.insert(algo);
136 mTimerWidget->show();
137 mTimerWidget->
start();
139 mProgressBar->setRange(0, maxSteps);
140 mProgressBar->setValue(0);
141 mProgressBar->show();
144 void TimedAlgorithmProgressBar::algorithmFinishedSlot()
146 TimedBaseAlgorithm* algo =
dynamic_cast<TimedBaseAlgorithm*
>(sender());
147 this->algorithmFinished(algo);
150 void TimedAlgorithmProgressBar::algorithmFinished(TimedBaseAlgorithm* algo)
152 QString product =
"algorithm";
154 product = algo->getProduct();
156 mStartedAlgos.erase(algo);
157 if (!mStartedAlgos.empty())
160 mProgressBar->setValue(0);
161 mProgressBar->hide();
164 mTimerWidget->hide();
165 mTimerWidget->
stop();
Base class for algorithms that wants to time their execution.
void detach(TimedAlgorithmPtr algorithm)
boost::shared_ptr< class TimedBaseAlgorithm > TimedAlgorithmPtr
virtual QString getProduct() const
TimedAlgorithmProgressBar(QWidget *parent=NULL)
void attach(TimedAlgorithmPtr algorithm)
void setShowTextLabel(bool on)