From 1c840a1e2561ee5232b56983ae479b2c7013c723 Mon Sep 17 00:00:00 2001 From: Lee Young Hoon Date: Sun, 8 Dec 2024 01:06:45 +0900 Subject: [PATCH] Update MgrCalibreDB.py and UI.py --- MgrCalibreDB.py | 45 ++++++++++++++++++++++++++++++--------------- UI.py | 19 +++++++++++++++---- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/MgrCalibreDB.py b/MgrCalibreDB.py index 39ad209..b0863a1 100644 --- a/MgrCalibreDB.py +++ b/MgrCalibreDB.py @@ -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") diff --git a/UI.py b/UI.py index 6e56ba2..f7e6d0e 100644 --- a/UI.py +++ b/UI.py @@ -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