changeset 3:190ded9438c0

Fix many warnings
author Paper <mrpapersonic@gmail.com>
date Sat, 12 Aug 2023 11:57:25 -0400
parents 23d0d9319a00
children 5af270662505
files CMakeLists.txt src/anilist.cpp src/anime.cpp src/dialog/information.cpp src/string_utils.cpp
diffstat 5 files changed, 27 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Sat Aug 12 03:16:26 2023 -0400
+++ b/CMakeLists.txt	Sat Aug 12 11:57:25 2023 -0400
@@ -33,4 +33,5 @@
 find_package(Qt5 COMPONENTS Widgets REQUIRED)
 find_package(CURL REQUIRED)
 target_include_directories(weeaboo PUBLIC ${Qt5Widgets_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} PRIVATE src/include src/icons)
+target_compile_options(weeaboo PRIVATE -Wall -Wextra)
 target_link_libraries(weeaboo ${Qt5Widgets_LIBRARIES} ${CURL_LIBRARIES})
--- a/src/anilist.cpp	Sat Aug 12 03:16:26 2023 -0400
+++ b/src/anilist.cpp	Sat Aug 12 11:57:25 2023 -0400
@@ -168,11 +168,9 @@
 	   if we can just get wide strings back from nlohmann::json */
 	for (const auto& list : res["data"]["MediaListCollection"]["lists"].items()) {
 		/* why are the .key() values strings?? */
-		int list_key = std::stoi(list.key());
 		AnimeList anime_list;
 		anime_list.name = StringUtils::Utf8ToWstr(JSON::GetString(list.value(), "name"));
 		for (const auto& entry : list.value()["entries"].items()) {
-			int entry_key = std::stoi(entry.key());
 			Anime anime;
 			anime.score = JSON::GetInt(entry.value(), "score");
 			anime.progress = JSON::GetInt(entry.value(), "progress");
--- a/src/anime.cpp	Sat Aug 12 03:16:26 2023 -0400
+++ b/src/anime.cpp	Sat Aug 12 11:57:25 2023 -0400
@@ -118,7 +118,7 @@
 
 AnimeList::AnimeList() {}
 AnimeList::AnimeList(const AnimeList& l) {
-	for (int i = 0; i < l.Size(); i++) {
+	for (unsigned long long i = 0; i < l.Size(); i++) {
 		anime_list.push_back(Anime(l[i]));
 	}
 	name = l.name;
@@ -138,7 +138,7 @@
 }
 
 int AnimeList::GetAnimeIndex(Anime& anime) const {
-	for (int i = 0; i < Size(); i++) {
+	for (unsigned long long i = 0; i < Size(); i++) {
 		if (&anime_list.at(i) == &anime) { // lazy
 			return i;
 		}
@@ -166,10 +166,12 @@
 
 int AnimeListWidgetModel::rowCount(const QModelIndex& parent) const {
 	return list.Size();
+	(void)(parent);
 }
 
 int AnimeListWidgetModel::columnCount(const QModelIndex& parent) const {
 	return NB_COLUMNS;
+	(void)(parent);
 }
 
 QVariant AnimeListWidgetModel::headerData(const int section, const Qt::Orientation orientation, const int role) const {
@@ -336,8 +338,7 @@
     menu->setTitle(tr("Column visibility"));
     menu->setToolTipsVisible(true);
 
-    for (int i = 0; i < AnimeListWidgetModel::NB_COLUMNS; i++)
-    {
+    for (int i = 0; i < AnimeListWidgetModel::NB_COLUMNS; i++) {
 		if (i == AnimeListWidgetModel::AL_TITLE)
 			continue;
         const auto column_name = model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString();
@@ -357,42 +358,45 @@
     }
 
     menu->addSeparator();
-    QAction *resetAction = menu->addAction(tr("Reset to defaults"), this, [this]()
-    {
+    QAction *resetAction = menu->addAction(tr("Reset to defaults"), this, [this]() {
         for (int i = 0, count = header()->count(); i < count; ++i)
         {
             SetColumnDefaults();
         }
 		// SaveSettings();
     });
-
     menu->popup(QCursor::pos());
+	(void)(resetAction);
 }
 
 void AnimeListWidget::DisplayListMenu() {
 	/* throw out any other garbage */
     const QModelIndexList selected_items = selectionModel()->selectedRows();
-    if (selected_items.size() != 1 || !selected_items.first().isValid())
+    if (selected_items.size() != 1 || !selected_items.first().isValid()) {
         return;
+	}
 
 	const QModelIndex index = model->index(selected_items.first().row());
 	Anime* anime = model->GetAnimeFromIndex(index);
-	if (!anime)
+	if (!anime) {
 		return;
+	}
 
 }
 
 void AnimeListWidget::ItemDoubleClicked() {
 	/* throw out any other garbage */
     const QModelIndexList selected_items = selectionModel()->selectedRows();
-    if (selected_items.size() != 1 || !selected_items.first().isValid())
+    if (selected_items.size() != 1 || !selected_items.first().isValid()) {
         return;
+	}
 
 	/* TODO: after we implement our sort model, we have to use mapToSource here... */
 	const QModelIndex index = model->index(selected_items.first().row());
 	Anime* anime = model->GetAnimeFromIndex(index);
-	if (!anime)
+	if (!anime) {
 		return;
+	}
 
 	InformationDialog* dialog = new InformationDialog(*anime, model, this);
 
@@ -414,19 +418,19 @@
 	setItemsExpandable(false);
 	setRootIsDecorated(false);
 	setContextMenuPolicy(Qt::CustomContextMenu);
-	connect(this, &QAbstractItemView::doubleClicked, this, &ItemDoubleClicked);
-	connect(this, &QWidget::customContextMenuRequested, this, &DisplayListMenu);
+	connect(this, &QAbstractItemView::doubleClicked, this, &AnimeListWidget::ItemDoubleClicked);
+	connect(this, &QWidget::customContextMenuRequested, this, &AnimeListWidget::DisplayListMenu);
 
 	/* Enter & return keys */
     connect(new QShortcut(Qt::Key_Return, this, nullptr, nullptr, Qt::WidgetShortcut),
-	        &QShortcut::activated, this, &ItemDoubleClicked);
+	        &QShortcut::activated, this, &AnimeListWidget::ItemDoubleClicked);
 
     connect(new QShortcut(Qt::Key_Enter, this, nullptr, nullptr, Qt::WidgetShortcut),
-	        &QShortcut::activated, this, &ItemDoubleClicked);
+	        &QShortcut::activated, this, &AnimeListWidget::ItemDoubleClicked);
 
 	header()->setStretchLastSection(false);
 	header()->setContextMenuPolicy(Qt::CustomContextMenu);
-	connect(header(), &QWidget::customContextMenuRequested, this, &DisplayColumnHeaderMenu);
+	connect(header(), &QWidget::customContextMenuRequested, this, &AnimeListWidget::DisplayColumnHeaderMenu);
 	// if(!session.config.anime_list.columns) {
 		SetColumnDefaults();
 	// }
@@ -450,6 +454,8 @@
 			anilist.UpdateAnimeList(&anime_lists, session.config.anilist.user_id);
 			break;
 		}
+		default:
+			break;
 	}
 }
 
--- a/src/dialog/information.cpp	Sat Aug 12 03:16:26 2023 -0400
+++ b/src/dialog/information.cpp	Sat Aug 12 11:57:25 2023 -0400
@@ -52,9 +52,9 @@
 	UiUtils::CreateSelectableTextParagraph(main_information_widget, "Synopsis", QString::fromWCharArray(anime->synopsis.c_str()), QPoint(6, 202), QSize(636-18, 253));
 	tabbed_widget->addTab(main_information_widget, "Main information");
 	QWidget* settings_widget = new QWidget(tabbed_widget);
-	
+	tabbed_widget->addTab(settings_widget, "My list and settings");
 	QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
-	connect(button_box, &QDialogButtonBox::accepted, this, &OnOK);
+	connect(button_box, &QDialogButtonBox::accepted, this, &InformationDialog::OnOK);
 	connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
 	QVBoxLayout* buttons_layout = new QVBoxLayout(widget);
 	buttons_layout->addWidget(widget, 0, Qt::AlignTop);
--- a/src/string_utils.cpp	Sat Aug 12 03:16:26 2023 -0400
+++ b/src/string_utils.cpp	Sat Aug 12 11:57:25 2023 -0400
@@ -14,7 +14,7 @@
 std::string StringUtils::Implode(const std::vector<std::string>& vector,
                                  const std::string& delimiter) {
 	std::string out = "";
-	for (int i = 0; i < vector.size(); i++) {
+	for (unsigned long long i = 0; i < vector.size(); i++) {
 		out.append(vector.at(i));
 		if (i < vector.size()-1)
 			out.append(delimiter);
@@ -25,7 +25,7 @@
 std::wstring StringUtils::Implode(const std::vector<std::wstring>& vector,
                                   const std::wstring& delimiter) {
 	std::wstring out = L"";
-	for (int i = 0; i < vector.size(); i++) {
+	for (unsigned long long i = 0; i < vector.size(); i++) {
 		out.append(vector.at(i));
 		if (i < vector.size()-1)
 			out.append(delimiter);