OpenShot Video Editor  2.0.0
add_to_timeline_treeview.py
Go to the documentation of this file.
1 ##
2 #
3 # @file
4 # @brief This file contains the add to timeline file treeview
5 # @author Jonathan Thomas <jonathan@openshot.org>
6 #
7 # @section LICENSE
8 #
9 # Copyright (c) 2008-2018 OpenShot Studios, LLC
10 # (http://www.openshotstudios.com). This file is part of
11 # OpenShot Video Editor (http://www.openshot.org), an open-source project
12 # dedicated to delivering high quality video editing and animation solutions
13 # to the world.
14 #
15 # OpenShot Video Editor is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU General Public License as published by
17 # the Free Software Foundation, either version 3 of the License, or
18 # (at your option) any later version.
19 #
20 # OpenShot Video Editor is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
27 #
28 
29 from PyQt5.QtCore import QSize
30 from PyQt5.QtWidgets import *
31 
32 from classes.logger import log
33 from classes.app import get_app
34 from windows.models.add_to_timeline_model import TimelineModel
35 
36 try:
37  import json
38 except ImportError:
39  import simplejson as json
40 
41 
42 ##
43 # A TreeView QWidget used on the add to timeline window
44 class TimelineTreeView(QTreeView):
45 
46  def currentChanged(self, selected, deselected):
47  # Get selected item
48  self.selected = selected
49  self.deselected = deselected
50 
51  # Get translation object
52  _ = self.app._tr
53 
54  def contextMenuEvent(self, event):
55  # # Ignore event, propagate to parent
56  event.ignore()
57 
58  def mousePressEvent(self, event):
59 
60  # Ignore event, propagate to parent
61  event.ignore()
62  super().mousePressEvent(event)
63 
64  def refresh_view(self):
65  self.timeline_model.update_model()
66  self.hideColumn(2)
67 
68  def __init__(self, *args):
69  # Invoke parent init
70  QTreeView.__init__(self, *args)
71 
72  # Get a reference to the window object
73  self.app = get_app()
74  self.win = args[0]
75 
76  # Get Model data
77  self.timeline_model = TimelineModel()
78 
79  # Keep track of mouse press start position to determine when to start drag
80  self.selected = None
81  self.deselected = None
82 
83  # Setup header columns
84  self.setModel(self.timeline_model.model)
85  self.setIconSize(QSize(131, 108))
86  self.setIndentation(0)
87  self.setSelectionBehavior(QTreeView.SelectRows)
88  self.setSelectionBehavior(QAbstractItemView.SelectRows)
89  self.setWordWrap(True)
90  self.setStyleSheet('QTreeView::item { padding-top: 2px; }')
91 
92  # Refresh view
93  self.refresh_view()
def get_app
Returns the current QApplication instance of OpenShot.
Definition: app.py:55
A TreeView QWidget used on the add to timeline window.