rock_widget_collection  0.1
Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | List of all members
Timeline Class Reference

#include <Timeline.h>

Inherits QGraphicsView.

Public Slots

int getBookmarkHeight () const
 
void setBookmarkHeight (int height)
 
int getMarginTopBot ()
 
void setMarginTopBot (int margin)
 
int getMarginLR ()
 
void setMarginLR (int margin)
 
const QColor & getBackgroundColor () const
 
void setBackgroundColor (const QColor &color)
 
int getWidth ()
 
void setWidth (int width)
 
int getMinIndex ()
 
void setMinIndex (int minIndex)
 
int getSteps ()
 
void setSteps (int steps)
 
int getStepSize ()
 
void setStepSize (int stepSize)
 
int getMaxIndex ()
 
int getSliderIndex ()
 
int getStartMarkerIndex ()
 
void setStartMarkerIndex (int idx)
 
int getEndMarkerIndex ()
 
void setEndMarkerIndex (int idx)
 
void setSliderIndex (int idx)
 
void addBookmark (int idx)
 
void addBookmarks (QVector< int > bookmarks)
 
void removeBookmark (int idx)
 
void removeAllBookmarks ()
 
bool hasBookmarkAtIndex (int idx)
 

Signals

void indexSliderClicked ()
 
void endMarkerClicked ()
 
void startMarkerClicked ()
 
void indexSliderReleased (int idx)
 
void startMarkerMoved (int idx)
 
void endMarkerMoved (int idx)
 
void indexSliderMoved (int idx)
 
void startMarkerReleased (int idx)
 
void endMarkerReleased (int idx)
 
void bookmarkClicked (int idx)
 
void bookmarkRemoved (int idx)
 
void timeout ()
 

Public Member Functions

 Timeline (QWidget *parent=0)
 

Protected Member Functions

void resizeEvent (QResizeEvent *event)
 

Properties

int bookmark_height
 
int margin_topbot
 
int margin_lr
 
QColor backgroundColor
 
int width
 
unsigned minIndex READ
 
unsigned steps READ
 
unsigned stepSize READ
 

Detailed Description

This widget provides an improved Slider. Besides the standard slider functionality you can mark a region on the slide bar to select a certain interval between two indices. There are two markers: the start marker (left) and the end marker (right). The thin vertical slider is the index slider which is the pendant to the standard slider.

Author
Allan E. Conquest - allan.nosp@m..con.nosp@m.quest.nosp@m.@dfk.nosp@m.i.de

Definition at line 25 of file Timeline.h.

Constructor & Destructor Documentation

Timeline::Timeline ( QWidget *  parent = 0)

Definition at line 9 of file Timeline.cc.

9  {
10  setParent(parent);
11 
12  // Default property values
13  bookmarkHeight = 6;
14  marginTopBot = 5;
15  marginLR = 5;
16  bgColor = QColor(Qt::white);
17  ordered_width = 400;
18  minIndex = 0;
19  steps = 10;
20  stepSize = 1;
21 
22  reconfigure_slidebar = false;
23 
24  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
25  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
26 
27  // Setup scene
28  scene = new QGraphicsScene;
29  scene->setBackgroundBrush(getBackgroundColor());
30  setAlignment(Qt::AlignLeft | Qt::AlignTop);
31  setScene(scene);
32  setRenderHint(QPainter::Antialiasing);
33  setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
34 
35  // Add items
36  slidebar = new SlideBarItem(getMinIndex(), getSteps(), getStepSize());
38  slidebar->setWidth(ordered_width - getMarginLR()*2);
39  slidebar->setHeight(ordered_width - height());
40 
41  scene->addItem(slidebar);
42 
43  startmarker = new BoundarySlider(slidebar, getMinIndex());
44  slidebar->addTimeMarker(startmarker);
45 
46  endmarker = new BoundarySlider(slidebar, getMaxIndex());
47  slidebar->addTimeMarker(endmarker);
48 
49  connect(slidebar->getIndexSlider(), SIGNAL(sliderReleased(Slider*, int)), this, SLOT(sliderReleased(Slider*, int)));
50  connect(startmarker, SIGNAL(sliderReleased(Slider*, int)), this, SLOT(sliderReleased(Slider*, int)));
51  connect(endmarker, SIGNAL(sliderReleased(Slider*, int)), this, SLOT(sliderReleased(Slider*, int)));
52  connect(slidebar->getIndexSlider(), SIGNAL(sliderMoved(Slider*, int)), this, SLOT(sliderMoved(Slider*, int)));
53  connect(startmarker, SIGNAL(sliderMoved(Slider*, int)), this, SLOT(sliderMoved(Slider*, int)));
54  connect(endmarker, SIGNAL(sliderMoved(Slider*, int)), this, SLOT(sliderMoved(Slider*, int)));
55  connect(slidebar->getIndexSlider(), SIGNAL(sliderClicked(Slider*)), this, SLOT(sliderClicked(Slider*)));
56  connect(startmarker, SIGNAL(sliderClicked(Slider*)), this, SLOT(sliderClicked(Slider*)));
57  connect(endmarker, SIGNAL(sliderClicked(Slider*)), this, SLOT(sliderClicked(Slider*)));
58  connect(slidebar, SIGNAL(bookmarkClicked(int)), this, SLOT(bookmarkClickedSlot(int)));
59 
60  /* Timeout, at the moment only used for TestWidget */
61  timer = new QTimer(this);
62  timer->setInterval(25);
63  connect(timer, SIGNAL(timeout()), this, SLOT(fireTimeout()));
64  timer->start();
65 
66  updateScene();
67 }
int getMarginLR()
Definition: Timeline.cc:85
Definition: Slider.h:7
int getSteps()
Definition: Timeline.cc:118
void setHeight(int width)
Definition: SlideBarItem.cc:60
void timeout()
void addTimeMarker(BoundarySlider *marker)
Definition: SlideBarItem.cc:72
void bookmarkClicked(int idx)
int getBookmarkHeight() const
Definition: Timeline.cc:69
IndexSlider * getIndexSlider()
void setBookmarkHeight(qreal height)
Definition: SlideBarItem.cc:52
int getStepSize()
Definition: Timeline.cc:127
int getMinIndex()
Definition: Timeline.cc:109
int getMaxIndex()
Definition: Timeline.cc:296
void setWidth(int width)
Definition: SlideBarItem.cc:56
const QColor & getBackgroundColor() const
Definition: Timeline.cc:93

Member Function Documentation

void Timeline::addBookmark ( int  idx)
slot

Adds a bookmark for the specified index. Only one bookmark per index is possible.

Definition at line 168 of file Timeline.cc.

168  {
169  if(hasBookmarkAtIndex(idx)) {
170  return;
171  }
172 
173  QVector<int> vec;
174  vec << idx;
175  addBookmarks(vec);
176 }
void addBookmarks(QVector< int > bookmarks)
Definition: Timeline.cc:178
bool hasBookmarkAtIndex(int idx)
Definition: Timeline.cc:201
void Timeline::addBookmarks ( QVector< int >  bookmarks)
slot

Adds multiple bookmarks at once. See addBookmark().

Definition at line 178 of file Timeline.cc.

178  {
179  Q_FOREACH(int bookmark, bookmarks) {
180  this->bookmarks << bookmark;
181  }
182  slidebar->updateBookmarks(this->bookmarks);
183 }
void updateBookmarks(QVector< int > &bookmarks)
void Timeline::bookmarkClicked ( int  idx)
signal
void Timeline::bookmarkRemoved ( int  idx)
signal
void Timeline::endMarkerClicked ( )
signal
void Timeline::endMarkerMoved ( int  idx)
signal
void Timeline::endMarkerReleased ( int  idx)
signal
const QColor & Timeline::getBackgroundColor ( ) const
slot

Definition at line 93 of file Timeline.cc.

93  {
94  return bgColor;
95 }
int Timeline::getBookmarkHeight ( ) const
slot

Definition at line 69 of file Timeline.cc.

69  {
70  return bookmarkHeight;
71 }
int Timeline::getEndMarkerIndex ( )
slot

Returns the current index of the start marker.

Definition at line 149 of file Timeline.cc.

149  {
150  return endmarker->getLastIndex();
151 }
unsigned getLastIndex()
Definition: Slider.cc:51
int Timeline::getMarginLR ( )
slot

Definition at line 85 of file Timeline.cc.

85  {
86  return marginLR;
87 }
int Timeline::getMarginTopBot ( )
slot

Definition at line 77 of file Timeline.cc.

77  {
78  return marginTopBot;
79 }
int Timeline::getMaxIndex ( )
slot

Returns the maximum index, i.e. the highest index on the timeline.

Definition at line 296 of file Timeline.cc.

296  {
297  return getMinIndex() + getSteps() * getStepSize();
298 }
int getSteps()
Definition: Timeline.cc:118
int getStepSize()
Definition: Timeline.cc:127
int getMinIndex()
Definition: Timeline.cc:109
int Timeline::getMinIndex ( )
slot

Definition at line 109 of file Timeline.cc.

109  {
110  return minIndex;
111 }
int Timeline::getSliderIndex ( )
slot

Returns the current index of the index slider.

Definition at line 136 of file Timeline.cc.

136  {
137  return slidebar->getIndexSlider()->getLastIndex();
138 }
unsigned getLastIndex()
Definition: Slider.cc:51
IndexSlider * getIndexSlider()
int Timeline::getStartMarkerIndex ( )
slot

Returns the current index of the start marker.

Definition at line 140 of file Timeline.cc.

140  {
141  return startmarker->getLastIndex();
142 }
unsigned getLastIndex()
Definition: Slider.cc:51
int Timeline::getSteps ( )
slot

Definition at line 118 of file Timeline.cc.

118  {
119  return steps;
120 }
int Timeline::getStepSize ( )
slot

Definition at line 127 of file Timeline.cc.

127  {
128  return stepSize;
129 }
int Timeline::getWidth ( )
slot

Definition at line 101 of file Timeline.cc.

101  {
102  return ordered_width;
103 }
bool Timeline::hasBookmarkAtIndex ( int  idx)
slot

Returns true if there is a bookmark located at the specified index.

Definition at line 201 of file Timeline.cc.

201  {
202  for(int i = 0; i < bookmarks.size(); i++) {
203  if (bookmarks.at(i) == idx) {
204  return true;
205  }
206  }
207  return false;
208 }
void Timeline::indexSliderClicked ( )
signal
void Timeline::indexSliderMoved ( int  idx)
signal
void Timeline::indexSliderReleased ( int  idx)
signal
void Timeline::removeAllBookmarks ( )
slot

Removes all bookmarks.

Definition at line 196 of file Timeline.cc.

196  {
197  bookmarks.clear();
198  slidebar->updateBookmarks(bookmarks);
199 }
void updateBookmarks(QVector< int > &bookmarks)
void Timeline::removeBookmark ( int  idx)
slot

Removes the bookmark at the specified index if there one.

Definition at line 185 of file Timeline.cc.

185  {
186  for(int i = 0; i < bookmarks.size(); i++) {
187  if (bookmarks.at(i) == idx) {
188  bookmarks.remove(i);
189  emit bookmarkRemoved(idx);
190  slidebar->updateBookmarks(bookmarks);
191  break;
192  }
193  }
194 }
void bookmarkRemoved(int idx)
void updateBookmarks(QVector< int > &bookmarks)
void Timeline::resizeEvent ( QResizeEvent *  event)
protected

Definition at line 210 of file Timeline.cc.

210  {
211  QSize size = event->size();
212  updateScene(size);
213 }
void Timeline::setBackgroundColor ( const QColor &  color)
slot

Definition at line 97 of file Timeline.cc.

97  {
98  bgColor = color;
99 }
void Timeline::setBookmarkHeight ( int  height)
slot

Definition at line 73 of file Timeline.cc.

73  {
74  bookmarkHeight = height;
75 }
void Timeline::setEndMarkerIndex ( int  idx)
slot

Sets the index of the end marker.

Definition at line 153 of file Timeline.cc.

153  {
154  setSliderIndex(idx, endmarker);
155 }
void setSliderIndex(int idx)
Definition: Timeline.cc:157
void Timeline::setMarginLR ( int  margin)
slot

Definition at line 89 of file Timeline.cc.

89  {
90  marginLR = margin;
91 }
void Timeline::setMarginTopBot ( int  margin)
slot

Definition at line 81 of file Timeline.cc.

81  {
82  marginTopBot = margin;
83 }
void Timeline::setMinIndex ( int  minIndex)
slot

Definition at line 113 of file Timeline.cc.

113  {
114  this->minIndex = minIndex;
115  reconfigure_slidebar = true;
116 }
void Timeline::setSliderIndex ( int  idx)
slot

Sets the index of the index slider.

Definition at line 157 of file Timeline.cc.

157  {
158  setSliderIndex(idx, slidebar->getIndexSlider());
159 }
void setSliderIndex(int idx)
Definition: Timeline.cc:157
IndexSlider * getIndexSlider()
void Timeline::setStartMarkerIndex ( int  idx)
slot

Sets the index of the start marker.

Definition at line 144 of file Timeline.cc.

144  {
145  setSliderIndex(idx, startmarker);
146 
147 }
void setSliderIndex(int idx)
Definition: Timeline.cc:157
void Timeline::setSteps ( int  steps)
slot

Definition at line 122 of file Timeline.cc.

122  {
123  this->steps = steps;
124  reconfigure_slidebar = true;
125 }
void Timeline::setStepSize ( int  stepSize)
slot

Definition at line 131 of file Timeline.cc.

131  {
132  this->stepSize = stepSize;
133  reconfigure_slidebar = true;
134 }
void Timeline::setWidth ( int  width)
slot

Definition at line 105 of file Timeline.cc.

105  {
106  ordered_width = width;
107 }
int width
Definition: Timeline.h:32
void Timeline::startMarkerClicked ( )
signal
void Timeline::startMarkerMoved ( int  idx)
signal
void Timeline::startMarkerReleased ( int  idx)
signal
void Timeline::timeout ( )
signal

Property Documentation

QColor Timeline::backgroundColor
readwrite

Definition at line 31 of file Timeline.h.

int Timeline::bookmark_height
readwrite

Definition at line 28 of file Timeline.h.

int Timeline::margin_lr
readwrite

Definition at line 30 of file Timeline.h.

int Timeline::margin_topbot
readwrite

Definition at line 29 of file Timeline.h.

unsigned minIndex Timeline::READ
write

Definition at line 33 of file Timeline.h.

unsigned stepSize Timeline::READ
write

Definition at line 35 of file Timeline.h.

unsigned steps Timeline::READ
write

Definition at line 34 of file Timeline.h.

int Timeline::width
readwrite

Definition at line 32 of file Timeline.h.


The documentation for this class was generated from the following files: