[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: Re: extragear/graphics/digikam/libs
From: "Gilles Caulier" <caulier.gilles () gmail ! com>
Date: 2007-06-30 19:43:10
Message-ID: b4b1230e0706301243t204bfe29ya3aaec8cb45c27d4 () mail ! gmail ! com
[Download RAW message or body]
Marcel,
Image plugins thread interface is not yet fixed in this way. When i have
ported the code, i have done as well, without use new features of Qt4
Gilles
2007/6/30, Marcel Wiesweg <marcel.wiesweg@gmx.de>:
>
> SVN commit 681905 by mwiesweg:
>
> Remove custom event sending, use queued signals.
> Fixes a crash (and is so much more elegant anyway)
>
>
> M +5 -13 histogram/imagehistogram.cpp
> M +7 -18 histogram/imagehistogram.h
> M +28 -30 widgets/common/curveswidget.cpp
> M +2 -4 widgets/common/curveswidget.h
> M +67 -57 widgets/common/histogramwidget.cpp
> M +4 -2 widgets/common/histogramwidget.h
>
>
> --- trunk/extragear/graphics/digikam/libs/histogram/imagehistogram.cpp
> #681904:681905
> @@ -43,6 +43,7 @@
> #include "ddebug.h"
> #include "dimg.h"
> #include "imagehistogram.h"
> +#include "imagehistogram.moc"
>
> namespace Digikam
> {
> @@ -123,7 +124,7 @@
> else
> {
> if (d->parent)
> - postProgress(false, false);
> + emit calculationFinished(this, false);
> }
> }
>
> @@ -142,15 +143,6 @@
> return d->histoSegments;
> }
>
> -void ImageHistogram::postProgress(bool starting, bool success)
> -{
> - EventData *eventData = new EventData();
> - eventData->starting = starting;
> - eventData->success = success;
> - eventData->histogram = this;
> - QApplication::postEvent(d->parent, eventData);
> -}
> -
> void ImageHistogram::stopCalcHistogramValues(void)
> {
> d->runningFlag = false;
> @@ -170,7 +162,7 @@
> int max;
>
> if (d->parent)
> - postProgress(true, false);
> + emit calculationStarted(this);
>
> d->histogram = new
> ImageHistogramPriv::double_packet[d->histoSegments];
> memset(d->histogram, 0,
> d->histoSegments*sizeof(ImageHistogramPriv::double_packet));
> @@ -180,7 +172,7 @@
> DWarning() << ("HistogramWidget::calcHistogramValues: Unable to
> allocate memory!") << endl;
>
> if (d->parent)
> - postProgress(false, false);
> + emit calculationFinished(this, false);
>
> return;
> }
> @@ -239,7 +231,7 @@
> }
>
> if (d->parent && d->runningFlag)
> - postProgress(false, true);
> + emit calculationFinished(this, true);
> }
>
> double ImageHistogram::getCount(int channel, int start, int end)
> --- trunk/extragear/graphics/digikam/libs/histogram/imagehistogram.h
> #681904:681905
> @@ -45,6 +45,8 @@
> class DIGIKAM_EXPORT ImageHistogram : public QThread
> {
>
> + Q_OBJECT
> +
> public:
>
> enum HistogramChannelType
> @@ -56,26 +58,8 @@
> AlphaChannel
> };
>
> -class EventData : public QEvent
> -{
> public:
>
> - EventData() : QEvent(QEvent::User)
> - {
> - starting = false;
> - success = false;
> - histogram = 0;
> - }
> -
> - bool starting;
> - bool success;
> - ImageHistogram *histogram;
> -
> - virtual ~EventData(){};
> -};
> -
> -public:
> -
> ImageHistogram(uchar *i_data, uint i_w, uint i_h, bool i_sixteenBits,
> QObject *parent=0);
>
> ImageHistogram(const DImg& image, QObject *parent=0);
> @@ -97,6 +81,11 @@
> int getHistogramSegment(void);
> int getMedian(int channel, int start, int end);
>
> +signals:
> +
> + void calculationFinished(const ImageHistogram *histogram, bool
> success);
> + void calculationStarted(const ImageHistogram *histogram);
> +
> protected:
>
> virtual void run();
> --- trunk/extragear/graphics/digikam/libs/widgets/common/curveswidget.cpp
> #681904:681905
> @@ -133,6 +133,12 @@
> this, SLOT(slotBlinkTimerDone()) );
>
> m_imageHistogram = new ImageHistogram(i_data, i_w, i_h,
> i_sixteenBits, this);
> +
> + connect(m_imageHistogram, SIGNAL(calculationStarted(const
> ImageHistogram *)),
> + this, SLOT(slotCalculationStarted(const ImageHistogram *)));
> +
> + connect(m_imageHistogram, SIGNAL(calculationFinished(const
> ImageHistogram *, bool)),
> + this, SLOT(slotCalculationFinished(const ImageHistogram *,
> bool)));
> }
>
> CurvesWidget::~CurvesWidget()
> @@ -189,42 +195,34 @@
> emit signalCurvesChanged();
> }
>
> -void CurvesWidget::customEvent(QEvent *event)
> +void CurvesWidget::slotCalculationProgress(const ImageHistogram
> *histogram)
> {
> - if (!event) return;
> + Q_UNUSED(histogram);
> + setCursor( Qt::WaitCursor );
> + d->clearFlag = CurvesWidgetPriv::HistogramStarted;
> + d->blinkTimer->start( 200 );
> + repaint();
> +}
>
> - ImageHistogram::EventData *ed = (ImageHistogram::EventData*) event;
> -
> - if (!ed) return;
> -
> - if (ed->starting)
> +void CurvesWidget::slotCalculationFinished(const ImageHistogram
> *histogram, bool success)
> +{
> + Q_UNUSED(histogram);
> + if (success)
> {
> - setCursor( Qt::WaitCursor );
> - d->clearFlag = CurvesWidgetPriv::HistogramStarted;
> - d->blinkTimer->start( 200 );
> + // Repaint histogram
> + d->clearFlag = CurvesWidgetPriv::HistogramCompleted;
> + d->blinkTimer->stop();
> repaint();
> - }
> - else
> + setCursor( Qt::ArrowCursor );
> + }
> + else
> {
> - if (ed->success)
> - {
> - // Repaint histogram
> - d->clearFlag = CurvesWidgetPriv::HistogramCompleted;
> - d->blinkTimer->stop();
> - repaint();
> - setCursor( Qt::ArrowCursor );
> - }
> - else
> - {
> - d->clearFlag = CurvesWidgetPriv::HistogramFailed;
> - d->blinkTimer->stop();
> - repaint();
> - setCursor( Qt::ArrowCursor );
> - emit signalHistogramComputationFailed();
> - }
> + d->clearFlag = CurvesWidgetPriv::HistogramFailed;
> + d->blinkTimer->stop();
> + repaint();
> + setCursor( Qt::ArrowCursor );
> + emit signalHistogramComputationFailed();
> }
> -
> - delete ed;
> }
>
> void CurvesWidget::stopHistogramComputation(void)
> --- trunk/extragear/graphics/digikam/libs/widgets/common/curveswidget.h
> #681904:681905
> @@ -100,6 +100,8 @@
> protected slots:
>
> void slotBlinkTimerDone( void );
> + void slotCalculationProgress(const ImageHistogram *histogram);
> + void slotCalculationFinished(const ImageHistogram *histogram, bool
> success);
>
> protected:
>
> @@ -111,10 +113,6 @@
>
> private:
>
> - void customEvent(QEvent *event);
> -
> -private:
> -
> CurvesWidgetPriv* d;
> };
>
> ---
> trunk/extragear/graphics/digikam/libs/widgets/common/histogramwidget.cpp
> #681904:681905
> @@ -41,8 +41,6 @@
> #include <qfont.h>
> #include <qfontmetrics.h>
> #include <qtooltip.h>
> -//Added by qt3to4:
> -#include <QCustomEvent>
> #include <QPaintEvent>
> #include <QMouseEvent>
>
> @@ -142,6 +140,8 @@
>
> m_imageHistogram = new ImageHistogram(i_data, i_w, i_h,
> i_sixteenBits, this);
> m_selectionHistogram = 0L;
> +
> + connectHistogram(m_imageHistogram);
> }
>
> // Constructor with image selection.
> @@ -161,6 +161,9 @@
>
> m_imageHistogram = new ImageHistogram(i_data, i_w, i_h,
> i_sixteenBits, this);
> m_selectionHistogram = new ImageHistogram(s_data, s_w, s_h,
> i_sixteenBits, this);
> +
> + connectHistogram(m_imageHistogram);
> + connectHistogram(m_selectionHistogram);
> }
>
> HistogramWidget::~HistogramWidget()
> @@ -195,6 +198,15 @@
> this, SLOT(slotBlinkTimerDone()) );
> }
>
> +void HistogramWidget::connectHistogram(const ImageHistogram *histogram)
> +{
> + connect(histogram, SIGNAL(calculationStarted(const ImageHistogram
> *)),
> + this, SLOT(slotCalculationStarted(const ImageHistogram *)));
> +
> + connect(histogram, SIGNAL(calculationFinished(const ImageHistogram *,
> bool)),
> + this, SLOT(slotCalculationFinished(const ImageHistogram *,
> bool)));
> +}
> +
> void HistogramWidget::setHistogramGuideByColor(DColor color)
> {
> d->guideVisible = true;
> @@ -208,82 +220,75 @@
> repaint();
> }
>
> -void HistogramWidget::customEvent(QEvent *event)
> +void HistogramWidget::slotCalculationStarted(const ImageHistogram
> *histogram)
> {
> - if (!event) return;
> -
> - ImageHistogram::EventData *ed = (ImageHistogram::EventData*) event;
> -
> - if (!ed) return;
> -
> - if (ed->histogram != m_imageHistogram && ed->histogram !=
> m_selectionHistogram)
> + if (histogram != m_imageHistogram && histogram !=
> m_selectionHistogram)
> return;
>
> - if (ed->starting)
> + setCursor( Qt::WaitCursor );
> + d->clearFlag = HistogramWidgetPriv::HistogramStarted;
> + if (!d->inInitialRepaintWait)
> {
> - setCursor( Qt::WaitCursor );
> - d->clearFlag = HistogramWidgetPriv::HistogramStarted;
> - if (!d->inInitialRepaintWait)
> + if (d->clearFlag != HistogramWidgetPriv::HistogramDataLoading)
> {
> - if (d->clearFlag !=
> HistogramWidgetPriv::HistogramDataLoading)
> - {
> // enter initial repaint wait, repaint only after waiting
> // a short time so that very fast computation does not
> create flicker
> - d->inInitialRepaintWait = true;
> - d->blinkTimer->start( 100 );
> - }
> - else
> - {
> + d->inInitialRepaintWait = true;
> + d->blinkTimer->start( 100 );
> + }
> + else
> + {
> // after the initial repaint, we can repaint immediately
> - repaint();
> - d->blinkTimer->start( 200 );
> - }
> + repaint();
> + d->blinkTimer->start( 200 );
> }
> }
> - else
> +}
> +
> +void HistogramWidget::slotCalculationFinished(const ImageHistogram
> *histogram, bool success)
> +{
> + if (histogram != m_imageHistogram && histogram !=
> m_selectionHistogram)
> + return;
> +
> + if (success)
> {
> - if (ed->success)
> - {
> // Repaint histogram
> - d->clearFlag = HistogramWidgetPriv::HistogramCompleted;
> - d->blinkTimer->stop();
> - d->inInitialRepaintWait = false;
> - setCursor( Qt::ArrowCursor );
> + d->clearFlag = HistogramWidgetPriv::HistogramCompleted;
> + d->blinkTimer->stop();
> + d->inInitialRepaintWait = false;
> + setCursor( Qt::ArrowCursor );
>
> // Send signals to refresh information if necessary.
> // The signals may trigger multiple repaints, avoid this,
> // we repaint once afterwards.
> - setUpdatesEnabled(false);
> + setUpdatesEnabled(false);
>
> - notifyValuesChanged();
> - emit signalHistogramComputationDone(d->sixteenBits);
> + notifyValuesChanged();
> + emit signalHistogramComputationDone(d->sixteenBits);
>
> - setUpdatesEnabled(true);
> - repaint();
> + setUpdatesEnabled(true);
> + repaint();
> + }
> + else
> + {
> + d->clearFlag = HistogramWidgetPriv::HistogramFailed;
> + d->blinkTimer->stop();
> + d->inInitialRepaintWait = false;
> + repaint();
> + setCursor( Qt::ArrowCursor );
> + // Remove old histogram data from memory.
> + if (m_imageHistogram)
> + {
> + delete m_imageHistogram;
> + m_imageHistogram = 0;
> }
> - else
> + if (m_selectionHistogram)
> {
> - d->clearFlag = HistogramWidgetPriv::HistogramFailed;
> - d->blinkTimer->stop();
> - d->inInitialRepaintWait = false;
> - repaint();
> - setCursor( Qt::ArrowCursor );
> - // Remove old histogram data from memory.
> - if (m_imageHistogram)
> - {
> - delete m_imageHistogram;
> - m_imageHistogram = 0;
> - }
> - if (m_selectionHistogram)
> - {
> - delete m_selectionHistogram;
> - m_selectionHistogram = 0;
> - }
> - emit signalHistogramComputationFailed();
> + delete m_selectionHistogram;
> + m_selectionHistogram = 0;
> }
> + emit signalHistogramComputationFailed();
> }
> -
> - delete ed;
> }
>
> void HistogramWidget::setDataLoading()
> @@ -346,10 +351,14 @@
>
> // Calc new histogram data
> m_imageHistogram = new ImageHistogram(i_data, i_w, i_h,
> i_sixteenBits, this);
> + connectHistogram(m_imageHistogram);
>
> if (s_data && s_w && s_h)
> + {
> m_selectionHistogram = new ImageHistogram(s_data, s_w, s_h,
> i_sixteenBits, this);
> - else
> + connectHistogram(m_selectionHistogram);
> + }
> + else
> m_selectionHistogram = 0L;
> }
>
> @@ -366,6 +375,7 @@
>
> // Calc new histogram data
> m_selectionHistogram = new ImageHistogram(s_data, s_w, s_h,
> i_sixteenBits, this);
> + connectHistogram(m_selectionHistogram);
> }
>
> void HistogramWidget::slotBlinkTimerDone( void )
> --- trunk/extragear/graphics/digikam/libs/widgets/common/histogramwidget.h
> #681904:681905
> @@ -154,6 +154,8 @@
> protected slots:
>
> void slotBlinkTimerDone( void );
> + void slotCalculationStarted(const ImageHistogram *histogram);
> + void slotCalculationFinished(const ImageHistogram *histogram, bool
> success);
>
> protected:
>
> @@ -162,10 +164,10 @@
> void mouseReleaseEvent ( QMouseEvent * e );
> void mouseMoveEvent ( QMouseEvent * e );
>
> -private :
> +private:
>
> - void customEvent(QEvent *event);
> void notifyValuesChanged();
> + void connectHistogram(const ImageHistogram *histogram);
>
> private:
>
>
[Attachment #3 (text/html)]
Marcel, <br><br>Image plugins thread interface is not yet fixed in this way. When i \
have ported the code, i have done as well, without use new features of \
Qt4<br><br>Gilles<br><br><div><span class="gmail_quote">2007/6/30, Marcel Wiesweg \
< <a href="mailto:marcel.wiesweg@gmx.de">marcel.wiesweg@gmx.de</a>>:</span><blockquote \
class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt \
0pt 0.8ex; padding-left: 1ex;">SVN commit 681905 by mwiesweg: <br><br>Remove custom \
event sending, use queued signals.<br>Fixes a crash (and is so much more elegant \
anyway)<br><br><br> M +5 -13 \
histogram/imagehistogram.cpp<br> M +7 -18 \
histogram/imagehistogram.h<br> M +28 \
-30 widgets/common/curveswidget.cpp <br> M +2 \
-4 widgets/common/curveswidget.h<br> \
M +67 -57 widgets/common/histogramwidget.cpp<br> \
M +4 -2 widgets/common/histogramwidget.h<br><br><br>--- \
trunk/extragear/graphics/digikam/libs/histogram/imagehistogram.cpp #681904:681905 \
<br>@@ -43,6 +43,7 @@<br> #include "ddebug.h"<br> #include \
"dimg.h"<br> #include "imagehistogram.h"<br>+#include \
"imagehistogram.moc"<br><br> namespace Digikam<br> {<br>@@ -123,7 +124,7 @@ \
<br> else<br> \
{<br> if \
(d->parent)<br>- postProgress(false, \
false);<br>+ emit \
calculationFinished(this, false);<br> }<br> }<br><br>@@ \
-142,15 +143,6 @@<br> return d->histoSegments; <br> \
}<br><br>-void ImageHistogram::postProgress(bool starting, bool \
success)<br>-{<br>- EventData *eventData = new \
EventData();<br>- eventData->starting = \
starting;<br>- eventData->success = \
success;<br>
- eventData->histogram = \
this;<br>- QApplication::postEvent(d->parent, \
eventData);<br>-}<br>-<br> void ImageHistogram::stopCalcHistogramValues(void)<br> \
{<br> d->runningFlag = false;<br>@@ -170,7 +162,7 @@ \
<br> \
int max;<br><br> \
if (d->parent)<br>- postProgress(true, \
false);<br>+ emit \
calculationStarted(this);<br><br> d->histogram = new \
ImageHistogramPriv::double_packet[d->histoSegments]; <br> \
memset(d->histogram, 0, \
d->histoSegments*sizeof(ImageHistogramPriv::double_packet));<br>@@ -180,7 +172,7 \
@@<br> DWarning() << \
("HistogramWidget::calcHistogramValues: Unable to allocate memory!") \
<< endl; <br><br> if \
(d->parent)<br>- postProgress(false, \
false);<br>+ emit \
calculationFinished(this, \
false);<br><br> return;<br> \
}<br>@@ -239,7 +231,7 @@<br> \
}<br><br> if (d->parent && d->runningFlag) \
<br>- postProgress(false, \
true);<br>+ emit \
calculationFinished(this, true);<br> }<br><br> double ImageHistogram::getCount(int \
channel, int start, int end)<br>--- \
trunk/extragear/graphics/digikam/libs/histogram/imagehistogram.h #681904:681905 \
<br>@@ -45,6 +45,8 @@<br> class DIGIKAM_EXPORT ImageHistogram : public QThread<br> \
{<br><br>+ Q_OBJECT<br>+<br> public:<br><br> enum \
HistogramChannelType<br>@@ -56,26 +58,8 @@<br> \
AlphaChannel<br> };<br><br>-class EventData : public QEvent <br>-{<br> \
public:<br><br>- EventData() : \
QEvent(QEvent::User)<br>- {<br>- \
starting = false;<br>- \
success = false;<br>- histogram = \
0;<br>- }<br>-<br>- bool &nbs \
p; starting;<br>- &nbs \
p; bool success;
<br>- ImageHistogram \
*histogram;<br>-<br>- virtual \
~EventData(){};<br>-};<br>-<br>-public:<br>-<br> \
ImageHistogram(uchar *i_data, uint i_w, uint i_h, bool i_sixteenBits, QObject \
*parent=0);<br><br> ImageHistogram(const DImg& image, \
QObject *parent=0); <br>@@ -97,6 +81,11 @@<br> \
int getHistogramSegment(void);<br> \
int getMedian(int channel, int start, int \
end);<br><br>+signals:<br>+<br>+ void \
calculationFinished(const ImageHistogram *histogram, bool success); \
<br>+ void calculationStarted(const ImageHistogram \
*histogram);<br>+<br> protected:<br><br> virtual void \
run();<br>--- trunk/extragear/graphics/digikam/libs/widgets/common/curveswidget.cpp \
#681904:681905<br>@@ -133,6 +133,12 @@ \
<br> this, \
SLOT(slotBlinkTimerDone()) );<br><br> m_imageHistogram = new \
ImageHistogram(i_data, i_w, i_h, i_sixteenBits, \
this);<br>+<br>+ connect(m_imageHistogram, \
SIGNAL(calculationStarted(const ImageHistogram *)), \
<br>+ this, \
SLOT(slotCalculationStarted(const ImageHistogram \
*)));<br>+<br>+ connect(m_imageHistogram, \
SIGNAL(calculationFinished(const ImageHistogram *, \
bool)),<br>+ this, \
SLOT(slotCalculationFinished(const ImageHistogram *, bool))); <br> }<br><br> \
CurvesWidget::~CurvesWidget()<br>@@ -189,42 +195,34 @@<br> \
emit signalCurvesChanged();<br> }<br><br>-void CurvesWidget::customEvent(QEvent \
*event)<br>+void CurvesWidget::slotCalculationProgress(const ImageHistogram \
*histogram) <br> {<br>- if (!event) \
return;<br>+ Q_UNUSED(histogram);<br>+ setCursor( \
Qt::WaitCursor );<br>+ d->clearFlag = \
CurvesWidgetPriv::HistogramStarted;<br>+ d->blinkTimer->start( \
200 );<br>+ repaint(); \
<br>+}<br><br>- ImageHistogram::EventData *ed = \
(ImageHistogram::EventData*) event;<br>-<br>- if (!ed) \
return;<br>-<br>- if (ed->starting)<br>+void \
CurvesWidget::slotCalculationFinished(const ImageHistogram *histogram, bool success) \
<br>+{<br>+ Q_UNUSED(histogram);<br>+ if \
(success)<br> \
{<br>- setCursor( Qt::WaitCursor \
);<br>- d->clearFlag = \
CurvesWidgetPriv::HistogramStarted;<br>- d->blinkTimer->start( \
200 );<br> + // Repaint \
histogram<br>+ d->clearFlag = \
CurvesWidgetPriv::HistogramCompleted;<br>+ &n \
bsp;d->blinkTimer->stop();<br> \
repaint();<br>- }<br>- else<br>+ setCursor( \
Qt::ArrowCursor ); <br>+ }<br>+ else<br> \
{<br>- if \
(ed->success)<br>- {<br>- // \
Repaint histogram<br>- d->clearFlag \
= CurvesWidgetPriv::HistogramCompleted;<br>- d->blinkTimer->stop();
<br>- repaint( \
);<br>- setCursor( \
Qt::ArrowCursor );<br>- }<br>- &nb \
sp; else<br>- &n \
bsp; {<br>- d->clearFlag \
= CurvesWidgetPriv::HistogramFailed;<br>- d->blinkTimer->stop();
<br>- repaint( \
);<br>- setCursor( \
Qt::ArrowCursor );<br>- emit \
signalHistogramComputationFailed();<br>- }<br>+ d->clearFlag \
= CurvesWidgetPriv::HistogramFailed;<br>+ d->blinkTimer->stop();
<br>+ repaint();<br>+ setCursor( \
Qt::ArrowCursor );<br>+ emit \
signalHistogramComputationFailed();<br> \
}<br>-<br>- delete ed;<br> }<br><br> void \
CurvesWidget::stopHistogramComputation(void)<br>--- \
trunk/extragear/graphics/digikam/libs/widgets/common/curveswidget.h #681904:681905 \
<br>@@ -100,6 +100,8 @@<br> protected slots:<br><br> void \
slotBlinkTimerDone( void );<br>+ void \
slotCalculationProgress(const ImageHistogram \
*histogram);<br>+ void slotCalculationFinished(const \
ImageHistogram *histogram, bool success); <br><br> protected:<br><br>@@ -111,10 \
+113,6 @@<br><br> private:<br><br>- void customEvent(QEvent \
*event);<br>-<br>-private:<br>-<br> CurvesWidgetPriv* d;<br> \
};<br><br>--- trunk/extragear/graphics/digikam/libs/widgets/common/histogramwidget.cpp \
#681904:681905 <br>@@ -41,8 +41,6 @@<br> #include <qfont.h><br> #include \
<qfontmetrics.h><br> #include <qtooltip.h><br>-//Added by \
qt3to4:<br>-#include <QCustomEvent><br> #include <QPaintEvent><br> \
#include <QMouseEvent> <br><br>@@ -142,6 +140,8 \
@@<br><br> m_imageHistogram = new \
ImageHistogram(i_data, i_w, i_h, i_sixteenBits, this);<br> \
m_selectionHistogram = \
0L;<br>+<br>+ connectHistogram(m_imageHistogram);<br> \
}<br><br> // Constructor with image selection. <br>@@ -161,6 +161,9 \
@@<br><br> m_imageHistogram = new \
ImageHistogram(i_data, i_w, i_h, i_sixteenBits, this);<br> \
m_selectionHistogram = new ImageHistogram(s_data, s_w, s_h, i_sixteenBits, \
this);<br>+<br>+ connectHistogram(m_imageHistogram); \
<br>+ connectHistogram(m_selectionHistogram);<br> }<br><br> \
HistogramWidget::~HistogramWidget()<br>@@ -195,6 +198,15 \
@@<br> this, \
SLOT(slotBlinkTimerDone()) );<br> }<br><br>+void \
HistogramWidget::connectHistogram(const ImageHistogram *histogram) \
<br>+{<br>+ connect(histogram, SIGNAL(calculationStarted(const \
ImageHistogram *)),<br>+ this, \
SLOT(slotCalculationStarted(const ImageHistogram \
*)));<br>+<br>+ connect(histogram, \
SIGNAL(calculationFinished(const ImageHistogram *, bool)), \
<br>+ this, \
SLOT(slotCalculationFinished(const ImageHistogram *, bool)));<br>+}<br>+<br> void \
HistogramWidget::setHistogramGuideByColor(DColor color)<br> \
{<br> d->guideVisible = true;<br>@@ -208,82 +220,75 @@ \
<br> repaint();<br> }<br><br>-void \
HistogramWidget::customEvent(QEvent *event)<br>+void \
HistogramWidget::slotCalculationStarted(const ImageHistogram *histogram)<br> \
{<br>- if (!event) \
return;<br>-<br>- ImageHistogram::EventData *ed = \
(ImageHistogram::EventData*) event; <br>-<br>- if (!ed) \
return;<br>-<br>- if (ed->histogram != m_imageHistogram \
&& ed->histogram != m_selectionHistogram)<br>+ if \
(histogram != m_imageHistogram && histogram != m_selectionHistogram) \
<br> \
return;<br><br>- if \
(ed->starting)<br>+ setCursor( Qt::WaitCursor \
);<br>+ d->clearFlag = \
HistogramWidgetPriv::HistogramStarted;<br>+ if \
(!d->inInitialRepaintWait)<br> \
{<br>- setCursor( Qt::WaitCursor ); \
<br>- d->clearFlag = \
HistogramWidgetPriv::HistogramStarted;<br>- if \
(!d->inInitialRepaintWait)<br>+ if \
(d->clearFlag != HistogramWidgetPriv::HistogramDataLoading)<br> \
{<br>- if \
(d->clearFlag != HistogramWidgetPriv::HistogramDataLoading) \
<br>- {<br>&nbs \
p; \
// enter initial repaint wait, repaint only after \
waiting<br> \
// a short time so that very fast computation does not create \
flicker<br>- d->inInitialRepaintWait \
= true; <br>- d->blinkTimer->start( \
100 );<br>- }<b \
r>- else<br>-&n \
bsp; {<br>+ &nbs \
p; d->inInitialRepaintWait \
= true;<br>+ d->blinkTimer->start( \
100 );<br>+ } \
<br>+ else<br>+ \
{<br> \
// after the initial repaint, we can repaint \
immediately<br>- &nbs \
p; repaint();<br>- d->blinkTimer->start( \
200 );<br>- }<b \
r>+ repaint(); \
<br>+ d->blinkTimer->start( \
200 );<br> \
}<br> }<br>- else<br>+}<br>+<br>+void \
HistogramWidget::slotCalculationFinished(const ImageHistogram *histogram, bool \
success)<br>+{<br>+ if (histogram != m_imageHistogram \
&& histogram != m_selectionHistogram) \
<br>+ return;<br>+<br>+ if \
(success)<br> \
{<br>- if \
(ed->success)<br>- {<br> \
// Repaint histogram<br>- d->clearFlag \
= HistogramWidgetPriv::HistogramCompleted;<br>- d->blinkTimer->stop();
<br>- d->inInitialRepaintWait \
= false;<br>- setCursor( \
Qt::ArrowCursor );<br>+ d->clearFlag \
= HistogramWidgetPriv::HistogramCompleted;<br>+ &nb \
sp; d->blinkTimer->stop();<br>+ d->inInitialRepaintWait \
= false; <br>+ setCursor( \
Qt::ArrowCursor );<br><br> \
<br>- setUpdate \
sEnabled(false);<br>+ setUpdatesEnabled \
(false);<br><br>- &nb \
sp;notifyValuesChanged();<br>- emit \
signalHistogramComputationDone(d->sixteenBits);<br>+ notifyValuesChanged();
<br>+ emit \
signalHistogramComputationDone(d->sixteenBits);<br><br>- &nb \
sp; setUpdatesEnabled(true);<br>- \
repaint();<br>+   \
; setUpdatesEnabled(true);<br>+ &n \
bsp; repaint();<br>+ }<br>+ else
<br>+ {<br>+ d->clearFlag \
= HistogramWidgetPriv::HistogramFailed;<br>+ \
d->blinkTimer->stop();<br>+ d->inInitialRepaintWait \
= false;<br>+ repaint();<br>+ setCursor( \
Qt::ArrowCursor ); <br>+ // \
Remove old histogram data from \
memory.<br>+ if \
(m_imageHistogram)<br>+ {<br>+ delete \
m_imageHistogram;<br>+ m_imageHistogram \
= 0;<br> \
}<br>- else<br>+ if \
(m_selectionHistogram) <br> \
{<br>- d->clearFlag \
= HistogramWidgetPriv::HistogramFailed;<br>- \
d->blinkTimer->stop();<br>- d->inInitialRepaintWait \
= false;<br>- r \
epaint();<br>- setCursor( \
Qt::ArrowCursor ); <br>- // \
Remove old histogram data from \
memory.<br>- if \
(m_imageHistogram)<br>- &nb \
sp; {<br>- delete \
m_imageHistogram;<br>- m_imageHistogram \
= 0;<br>- }<br>
- if \
(m_selectionHistogram)<br>-   \
; {<br>- delete \
m_selectionHistogram;<br>- m_selectionHistogram \
= 0;<br>- }<br>- emit \
signalHistogramComputationFailed(); \
<br>+ delete \
m_selectionHistogram;<br>+ m_selectionHistogram \
= 0;<br> \
}<br>+ emit \
signalHistogramComputationFailed();<br> \
}<br>-<br>- delete ed;<br> }<br><br> void \
HistogramWidget::setDataLoading() <br>@@ -346,10 +351,14 \
@@<br><br> // Calc new histogram \
data<br> m_imageHistogram = new ImageHistogram(i_data, i_w, \
i_h, i_sixteenBits, this);<br>+ connectHistogram(m_imageHistogram);<br><br> \
if (s_data && s_w && s_h) \
<br>+ {<br> \
m_selectionHistogram = new ImageHistogram(s_data, s_w, s_h, i_sixteenBits, \
this);<br>- else<br>+ \
connectHistogram(m_selectionHistogram);<br>+ }<br>+ else<br> \
m_selectionHistogram = 0L; <br> }<br><br>@@ -366,6 +375,7 \
@@<br><br> // Calc new histogram \
data<br> m_selectionHistogram = new ImageHistogram(s_data, \
s_w, s_h, i_sixteenBits, \
this);<br>+ connectHistogram(m_selectionHistogram);<br> \
}<br><br> void HistogramWidget::slotBlinkTimerDone( void )<br>--- \
trunk/extragear/graphics/digikam/libs/widgets/common/histogramwidget.h \
#681904:681905<br>@@ -154,6 +154,8 @@<br> protected \
slots:<br><br> void slotBlinkTimerDone( void ); \
<br>+ void slotCalculationStarted(const ImageHistogram \
*histogram);<br>+ void slotCalculationFinished(const \
ImageHistogram *histogram, bool success);<br><br> protected:<br><br>@@ -162,10 \
+164,10 @@<br> void mouseReleaseEvent ( QMouseEvent * e ); \
<br> void mouseMoveEvent ( QMouseEvent * e );<br><br>-private \
:<br>+private:<br><br>- void customEvent(QEvent \
*event);<br> void \
notifyValuesChanged();<br>+ void connectHistogram(const \
ImageHistogram *histogram); <br><br> private:<br><br></blockquote></div><br>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic