Skip to content
This repository has been archived by the owner on Mar 14, 2020. It is now read-only.

Commit

Permalink
Pewnet refactor; Start on tableview redesign;
Browse files Browse the repository at this point in the history
  • Loading branch information
twiddli committed Jan 1, 2016
1 parent a0e2106 commit 21f3c0a
Show file tree
Hide file tree
Showing 12 changed files with 605 additions and 396 deletions.
Binary file modified happypanda.ico
Binary file not shown.
18 changes: 10 additions & 8 deletions version/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ def tray_activate(r=None):
self.resize(x, y)
else:
self.resize(app_constants.MAIN_W, app_constants.MAIN_H)
self.setMinimumWidth(600)
self.setMinimumHeight(400)
misc.centerWidget(self)
self.init_spinners()
self.show()
Expand Down Expand Up @@ -422,14 +424,14 @@ def manga_display(self):
self.manga_table_view.sort_model = self.manga_list_view.sort_model
self.manga_table_view.setModel(self.manga_table_view.sort_model)
self.manga_table_view.sort_model.change_model(self.manga_table_view.gallery_model)
self.manga_table_view.setColumnWidth(app_constants.FAV, 20)
self.manga_table_view.setColumnWidth(app_constants.ARTIST, 200)
self.manga_table_view.setColumnWidth(app_constants.TITLE, 400)
self.manga_table_view.setColumnWidth(app_constants.TAGS, 300)
self.manga_table_view.setColumnWidth(app_constants.TYPE, 60)
self.manga_table_view.setColumnWidth(app_constants.CHAPTERS, 60)
self.manga_table_view.setColumnWidth(app_constants.LANGUAGE, 100)
self.manga_table_view.setColumnWidth(app_constants.LINK, 400)
#self.manga_table_view.setColumnWidth(app_constants.FAV, 20)
#self.manga_table_view.setColumnWidth(app_constants.ARTIST, 200)
#self.manga_table_view.setColumnWidth(app_constants.TITLE, 400)
#self.manga_table_view.setColumnWidth(app_constants.TAGS, 300)
#self.manga_table_view.setColumnWidth(app_constants.TYPE, 60)
#self.manga_table_view.setColumnWidth(app_constants.CHAPTERS, 60)
#self.manga_table_view.setColumnWidth(app_constants.LANGUAGE, 100)
#self.manga_table_view.setColumnWidth(app_constants.LINK, 400)


def init_spinners(self):
Expand Down
2 changes: 2 additions & 0 deletions version/app_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
SIZE_FACTOR = get(10, 'Visual', 'size factor', int)
GRIDBOX_H_SIZE = 200 + SIZE_FACTOR
GRIDBOX_W_SIZE = GRIDBOX_H_SIZE//1.40 #1.47
LISTBOX_H_SIZE = 190
LISTBOX_W_SIZE = 950
GRIDBOX_LBL_H = 50 + SIZE_FACTOR
GRIDBOX_H_SIZE += GRIDBOX_LBL_H
THUMB_H_SIZE = 190 + SIZE_FACTOR
Expand Down
18 changes: 16 additions & 2 deletions version/database/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,14 @@ def begin(cls):
"Useful when modifying for a large amount of data"
cls._AUTO_COMMIT = False
cls.execute(cls, "BEGIN TRANSACTION")
print("STARTED DB OPTIMIZE")

@classmethod
def end(cls):
"Called to commit and end transaction"
cls._AUTO_COMMIT = True
cls._DB_CONN.commit()
print("ENDED DB OPTIMIZE")

def execute(self, *args):
"Same as cursor.execute"
Expand All @@ -339,9 +341,21 @@ def execute(self, *args):
log_d('DB Query: {}'.format(args).encode(errors='ignore'))
if self._AUTO_COMMIT:
with self._DB_CONN:
return self._DB_CONN.execute(*args)
try:
return self._DB_CONN.execute(*args)
except:
print("with autocommit")
print(args)
print(type(args[1][0]))
raise RuntimeError
else:
return self._DB_CONN.execute(*args)
try:
return self._DB_CONN.execute(*args)
except:
print("no autocommit")
print(args)
print(type(args[1][0]))
raise RuntimeError

def executemany(self, *args):
"Same as cursor.executemany"
Expand Down
64 changes: 3 additions & 61 deletions version/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,64 +272,6 @@ def _return_gallery_metadata(self, gallery):
self.GALLERY_EMITTER.emit(gallery, None, False)
log_d('Success')

@staticmethod
def apply_metadata(g, data, append=True):
if app_constants.USE_JPN_TITLE:
try:
title = data['title']['jpn']
except KeyError:
title = data['title']['def']
else:
title = data['title']['def']

if 'Language' in data['tags']:
try:
lang = [x for x in data['tags']['Language'] if not x == 'translated'][0].capitalize()
except IndexError:
lang = ""
else:
lang = ""

title_artist_dict = utils.title_parser(title)
if not append:
g.title = title_artist_dict['title']
if title_artist_dict['artist']:
g.artist = title_artist_dict['artist']
g.language = title_artist_dict['language'].capitalize()
if 'Artist' in data['tags']:
g.artist = data['tags']['Artist'][0].capitalize()
if lang:
g.language = lang
g.type = data['type']
g.pub_date = data['pub_date']
g.tags = data['tags']
else:
if not g.title:
g.title = title_artist_dict['title']
if not g.artist:
g.artist = title_artist_dict['artist']
if 'Artist' in data['tags']:
g.artist = data['tags']['Artist'][0].capitalize()
if not g.language:
g.language = title_artist_dict['language'].capitalize()
if lang:
g.language = lang
if not g.type or g.type == 'Other':
g.type = data['type']
if not g.pub_date:
g.pub_date = data['pub_date']
if not g.tags:
g.tags = data['tags']
else:
for ns in data['tags']:
if ns in g.tags:
for tag in data['tags'][ns]:
if not tag in g.tags[ns]:
g.tags[ns].append(tag)
else:
g.tags[ns] = data['tags'][ns]
return g

def fetch_metadata(self, gallery, hen, proc=False):
"""
Puts gallery in queue for metadata fetching. Applies received galleries and sends
Expand Down Expand Up @@ -365,10 +307,10 @@ def fetch_metadata(self, gallery, hen, proc=False):
log_i('({}/{}) Applying metadata for gallery: {}'.format(x, len(self.galleries_in_queue),
g.title.encode(errors='ignore')))
if app_constants.REPLACE_METADATA:
g = Fetch.apply_metadata(g, data, False)
g = hen.apply_metadata(g, data, False)
g.link = g.temp_url
else:
g = Fetch.apply_metadata(g, data)
g = hen.apply_metadata(g, data)
if not g.link:
g.link = g.temp_url
self._return_gallery_metadata(g)
Expand Down Expand Up @@ -438,7 +380,7 @@ def auto_web_metadata(self):

# dict -> hash:[list of title,url tuples] or None
self.AUTO_METADATA_PROGRESS.emit("({}/{}) Finding url for gallery: {}".format(x, len(self.galleries), gallery.title))
found_url = hen.eh_hash_search(gallery.hash)
found_url = hen.search(gallery.hash)
if found_url == 'error':
app_constants.GLOBAL_EHEN_LOCK = False
self.FINISHED.emit(True)
Expand Down
Loading

0 comments on commit 21f3c0a

Please sign in to comment.