Merge lp:~phill-ridout/openlp/1209515_2.0 into lp:openlp/2.0

Proposed by Phill
Status: Superseded
Proposed branch: lp:~phill-ridout/openlp/1209515_2.0
Merge into: lp:openlp/2.0
Diff against target: 175 lines (+68/-8)
7 files modified
openlp/core/lib/__init__.py (+1/-0)
openlp/core/lib/filedialog.py (+55/-0)
openlp/core/lib/mediamanageritem.py (+2/-2)
openlp/core/lib/ui.py (+4/-0)
openlp/core/ui/thememanager.py (+2/-2)
openlp/plugins/songs/forms/editsongform.py (+2/-2)
openlp/plugins/songs/forms/songimportform.py (+2/-2)
To merge this branch: bzr merge lp:~phill-ridout/openlp/1209515_2.0
Reviewer Review Type Date Requested Status
Raoul Snyman Needs Fixing
Phill Approve
Andreas Preikschat Pending
Review via email: mp+180471@code.launchpad.net

This proposal supersedes a proposal from 2013-08-13.

This proposal has been superseded by a proposal from 2013-08-17.

Description of the change

Fixes #1209515 by subclassing QFileDialog and attempting to urldecode any files not found

To post a comment you must log in.
Revision history for this message
Andreas Preikschat (googol-deactivatedaccount) wrote : Posted in a previous version of this proposal

No need to add a constructor.

Make the getOpenFileNames method static

review: Needs Fixing
Revision history for this message
Andreas Preikschat (googol-deactivatedaccount) wrote : Posted in a previous version of this proposal

113 + 'Abbreviated font pointsize unit')ad

review: Needs Fixing
Revision history for this message
Phill (phill-ridout) : Posted in a previous version of this proposal
review: Needs Fixing
Revision history for this message
Phill (phill-ridout) wrote : Posted in a previous version of this proposal

Andreas,
How do I make it static?

Revision history for this message
Phill (phill-ridout) wrote : Posted in a previous version of this proposal

Its asking me to review, presumably because I set it to need fixing before!

review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

47 +Provide a work around for a bug in QFileDialog (#1209515)

Can you just be specific and say this is for a Launchpad bug (I might think it is a PyQt4 bug).

63 + file_list = QtCore.QStringList()
73 + file_list.append(QtCore.QString(file))

Why? This is Python, use Python objects.

106 + self.FNFT = unicode(translate('OpenLP.Ui',
108 + self.FNF = unicode(translate('OpenLP.Ui',

What does FNFT and FNF mean? I would prefer self.FileNotFound and self.FileNotFoundMessage

109 + 'File %s not found.\nPlease try selecting it individually.'))

This is horrible. Is there truly no way we can fix this problem?

review: Needs Fixing
Revision history for this message
Phill (phill-ridout) wrote : Posted in a previous version of this proposal

> 63      + file_list = QtCore.QStringList()
> 73      + file_list.append(QtCore.QString(file))
>
> Why? This is Python, use Python objects.
As I was reimplementing and creating a "slot in" method I wanted to keep the same return type. But if you'd rather I'd use python objects I can. Also should I change the method name from camel case?

Note in the trunk version I have used python objects as we use PyQt API v2 (which automatically casts to python objects)

>
> 106     + self.FNFT = unicode(translate('OpenLP.Ui',
> 108     + self.FNF = unicode(translate('OpenLP.Ui',
>
> What does FNFT and FNF mean? I would prefer self.FileNotFound and self.FileNotFoundMessage

Sure, I was just following convention of the other variables.

> 109     + 'File %s not found.\nPlease try selecting it individually.'))
>
> This is horrible. Is there truly no way we can fix this problem?

Agreed, I included this as a belt and braces approach. I have tested this code with around 2000 files and have not seen this dialogue. I just added it because o wasn't 100% sure we might not have other encoding issues.

The bug is in Qt, select a single file and its fine, but select multiple files and it seems to URL encode the names. I don't see any other way round this!

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

OK, this is fine. Just change the names of the strings please.

Revision history for this message
Phill (phill-ridout) :
review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Line 140 should be in there. PEP8 says that there should be 2 blank lines between statements on the module level.

Oh, and even if it says you need to review yourself, please don't.

review: Needs Fixing
lp:~phill-ridout/openlp/1209515_2.0 updated
2157. By Phill

Space reinstated as per PEP8

2158. By Phill

added doc strings

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/lib/__init__.py'
2--- openlp/core/lib/__init__.py 2013-01-20 18:46:41 +0000
3+++ openlp/core/lib/__init__.py 2013-08-17 08:52:16 +0000
4@@ -384,6 +384,7 @@
5
6
7 from eventreceiver import Receiver
8+from filedialog import FileDialog
9 from listwidgetwithdnd import ListWidgetWithDnD
10 from formattingtags import FormattingTags
11 from spelltextedit import SpellTextEdit
12
13=== added file 'openlp/core/lib/filedialog.py'
14--- openlp/core/lib/filedialog.py 1970-01-01 00:00:00 +0000
15+++ openlp/core/lib/filedialog.py 2013-08-17 08:52:16 +0000
16@@ -0,0 +1,55 @@
17+# -*- coding: utf-8 -*-
18+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
19+
20+###############################################################################
21+# OpenLP - Open Source Lyrics Projection #
22+# --------------------------------------------------------------------------- #
23+# Copyright (c) 2008-2013 Raoul Snyman #
24+# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
25+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
26+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
27+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
28+# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
29+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
30+# Frode Woldsund, Martin Zibricky #
31+# --------------------------------------------------------------------------- #
32+# This program is free software; you can redistribute it and/or modify it #
33+# under the terms of the GNU General Public License as published by the Free #
34+# Software Foundation; version 2 of the License. #
35+# #
36+# This program is distributed in the hope that it will be useful, but WITHOUT #
37+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
38+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
39+# more details. #
40+# #
41+# You should have received a copy of the GNU General Public License along #
42+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
43+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
44+###############################################################################
45+
46+"""
47+Provide a work around for a bug in QFileDialog <https://bugs.launchpad.net/openlp/+bug/1209515>
48+"""
49+import os
50+import urllib
51+
52+from PyQt4 import QtCore, QtGui
53+
54+from openlp.core.lib.ui import UiStrings
55+
56+class FileDialog(QtGui.QFileDialog):
57+ @staticmethod
58+ def getOpenFileNames(parent, title, path, filters):
59+ files = QtGui.QFileDialog.getOpenFileNames(parent, title, path, filters)
60+ file_list = QtCore.QStringList()
61+ for file in files:
62+ file = unicode(file)
63+ if not os.path.exists(file):
64+ file = urllib.unquote(file)
65+ if not os.path.exists(file):
66+ QtGui.QMessageBox.information(parent,
67+ UiStrings().FileNotFound,
68+ UiStrings().FileNotFoundMessage % file)
69+ continue
70+ file_list.append(QtCore.QString(file))
71+ return file_list
72\ No newline at end of file
73
74=== modified file 'openlp/core/lib/mediamanageritem.py'
75--- openlp/core/lib/mediamanageritem.py 2013-01-05 11:31:02 +0000
76+++ openlp/core/lib/mediamanageritem.py 2013-08-17 08:52:16 +0000
77@@ -35,7 +35,7 @@
78
79 from PyQt4 import QtCore, QtGui
80
81-from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \
82+from openlp.core.lib import FileDialog, SettingsManager, OpenLPToolbar, ServiceItem, \
83 StringContent, build_icon, translate, Receiver, ListWidgetWithDnD
84 from openlp.core.lib.searchedit import SearchEdit
85 from openlp.core.lib.ui import UiStrings, create_widget_action, \
86@@ -337,7 +337,7 @@
87 """
88 Add a file to the list widget to make it available for showing
89 """
90- files = QtGui.QFileDialog.getOpenFileNames(
91+ files = FileDialog.getOpenFileNames(
92 self, self.onNewPrompt,
93 SettingsManager.get_last_dir(self.settingsSection),
94 self.onNewFileMasks)
95
96=== modified file 'openlp/core/lib/ui.py'
97--- openlp/core/lib/ui.py 2012-12-30 19:41:24 +0000
98+++ openlp/core/lib/ui.py 2013-08-17 08:52:16 +0000
99@@ -77,6 +77,10 @@
100 self.Error = translate('OpenLP.Ui', 'Error')
101 self.Export = translate('OpenLP.Ui', 'Export')
102 self.File = translate('OpenLP.Ui', 'File')
103+ self.FileNotFound = unicode(translate('OpenLP.Ui',
104+ 'File Not Found'))
105+ self.FileNotFoundMessage = unicode(translate('OpenLP.Ui',
106+ 'File %s not found.\nPlease try selecting it individually.'))
107 self.FontSizePtUnit = translate('OpenLP.Ui', 'pt',
108 'Abbreviated font pointsize unit')
109 self.Help = translate('OpenLP.Ui', 'Help')
110
111=== modified file 'openlp/core/ui/thememanager.py'
112--- openlp/core/ui/thememanager.py 2012-12-30 19:41:24 +0000
113+++ openlp/core/ui/thememanager.py 2013-08-17 08:52:16 +0000
114@@ -36,7 +36,7 @@
115 from xml.etree.ElementTree import ElementTree, XML
116 from PyQt4 import QtCore, QtGui
117
118-from openlp.core.lib import OpenLPToolbar, get_text_file_string, build_icon, \
119+from openlp.core.lib import FileDialog, OpenLPToolbar, get_text_file_string, build_icon, \
120 Receiver, SettingsManager, translate, check_item_selected, \
121 check_directory_exists, create_thumb, validate_thumb, ImageSource
122 from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, \
123@@ -420,7 +420,7 @@
124 attempting to extract OpenLP themes from those files. This process
125 will load both OpenLP version 1 and version 2 themes.
126 """
127- files = QtGui.QFileDialog.getOpenFileNames(self,
128+ files = FileDialog.getOpenFileNames(self,
129 translate('OpenLP.ThemeManager', 'Select Theme Import File'),
130 SettingsManager.get_last_dir(self.settingsSection),
131 unicode(translate('OpenLP.ThemeManager',
132
133=== modified file 'openlp/plugins/songs/forms/editsongform.py'
134--- openlp/plugins/songs/forms/editsongform.py 2013-06-16 17:19:32 +0000
135+++ openlp/plugins/songs/forms/editsongform.py 2013-08-17 08:52:16 +0000
136@@ -34,7 +34,7 @@
137
138 from PyQt4 import QtCore, QtGui
139
140-from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, \
141+from openlp.core.lib import FileDialog, PluginStatus, Receiver, MediaType, translate, \
142 create_separated_list, check_directory_exists
143 from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, \
144 critical_error_message_box, find_and_set_in_combo_box
145@@ -757,7 +757,7 @@
146 Loads file(s) from the filesystem.
147 """
148 filters = u'%s (*)' % UiStrings().AllFiles
149- filenames = QtGui.QFileDialog.getOpenFileNames(self,
150+ filenames = FileDialog.getOpenFileNames(self,
151 translate('SongsPlugin.EditSongForm', 'Open File(s)'),
152 QtCore.QString(), filters)
153 for filename in filenames:
154
155=== modified file 'openlp/plugins/songs/forms/songimportform.py'
156--- openlp/plugins/songs/forms/songimportform.py 2012-12-30 19:41:24 +0000
157+++ openlp/plugins/songs/forms/songimportform.py 2013-08-17 08:52:16 +0000
158@@ -35,7 +35,7 @@
159
160 from PyQt4 import QtCore, QtGui
161
162-from openlp.core.lib import Receiver, SettingsManager, translate
163+from openlp.core.lib import FileDialog, Receiver, SettingsManager, translate
164 from openlp.core.lib.ui import UiStrings, critical_error_message_box
165 from openlp.core.lib.settings import Settings
166 from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
167@@ -281,7 +281,7 @@
168 if filters:
169 filters += u';;'
170 filters += u'%s (*)' % UiStrings().AllFiles
171- filenames = QtGui.QFileDialog.getOpenFileNames(self, title,
172+ filenames = FileDialog.getOpenFileNames(self, title,
173 SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
174 filters)
175 if filenames:

Subscribers

People subscribed via source and target branches