Skip to content

Commit

Permalink
ImageList introduced
Browse files Browse the repository at this point in the history
  • Loading branch information
jabbalaci committed Jul 8, 2018
1 parent 5cb59ec commit 47c37dc
Show file tree
Hide file tree
Showing 4 changed files with 380 additions and 361 deletions.
28 changes: 14 additions & 14 deletions jive/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ def to_save(self):
"""
Number of images flagged to be saved.
"""
return sum(1 for img in self.parent.list_of_images if img.to_save)
return sum(1 for img in self.parent.imgList.list_of_images if img.to_save)

def to_delete(self):
"""
Number of images flagged to be deleted.
"""
return sum(1 for img in self.parent.list_of_images if img.to_delete)
return sum(1 for img in self.parent.imgList.list_of_images if img.to_delete)

def to_wallpaper(self):
"""
Number of images flagged to be saved as wallpapers.
"""
return sum(1 for img in self.parent.list_of_images if img.to_wallpaper)
return sum(1 for img in self.parent.imgList.list_of_images if img.to_wallpaper)

def has_something_to_commit(self):
val1 = self.to_save()
Expand Down Expand Up @@ -79,7 +79,7 @@ def save_wallpapers(self):
Return the number of images that were saved successfully.
"""
folder = cfg.PLATFORM_SETTINGS['wallpapers_dir']
lst = [img for img in self.parent.list_of_images if img.to_wallpaper]
lst = [img for img in self.parent.imgList.list_of_images if img.to_wallpaper]

return self._save_files(folder, lst, "saving wallpapers", cfg.WALLPAPER_SAVE)

Expand All @@ -90,7 +90,7 @@ def save_others(self):
Return the number of images that were saved successfully.
"""
folder = cfg.PLATFORM_SETTINGS['saves_dir']
lst = [img for img in self.parent.list_of_images if img.to_save]
lst = [img for img in self.parent.imgList.list_of_images if img.to_save]

return self._save_files(folder, lst, "saving", cfg.NORMAL_SAVE)

Expand All @@ -99,31 +99,31 @@ def delete_files(self):
return 0
# else, there's something to delete
pos_img = None
if not self.parent.curr_img.to_delete:
if not self.parent.imgList.curr_img.to_delete:
# we don't want to delete the current image
pos_img = self.parent.curr_img
pos_img = self.parent.imgList.curr_img
else:
# we want to delete the current image
images_to_keep_right = [img for img in self.parent.list_of_images[self.parent.curr_img_idx + 1:] if
images_to_keep_right = [img for img in self.parent.imgList.list_of_images[self.parent.imgList.curr_img_idx + 1:] if
not img.to_delete]
if len(images_to_keep_right) > 0:
pos_img = images_to_keep_right[0]
else:
images_to_keep_left = [img for img in self.parent.list_of_images[:self.parent.curr_img_idx] if
images_to_keep_left = [img for img in self.parent.imgList.list_of_images[:self.parent.imgList.curr_img_idx] if
not img.to_delete]
if len(images_to_keep_left) > 0:
pos_img = images_to_keep_left[-1]
#
to_delete = [img for img in self.parent.list_of_images if img.to_delete]
to_delete = [img for img in self.parent.imgList.list_of_images if img.to_delete]
result = self.delete_physically(to_delete)

to_keep = [img for img in self.parent.list_of_images if not img.to_delete]
self.parent.list_of_images = to_keep
to_keep = [img for img in self.parent.imgList.list_of_images if not img.to_delete]
self.parent.imgList.list_of_images = to_keep
if len(to_keep) > 0:
# there are remaining images, thus pos_img points to an image that we want to keep
idx = self.parent.list_of_images.index(pos_img)
idx = self.parent.imgList.list_of_images.index(pos_img)
# log.debug(f"index: {idx}")
self.parent.jump_to_image_and_dont_care_about_the_previous_image(idx)
self.parent.imgList.jump_to_image_and_dont_care_about_the_previous_image(idx)
else:
self.parent.reset()

Expand Down
10 changes: 5 additions & 5 deletions jive/extractors/subreddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def get_subreddit_name(text):
return None


def read_subreddit(subreddit, after_id=None, statusbar=None, parent=None):
def read_subreddit(subreddit, after_id=None, statusbar=None, mainWindow=None):
try:
if parent:
parent.loading_line.show()
if mainWindow:
mainWindow.loading_line.show()
if not after_id:
img_url = url_template.format(subreddit=subreddit)
else:
Expand Down Expand Up @@ -118,5 +118,5 @@ def read_subreddit(subreddit, after_id=None, statusbar=None, parent=None):
finally:
if statusbar:
statusbar.progressbar.hide()
if parent:
parent.loading_line.hide()
if mainWindow:
mainWindow.loading_line.hide()
4 changes: 2 additions & 2 deletions jive/imageinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def grid_layout_creation_1(self):
def grid_layout_creation_2(self):
self.group_box_2 = QGroupBox("Summary")

length = len(self.parent.list_of_images)
length = len(self.parent.imgList.list_of_images)

layout = QGridLayout()
layout.addWidget(QLabel(bold("Marked to be saved:")), 0, 0)
Expand All @@ -84,7 +84,7 @@ def grid_layout_creation_2(self):

layout.addWidget(QLabel(bold("Marked to be deleted:")), 1, 0)
num = self.commit.to_delete()
remain = len(self.parent.list_of_images) - num
remain = len(self.parent.imgList.list_of_images) - num
text = f"{num} (out of {length}) [remain {remain}]"
layout.addWidget(QLabel(text), 1, 1)

Expand Down
Loading

0 comments on commit 47c37dc

Please sign in to comment.