Update MgrCalibreDB.py and UI.py

This commit is contained in:
2024-12-08 01:06:45 +09:00
parent 1e06484b4e
commit 1c840a1e25
2 changed files with 45 additions and 19 deletions

View File

@@ -49,6 +49,21 @@ class MgrCalibreDB:
return listRet
def GetBookListforUI_ArcList(self):
if None == self.cursor:
return None
try:
strSQL = f"Select title, path from books;"
self.cursor.execute(strSQL)
listRet = self.cursor.fetchall()
except sqlite3.Error as e:
listRet = []
print(f"SQLite Erro occurred: {e}")
return listRet
def UpdateTableValue(self,Table, nID, ColName, Value):
if None == self.cursor:
return
@@ -71,29 +86,29 @@ class MgrCalibreDB:
strSQL = f"SELECT MAX(id) FROM \'{strTableName}\';"
self.cursor.execute(strSQL)
nMaxID = self.cursor.fetchone()[0]
nMaxID += 1.
nMaxID += 1
strAuthorSort = strAuthor.replace(" ", ",")
strSQL = f"INSERT OR IGNORE INTO \'{strTableName}\' VALUES ({nMaxID}, \'{strAuthor}\',\'{strAuthorSort}\', \'\');"
self.cursor.execute(strSQL)
self.conn.commit()
def InsertTag(self, tag):
if None == self.cursor:
return
if True == util.IsEmptyStr(tag):
return
def InsertTag(self, tag):
if None == self.cursor:
return
if True == util.IsEmptyStr(tag):
return
strTableName = "tags"
strSQL = f"SELECT MAX(id) FROM \'{strTableName}\';"
self.cursor.execute(strSQL)
nMaxID = self.cursor.fetchone()[0]
nMaxID += 1.
strTableName = "tags"
strSQL = f"SELECT MAX(id) FROM \'{strTableName}\';"
self.cursor.execute(strSQL)
nMaxID = self.cursor.fetchone()[0]
nMaxID += 1.
strSQL = f"INSERT OR IGNORE INTO \'{strTableName}\' VALUES ({nMaxID}, \'{strAuthor}\', \'\');"
self.cursor.execute(strSQL)
self.conn.commit()
strSQL = f"INSERT OR IGNORE INTO \'{strTableName}\' VALUES ({nMaxID}, \'{strAuthor}\', \'\');"
self.cursor.execute(strSQL)
self.conn.commit()
def main():
db = MgrCalibreDB("/Users/minarinari/캘리버 서재/metadata.db")

19
UI.py
View File

@@ -1,6 +1,8 @@
import sys
import os
import UtilPack as util
import MgrCalibreDB as calDB
import MgrCalibreLibs as calLib
from io import BytesIO
@@ -21,6 +23,7 @@ class MyApp(QMainWindow):
self.saveINI()
event.accept()
def resizeEvent(self, event):
self.GetFitSize(self.label_Image.size())
print( self.label_Image.size() )
@@ -107,6 +110,7 @@ class MyApp(QMainWindow):
return layout
def GetFitSize(self, szTarget):
szDesktop = self.screen().size()
szWindow = self.size()
@@ -115,8 +119,6 @@ class MyApp(QMainWindow):
nTrgWidth = szWindow.width() - ( self.list_ArcList.width() + self.list_Items.width() )
def on_click_SrcAdd(self):
# 폴더 선택 창을 띄움
folder_path = QFileDialog.getExistingDirectory(self, '폴더 선택', '')
@@ -163,8 +165,16 @@ class MyApp(QMainWindow):
ItemName = os.path.join(FolderName, filename)
item = QListWidgetItem(ItemName)
# 전체 경로를 따로 저장
item.setData(Qt.UserRole, pathFile)
self.list_ArcList.addItem(item)
#item.setData(Qt.UserRole, pathFile)
#self.list_ArcList.addItem(item)
print(pathFile)
db = calDB.MgrCalibreDB(pathFile)
db.init()
listBooks = db.GetBookListforUI_ArcList()
for book in listBooks:
item.setData(Qt.UserRole, book[1])
self.list_ArcList.addItem(book[0])
# 이미지 파일이 들어있다면...
if fileExt.lower() in [".jpg", ".webp", ".jpeg", ".png", ".gif"]:
@@ -205,6 +215,7 @@ class MyApp(QMainWindow):
for item in items:
pathTarget = item.data(Qt.UserRole)
print(f"arc : {pathTarget}")
if False == os.path.exists(pathTarget):
return