Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

some progress on timeline view

svn path=/branches/KDE4/; revision=1806
parent a3b0f8cf
......@@ -51,7 +51,7 @@ int ClipItem::type () const
QWidget *widget)
{
painter->setClipRect( option->exposedRect );
painter->fillRect(rect(), Qt::red);
painter->fillRect(rect(), QColor(200, 50, 50, 150));
//kDebug()<<"ITEM REPAINT RECT: "<<boundingRect().width();
//painter->drawText(rect(), Qt::AlignCenter, m_name);
painter->drawRect(rect());
......
......@@ -91,7 +91,7 @@ CustomRuler::CustomRuler(Timecode tc, QWidget *parent)
void CustomRuler::mousePressEvent ( QMouseEvent * event )
{
int pos = event->x();
slotNewValue( pos );
slotNewValue( pos, true );
kDebug()<<pos;
}
......@@ -99,14 +99,14 @@ void CustomRuler::mousePressEvent ( QMouseEvent * event )
void CustomRuler::mouseMoveEvent ( QMouseEvent * event )
{
int pos = event->x();
slotNewValue( pos );
slotNewValue( pos, true );
kDebug()<<pos;
}
void CustomRuler::slotNewValue ( int _value )
void CustomRuler::slotNewValue ( int _value, bool emitSignal )
{
m_cursorPosition = _value / pixelPerMark();
emit cursorMoved(m_cursorPosition / FRAME_SIZE);
if (emitSignal) emit cursorMoved(m_cursorPosition / FRAME_SIZE);
KRuler::slotNewValue(_value);
}
......
......@@ -23,7 +23,7 @@ class CustomRuler : public KRuler
Timecode m_timecode;
public slots:
void slotNewValue ( int _value );
void slotNewValue ( int _value, bool emitSignal = false );
signals:
void cursorMoved(int);
......
......@@ -23,6 +23,7 @@
#include <QDomDocument>
#include <KDebug>
#include <KLocale>
#include <KUrl>
#include "customtrackview.h"
......@@ -30,12 +31,23 @@
#include "definitions.h"
CustomTrackView::CustomTrackView(QGraphicsScene * scene, QWidget *parent)
: QGraphicsView(scene, parent), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL)
: QGraphicsView(scene, parent), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL), m_cursorLine(NULL)
{
setMouseTracking(true);
setAcceptDrops(true);
}
void CustomTrackView::initView()
{
m_cursorLine = scene()->addLine(0, 0, 0, height());
}
// virtual
void CustomTrackView::resizeEvent ( QResizeEvent * event )
{
if (m_cursorLine) m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), height());
}
// virtual
void CustomTrackView::mouseMoveEvent ( QMouseEvent * event )
{
......@@ -45,10 +57,16 @@ void CustomTrackView::mouseMoveEvent ( QMouseEvent * event )
else if (event->modifiers() == Qt::ShiftModifier)
setDragMode(QGraphicsView::RubberBandDrag);
else {
QGraphicsItem * item = itemAt(event->pos());
QList<QGraphicsItem *> itemList = items ( event->pos());
int i = 0;
QGraphicsItem *item = NULL;
for (int i = 0; i < itemList.count(); i++) {
if (itemList.at(i)->type() == 70000) {
item = itemList.at(i);
break;
}
}
if (item) {
while (item->parentItem())
item = item->parentItem();
int cursorPos = event->x();
QRectF itemRect = item->sceneBoundingRect();
int itemStart = mapFromScene(itemRect.x(), 0).x();
......@@ -175,6 +193,7 @@ void CustomTrackView::removeTrack ()
void CustomTrackView::setCursorPos(int pos)
{
m_cursorPos = pos;
m_cursorLine->setPos(pos, 0);
}
int CustomTrackView::cursorPos()
......@@ -191,17 +210,19 @@ void CustomTrackView::mouseReleaseEvent ( QMouseEvent * event )
void CustomTrackView::drawBackground ( QPainter * painter, const QRectF & rect )
{
//kDebug()<<"///// DRAWING BG: "<<rect.x()<<", width: "<<rect.width();
painter->drawRect(rect);
painter->drawLine(rect.x(), 0, rect.x() + rect.width(), 0);
for (uint i = 0; i < m_tracksCount;i++)
{
painter->drawLine(rect.x(), 50 * i, rect.x() + rect.width(), 50 * i);
painter->drawLine(rect.x(), 50 * (i+1), rect.x() + rect.width(), 50 * (i+1));
painter->drawText(QRectF(10, 50 * i, 100, 50 * i + 49), Qt::AlignLeft, i18n(" Track ") + QString::number(i));
}
}
/*
void CustomTrackView::drawForeground ( QPainter * painter, const QRectF & rect )
{
//kDebug()<<"///// DRAWING FB: "<<rect.x()<<", width: "<<rect.width();
painter->fillRect(rect, QColor(50, rand() % 250,50,100));
painter->drawLine(m_cursorPos, rect.y(), m_cursorPos, rect.y() + rect.height());
}
*/
#include "customtrackview.moc"
......@@ -38,22 +38,25 @@ class CustomTrackView : public QGraphicsView
void removeTrack();
void setCursorPos(int pos);
int cursorPos();
void initView();
protected:
virtual void drawBackground ( QPainter * painter, const QRectF & rect );
virtual void drawForeground ( QPainter * painter, const QRectF & rect );
//virtual void drawForeground ( QPainter * painter, const QRectF & rect );
virtual void dragEnterEvent ( QDragEnterEvent * event );
virtual void dragMoveEvent(QDragMoveEvent * event);
virtual void dragLeaveEvent ( QDragLeaveEvent * event );
virtual void dropEvent ( QDropEvent * event );
virtual QStringList mimeTypes() const;
virtual Qt::DropActions supportedDropActions () const;
virtual void resizeEvent ( QResizeEvent * event );
private:
int m_tracksCount;
int m_cursorPos;
ClipItem *m_dropItem;
void addItem(QString producer, QPoint pos);
QGraphicsLineItem *m_cursorLine;
signals:
void cursorMoved(int);
......
......@@ -27,7 +27,7 @@
#include "labelitem.h"
LabelItem::LabelItem(QString text, QGraphicsRectItem *parent)
: QGraphicsSimpleTextItem(text, parent)
: QGraphicsSimpleTextItem(" " + text + " ", parent)
{
//setParentItem(parent);
setFlags(QGraphicsItem::ItemIgnoresTransformations);
......@@ -39,7 +39,7 @@ int LabelItem::type () const
}
// virtual
/*
void LabelItem::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget)
......@@ -56,13 +56,13 @@ int LabelItem::type () const
//painter->setClipRect( par);
//painter->fillRect(rect(), Qt::red);
QPainterPath path;
path.addPolygon(mapFromParent(parentItem()->boundingRect()));
path.addRoundRect(boundingRect(), 40);
//painter->fillPath(path, QColor(200, 100, 200, 150));
//painter->setClipPath(path);
painter->fillRect(boundingRect(), QColor(200, 100, 200, 150));
painter->fillPath(path, QColor(200, 200, 200, 100));
painter->drawText(boundingRect(), Qt::AlignCenter, text());
//painter->drawRect(rect());
//painter->drawRoundRect(-10, -10, 20, 20);
}*/
}
#include "labelitem.moc"
......@@ -30,7 +30,7 @@ class LabelItem : public QGraphicsSimpleTextItem
public:
LabelItem(QString text, QGraphicsRectItem *parent = 0);
//virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual int type () const;
};
......
......@@ -70,7 +70,7 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent)
connect(m_ruler, SIGNAL(cursorMoved ( int )), this, SLOT(slotCursorMoved( int )));
connect(m_trackview, SIGNAL(cursorMoved ( int )), this, SLOT(slotCursorMoved( int )));
m_cursorLine = m_scene->addLine(0, 0, 0, 200); //m_trackview->height());
m_trackview->initView();
}
void TrackView::registerFunction(const QString & name, TrackPanelFunction * function)
......@@ -109,10 +109,10 @@ void TrackView::parseDocument(QDomDocument doc)
void TrackView::slotCursorMoved(int pos)
{
kDebug()<<"///// CURSOR: "<<pos;
//m_cursorLine->setPos(pos, 0);
//kDebug()<<"///// CURSOR: "<<pos;
m_ruler->slotNewValue(m_trackview->mapToScene(QPoint(pos, 0)).x());
m_trackview->setCursorPos(pos);
m_trackview->invalidateScene(QRectF(), QGraphicsScene::ForegroundLayer);
//m_trackview->invalidateScene(QRectF(), QGraphicsScene::ForegroundLayer);
}
void TrackView::slotChangeZoom(int factor)
......
......@@ -76,7 +76,7 @@ class TrackView : public QWidget
QString m_editMode;
QGraphicsScene *m_scene;
uint m_currentZoom;
QGraphicsLineItem *m_cursorLine;
KdenliveDoc *m_doc;
QVBoxLayout *m_tracksLayout;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment