Skip to content

Commit

Permalink
refactor: fix a lot of diagnostic warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
KorigamiK committed Dec 29, 2024
1 parent 82d807a commit c588b28
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 98 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ qt_add_executable(sioyek WIN32 MACOSX_BUNDLE
pdf_viewer/utils.cpp pdf_viewer/utils.h
)

target_compile_options(sioyek PRIVATE -Wno-inconsistent-missing-override)

target_include_directories(sioyek PRIVATE
pdf_viewer
${SQLite3_INCLUDE_DIRS}
Expand Down
4 changes: 2 additions & 2 deletions pdf_viewer/database.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "database.h";
#include "database.h"
#include <sstream>
#include <cassert>
#include <utility>
Expand Down Expand Up @@ -1880,7 +1880,7 @@ std::wstring encode_variant(QVariant var) {


std::vector<QString> specials = { "CURRENT_TIMESTAMP", "datetime('now')" };
if ((var.type() == QVariant::String) || (var.type() == QVariant::Char)) {
if ((var.typeId() == QMetaType::QString) || (var.typeId() == QMetaType::Char)) {
if (std::find(specials.begin(), specials.end(), var.toString()) != specials.end()) {
return var.toString().toStdWString();
}
Expand Down
10 changes: 5 additions & 5 deletions pdf_viewer/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ std::optional<std::pair<std::wstring, std::wstring>> Document::get_generic_link_
std::pair<int,
int>* out_range) {

std::wregex regex(L"[a-zA-Z]{3,}(\.){0,1}[ \t]+[0-9]+(\.[0-9]+)*");
std::wregex regex(L"[a-zA-Z]{3,}(\\.){0,1}[ \t]+[0-9]+(\\.[0-9]+)*");
std::optional<std::wstring> match_string = get_regex_match_at_position(regex, flat_chars, position, out_range);
if (match_string) {
std::vector<std::wstring> parts = split_whitespace(match_string.value());
Expand Down Expand Up @@ -1985,7 +1985,7 @@ void Document::get_text_selection(fz_context* ctx, AbsoluteDocumentPos selection
selected_text.push_back(current_char->c);
selected_characters.push_back(to_absolute(i, current_char->quad));
}
if ((current_char->next == nullptr)) {
if (current_char->next == nullptr) {
if (current_char->c != '-')
{
selected_text.push_back(' ');
Expand Down Expand Up @@ -2843,7 +2843,7 @@ const std::vector<AbsoluteRect>& Document::get_page_lines(
}
else {
fz_pixmap* pixmap = get_small_pixmap(page);
if (pixmap == nullptr) return {};
if (pixmap == nullptr) return std::vector<AbsoluteRect>();
std::vector<unsigned int> hist = get_max_width_histogram_from_pixmap(pixmap);
std::vector<unsigned int> line_locations;
std::vector<unsigned int> line_locations_begins;
Expand Down Expand Up @@ -4040,7 +4040,7 @@ std::optional<DocumentPos> Document::find_abbreviation(std::wstring abbr, std::v

int Document::find_reference_page_with_reference_text(std::wstring ref) {

QStringList parts = QString::fromStdWString(ref).split(QRegularExpression("[ \w\(\);,]"));
QStringList parts = QString::fromStdWString(ref).split(QRegularExpression("[ \\w\\(\\);,]"));
QString largest_part = "";
for (int i = 0; i < parts.size(); i++) {
if (parts.at(i).size() > largest_part.size() ) {
Expand Down Expand Up @@ -4250,7 +4250,7 @@ int Document::get_page_text_and_line_rects_after_rect(int page_number,
line_rects.push_back(line->bbox);
char_rects.push_back(fz_rect_from_quad(chr->quad));

if ((chr->next == nullptr)) {
if (chr->next == nullptr) {
text.push_back(' ');

line_rects.push_back(line->bbox);
Expand Down
4 changes: 3 additions & 1 deletion pdf_viewer/document_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ NormalizedWindowPos DocumentView::document_to_window_pos(DocumentPos doc_pos) {
float window_y = static_cast<float>((window_pos.y - halfheight) / halfheight);
return { window_x, -window_y };
}

return { 0, 0 };
}

WindowPos DocumentView::absolute_to_window_pos_in_pixels(AbsoluteDocumentPos abspos) {
Expand Down Expand Up @@ -1337,7 +1339,7 @@ std::vector<SmartViewCandidate> DocumentView::find_line_definitions() {
return result;
}

std::wstring item_regex(L"[a-zA-Z]{2,}\\.?[ \t]+[0-9]+(\.[0-9]+)*");
std::wstring item_regex(L"[a-zA-Z]{2,}\\.?[ \t]+[0-9]+(\\.?[0-9]+)*");
std::wstring reference_regex(L"\\[[a-zA-Z0-9, ]+\\]");
std::wstring equation_regex(L"\\([0-9]+(\\.[0-9]+)*\\)");

Expand Down
Loading

0 comments on commit c588b28

Please sign in to comment.