7 #include <base-logging/Logging.hpp> 10 QGraphicsItem(parent),height(10),width(100), color(QColor(Qt::gray))
14 allSliders.append(slider);
18 LOG_DEBUG(
"Reconfiguring slidebar: startIndex=%d, steps=%d, stepSize=%d\n", startIndex, steps, stepSize);
19 this->startIndex = startIndex;
21 this->stepSize = stepSize;
28 void SlideBarItem::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget) {
31 painter->setPen(QPen(Qt::black, 1));
32 painter->setBrush(QBrush(color));
35 Q_FOREACH(
unsigned bookmark, bookmarks) {
39 painter->drawLine(x_pos, y_top, x_pos, y_bottom);
49 return bookmark_height;
53 this->bookmark_height = bookmark_height;
61 this->height = height;
73 timeMarkers.append(marker);
74 allSliders.append(marker);
88 if(otherMarker == marker) {
97 if(marker->pos().x() < otherMarker->pos().x()) {
103 if(marker->pos().x() >= otherMarker->pos().x()) {
108 std::cerr <<
"Unknown direction!" << std::endl;
112 if(marker->collidesWithItem(otherMarker) || overlap) {
121 if(otherMarker == marker) {
124 if(otherMarker->contains(point)) {
134 return (
unsigned) QStyle::sliderValueFromPosition(startIndex, steps*stepSize, marker->pos().x(),
getWidth());
138 return QStyle::sliderPositionFromValue(startIndex, steps*stepSize, index,
getWidth());
146 this->bookmarks = bookmarks;
152 Q_FOREACH(
int bookmark, bookmarks) {
155 if(clickRegion.contains(event->pos())) {
const QList< Slider * > & getAllSliders()
int markerPositionForIndex(unsigned index)
SlideBarItem(unsigned startIndex, unsigned steps, unsigned stepSize, QGraphicsItem *parent=0)
void reconfigure(unsigned startIndex, unsigned steps, unsigned stepSize)
unsigned markerIndex(Slider *marker)
qreal getBookmarkHeight() const
void setHeight(int width)
void updateBookmarks(QVector< int > &bookmarks)
const QList< BoundarySlider * > & getTimeMarkers()
void addTimeMarker(BoundarySlider *marker)
BoundarySlider * markerOverlap(BoundarySlider *marker)
void bookmarkClicked(int idx)
Direction leftRight(BoundarySlider *otherMarker)
unsigned getStartIndex() const
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
IndexSlider * getIndexSlider()
void setBookmarkHeight(qreal height)
void mousePressEvent(QGraphicsSceneMouseEvent *event)
bool markerContainsPoint(BoundarySlider *marker, const QPointF &point)
void setLastIndex(unsigned index)
QRectF boundingRect() const