Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
showing images in two options, cells view or rows view
Browse files Browse the repository at this point in the history
the user can choose to show the images in cells view to see n x n table
with an image in every cell.
Or rows view to see 1 x n table with an image in every row as used
before. The preference is persisted in the config file with the tag
images_view
  • Loading branch information
jejimenez committed Dec 16, 2016
1 parent 4046caa commit 43d442a
Show file tree
Hide file tree
Showing 26 changed files with 623 additions and 510 deletions.
1 change: 1 addition & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
eclipse.preferences.version=1
encoding//scripts/petgfilehandling.py=utf-8
encoding//scripts/petgfunctions.py=utf-8
encoding//scripts/programinfo.py=utf-8
encoding//scripts/programstrings.py=utf-8
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions scripts/petgfilehandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def write_default_config():
config += "\t<alternate_exiftool>False</alternate_exiftool>\n"
config += "\t<exiftooloption></exiftooloption>\n"
config += "\t<pref_thumbnail_preview>True</pref_thumbnail_preview>\n"
config += "\t<images_view>by cells</images_view>\n"
config += "\t<def_startupfolder></def_startupfolder>\n"
config += "\t<def_creator></def_creator>\n"
config += "\t<def_copyright></def_copyright>\n"
Expand Down Expand Up @@ -96,6 +97,12 @@ def read_xml_config(self):
self.def_creator.setText(tags.text)
for tags in pref_record.iter('def_copyright'):
self.def_copyright.setText(tags.text)
for tags in pref_record.iter('images_view'):
print(tags.text)
index = self.images_view.findText(tags.text, Qt.MatchFixedString)
if index >= 0:
self.images_view.setCurrentIndex(index)


def write_xml_config(self):
for pref_record in self.configroot:
Expand All @@ -119,6 +126,8 @@ def write_xml_config(self):
tags.text = self.def_creator.text()
for tags in pref_record.iter('def_copyright'):
tags.text = self.def_copyright.text()
for tags in pref_record.iter('images_view'):
tags.text = self.images_view.currentText()

try:
userpath = os.path.expanduser('~')
Expand Down
Binary file added scripts/petgfilehandling.pyc
Binary file not shown.
66 changes: 45 additions & 21 deletions scripts/petgfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# command line tool exiftool by Phil Harvey, but it's not
# a complete exiftool gui: not at all.

import os, sys, platform, shlex, subprocess, time, re, string, datetime
import os, sys, platform, shlex, subprocess, time, re, string, datetime, math

import PySide
from PySide.QtCore import *
Expand Down Expand Up @@ -256,7 +256,7 @@ def images_dialog(self, qApp):

def imagegridsizes(self, numImages):
colswidth = 100
cols = self.MaintableWidget.width()/(colswidth+8)
cols = self.MaintableWidget.width()/float(colswidth+8.0)
return cols, colswidth

def loadimages(self ,fileNames, qApp):
Expand All @@ -278,34 +278,54 @@ def loadimages(self ,fileNames, qApp):
self.progressbar.show()
qApp.processEvents()
self.MaintableWidget.clearContents()
self.MaintableWidget.setRowCount(int(len(fileNames)/cols))
self.MaintableWidget.setColumnCount(cols)
#self.MaintableWidget.setColumnWidth(0,100)
#self.MaintableWidget.setColumnWidth(1,225)
print(self.MaintableWidget.width())
if self.images_view.currentText() == "by cells":
self.MaintableWidget.setSelectionBehavior(QAbstractItemView.SelectItems)
self.MaintableWidget.setRowCount(math.ceil(len(fileNames)/cols))
self.MaintableWidget.setColumnCount(cols)
cols = int(cols)
else:
self.MaintableWidget.setSelectionBehavior(QAbstractItemView.SelectRows)
self.MaintableWidget.setRowCount(len(fileNames))
self.MaintableWidget.setColumnCount(2)
self.MaintableWidget.setColumnWidth(0,100)
self.MaintableWidget.setColumnWidth(1,225)

for loadedimage in fileNames:
if self.DebugMsg:
print(rowcounter)
print(loadedimage + "\n")
folder,imagefile = os.path.split(loadedimage)
#self.MaintableWidget.insertRow(int(rowcounter/cols))
#qtablefilename = QTableWidgetItem(imagefile)
#self.MaintableWidget.setItem(rowcounter, 1, qtablefilename)
#self.MaintableWidget.insertRow(rowcounter)
if self.images_view.currentText() == "by cells":
pass
else:
qtablefilename = QTableWidgetItem(imagefile)
self.MaintableWidget.setItem(rowcounter, 1, qtablefilename)
if self.pref_thumbnail_preview.isChecked():
self.MaintableWidget.setColumnWidth(int(rowcounter%cols),colwidth)
self.MaintableWidget.setRowHeight(int(rowcounter/cols),(colwidth*0.75))
# Now create the thumbnail to be displayed
thumbnail = QLabel(self)
thumbnail.setMargin(8)
image = QImage(loadedimage)
thumbnail.setPixmap(QPixmap.fromImage(image))
thumbnail.setScaledContents(True)
thumbnail.setToolTip(imagefile)
# Fill the table
self.MaintableWidget.setCellWidget(int(rowcounter/cols), int(rowcounter%cols), thumbnail)
if self.images_view.currentText() == "by cells":
print(rowcounter)
print(int(rowcounter/cols), int(rowcounter%cols))
self.MaintableWidget.setColumnWidth(int(rowcounter%cols),colwidth)
self.MaintableWidget.setRowHeight(int(rowcounter/cols),(colwidth*0.75))
self.MaintableWidget.setCellWidget(int(rowcounter/cols), int(rowcounter%cols), thumbnail)
else:
self.MaintableWidget.setRowHeight(rowcounter,75)
self.MaintableWidget.setCellWidget(rowcounter, 0, thumbnail)
else:
# Fill the table when thumbs are disabled
dis_thumb_string = QTableWidgetItem("disabled")
self.MaintableWidget.setItem(int(rowcounter/cols), int(rowcounter%cols), dis_thumb_string)
if self.images_view.currentText() == "by cells":
self.MaintableWidget.setItem(int(rowcounter/cols), int(rowcounter%cols), dis_thumb_string)
else:
self.MaintableWidget.setItem(rowcounter, 0, dis_thumb_string)
rowcounter += 1
self.progressbar.setValue(rowcounter)
self.statusbar.showMessage("Creating thumbnail of: " + os.path.basename(loadedimage))
Expand Down Expand Up @@ -2092,14 +2112,18 @@ def write_image_info(self, exiftoolparams, qApp, backup_originals):
self.progressbar.show()
rows = []
for selected_row in selected_rows:
selected_row = str(selected_row)
selected_row = selected_row.replace("<PySide.QtCore.QModelIndex(",'')
selected_row, tail = re.split(',0x0',selected_row)
#selected_row = str(selected_row)
#selected_row = selected_row.replace("<PySide.QtCore.QModelIndex(",'')
#selected_row, tail = re.split(',0x0',selected_row)
#print str(selected_row)
row, column = re.split(',',selected_row)
if row not in rows:
rows.append(row)
selected_image = "\"" + self.fileNames[int(row)] + "\""
#row, column = re.split(',',selected_row)
row, column = selected_row.row(), selected_row.column()
if str(str(row)+","+str(column)) not in rows:
rows.append(str(row)+","+str(column))
if self.images_view.currentText() == "by cells":
selected_image = "\"" + self.fileNames[int((self.MaintableWidget.columnCount()*row)+column)] + "\""
else:
selected_image = "\"" + self.fileNames[int(row)] + "\""
print('exiftool ' + exiftoolparams + ' ' + selected_image)
#print 'exiftool "-FileModifyDate<DateTimeOriginal" ' + selected_image
rowcounter += 1
Expand Down
Binary file added scripts/petgfunctions.pyc
Binary file not shown.
Binary file added scripts/programinfo.pyc
Binary file not shown.
Binary file added scripts/programstrings.pyc
Binary file not shown.
8 changes: 8 additions & 0 deletions scripts/pyexiftoolgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def __init__(self, parent=None):
self.imagereference = QAction("Select photo as reference for \"Extra\" menu", self, triggered = self.reference_image)
self.displayphoto = QAction("Display selected photo", self, triggered = self.showimage)
# Load several views, buttons, comboboxes, spinboxes and labels from main screen
self.linkbtn_reloadimages.clicked.connect(self.reloadimages)
self.btn_loadimages.clicked.connect(self.loadimages)
self.showimagebutton.clicked.connect(self.showimage)
self.showimagebutton.setEnabled(False)
Expand Down Expand Up @@ -195,6 +196,8 @@ def __init__(self, parent=None):
# if self.logtofile:
# logging.info(self.tmpworkdir + " already exists.")

# class var with images loaded
self.loaded_images = []
#------------------------------------------------------------------------
# Initialize file paths
self.realfile_dir = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -219,6 +222,7 @@ def __init__(self, parent=None):
# Initialize Combobox on lens tab with loaded lenses (if any)
self.lens_current_index = '' # We need this later when updating or deleting lenses
petgfilehandling.read_defined_lenses(self, qApp)


# Initialize Combobox mass change tab
'''self.grouplist = [
Expand Down Expand Up @@ -252,9 +256,13 @@ def enableimagebuttons(self):
self.imageinfobutton.setEnabled(True)


def reloadimages(self):
petgfunctions.loadimages(self, self.loaded_images, qApp)

def loadimages(self):
''' show dialog of image files and load images selected '''
selectedimages = petgfunctions.images_dialog(self, qApp)
self.loaded_images = selectedimages
petgfunctions.loadimages(self, selectedimages, qApp)
# If we alread did some copying or simply working on the GPS:edit tab we need to clean it after loading new images
#petgfunctions.clear_gps_fields(self)
Expand Down
Binary file added scripts/renaming.pyc
Binary file not shown.
Loading

0 comments on commit 43d442a

Please sign in to comment.