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-2016 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  # menu = QMenu(self)
56  # menu.addAction(self.win.actionDetailsView)
57  # menu.addAction(self.win.actionThumbnailView)
58  # menu.exec_(QCursor.pos())
59  #
60  # # Ignore event, propagate to parent
61  event.ignore()
62 
63  def mousePressEvent(self, event):
64 
65  # Ignore event, propagate to parent
66  event.ignore()
67  super().mousePressEvent(event)
68 
69  def refresh_view(self):
70  self.timeline_model.update_model()
71  self.hideColumn(2)
72 
73  def __init__(self, *args):
74  # Invoke parent init
75  QTreeView.__init__(self, *args)
76 
77  # Get a reference to the window object
78  self.app = get_app()
79  self.win = args[0]
80 
81  # Get Model data
82  self.timeline_model = TimelineModel()
83 
84  # Keep track of mouse press start position to determine when to start drag
85  self.selected = None
86  self.deselected = None
87 
88  # Setup header columns
89  self.setModel(self.timeline_model.model)
90  self.setIconSize(QSize(131, 108))
91  self.setIndentation(0)
92  self.setSelectionBehavior(QTreeView.SelectRows)
93  self.setSelectionBehavior(QAbstractItemView.SelectRows)
94  self.setWordWrap(True)
95  self.setStyleSheet('QTreeView::item { padding-top: 2px; }')
96 
97  # Refresh view
98  self.refresh_view()
def get_app()
Returns the current QApplication instance of OpenShot.
Definition: app.py:54
def currentChanged(self, selected, deselected)
A TreeView QWidget used on the add to timeline window.