Confronta commit
	
		
			3 Commit
		
	
	
		
			42e9ac5f41
			...
			1b1ab2387e
		
	
	| Autore | SHA1 | Data | |
|---|---|---|---|
| 1b1ab2387e | |||
| 49a1a14009 | |||
| 48ca25abe3 | 
| @@ -23,16 +23,6 @@ class MainWindow : public QMainWindow | |||||||
| { | { | ||||||
| 	Q_OBJECT | 	Q_OBJECT | ||||||
|  |  | ||||||
|   public: |  | ||||||
| 	explicit MainWindow(QWidget *parent, QString socketPath); |  | ||||||
| 	~MainWindow(); |  | ||||||
|   signals: |  | ||||||
| 	void beginSearch(const QString &query); |  | ||||||
| 	void startPdfPreviewGeneration(QVector<SearchResult> paths, double scalefactor); |  | ||||||
|  |  | ||||||
|   protected: |  | ||||||
| 	void closeEvent(QCloseEvent *event) override; |  | ||||||
|  |  | ||||||
|   private: |   private: | ||||||
| 	DatabaseFactory *dbFactory; | 	DatabaseFactory *dbFactory; | ||||||
| 	SqliteDbService *dbService; | 	SqliteDbService *dbService; | ||||||
| @@ -40,40 +30,39 @@ class MainWindow : public QMainWindow | |||||||
| 	IPCPreviewClient ipcPreviewClient; | 	IPCPreviewClient ipcPreviewClient; | ||||||
| 	QThread ipcClientThread; | 	QThread ipcClientThread; | ||||||
| 	QThread syncerThread; | 	QThread syncerThread; | ||||||
|  | 	Indexer *indexer; | ||||||
| 	IndexSyncer *indexSyncer; | 	IndexSyncer *indexSyncer; | ||||||
| 	QProgressDialog progressDialog; | 	QProgressDialog progressDialog; | ||||||
|  |  | ||||||
| 	Indexer *indexer; |  | ||||||
| 	QFileIconProvider iconProvider; | 	QFileIconProvider iconProvider; | ||||||
| 	bool previewDirty; |  | ||||||
| 	QSqlDatabase db; | 	QSqlDatabase db; | ||||||
| 	QFutureWatcher<QVector<SearchResult>> searchWatcher; | 	QFutureWatcher<QVector<SearchResult>> searchWatcher; | ||||||
| 	void add(QString path, unsigned int page); |  | ||||||
| 	QVector<SearchResult> previewableSearchResults; | 	QVector<SearchResult> previewableSearchResults; | ||||||
| 	void connectSignals(); |  | ||||||
| 	void makePreviews(int page); |  | ||||||
| 	bool previewTabActive(); |  | ||||||
| 	bool indexerTabActive(); |  | ||||||
| 	void keyPressEvent(QKeyEvent *event) override; |  | ||||||
| 	unsigned int processedPdfPreviews; |  | ||||||
| 	void handleSearchResults(const QVector<SearchResult> &results); |  | ||||||
| 	void handleSearchError(QString error); |  | ||||||
| 	LooqsQuery contentSearchQuery; | 	LooqsQuery contentSearchQuery; | ||||||
| 	int previewsPerPage; |  | ||||||
| 	void createSearchResutlMenu(QMenu &menu, const QFileInfo &fileInfo); |  | ||||||
| 	void openDocument(QString path, int num); |  | ||||||
| 	void openFile(QString path); |  | ||||||
| 	unsigned int currentPreviewGeneration = 1; |  | ||||||
| 	void initSettingsTabs(); |  | ||||||
| 	int currentSelectedScale(); |  | ||||||
| 	void processShortcut(int key); |  | ||||||
| 	bool eventFilter(QObject *object, QEvent *event); |  | ||||||
| 	QVector<QString> searchHistory; | 	QVector<QString> searchHistory; | ||||||
| 	int currentSearchHistoryIndex = 0; | 	int currentSearchHistoryIndex = 0; | ||||||
| 	QString currentSavedSearchText; | 	QString currentSavedSearchText; | ||||||
| 	QHash<QString, int> previewOrder; /* Quick lookup for the order a preview should have */ | 	QHash<QString, int> previewOrder; /* Quick lookup for the order a preview should have */ | ||||||
| 	QMap<int, QWidget *> | 	QMap<int, QWidget *> | ||||||
| 		previewWidgetOrderCache /* Saves those that arrived out of order to be inserted later at the correct pos */; | 		previewWidgetOrderCache /* Saves those that arrived out of order to be inserted later at the correct pos */; | ||||||
|  | 	bool previewDirty; | ||||||
|  | 	int previewsPerPage; | ||||||
|  | 	unsigned int processedPdfPreviews; | ||||||
|  | 	unsigned int currentPreviewGeneration = 1; | ||||||
|  |  | ||||||
|  | 	void connectSignals(); | ||||||
|  | 	void makePreviews(int page); | ||||||
|  | 	bool previewTabActive(); | ||||||
|  | 	bool indexerTabActive(); | ||||||
|  | 	void keyPressEvent(QKeyEvent *event) override; | ||||||
|  | 	void handleSearchResults(const QVector<SearchResult> &results); | ||||||
|  | 	void handleSearchError(QString error); | ||||||
|  | 	void createSearchResutlMenu(QMenu &menu, const QFileInfo &fileInfo); | ||||||
|  | 	void openDocument(QString path, int num); | ||||||
|  | 	void openFile(QString path); | ||||||
|  | 	void initSettingsTabs(); | ||||||
|  | 	int currentSelectedScale(); | ||||||
|  | 	void processShortcut(int key); | ||||||
|  | 	bool eventFilter(QObject *object, QEvent *event); | ||||||
|  |  | ||||||
|   private slots: |   private slots: | ||||||
| 	void lineEditReturnPressed(); | 	void lineEditReturnPressed(); | ||||||
| @@ -94,6 +83,16 @@ class MainWindow : public QMainWindow | |||||||
| 	void startIpcPreviews(RenderConfig config, const QVector<RenderTarget> &targets); | 	void startIpcPreviews(RenderConfig config, const QVector<RenderTarget> &targets); | ||||||
| 	void stopIpcPreviews(); | 	void stopIpcPreviews(); | ||||||
| 	void beginIndexSync(); | 	void beginIndexSync(); | ||||||
|  |  | ||||||
|  |   public: | ||||||
|  | 	explicit MainWindow(QWidget *parent, QString socketPath); | ||||||
|  | 	~MainWindow(); | ||||||
|  |   signals: | ||||||
|  | 	void beginSearch(const QString &query); | ||||||
|  | 	void startPdfPreviewGeneration(QVector<SearchResult> paths, double scalefactor); | ||||||
|  |  | ||||||
|  |   protected: | ||||||
|  | 	void closeEvent(QCloseEvent *event) override; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #endif // MAINWINDOW_H | #endif // MAINWINDOW_H | ||||||
|   | |||||||
| @@ -1,20 +1,24 @@ | |||||||
| #include "../shared/common.h" | #include "../shared/common.h" | ||||||
| #include "previewgenerator.h" | #include "previewgenerator.h" | ||||||
|  | #include <QMutexLocker> | ||||||
| #include "previewgeneratorpdf.h" | #include "previewgeneratorpdf.h" | ||||||
| #include "previewgeneratorplaintext.h" | #include "previewgeneratorplaintext.h" | ||||||
| #include "previewgeneratorodt.h" | #include "previewgeneratorodt.h" | ||||||
|  |  | ||||||
| static PreviewGenerator *plainTextGenerator = new PreviewGeneratorPlainText(); | static PreviewGenerator *plainTextGenerator = new PreviewGeneratorPlainText(); | ||||||
|  |  | ||||||
| static QMap<QString, PreviewGenerator *> generators{ | static QHash<QString, PreviewGenerator *> generators{ | ||||||
| 	{"pdf", new PreviewGeneratorPdf()}, {"txt", plainTextGenerator},  {"md", plainTextGenerator}, | 	{"pdf", new PreviewGeneratorPdf()}, {"txt", plainTextGenerator},  {"md", plainTextGenerator}, | ||||||
| 	{"py", plainTextGenerator},			{"java", plainTextGenerator}, {"js", plainTextGenerator}, | 	{"py", plainTextGenerator},			{"java", plainTextGenerator}, {"js", plainTextGenerator}, | ||||||
| 	{"cpp", plainTextGenerator},		{"c", plainTextGenerator},	  {"sql", plainTextGenerator}, | 	{"cpp", plainTextGenerator},		{"c", plainTextGenerator},	  {"sql", plainTextGenerator}, | ||||||
| 	{"odt", new PreviewGeneratorOdt()}}; | 	{"odt", new PreviewGeneratorOdt()}}; | ||||||
|  |  | ||||||
|  | static QMutex generatorsMutex; | ||||||
| PreviewGenerator *PreviewGenerator::get(QFileInfo &info) | PreviewGenerator *PreviewGenerator::get(QFileInfo &info) | ||||||
| { | { | ||||||
|  | 	QMutexLocker locker(&generatorsMutex); | ||||||
| 	PreviewGenerator *result = generators.value(info.suffix(), nullptr); | 	PreviewGenerator *result = generators.value(info.suffix(), nullptr); | ||||||
|  | 	locker.unlock(); | ||||||
| 	if(result == nullptr) | 	if(result == nullptr) | ||||||
| 	{ | 	{ | ||||||
| 		if(Common::isTextFile(info)) | 		if(Common::isTextFile(info)) | ||||||
|   | |||||||
| @@ -7,10 +7,12 @@ static QMutex cacheMutex; | |||||||
|  |  | ||||||
| Poppler::Document *PreviewGeneratorPdf::document(QString path) | Poppler::Document *PreviewGeneratorPdf::document(QString path) | ||||||
| { | { | ||||||
|  | 	QMutexLocker locker(&cacheMutex); | ||||||
| 	if(documentcache.contains(path)) | 	if(documentcache.contains(path)) | ||||||
| 	{ | 	{ | ||||||
| 		return documentcache.value(path); | 		return documentcache.value(path); | ||||||
| 	} | 	} | ||||||
|  | 	locker.unlock(); | ||||||
| 	Poppler::Document *result = Poppler::Document::load(path); | 	Poppler::Document *result = Poppler::Document::load(path); | ||||||
| 	if(result == nullptr) | 	if(result == nullptr) | ||||||
| 	{ | 	{ | ||||||
| @@ -19,7 +21,7 @@ Poppler::Document *PreviewGeneratorPdf::document(QString path) | |||||||
| 	} | 	} | ||||||
| 	result->setRenderHint(Poppler::Document::TextAntialiasing); | 	result->setRenderHint(Poppler::Document::TextAntialiasing); | ||||||
|  |  | ||||||
| 	QMutexLocker locker(&cacheMutex); | 	locker.relock(); | ||||||
| 	documentcache.insert(path, result); | 	documentcache.insert(path, result); | ||||||
| 	locker.unlock(); | 	locker.unlock(); | ||||||
| 	return result; | 	return result; | ||||||
|   | |||||||
		Fai riferimento in un nuovo problema
	
	Block a user