مقایسه کامیتها
	
		
			3 کامیتها
		
	
	
		
			42e9ac5f41
			...
			1b1ab2387e
		
	
	| مولف | SHA1 | تاریخ | |
|---|---|---|---|
| 1b1ab2387e | |||
| 49a1a14009 | |||
| 48ca25abe3 | 
| @@ -23,16 +23,6 @@ class MainWindow : public QMainWindow | ||||
| { | ||||
| 	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: | ||||
| 	DatabaseFactory *dbFactory; | ||||
| 	SqliteDbService *dbService; | ||||
| @@ -40,40 +30,39 @@ class MainWindow : public QMainWindow | ||||
| 	IPCPreviewClient ipcPreviewClient; | ||||
| 	QThread ipcClientThread; | ||||
| 	QThread syncerThread; | ||||
| 	Indexer *indexer; | ||||
| 	IndexSyncer *indexSyncer; | ||||
| 	QProgressDialog progressDialog; | ||||
|  | ||||
| 	Indexer *indexer; | ||||
| 	QFileIconProvider iconProvider; | ||||
| 	bool previewDirty; | ||||
| 	QSqlDatabase db; | ||||
| 	QFutureWatcher<QVector<SearchResult>> searchWatcher; | ||||
| 	void add(QString path, unsigned int page); | ||||
| 	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; | ||||
| 	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; | ||||
| 	int currentSearchHistoryIndex = 0; | ||||
| 	QString currentSavedSearchText; | ||||
| 	QHash<QString, int> previewOrder; /* Quick lookup for the order a preview should have */ | ||||
| 	QMap<int, QWidget *> | ||||
| 		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: | ||||
| 	void lineEditReturnPressed(); | ||||
| @@ -94,6 +83,16 @@ class MainWindow : public QMainWindow | ||||
| 	void startIpcPreviews(RenderConfig config, const QVector<RenderTarget> &targets); | ||||
| 	void stopIpcPreviews(); | ||||
| 	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 | ||||
|   | ||||
| @@ -1,20 +1,24 @@ | ||||
| #include "../shared/common.h" | ||||
| #include "previewgenerator.h" | ||||
| #include <QMutexLocker> | ||||
| #include "previewgeneratorpdf.h" | ||||
| #include "previewgeneratorplaintext.h" | ||||
| #include "previewgeneratorodt.h" | ||||
|  | ||||
| static PreviewGenerator *plainTextGenerator = new PreviewGeneratorPlainText(); | ||||
|  | ||||
| static QMap<QString, PreviewGenerator *> generators{ | ||||
| static QHash<QString, PreviewGenerator *> generators{ | ||||
| 	{"pdf", new PreviewGeneratorPdf()}, {"txt", plainTextGenerator},  {"md", plainTextGenerator}, | ||||
| 	{"py", plainTextGenerator},			{"java", plainTextGenerator}, {"js", plainTextGenerator}, | ||||
| 	{"cpp", plainTextGenerator},		{"c", plainTextGenerator},	  {"sql", plainTextGenerator}, | ||||
| 	{"odt", new PreviewGeneratorOdt()}}; | ||||
|  | ||||
| static QMutex generatorsMutex; | ||||
| PreviewGenerator *PreviewGenerator::get(QFileInfo &info) | ||||
| { | ||||
| 	QMutexLocker locker(&generatorsMutex); | ||||
| 	PreviewGenerator *result = generators.value(info.suffix(), nullptr); | ||||
| 	locker.unlock(); | ||||
| 	if(result == nullptr) | ||||
| 	{ | ||||
| 		if(Common::isTextFile(info)) | ||||
|   | ||||
| @@ -7,10 +7,12 @@ static QMutex cacheMutex; | ||||
|  | ||||
| Poppler::Document *PreviewGeneratorPdf::document(QString path) | ||||
| { | ||||
| 	QMutexLocker locker(&cacheMutex); | ||||
| 	if(documentcache.contains(path)) | ||||
| 	{ | ||||
| 		return documentcache.value(path); | ||||
| 	} | ||||
| 	locker.unlock(); | ||||
| 	Poppler::Document *result = Poppler::Document::load(path); | ||||
| 	if(result == nullptr) | ||||
| 	{ | ||||
| @@ -19,7 +21,7 @@ Poppler::Document *PreviewGeneratorPdf::document(QString path) | ||||
| 	} | ||||
| 	result->setRenderHint(Poppler::Document::TextAntialiasing); | ||||
|  | ||||
| 	QMutexLocker locker(&cacheMutex); | ||||
| 	locker.relock(); | ||||
| 	documentcache.insert(path, result); | ||||
| 	locker.unlock(); | ||||
| 	return result; | ||||
|   | ||||
		مرجع در شماره جدید
	
	Block a user