pull/1/head v1.0.0
pinb 5 months ago
parent 2240204c5e
commit 167412bedf

@ -46,6 +46,8 @@ def update_job_in_db(old_name, new_name, folder1, folder2, interval):
cursor.execute(''' cursor.execute('''
UPDATE jobs SET name = ?, folder1 = ?, folder2 = ?, interval = ? WHERE name = ? UPDATE jobs SET name = ?, folder1 = ?, folder2 = ?, interval = ? WHERE name = ?
''', (new_name, folder1, folder2, interval, old_name)) ''', (new_name, folder1, folder2, interval, old_name))
if old_name != new_name:
cursor.execute(f'ALTER TABLE {old_name} RENAME TO {new_name};')
conn.commit() conn.commit()
conn.close() conn.close()

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 MiB

@ -8,7 +8,7 @@ class JobItem(QWidget):
self.folder1 = folder1 self.folder1 = folder1
self.folder2 = folder2 self.folder2 = folder2
self.interval = interval self.interval = interval
self.thread = JobThread(self) self.setup_thread()
self.setup_ui() self.setup_ui()
def setup_ui(self): def setup_ui(self):
@ -33,6 +33,9 @@ class JobItem(QWidget):
self.sync_button.clicked.connect(self.run_sync) self.sync_button.clicked.connect(self.run_sync)
self.thread.current_log.connect(self.update_log) self.thread.current_log.connect(self.update_log)
def setup_thread(self):
self.thread = JobThread(self)
def toggle_play(self): def toggle_play(self):
if self.thread.is_running: if self.thread.is_running:
self.thread.stop() self.thread.stop()

@ -106,7 +106,7 @@ class JobListWidget(QWidget):
list_item.setSizeHint(job_item.sizeHint()) list_item.setSizeHint(job_item.sizeHint())
self.job_list.addItem(list_item) self.job_list.addItem(list_item)
self.job_list.setItemWidget(list_item, job_item) self.job_list.setItemWidget(list_item, job_item)
self.job_list.setCurrentItem(list_item)
job_item.delete_button.clicked.connect(lambda checked, item=list_item: self.delete_job(item)) job_item.delete_button.clicked.connect(lambda checked, item=list_item: self.delete_job(item))
add_job_to_db(name, folder1, folder2, int(interval)) add_job_to_db(name, folder1, folder2, int(interval))
@ -129,9 +129,9 @@ class JobListWidget(QWidget):
self.interval_edit.setText(str(job_item.interval)) self.interval_edit.setText(str(job_item.interval))
def apply_job(self): def apply_job(self):
self.selected_items = self.job_list.selectedItems() self.selected_item = self.job_list.selectedItems()[0]
if self.selected_items: if self.selected_item:
job_item = self.job_list.itemWidget(self.selected_items[0]) job_item = self.job_list.itemWidget(self.selected_item)
old_name = job_item.name old_name = job_item.name
new_name = self.job_name_edit.text() new_name = self.job_name_edit.text()
@ -141,20 +141,24 @@ class JobListWidget(QWidget):
if new_name and folder1 and folder2 and interval: if new_name and folder1 and folder2 and interval:
# Check if new job name already exists in other jobs # Check if new job name already exists in other jobs
if old_name != new_name and any(self.job_list.itemWidget(self.job_list.item(i)).name == new_name for i in range(self.job_list.count())): item_cnt = self.job_list.count()
if old_name != new_name and any(self.job_list.itemWidget(self.job_list.item(i)).name == new_name for i in range(item_cnt)):
self.window().add_log(f"Job with name '{old_name}' already exists.", QColor('white'), QColor('red')) self.window().add_log(f"Job with name '{old_name}' already exists.", QColor('white'), QColor('red'))
return return
# Update the job item
job_item.name = new_name
job_item.folder1 = folder1
job_item.folder2 = folder2
job_item.interval = int(interval)
job_item.name_label.setText(new_name)
# Update the database # Update the database
update_job_in_db(old_name, new_name, folder1, folder2, int(interval)) update_job_in_db(old_name, new_name, folder1, folder2, int(interval))
# Update the job item
# job_item.name = new_name
# job_item.folder1 = folder1
# job_item.folder2 = folder2
# job_item.interval = int(interval)
# job_item.name_label.setText(new_name)
job_item = JobItem(new_name, folder1, folder2, int(interval))
job_item.delete_button.clicked.connect(lambda checked, item=self.selected_item: self.delete_job(item))
self.job_list.setItemWidget(self.selected_item, job_item)
self.window().add_log(f'Clicked \'Apply Job\' - ({job_item.name}) !', QColor('yellow'), QColor('green')) self.window().add_log(f'Clicked \'Apply Job\' - ({job_item.name}) !', QColor('yellow'), QColor('green'))
def load_jobs_from_db(self): def load_jobs_from_db(self):

@ -27,4 +27,4 @@ class JobThread(QThread):
def sync(self): def sync(self):
log = self.synchronizer.sync_folders() log = self.synchronizer.sync_folders()
self.current_log.emit(log, QColor("yellow"), QColor("green")) self.current_log.emit(log, QColor("white"), QColor("green"))
Loading…
Cancel
Save