Сравнить коммиты

..

Нет общих коммитов. «43a0f085796d78ffa10c74e6858a99747e78e0b8» и «4ce14a7284f7c0e1a436518a44c7390564223a38» имеют совершенно разные истории.

13 изменённых файлов: 56 добавлений и 173 удалений

Просмотреть файл

@ -36,11 +36,9 @@ SOURCES += \
clicklabel.cpp \
previewgenerator.cpp \
previewgeneratormapfunctor.cpp \
previewgeneratorodt.cpp \
previewgeneratorpdf.cpp \
previewgeneratorplaintext.cpp \
previewresult.cpp \
previewresultodt.cpp \
previewresultpdf.cpp \
previewresultplaintext.cpp \
renderconfig.cpp \
@ -56,11 +54,9 @@ HEADERS += \
clicklabel.h \
previewgenerator.h \
previewgeneratormapfunctor.h \
previewgeneratorodt.h \
previewgeneratorpdf.h \
previewgeneratorplaintext.h \
previewresult.h \
previewresultodt.h \
previewresultpdf.h \
previewresultplaintext.h \
renderconfig.h \
@ -70,7 +66,6 @@ FORMS += \
mainwindow.ui
INCLUDEPATH += /usr/include/poppler/qt5/
INCLUDEPATH += /usr/include/quazip5
QT += widgets sql

Просмотреть файл

@ -33,6 +33,28 @@ MainWindow::MainWindow(QWidget *parent, QString socketPath)
setWindowTitle(QCoreApplication::applicationName());
this->ipcPreviewClient.moveToThread(&this->ipcClientThread);
this->ipcPreviewClient.setSocketPath(socketPath);
connect(&ipcPreviewClient, &IPCPreviewClient::previewReceived, this, &MainWindow::previewReceived,
Qt::QueuedConnection);
connect(&ipcPreviewClient, &IPCPreviewClient::finished, this,
[&]
{
this->ui->previewProcessBar->setValue(this->ui->previewProcessBar->maximum());
this->ui->spinPreviewPage->setEnabled(true);
this->ui->comboPreviewFiles->setEnabled(true);
});
connect(&ipcPreviewClient, &IPCPreviewClient::error, this,
[this](QString msg)
{
qCritical() << msg << Qt::endl;
QMessageBox::critical(this, "IPC error", msg);
});
connect(this, &MainWindow::startIpcPreviews, &ipcPreviewClient, &IPCPreviewClient::startGeneration,
Qt::QueuedConnection);
connect(this, &MainWindow::stopIpcPreviews, &ipcPreviewClient, &IPCPreviewClient::stopGeneration,
Qt::QueuedConnection);
this->ipcClientThread.start();
QSettings settings;
this->dbFactory = new DatabaseFactory(Common::databasePath());
@ -69,8 +91,6 @@ MainWindow::MainWindow(QWidget *parent, QString socketPath)
auto policy = ui->btnOpenFailed->sizePolicy();
policy.setRetainSizeWhenHidden(true);
ui->btnOpenFailed->setSizePolicy(policy);
this->ipcClientThread.start();
}
void MainWindow::addPathToIndex()
@ -171,9 +191,6 @@ void MainWindow::connectSignals()
connect(ui->menuAboutQtAction, &QAction::triggered, this,
[this](bool checked) { QMessageBox::aboutQt(this, "About Qt"); });
connect(ui->menuSyncIndexAction, &QAction::triggered, this, &MainWindow::startIndexSync);
connect(ui->menuOpenUserManualAction, &QAction::triggered, this,
[this]() { QDesktopServices::openUrl(Common::userManualUrl()); });
connect(indexSyncer, &IndexSyncer::finished, this,
[&](unsigned int totalUpdated, unsigned int totalDeleted, unsigned int totalErrored)
{
@ -193,26 +210,6 @@ void MainWindow::connectSignals()
connect(
ui->comboPreviewFiles, qOverload<int>(&QComboBox::currentIndexChanged), this, [&]() { makePreviews(1); },
Qt::QueuedConnection);
connect(&ipcPreviewClient, &IPCPreviewClient::previewReceived, this, &MainWindow::previewReceived,
Qt::QueuedConnection);
connect(&ipcPreviewClient, &IPCPreviewClient::finished, this,
[&]
{
this->ui->previewProcessBar->setValue(this->ui->previewProcessBar->maximum());
this->ui->spinPreviewPage->setEnabled(true);
this->ui->comboPreviewFiles->setEnabled(true);
});
connect(&ipcPreviewClient, &IPCPreviewClient::error, this,
[this](QString msg)
{
qCritical() << msg << Qt::endl;
QMessageBox::critical(this, "IPC error", msg);
});
connect(this, &MainWindow::startIpcPreviews, &ipcPreviewClient, &IPCPreviewClient::startGeneration,
Qt::QueuedConnection);
connect(this, &MainWindow::stopIpcPreviews, &ipcPreviewClient, &IPCPreviewClient::stopGeneration,
Qt::QueuedConnection);
}
void MainWindow::exportFailedPaths()
@ -439,46 +436,19 @@ void MainWindow::previewReceived(QSharedPointer<PreviewResult> preview, unsigned
QString docPath = preview->getDocumentPath();
auto previewPage = preview->getPage();
ClickLabel *headerLabel = new ClickLabel();
headerLabel->setText(QString("Path: ") + preview->getDocumentPath());
ClickLabel *label = dynamic_cast<ClickLabel *>(preview->createPreviewWidget());
QVBoxLayout *previewLayout = new QVBoxLayout();
QFont font = label->font();
font.setPointSize(QApplication::font().pointSize() * currentSelectedScale() / 100);
label->setFont(font);
headerLabel->setFont(font);
auto leftClickHandler = [this, docPath, previewPage]() { openDocument(docPath, previewPage); };
auto rightClickhandler = [this, docPath, previewPage]()
{
QFileInfo fileInfo{docPath};
QMenu menu("labeRightClick", this);
createSearchResutlMenu(menu, fileInfo);
menu.addAction("Copy page number",
[previewPage] { QGuiApplication::clipboard()->setText(QString::number(previewPage)); });
menu.exec(QCursor::pos());
};
connect(label, &ClickLabel::leftClick, leftClickHandler);
connect(label, &ClickLabel::rightClick, rightClickhandler);
connect(headerLabel, &ClickLabel::rightClick, rightClickhandler);
previewLayout->addWidget(label);
previewLayout->addWidget(headerLabel);
previewLayout->setMargin(0);
previewLayout->insertStretch(0, 1);
previewLayout->insertStretch(-1, 1);
QWidget *previewWidget = new QWidget();
previewWidget->setLayout(previewLayout);
ui->scrollAreaWidgetContents->layout()->addWidget(previewWidget);
ui->scrollAreaWidgetContents->layout()->addWidget(label);
connect(label, &ClickLabel::leftClick, [this, docPath, previewPage]() { openDocument(docPath, previewPage); });
connect(label, &ClickLabel::rightClick,
[this, docPath, previewPage]()
{
QFileInfo fileInfo{docPath};
QMenu menu("labeRightClick", this);
createSearchResutlMenu(menu, fileInfo);
menu.addAction("Copy page number", [previewPage]
{ QGuiApplication::clipboard()->setText(QString::number(previewPage)); });
menu.exec(QCursor::pos());
});
}
}
@ -597,13 +567,6 @@ void MainWindow::handleSearchResults(const QVector<SearchResult> &results)
ui->lblSearchResults->setText(statusText);
}
int MainWindow::currentSelectedScale()
{
QString scaleText = ui->comboScale->currentText();
scaleText.chop(1);
return scaleText.toInt();
}
void MainWindow::makePreviews(int page)
{
if(this->previewableSearchResults.empty())
@ -615,6 +578,8 @@ void MainWindow::makePreviews(int page)
ui->scrollAreaWidgetContents->setLayout(new QHBoxLayout());
ui->previewProcessBar->setMaximum(this->previewableSearchResults.size());
processedPdfPreviews = 0;
QString scaleText = ui->comboScale->currentText();
scaleText.chop(1);
QVector<QString> wordsToHighlight;
QRegularExpression extractor(R"#("([^"]*)"|((\p{L}|\p{N})+))#");
@ -643,10 +608,9 @@ void MainWindow::makePreviews(int page)
begin = 0;
}
int currentScale = currentSelectedScale();
RenderConfig renderConfig;
renderConfig.scaleX = QGuiApplication::primaryScreen()->physicalDotsPerInchX() * (currentScale / 100.);
renderConfig.scaleY = QGuiApplication::primaryScreen()->physicalDotsPerInchY() * (currentScale / 100.);
renderConfig.scaleX = QGuiApplication::primaryScreen()->physicalDotsPerInchX() * (scaleText.toInt() / 100.);
renderConfig.scaleY = QGuiApplication::primaryScreen()->physicalDotsPerInchY() * (scaleText.toInt() / 100.);
renderConfig.wordsToHighlight = wordsToHighlight;
QVector<RenderTarget> targets;

Просмотреть файл

@ -62,7 +62,6 @@ class MainWindow : public QMainWindow
void openFile(QString path);
unsigned int currentPreviewGeneration = 1;
void initSettingsTabs();
int currentSelectedScale();
private slots:
void lineEditReturnPressed();
void treeSearchItemActivated(QTreeWidgetItem *item, int i);

Просмотреть файл

@ -626,7 +626,6 @@
<string>looqs</string>
</property>
<addaction name="menuSyncIndexAction"/>
<addaction name="menuOpenUserManualAction"/>
<addaction name="menuAboutAction"/>
<addaction name="menuAboutQtAction"/>
<addaction name="separator"/>
@ -648,11 +647,6 @@
<string>Sync index (remove deleted, update existing files)</string>
</property>
</action>
<action name="menuOpenUserManualAction">
<property name="text">
<string>Open user manual</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>

Просмотреть файл

@ -2,15 +2,13 @@
#include "previewgenerator.h"
#include "previewgeneratorpdf.h"
#include "previewgeneratorplaintext.h"
#include "previewgeneratorodt.h"
static PreviewGenerator *plainTextGenerator = new PreviewGeneratorPlainText();
static QMap<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()}};
{"cpp", plainTextGenerator}, {"c", plainTextGenerator}, {"sql", plainTextGenerator}};
PreviewGenerator *PreviewGenerator::get(QFileInfo &info)
{

Просмотреть файл

@ -1,32 +0,0 @@
#include <quazip.h>
#include <quazipfile.h>
#include "previewgeneratorplaintext.h"
#include "previewgeneratorodt.h"
#include "previewresultodt.h"
#include "../shared/tagstripperprocessor.h"
QSharedPointer<PreviewResult> PreviewGeneratorOdt::generate(RenderConfig config, QString documentPath,
unsigned int page)
{
PreviewResultOdt *result = new PreviewResultOdt(documentPath, page);
QFileInfo info{documentPath};
QuaZipFile zipFile(documentPath);
zipFile.setFileName("content.xml");
if(!zipFile.open(QIODevice::ReadOnly))
{
return QSharedPointer<PreviewResult>(result);
}
QByteArray entireContent = zipFile.readAll();
if(entireContent.isEmpty())
{
throw LooqsGeneralException("Error while reading content.xml of " + documentPath);
}
TagStripperProcessor tsp;
QString content = tsp.process(entireContent).first().content;
PreviewGeneratorPlainText plainTextGenerator;
result->setText(plainTextGenerator.generatePreviewText(content, config, info.fileName()));
return QSharedPointer<PreviewResult>(result);
}

Просмотреть файл

@ -1,12 +0,0 @@
#ifndef PREVIEWGENERATORODT_H
#define PREVIEWGENERATORODT_H
#include "previewgenerator.h"
class PreviewGeneratorOdt : public PreviewGenerator
{
public:
using PreviewGenerator::PreviewGenerator;
QSharedPointer<PreviewResult> generate(RenderConfig config, QString documentPath, unsigned int page);
};
#endif // PREVIEWGENERATORODT_H

Просмотреть файл

@ -3,15 +3,24 @@
#include "previewgeneratorplaintext.h"
#include "previewresultplaintext.h"
QString PreviewGeneratorPlainText::generatePreviewText(QString content, RenderConfig config, QString fileName)
QSharedPointer<PreviewResult> PreviewGeneratorPlainText::generate(RenderConfig config, QString documentPath,
unsigned int page)
{
QString resulText = "";
PreviewResultPlainText *result = new PreviewResultPlainText(documentPath, page);
QFile file(documentPath);
if(!file.open(QFile::ReadOnly | QFile::Text))
{
return QSharedPointer<PreviewResultPlainText>(result);
}
QTextStream in(&file);
QString resulText = "";
QString content = in.readAll();
QMap<int, QString> snippet;
int coveredRange = -1;
int lastWordPos = -1;
int coveredRange = 0;
int lastWordPos = 0;
QHash<QString, int> countmap;
const unsigned int maxSnippets = 7;
@ -62,7 +71,9 @@ QString PreviewGeneratorPlainText::generatePreviewText(QString content, RenderCo
resulText.replace(word, "<span style=\"background-color: yellow;\">" + word + "</span>", Qt::CaseInsensitive);
}
QString header = "<b>" + fileName + "</b> ";
QFileInfo info{documentPath};
QString header = "<b>" + info.fileName() + "</b> ";
for(QString &word : config.wordsToHighlight)
{
header += word + ": " + QString::number(countmap[word]) + " ";
@ -74,22 +85,6 @@ QString PreviewGeneratorPlainText::generatePreviewText(QString content, RenderCo
header += "<hr>";
return header + resulText.replace("\n", "<br>").mid(0, 1000);
}
QSharedPointer<PreviewResult> PreviewGeneratorPlainText::generate(RenderConfig config, QString documentPath,
unsigned int page)
{
PreviewResultPlainText *result = new PreviewResultPlainText(documentPath, page);
QFile file(documentPath);
if(!file.open(QFile::ReadOnly | QFile::Text))
{
return QSharedPointer<PreviewResultPlainText>(result);
}
QTextStream in(&file);
QString content = in.readAll();
QFileInfo info{documentPath};
result->setText(generatePreviewText(content, config, info.fileName()));
result->setText(header + resulText.replace("\n", "<br>").mid(0, 1000));
return QSharedPointer<PreviewResultPlainText>(result);
}

Просмотреть файл

@ -6,7 +6,6 @@ class PreviewGeneratorPlainText : public PreviewGenerator
{
public:
using PreviewGenerator::PreviewGenerator;
QString generatePreviewText(QString content, RenderConfig config, QString fileName);
QSharedPointer<PreviewResult> generate(RenderConfig config, QString documentPath, unsigned int page);
};

Просмотреть файл

@ -1 +0,0 @@
#include "previewresultodt.h"

Просмотреть файл

@ -1,10 +0,0 @@
#ifndef PREVIEWRESULTODT_H
#define PREVIEWRESULTODT_H
#include "previewresultplaintext.h"
class PreviewResultOdt : public PreviewResultPlainText
{
using PreviewResultPlainText::PreviewResultPlainText;
};
#endif // PREVIEWRESULTODT_H

Просмотреть файл

@ -234,8 +234,3 @@ QString Common::versionText()
QString tag = GIT_TAG;
return tag + " (" + commitid + ") built " + __DATE__ + " " + __TIME__;
}
QString Common::userManualUrl()
{
return QString("https://github.com/quitesimpleorg/looqs/blob/%1/USAGE.md").arg(QString(GIT_COMMIT_ID));
}

Просмотреть файл

@ -25,6 +25,5 @@ bool isTextFile(QFileInfo fileInfo);
bool isMountPath(QString path);
bool noSandboxModeRequested();
QString versionText();
QString userManualUrl();
} // namespace Common
#endif