22 #include <QApplication> 23 #include <QMouseEvent> 24 #include <QPaintEvent> 26 #include <QResizeEvent> 27 #include <QVBoxLayout> 42 #define REPAINT_INTERVAL 250 48 #define REPAINT_INTERVAL_FAST 50 50 #define BAR_BACKGROUND palette().mid().color() 51 #define BAR_FOREGROUND palette().light().color() 57 :QThread(), m_overview(overview)
64 Q_ASSERT(!isRunning());
84 Q_ASSERT(this->thread() == QThread::currentThread());
85 Q_ASSERT(this->thread() == qApp->thread());
111 setMouseTracking(
true);
118 Q_ASSERT(this->thread() == QThread::currentThread());
119 Q_ASSERT(this->thread() == qApp->thread());
136 if (e->buttons() != Qt::LeftButton) {
145 offset = (offset > half) ? (offset - half) : 0;
157 if (e->button() != Qt::LeftButton) {
169 if (e->modifiers() == Qt::NoModifier) {
172 }
else if (e->modifiers() == Qt::ShiftModifier) {
183 int width = this->width();
184 if (!width)
return 0;
186 if (pixels < 0) pixels = 0;
188 static_cast<double>(width - 1);
190 static_cast<double>(pixels) * zoom));
225 return QSize(30, 30);
238 Q_ASSERT(this->thread() == QThread::currentThread());
239 Q_ASSERT(this->thread() == qApp->thread());
259 Q_ASSERT(this->thread() == QThread::currentThread());
260 Q_ASSERT(this->thread() == qApp->thread());
276 Q_ASSERT(this->thread() == QThread::currentThread());
277 Q_ASSERT(this->thread() == qApp->thread());
282 if (new_pos == old_pos)
return;
293 const double scale =
static_cast<double>(width()) /
294 static_cast<double>(length);
296 static_cast<double>(old_pos) * scale);
298 static_cast<double>(new_pos) * scale);
299 if (old_pixel_pos == new_pixel_pos)
return;
318 const int y = (height - 1);
320 p.setCompositionMode(QPainter::CompositionMode_SourceOver);
322 p.setBrush(QBrush(color));
323 p.setPen(QPen(Qt::black));
325 mark.setPoints(3, x - w, 0, x + w, 0, x, w);
327 mark.setPoints(3, x - w, y, x + w, y, x, y - w);
335 Q_ASSERT(this->thread() == QThread::currentThread());
336 Q_ASSERT(this->thread() == qApp->thread());
359 int width = this->width();
360 int height = this->height();
364 const double scale =
static_cast<double>(width) /
365 static_cast<double>(length);
373 QImage image(width, height, QImage::Format_ARGB32_Premultiplied);
377 p.drawImage(0, 0, bitmap);
386 if (len < 1) len = 1;
389 QBrush hilight(Qt::yellow);
390 hilight.setStyle(Qt::SolidPattern);
392 p.setPen(QPen(Qt::yellow));
393 p.setCompositionMode(QPainter::CompositionMode_Exclusion);
394 p.drawRect(first, 0, len, height);
397 drawMark(p, first, height, Qt::blue);
398 drawMark(p, first + len, height, Qt::blue);
402 int last_label_pos = width + 1;
409 if (x == last_label_pos)
continue;
412 p.setPen(QPen(Qt::cyan));
413 p.setCompositionMode(QPainter::CompositionMode_Exclusion);
414 p.drawLine(x, 0, x, height);
426 QPen pen(Qt::yellow);
429 p.setCompositionMode(QPainter::CompositionMode_Exclusion);
430 p.drawLine(x, 0, x, height);
439 QBrush out_of_view(color);
440 out_of_view.setStyle(Qt::SolidPattern);
441 p.setBrush(out_of_view);
442 p.setPen(QPen(color));
443 p.setCompositionMode(QPainter::CompositionMode_SourceOver);
447 p.drawRect(0, 0, x, height);
453 p.drawRect(x, 0, width - x, height);
virtual QImage getOverView(int width, int height, const QColor &fg, const QColor &bg, double gain=1.0)
Kwave::Selection & selection()
virtual sample_index_t pos() const
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
void setImage(QImage image)
static double rect(double param)