OpenShot Video Editor  2.0.0
credits_treeview.py
Go to the documentation of this file.
1 ##
2 #
3 # @file
4 # @brief This file contains the credits treeview, used by the about window
5 # @author Noah Figg <eggmunkee@hotmail.com>
6 # @author Jonathan Thomas <jonathan@openshot.org>
7 #
8 # @section LICENSE
9 #
10 # Copyright (c) 2008-2018 OpenShot Studios, LLC
11 # (http://www.openshotstudios.com). This file is part of
12 # OpenShot Video Editor (http://www.openshot.org), an open-source project
13 # dedicated to delivering high quality video editing and animation solutions
14 # to the world.
15 #
16 # OpenShot Video Editor is free software: you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation, either version 3 of the License, or
19 # (at your option) any later version.
20 #
21 # OpenShot Video Editor is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 #
26 # You should have received a copy of the GNU General Public License
27 # along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
28 #
29 
30 import os
31 from urllib.parse import urlparse
32 
33 from PyQt5.QtCore import QSize, Qt, QPoint
34 from PyQt5.QtWidgets import QListView, QTreeView, QMessageBox, QAbstractItemView, QMenu, QSizePolicy, QHeaderView
35 
36 from classes.logger import log
37 from classes.app import get_app
38 from windows.models.credits_model import CreditsModel
39 
40 try:
41  import json
42 except ImportError:
43  import simplejson as json
44 
45 
46 ##
47 # A ListView QWidget used on the credits window
48 class CreditsTreeView(QTreeView):
49  def resize_contents(self):
50  pass
51 
52  def refresh_view(self, filter=None):
53  self.credits_model.update_model(filter=filter)
54 
55  # Format columns
56  self.header().setSectionResizeMode(0, QHeaderView.Fixed)
57  self.header().setSectionResizeMode(1, QHeaderView.Fixed)
58  self.setColumnWidth(0, 22)
59  self.setColumnWidth(1, 22)
60  self.setColumnWidth(2, 150)
61  self.setColumnWidth(3, 150)
62  self.setColumnWidth(4, 150)
63  self.sortByColumn(2, Qt.AscendingOrder)
64 
65  if "email" not in self.columns:
66  self.setColumnHidden(3, True)
67  if "website" not in self.columns:
68  self.setColumnHidden(4, True)
69 
70  def __init__(self, credits, columns, *args):
71  # Invoke parent init
72  QListView.__init__(self, *args)
73 
74  # Get a reference to the window object
75  self.win = get_app().window
76 
77  # Get Model data
78  self.credits_model = CreditsModel(credits)
79  self.selected = []
80 
81  # Setup header columns
82  self.setModel(self.credits_model.model)
83  self.setIndentation(0)
84  self.setSelectionBehavior(QTreeView.SelectRows)
85  self.setSelectionBehavior(QAbstractItemView.SelectRows)
86  self.setSelectionMode(QAbstractItemView.ExtendedSelection)
87  self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
88  self.setWordWrap(True)
89  self.setStyleSheet('QTreeView::item { padding-top: 2px; }')
90  self.columns = columns
91 
92 
93  # Refresh view
94  self.refresh_view()
95 
96  # setup filter events
97  app = get_app()
A ListView QWidget used on the credits window.
def get_app()
Returns the current QApplication instance of OpenShot.
Definition: app.py:55
def __init__(self, credits, columns, args)
def refresh_view(self, filter=None)