#include <QStyleOptionGraphicsItem>
#include <QDomDocument>
#include <QMimeData>
-
-
-AbstractGroupItem::AbstractGroupItem(double fps): QGraphicsItemGroup(), m_fps(fps) {
- setZValue(2);
- setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
+#include <QGraphicsSceneMouseEvent>
+
+AbstractGroupItem::AbstractGroupItem(double /* fps */) :
+ QObject(),
+ QGraphicsItemGroup()
+{
+ setZValue(1);
+ setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
setAcceptDrops(true);
}
-int AbstractGroupItem::type() const {
+int AbstractGroupItem::type() const
+{
return GROUPWIDGET;
}
-int AbstractGroupItem::track() const {
+int AbstractGroupItem::track() const
+{
return (int)(scenePos().y() / KdenliveSettings::trackheight());
}
-CustomTrackScene* AbstractGroupItem::projectScene() {
+CustomTrackScene* AbstractGroupItem::projectScene()
+{
if (scene()) return static_cast <CustomTrackScene*>(scene());
return NULL;
}
-QPainterPath AbstractGroupItem::groupShape(QPointF offset) {
+QPainterPath AbstractGroupItem::groupShape(QPointF offset)
+{
QPainterPath path;
QList<QGraphicsItem *> children = childItems();
for (int i = 0; i < children.count(); i++) {
return path;
}
-void AbstractGroupItem::addItem(QGraphicsItem * item) {
+void AbstractGroupItem::addItem(QGraphicsItem * item)
+{
addToGroup(item);
//fixItemRect();
}
-void AbstractGroupItem::fixItemRect() {
+void AbstractGroupItem::fixItemRect()
+{
QPointF start = boundingRect().topLeft();
if (start != QPointF(0, 0)) {
translate(0 - start.x(), 0 - start.y());
}*/
// virtual
-void AbstractGroupItem::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *) {
+void AbstractGroupItem::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *)
+{
const double scale = option->matrix.m11();
- QRect clipRect = option->exposedRect.toRect();
- clipRect.adjust(0, 0, 1 / scale + 0.5, 1);
- p->fillRect(option->exposedRect, QColor(100, 100, 200, 100));
- p->setClipRect(clipRect);
+ QColor bgcolor(100, 100, 200, 100);
+ p->fillRect(option->exposedRect, bgcolor);
+ p->setClipping(false);
QPen pen = p->pen();
pen.setColor(QColor(200, 90, 90));
pen.setStyle(Qt::DashLine);
+ pen.setWidthF(0.0);
+ //pen.setCosmetic(true);
p->setPen(pen);
- p->drawRect(boundingRect());
+ p->drawRect(boundingRect().adjusted(0, 0, - 1 / scale, 0));
}
//virtual
-QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant &value) {
+QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant &value)
+{
if (change == ItemPositionChange && scene()) {
// calculate new position.
const int trackHeight = KdenliveSettings::trackheight();
}
//virtual
-void AbstractGroupItem::dropEvent(QGraphicsSceneDragDropEvent * event) {
+void AbstractGroupItem::dropEvent(QGraphicsSceneDragDropEvent * event)
+{
QString effects = QString(event->mimeData()->data("kdenlive/effectslist"));
QDomDocument doc;
doc.setContent(effects, true);
}
//virtual
-void AbstractGroupItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) {
+void AbstractGroupItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
+{
event->setAccepted(event->mimeData()->hasFormat("kdenlive/effectslist"));
}
-void AbstractGroupItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) {
+void AbstractGroupItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
+{
Q_UNUSED(event);
}
+
+// virtual
+void AbstractGroupItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
+{
+ if (event->modifiers() & Qt::ShiftModifier) {
+ // User want to do a rectangle selection, so ignore the event to pass it to the view
+ event->ignore();
+ } else QGraphicsItem::mousePressEvent(event);
+}