]> git.sesse.net Git - kdenlive/blob - src/effectstack/collapsiblegroup.h
Fix crash when dropping effect on a group
[kdenlive] / src / effectstack / collapsiblegroup.h
1 /***************************************************************************
2  *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20
21 #ifndef COLLAPSIBLEGROUP_H
22 #define COLLAPSIBLEGROUP_H
23
24
25 #include "ui_collapsiblegroup_ui.h"
26
27 #include "abstractcollapsiblewidget.h"
28 #include "collapsibleeffect.h"
29 #include "timecode.h"
30 #include "keyframeedit.h"
31
32 #include <QDomElement>
33 #include <QToolButton>
34 #include <QLineEdit>
35 #include <QMutex>
36
37 class QFrame;
38
39 class MyEditableLabel : public QLineEdit
40 {
41     Q_OBJECT
42
43 public:
44     MyEditableLabel(QWidget * parent = 0);
45     
46 protected:
47     virtual void mouseDoubleClickEvent( QMouseEvent *e);
48 };
49
50
51 /**)
52  * @class CollapsibleEffect
53  * @brief A dialog for editing markers and guides.
54  * @author Jean-Baptiste Mardelle
55  */
56
57 class CollapsibleGroup : public AbstractCollapsibleWidget, public Ui::CollapsibleGroup_UI
58 {
59     Q_OBJECT
60
61 public:
62     CollapsibleGroup(int ix, bool firstGroup, bool lastGroup, QString groupName = QString(), QWidget * parent = 0);
63     ~CollapsibleGroup();
64     void updateTimecodeFormat();
65     void setActive(bool activate);
66     int groupIndex() const;
67     bool isGroup() const;
68     QString infoString() const;
69     bool isActive() const;
70     void addGroupEffect(CollapsibleEffect *effect);
71     void removeGroup(int ix, QVBoxLayout *layout);
72     /** @brief Return all effects in group. */
73     QList <CollapsibleEffect*> effects();
74     /** @brief Return the editable title widget. */
75     QWidget *title() const;
76     /** @brief Return the XML data describing all effects in group. */
77     QDomDocument effectsData();
78
79 public slots:
80     void slotEnable(bool enable);
81
82 private slots:
83     void slotSwitch();
84     void slotShow(bool show);
85     void slotDeleteEffect();
86     void slotEffectUp();
87     void slotEffectDown();
88     void slotSaveGroup();
89     void slotResetGroup();
90     void slotUnGroup();
91     void slotRenameGroup();
92
93 private:
94     QList <CollapsibleEffect *> m_subWidgets;
95     QMenu *m_menu;
96     EffectInfo m_info;
97     int m_index;
98     MyEditableLabel *m_title;
99     QMutex m_mutex;
100     
101 protected:
102     virtual void mouseDoubleClickEvent ( QMouseEvent * event );
103     virtual void dragEnterEvent(QDragEnterEvent *event);
104     virtual void dragLeaveEvent(QDragLeaveEvent *event);
105     virtual void dropEvent(QDropEvent *event);
106     
107 signals:
108     void syncEffectsPos(int);
109     void effectStateChanged(bool, int ix = -1);
110     void deleteGroup(int);
111     void changeGroupPosition(int, bool);
112     void activateEffect(int);
113     void moveEffect(int current_pos, int new_pos, int groupIndex, QString groupName);
114     void addEffect(QDomElement e);
115     void unGroup(CollapsibleGroup *);
116     void groupRenamed(CollapsibleGroup *);
117     void reloadEffects();
118 };
119
120
121 #endif
122