|
|
@ -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):
|
|
|
|