annotate edtimeline.cpp @ 401:2fdf440ea66a

Fix some segfaults, etc.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 19 Oct 2012 16:28:06 +0300
parents 8660c6005032
children 0f290af63fc1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 #include <QtGui>
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 #include "edtimeline.h"
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
5 QTimelineTrackDisplay::QTimelineTrackDisplay(QWidget *parent) : QWidget(parent)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 track = NULL;
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 time = offs = 0;
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 scale = 1.0f;
386
69ca8a83c25a Add size hints.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
10
69ca8a83c25a Add size hints.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
11 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
69ca8a83c25a Add size hints.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
12 }
69ca8a83c25a Add size hints.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
13
69ca8a83c25a Add size hints.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
14
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
15 QSize QTimelineTrackDisplay::minimumSizeHint() const
386
69ca8a83c25a Add size hints.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
16 {
69ca8a83c25a Add size hints.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
17 return QSize(100, 60);
69ca8a83c25a Add size hints.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
18 }
69ca8a83c25a Add size hints.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
19
69ca8a83c25a Add size hints.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
20
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
21 QSize QTimelineTrackDisplay::sizeHint() const
386
69ca8a83c25a Add size hints.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
22 {
69ca8a83c25a Add size hints.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
23 return QSize(600, 60);
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
27 void QTimelineTrackDisplay::setTrack(DMTimelineTrack *mtrack)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 track = mtrack;
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
33 void QTimelineTrackDisplay::setTime(const int mtime)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 time = mtime;
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
39 void QTimelineTrackDisplay::setOffset(const int moffs)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 offs = moffs;
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
45 void QTimelineTrackDisplay::setScale(const float mscale)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 if (mscale > 0.05)
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 scale = mscale;
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
52 void QTimelineTrackDisplay::paintEvent(QPaintEvent *)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 {
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
54 if (track == NULL)
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
55 return;
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
56
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 QColor eventColor(150, 150, 150);
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 QColor markerColor(255,255,255);
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 QPainter painter(this);
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 painter.setRenderHint(QPainter::Antialiasing);
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 painter.save();
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 painter.scale(scale, 1);
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 for (int event = 0; event < track->nevents; event++)
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 DMTimelineEvent *ev = track->events[event];
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
71 painter.restore();
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
72
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 if (time >= offs * scale && time - offs <= width() * scale)
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 int xc = time - offs;
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
76 painter.save();
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 painter.scale(scale, 1);
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 painter.setPen(markerColor);
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 painter.drawLine(xc, 0, xc, height());
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
80 painter.restore();
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
85 void QTimelineTrackDisplay::mousePressEvent(QMouseEvent *ev)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 /*
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 if (ev->button() == Qt::LeftButton)
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 lastPoint = ev->pos();
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 scribbling = true;
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 */
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
97 void QTimelineTrackDisplay::mouseMoveEvent(QMouseEvent *ev)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 /*
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 if ((ev->buttons() & Qt::LeftButton) && scribbling)
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 drawLineTo(ev->pos());
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 */
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
106 void QTimelineTrackDisplay::mouseReleaseEvent(QMouseEvent *ev)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 /*
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 if (ev->button() == Qt::LeftButton && scribbling)
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 drawLineTo(ev->pos());
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 scribbling = false;
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 */
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 }
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
116
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
117
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
118 QTimelineTrackView::QTimelineTrackView(QWidget *parent) : QWidget(parent)
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
119 {
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
120 QHBoxLayout *mainLayout = new QHBoxLayout(this);
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
121 mainLayout->setMargin(0);
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
122 track = new QTimelineTrackDisplay(this);
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
123
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
124 QFrame *infoLayoutContainer = new QFrame(this);
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
125 infoLayoutContainer->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
126 infoLayoutContainer->setLineWidth(2);
398
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
127 infoLayoutContainer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
128 infoLayoutContainer->setFixedWidth(200);
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
129
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
130 QVBoxLayout *infoLayout = new QVBoxLayout(infoLayoutContainer);
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
131 infoLayout->setMargin(0);
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
132 // QVBoxLayout *infoLayout = new QVBoxLayout();
398
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
133 infoName = new QLineEdit();
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
134 infoName->setFrame(false);
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
135 infoName->setMaxLength(DT_MAX_NAME_LENGTH);
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
136 infoName->setStyleSheet("QLineEdit { background-color: black; color: white; padding: 2px; }");
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
137 connect(infoName, SIGNAL(textEdited(const QString&)), this, SLOT(slotTrackNameChanged(const QString&)));
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
138 infoLayout->addWidget(infoName);
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
139
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
140
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
141 enabledCheck = new QCheckBox("Enabled");
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
142 infoLayout->addWidget(enabledCheck);
398
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
143 connect(enabledCheck, SIGNAL(toggled(bool)), this, SLOT(slotTrackEnabledChanged(bool)));
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
144
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
145 infoData = new QLabel();
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
146 infoData->setStyleSheet("QLabel { padding: 2px; }");
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
147 infoLayout->addWidget(infoData);
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
148
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
149 mainLayout->addWidget(infoLayoutContainer);
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
150 // mainLayout->addLayout(infoLayout);
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
151 mainLayout->addWidget(track);
398
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
152 }
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
153
398
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
154
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
155 void QTimelineTrackView::update()
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
156 {
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
157 if (track != NULL && track->track)
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
158 {
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
159 infoName->setText(QString(track->track->name));
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
160 enabledCheck->setChecked(track->track->enabled);
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
161 infoData->setText(QString("<b>%1</b> events").arg(track->track->nevents));
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
162 }
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
163 else
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
164 {
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
165 infoName->setText("");
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
166 infoData->setText("-");
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
167 enabledCheck->setChecked(false);
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
168 }
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
169
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
170 QWidget::update();
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
171 }
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
172
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
173
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
174 void QTimelineTrackView::setTrack(DMTimelineTrack *mtrack)
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
175 {
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
176 track->setTrack(mtrack);
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
177 update();
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
178 }
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
179
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
180
398
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
181 void QTimelineTrackView::slotTrackEnabledChanged(bool value)
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
182 {
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
183 track->track->enabled = value;
398
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
184 emit trackChanged();
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
185 }
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
186
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
187
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
188 void QTimelineTrackView::slotTrackNameChanged(const QString & text)
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
189 {
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
190 QByteArray ba = text.toUtf8();
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
191 track->track->name = dm_strdup(ba.constData());
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
192 emit trackChanged();
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
193 }
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
194
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
195
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
196
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
197 QTimelineView::QTimelineView(QWidget *parent) : QWidget(parent)
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
198 {
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
199 layout = new QVBoxLayout(this);
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
200 tl = NULL;
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
201 }
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
202
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
203
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
204 void QTimelineView::setTimeline(TimelineObject *mtl)
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
205 {
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
206 tl = mtl;
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
207
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
208 delete layout;
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
209 layout = new QVBoxLayout(this);
398
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
210 layout->setMargin(0);
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
211
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
212 tracks.clear();
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
213
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
214 if (tl != NULL && tl->tl != NULL)
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
215 {
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
216 for (int track = 0; track < tl->tl->ntracks; track++)
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
217 {
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
218 QTimelineTrackView *vtr = new QTimelineTrackView(this);
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
219 vtr->setTrack(tl->tl->tracks[track]);
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
220 tracks.append(vtr);
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
221 layout->addWidget(vtr);
398
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
222 connect(vtr, SIGNAL(trackChanged()), this, SLOT(slotTimelineChanged()));
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
223 }
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
224 }
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
225 update();
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
226 }
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
227
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
228
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
229 void QTimelineView::slotTimelineChanged()
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
230 {
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
231 if (tl != NULL)
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
232 {
401
2fdf440ea66a Fix some segfaults, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 398
diff changeset
233 tl->touch();
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
234 emit timelineChanged();
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
235 }
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
236 }
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
237
398
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 397
diff changeset
238
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
239 void QTimelineView::setTime(const int mtime)
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
240 {
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
241 if (tl != NULL && tl->tl != NULL)
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
242 {
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
243 QList<QTimelineTrackView *>::iterator track;
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
244 for (track = tracks.begin(); track != tracks.end(); track++)
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
245 {
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
246 (*track)->track->setTime(mtime);
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
247 }
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
248 update();
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
249 }
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
250 }
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
251
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
252
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
253 void QTimelineView::setOffset(const int moffs)
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
254 {
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
255 if (tl != NULL && tl->tl != NULL)
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
256 {
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
257 QList<QTimelineTrackView *>::iterator track;
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
258 for (track = tracks.begin(); track != tracks.end(); track++)
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
259 {
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
260 (*track)->track->setOffset(moffs);
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
261 }
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
262 update();
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
263 }
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 386
diff changeset
264 }
397
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
265
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
266
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
267 void QTimelineView::setScale(const float mscale)
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
268 {
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
269 if (tl != NULL && tl->tl != NULL)
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
270 {
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
271 QList<QTimelineTrackView *>::iterator track;
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
272 for (track = tracks.begin(); track != tracks.end(); track++)
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
273 {
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
274 (*track)->track->setScale(mscale);
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
275 }
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
276 update();
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
277 }
9993873ff655 More work towards editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
278 }