Skip to content

Commit

Permalink
Select-all in photograph collections.
Browse files Browse the repository at this point in the history
  • Loading branch information
textbrowser committed Jan 8, 2025
1 parent 2aaa634 commit 2f74404
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 43 deletions.
1 change: 1 addition & 0 deletions Documentation/Release-Notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<body>
<p><u>January 10, 2025</u></p>
<ul>
<li>New Select Images button for photograph collections.</li>
<li>PostgreSQL 15.10.3 on Windows.</li>
<li>Removed biblioteq.arm.pro as biblioteq.pro is suitable.
Modern distributions please.</li>
Expand Down
2 changes: 1 addition & 1 deletion Documentation/TO-DO
Original file line number Diff line number Diff line change
Expand Up @@ -692,5 +692,5 @@
336. Select-all shortcut for icon view in main table. Edit -> Select All.
(Completed)
337. Maybe icons on tabs of paged items. (Soon)
338. Photographs and select-all click. (Soon)
338. Photographs and select-all click. (Completed)
339. Test Android and correct. (Soon)
66 changes: 44 additions & 22 deletions Scripts/biblioteq-download-images-postgresql.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
#!/usr/bin/env sh
# Alexis Megas.

if [ ! -x "$(which base64)" ]; then
if [ ! -x "$(which base64)" ]
then
echo "Missing base64."
exit 1
fi

if [ ! -x "$(which psql)" ]; then
if [ ! -x "$(which psql)" ]
then
echo "Missing pqsql."
exit 1
fi

if [ ! -x "$(which wget)" ]; then
if [ ! -x "$(which wget)" ]
then
echo "Missing wget."
exit 1
fi

for i in "$@"; do
if [ "$i" = "--help" ]; then
for i in "$@"
do
if [ "$i" = "--help" ]
then
echo "$0:\n" \
" --account database account\n" \
" --database database name\n" \
Expand All @@ -35,55 +40,67 @@ database=""
host=""
query="SELECT TRIM(id, '-') FROM book WHERE id IS NOT NULL"

for i in "$@"; do
if [ "$account" = "1" ]; then
for i in "$@"
do
if [ "$account" = "1" ]
then
account="$i"
fi

if [ "$database" = "1" ]; then
if [ "$database" = "1" ]
then
database="$i"
fi

if [ "$host" = "1" ]; then
if [ "$host" = "1" ]
then
host="$i"
fi

if [ "$i" = "--account" ]; then
if [ "$i" = "--account" ]
then
account="1"
continue
fi

if [ "$i" = "--host" ]; then
if [ "$i" = "--host" ]
then
host="1"
continue
fi

if [ "$i" = "--database" ]; then
if [ "$i" = "--database" ]
then
database="1"
continue
fi

if [ "$i" = "--ignore-not-null" ]; then
if [ "$i" = "--ignore-not-null" ]
then
query="SELECT TRIM(id, '-') FROM book WHERE front_cover IS NULL AND \
id IS NOT NULL"
fi

if [ "$i" = "--open-library" ]; then
if [ "$i" = "--open-library" ]
then
amazon=0
fi
done

if [ -z "$account" ]; then
if [ -z "$account" ]
then
echo "Please provide a database account."
exit 1
fi

if [ -z "$database" ]; then
if [ -z "$database" ]
then
echo "Please provide a database name."
exit 1
fi

if [ -z "$host" ]; then
if [ -z "$host" ]
then
echo "Please provide a database host."
exit 1
fi
Expand All @@ -98,10 +115,12 @@ for id in $(psql -U "$account" \
-h "$host" \
-q \
-t \
--csv 2>/dev/null); do
--csv 2>/dev/null)
do
/bin/echo -n "Fetching $id's image... "

if [ $amazon -eq 1 ]; then
if [ $amazon -eq 1 ]
then
wget --output-document "$id.jpg" \
--quiet \
"https://m.media-amazon.com/images/P/$id.01._SCMZZZZZZZ_.jpg"
Expand All @@ -111,7 +130,8 @@ for id in $(psql -U "$account" \
"https://covers.openlibrary.org/b/isbn/$id-L.jpg"
fi

if [ $? -eq 0 ]; then
if [ $? -eq 0 ]
then
echo "Image downloaded."
echo "UPDATE book SET front_cover = " \
"'$(cat "$id.jpg" | base64)'" \
Expand All @@ -124,10 +144,12 @@ for id in $(psql -U "$account" \
rm -f "$id.jpg"
done

if [ -r "$0.output" ]; then
if [ -r "$0.output" ]
then
psql -U "$account" -W -d "$database" -f "$0.output" -h "$host" -q

if [ $? -eq 0 ]; then
if [ $? -eq 0 ]
then
echo "Database $database processed correctly."
else
echo "Error processing $database."
Expand Down
51 changes: 34 additions & 17 deletions Scripts/biblioteq-download-images-sqlite.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
#!/usr/bin/env sh
# Alexis Megas.

if [ ! -x "$(which base64)" ]; then
if [ ! -x "$(which base64)" ]
then
echo "Missing base64."
exit 1
fi

if [ ! -x "$(which sqlite3)" ]; then
if [ ! -x "$(which sqlite3)" ]
then
echo "Missing sqlite3."
exit 1
fi

if [ ! -x "$(which wget)" ]; then
if [ ! -x "$(which wget)" ]
then
echo "Missing wget."
exit 1
fi

for i in "$@"; do
if [ "$i" = "--help" ]; then
for i in "$@"
do
if [ "$i" = "--help" ]
then
echo "$0:\n" \
" --database file-name\n" \
" --help\n" \
Expand All @@ -31,43 +36,52 @@ amazon=1
file=""
query="SELECT TRIM(id, '-') FROM book WHERE id IS NOT NULL"

for i in "$@"; do
if [ "$i" = "--database" ]; then
for i in "$@"
do
if [ "$i" = "--database" ]
then
file="1"
continue
fi

if [ "$i" = "--ignore-not-null" ]; then
if [ "$i" = "--ignore-not-null" ]
then
query="SELECT TRIM(id, '-') FROM book WHERE front_cover IS NULL AND \
id IS NOT NULL"
fi

if [ "$i" = "--open-library" ]; then
if [ "$i" = "--open-library" ]
then
amazon=0
fi

if [ "$file" = "1" ]; then
if [ "$file" = "1" ]
then
file="$i"
fi
done

if [ ! -w "$file" ]; then
if [ ! -w "$file" ]
then
echo "Please specify a writable database file."
exit 1
fi

rm -f "$0.output"

if [ $amazon -eq 1 ]; then
if [ $amazon -eq 1 ]
then
echo "Downloading images from Amazon."
else
echo "Downloading images from OpenLibrary."
fi

for id in $(sqlite3 "$file" "$query"); do
for id in $(sqlite3 "$file" "$query")
do
/bin/echo -n "Fetching $id's image... "

if [ $amazon -eq 1 ]; then
if [ $amazon -eq 1 ]
then
wget --output-document "$id.jpg" \
--quiet \
"https://m.media-amazon.com/images/P/$id.01._SCMZZZZZZZ_.jpg"
Expand All @@ -77,7 +91,8 @@ for id in $(sqlite3 "$file" "$query"); do
"https://covers.openlibrary.org/b/isbn/$id-L.jpg"
fi

if [ $? -eq 0 ]; then
if [ $? -eq 0 ]
then
echo "Image downloaded."
echo "UPDATE book SET front_cover = " \
"'$(cat "$id.jpg" | base64)'" \
Expand All @@ -90,10 +105,12 @@ for id in $(sqlite3 "$file" "$query"); do
rm -f "$id.jpg"
done

if [ -r "$0.output" ]; then
if [ -r "$0.output" ]
then
sqlite3 "$file" < "$0.output" 2>/dev/null

if [ $? -eq 0 ]; then
if [ $? -eq 0 ]
then
echo "Database $file processed correctly."
else
echo "Error processing $file."
Expand Down
9 changes: 8 additions & 1 deletion Source/biblioteq_photographcollection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ biblioteq_photographcollection::biblioteq_photographcollection
SIGNAL(clicked(void)),
this,
SLOT(slotReset(void)));
connect(pc.selectAllButton,
SIGNAL(clicked(void)),
this,
SLOT(slotSelectAll(void)));
connect(pc.select_image_collection,
SIGNAL(clicked(void)),
this,
Expand Down Expand Up @@ -456,6 +460,7 @@ void biblioteq_photographcollection::insert(void)
activateWindow();
raise();
prepareIcons(this);
pc.selectAllButton->setIcon(QIcon());
}

void biblioteq_photographcollection::loadPhotographFromItem
Expand Down Expand Up @@ -714,6 +719,7 @@ void biblioteq_photographcollection::modify(const int state,
query.bindValue(0, m_oid);
pc.okButton->setText(tr("&Save"));
prepareIcons(this);
pc.selectAllButton->setIcon(QIcon());
QApplication::setOverrideCursor(Qt::WaitCursor);

if(!query.exec() || !query.next())
Expand Down Expand Up @@ -901,6 +907,7 @@ void biblioteq_photographcollection::search(const QString &field,
activateWindow();
raise();
prepareIcons(this);
pc.selectAllButton->setIcon(QIcon());
}

void biblioteq_photographcollection::setGlobalFonts(const QFont &font)
Expand Down Expand Up @@ -2348,6 +2355,7 @@ void biblioteq_photographcollection::slotPageChanged(int index)
void biblioteq_photographcollection::slotPrepareIcons(void)
{
prepareIcons(this);
pc.selectAllButton->setIcon(QIcon());
}

void biblioteq_photographcollection::slotPrint(void)
Expand Down Expand Up @@ -2542,7 +2550,6 @@ void biblioteq_photographcollection::slotSceneSelectionChanged(void)
if(items.isEmpty())
{
m_itemOid.clear();

pc.accession_number_item->clear();
pc.call_number_item->clear();
pc.copyright_item->clear();
Expand Down
18 changes: 16 additions & 2 deletions UI/biblioteq_photographinfo.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1100</width>
<width>1228</width>
<height>800</height>
</rect>
</property>
Expand All @@ -32,7 +32,7 @@
<rect>
<x>0</x>
<y>-404</y>
<width>1067</width>
<width>1195</width>
<height>1146</height>
</rect>
</property>
Expand Down Expand Up @@ -796,6 +796,19 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="selectAllButton">
<property name="minimumSize">
<size>
<width>145</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Select Images</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="minimumSize">
Expand Down Expand Up @@ -874,6 +887,7 @@
<tabstop>exportPhotographsToolButton</tabstop>
<tabstop>importItems</tabstop>
<tabstop>printButton</tabstop>
<tabstop>selectAllButton</tabstop>
<tabstop>cancelButton</tabstop>
</tabstops>
<resources>
Expand Down

0 comments on commit 2f74404

Please sign in to comment.