OpenShot Video Editor  2.0.0
changelog_model.py
Go to the documentation of this file.
1 ##
2 #
3 # @file
4 # @brief This file contains the git changelog model, used by the about window
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 import os
30 
31 from PyQt5.QtCore import Qt
32 from PyQt5.QtGui import *
33 
34 from classes import info
35 from classes.logger import log
36 from classes.app import get_app
37 
38 try:
39  import json
40 except ImportError:
41  import simplejson as json
42 
43 
44 class ChangelogStandardItemModel(QStandardItemModel):
45  def __init__(self, parent=None):
46  QStandardItemModel.__init__(self)
47 
48 
50 
51  def update_model(self, filter=None, clear=True):
52  log.info("updating changelog model.")
53  app = get_app()
54  _ = app._tr
55 
56  # Get window to check filters
57  win = app.window
58 
59  # Clear all items
60  if clear:
61  log.info('cleared changelog model')
62  self.model.clear()
63 
64  # Add Headers
65  self.model.setHorizontalHeaderLabels([_("Hash"), _("Date"), _("Author"), _("Subject")])
66 
67  for commit in self.commit_list:
68  # Get details of person
69  hash_str = commit.get("hash", "")
70  date_str = commit.get("date", "")
71  author_str = commit.get("author", "")
72  subject_str = commit.get("subject", "")
73 
74  if filter:
75  if not (filter.lower() in hash_str.lower() or filter.lower() in date_str.lower() or filter.lower() in author_str.lower() or filter.lower() in subject_str.lower()):
76  continue
77 
78  row = []
79 
80  # Append name
81  col = QStandardItem("Hash")
82  col.setText(hash_str)
83  col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
84  col.setToolTip(hash_str)
85  row.append(col)
86 
87  # Append email
88  col = QStandardItem("Date")
89  col.setText(date_str)
90  col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
91  col.setToolTip(date_str)
92  row.append(col)
93 
94  # Append website
95  col = QStandardItem("Author")
96  col.setText(author_str)
97  col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
98  col.setToolTip(author_str)
99  row.append(col)
100 
101  # Append website
102  col = QStandardItem("Subject")
103  col.setText(subject_str)
104  col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
105  col.setToolTip(subject_str)
106  row.append(col)
107 
108  # Append row to model
109  self.model.appendRow(row)
110 
111  def __init__(self, commits, *args):
112 
113  # Create standard model
114  self.app = get_app()
116  self.model.setColumnCount(4)
117  self.commit_list = commits
def get_app
Returns the current QApplication instance of OpenShot.
Definition: app.py:55