implement deletion of entries
这个提交包含在:
		@@ -295,6 +295,16 @@ void EntryProvider::saveUserEntry(const EntryConfig &config)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool EntryProvider::deleteUserEntry(const EntryConfig &config)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if(!config.userEntry || config.entryPath.isEmpty())
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							throw std::runtime_error("Only user entries can be saved");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						QFile file { config.entryPath };
 | 
				
			||||||
 | 
						return file.remove();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <class T> void assignIfDestDefault(T &dest, const T &source)
 | 
					template <class T> void assignIfDestDefault(T &dest, const T &source)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if(dest == T())
 | 
						if(dest == T())
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,6 +50,7 @@ class EntryProvider
 | 
				
			|||||||
	QVector<EntryConfig> getUserEntries();
 | 
						QVector<EntryConfig> getUserEntries();
 | 
				
			||||||
	QVector<EntryConfig> getSystemEntries();
 | 
						QVector<EntryConfig> getSystemEntries();
 | 
				
			||||||
	void saveUserEntry(const EntryConfig &config);
 | 
						void saveUserEntry(const EntryConfig &config);
 | 
				
			||||||
 | 
						bool deleteUserEntry(const EntryConfig &config);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // ENTRYPROVIDER_H
 | 
					#endif // ENTRYPROVIDER_H
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,7 +39,7 @@ class EntryPushButton : public QPushButton
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  signals:
 | 
					  signals:
 | 
				
			||||||
	void clicked(const EntryConfig &config);
 | 
						void clicked(const EntryConfig &config);
 | 
				
			||||||
	void deleteRequested(const EntryConfig &config);
 | 
						void deleteRequested(EntryConfig &config);
 | 
				
			||||||
	void addToFavourites(const EntryConfig &config);
 | 
						void addToFavourites(const EntryConfig &config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  protected:
 | 
					  protected:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -147,6 +147,12 @@ void Window::addToFavourites(const EntryPushButton &button)
 | 
				
			|||||||
	userEntryButtons.append(createEntryButton(userConfig));
 | 
						userEntryButtons.append(createEntryButton(userConfig));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Window::deleteEntry(EntryConfig &config)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						this->entryProvider->deleteUserEntry(config);
 | 
				
			||||||
 | 
						initFromConfig();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Window::closeWindow()
 | 
					void Window::closeWindow()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if(settingsProvider->singleInstanceMode())
 | 
						if(settingsProvider->singleInstanceMode())
 | 
				
			||||||
@@ -422,6 +428,7 @@ EntryPushButton *Window::createEntryButton(const EntryConfig &entry)
 | 
				
			|||||||
	EntryPushButton *button = new EntryPushButton(entry);
 | 
						EntryPushButton *button = new EntryPushButton(entry);
 | 
				
			||||||
	connect(button, &EntryPushButton::clicked, this, &Window::buttonClick);
 | 
						connect(button, &EntryPushButton::clicked, this, &Window::buttonClick);
 | 
				
			||||||
	connect(button, &EntryPushButton::addToFavourites, this, &Window::addToFavourites);
 | 
						connect(button, &EntryPushButton::addToFavourites, this, &Window::addToFavourites);
 | 
				
			||||||
 | 
						connect(button, &EntryPushButton::deleteRequested, this, &Window::deleteEntry);
 | 
				
			||||||
	return button;
 | 
						return button;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								window.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								window.h
									
									
									
									
									
								
							@@ -65,6 +65,7 @@ class Window : public QWidget
 | 
				
			|||||||
	void keyPressEvent(QKeyEvent *event);
 | 
						void keyPressEvent(QKeyEvent *event);
 | 
				
			||||||
	void buttonClick(const EntryPushButton &button);
 | 
						void buttonClick(const EntryPushButton &button);
 | 
				
			||||||
	void addToFavourites(const EntryPushButton &button);
 | 
						void addToFavourites(const EntryPushButton &button);
 | 
				
			||||||
 | 
						void deleteEntry(EntryConfig &config);
 | 
				
			||||||
	QLineEdit *lineEdit;
 | 
						QLineEdit *lineEdit;
 | 
				
			||||||
	QGridLayout *grid;
 | 
						QGridLayout *grid;
 | 
				
			||||||
	EntryPushButton *createEntryButton(const EntryConfig &config);
 | 
						EntryPushButton *createEntryButton(const EntryConfig &config);
 | 
				
			||||||
 
 | 
				
			|||||||
		在新工单中引用
	
	屏蔽一个用户