Skip to content

Commit

Permalink
const where it makes sense
Browse files Browse the repository at this point in the history
  • Loading branch information
duzda committed Feb 9, 2023
1 parent ed05bd8 commit 901046a
Show file tree
Hide file tree
Showing 36 changed files with 67 additions and 67 deletions.
2 changes: 1 addition & 1 deletion include/cache/covers/cover.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class Cache::Covers::Cover {
*
* @return Pointer to the cover art.
*/
virtual Glib::RefPtr<Gdk::Pixbuf> getIcon(std::filesystem::path path, uint size) = 0;
virtual Glib::RefPtr<Gdk::Pixbuf> getIcon(const std::filesystem::path& path, uint size) = 0;
private:
};
4 changes: 2 additions & 2 deletions include/cache/covers/implementation/coverfirst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Cache::Covers::CoverFirst : public Cache::Covers::Cover {
CoverFirst();
~CoverFirst();

Glib::RefPtr<Gdk::Pixbuf> getIcon(std::filesystem::path path, uint size);
Glib::RefPtr<Gdk::Pixbuf> getIcon(const std::filesystem::path& path, uint size);
private:
bool isNotChild(std::filesystem::path parent, std::filesystem::path child);
bool isNotChild(const std::filesystem::path& parent, const std::filesystem::path& child) const;
};
6 changes: 3 additions & 3 deletions include/cache/covers/implementation/metadatafirst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class Cache::Covers::MetadataFirst : public Cache::Covers::Cover {
MetadataFirst();
~MetadataFirst();

Glib::RefPtr<Gdk::Pixbuf> getIcon(std::filesystem::path path, uint size);
Glib::RefPtr<Gdk::Pixbuf> getIcon(const std::filesystem::path& path, uint size);
private:
bool isNotChild(std::filesystem::path parent, std::filesystem::path child);
Glib::RefPtr<Gdk::Pixbuf> hasChildrenIcon(std::filesystem::path cachePath, std::filesystem::path path, uint size);
bool isNotChild(const std::filesystem::path& parent, const std::filesystem::path& child) const;
Glib::RefPtr<Gdk::Pixbuf> hasChildrenIcon(const std::filesystem::path& cachePath, const std::filesystem::path& path, uint size);
};
6 changes: 3 additions & 3 deletions include/cache/covers/implementation/metadataonly.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class Cache::Covers::MetadataOnly : public Cache::Covers::Cover {
MetadataOnly();
~MetadataOnly();

Glib::RefPtr<Gdk::Pixbuf> getIcon(std::filesystem::path path, uint size);
Glib::RefPtr<Gdk::Pixbuf> getIcon(const std::filesystem::path& path, uint size);
private:
bool isNotChild(std::filesystem::path parent, std::filesystem::path child);
Glib::RefPtr<Gdk::Pixbuf> hasChildrenIcon(std::filesystem::path cachePath, std::filesystem::path path, uint size);
bool isNotChild(const std::filesystem::path& parent, const std::filesystem::path& child) const;
Glib::RefPtr<Gdk::Pixbuf> hasChildrenIcon(const std::filesystem::path& cachePath, const std::filesystem::path& path, uint size);
};
2 changes: 1 addition & 1 deletion include/cache/covers/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Cache::Covers::Utils {
*
* @return Path to the cache file
*/
static std::filesystem::path createCachePath(std::filesystem::path path, uint size);
static std::filesystem::path createCachePath(const std::filesystem::path& path, uint size);
private:
Utils();
~Utils();
Expand Down
2 changes: 1 addition & 1 deletion include/cache/treemodel/serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Cache::TreeModel::Serializer {
*
* @return True if tree should be recovered
*/
static bool shouldRecover(std::filesystem::path path);
static bool shouldRecover(const std::filesystem::path& path);

static void clearModel();
private:
Expand Down
4 changes: 2 additions & 2 deletions include/filebrowser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Filebrowser {
*
* @return Vector of directory entries for path
*/
static std::vector<std::filesystem::directory_entry> getFileList(std::filesystem::path path, bool sort, bool showHiddenFiles);
static std::vector<std::filesystem::directory_entry> getFileList(const std::filesystem::path& path, bool sort, bool showHiddenFiles);

/**
* @param directory
Expand All @@ -24,7 +24,7 @@ class Filebrowser {
*
* @return True if directory contains file, false otherwise.
*/
static bool hasFile(std::filesystem::path directory, std::vector<std::string> acceptedFiles, std::string* outputFile);
static bool hasFile(const std::filesystem::path& directory, std::vector<std::string> acceptedFiles, std::string* outputFile);
private:
Filebrowser();
virtual ~Filebrowser();
Expand Down
2 changes: 1 addition & 1 deletion include/gui/addressbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class GUI::Addressbox : public Gtk::HBox

void initialize(GUI::DispatcherBridge* bridge, GUI::FBTreeView* view, FBTreeFilter* filter, FBTreeModel* model);
void setAddress(std::string addres);
std::string getAddress();
std::string getAddress() const;

/**
* Changes progress of the action of Addressbox.
Expand Down
2 changes: 1 addition & 1 deletion include/gui/dispatcherbridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GUI::DispatcherBridge {

void initialize(Addressbox* addressbox, Searchbar* searchbar, FBTreeView* view, FBTreeModel* model);

bool inProgress();
bool inProgress() const;

void onStart();

Expand Down
8 changes: 4 additions & 4 deletions include/gui/fbtreemodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class GUI::FBTreeModel : public Gtk::TreeStore {
*
* @return Double between 0 and 1, 1 when finished
*/
double getProgress();
double getProgress() const;

/**
* Sets new root directory, refreshTree should probably be called immediately after.
*
* @param newDirectory New root directory
*/
void setTreeRoot(std::filesystem::path newDirectory);
void setTreeRoot(const std::filesystem::path& newDirectory);

/**
* Creates new thread that refreshes tree, removes all entries, and fills them again.
Expand Down Expand Up @@ -85,15 +85,15 @@ class GUI::FBTreeModel : public Gtk::TreeStore {
* @param entry Path to the new child.
* @param child Parent to of the current entry, can be null.
*/
void fillRow(std::filesystem::directory_entry entry, const Gtk::TreeNodeChildren* parent = nullptr);
void fillRow(const std::filesystem::directory_entry& entry, const Gtk::TreeNodeChildren* parent = nullptr);

/**
* Fills row of treeview, but is allowed to be exited prematurely. (This should be used when adding children of a node)
*
* @param entry Path to the new child.
* @param child Parent to the current entry.
*/
void fillChildrenRow(std::filesystem::directory_entry entry, const Gtk::TreeNodeChildren* parent);
void fillChildrenRow(const std::filesystem::directory_entry& entry, const Gtk::TreeNodeChildren* parent);

/**
* Fills information row to treeview.
Expand Down
6 changes: 3 additions & 3 deletions include/gui/views/fbtreeview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ class GUI::FBTreeView : public Gtk::TreeView {
*
* @return URI of selected row
*/
std::string getSelectedURI();
std::string getSelectedURI() const;

/**
* Returns all selected URIs from mTreeView.
*
* @return Vector of selected rows
*/
std::vector<std::string> getSelectedURIs();
std::vector<std::string> getSelectedURIs() const;

/**
* Returns true if any row in mTreeView is selected.
*
* @return True if any row is selected, false otherwise.
*/
bool hasSelected();
bool hasSelected() const;
private:
using Gtk::TreeView::set_model;

Expand Down
2 changes: 1 addition & 1 deletion include/iconutils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class IconUtils {
*
* @return Pointer to the icon.
*/
static Glib::RefPtr<Gdk::Pixbuf> getIcon(std::filesystem::path path, uint size);
static Glib::RefPtr<Gdk::Pixbuf> getIcon(const std::filesystem::path& path, uint size);
private:
IconUtils();
~IconUtils();
Expand Down
2 changes: 1 addition & 1 deletion include/metadata/implementation/flacreader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class FlacReader : public ID3v2Reader {
FlacReader();
~FlacReader();

Glib::RefPtr<Gdk::Pixbuf> getImage(std::filesystem::path path, int size) override;
Glib::RefPtr<Gdk::Pixbuf> getImage(const std::filesystem::path& path, int size) override;
private:
};
2 changes: 1 addition & 1 deletion include/metadata/implementation/mp3reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class MP3Reader : public ID3v2Reader {
MP3Reader();
~MP3Reader();

Glib::RefPtr<Gdk::Pixbuf> getImage(std::filesystem::path path, int size);
Glib::RefPtr<Gdk::Pixbuf> getImage(const std::filesystem::path& path, int size);
private:
};
2 changes: 1 addition & 1 deletion include/metadata/implementation/oggreader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class OggReader : public Reader {
OggReader();
~OggReader();

Glib::RefPtr<Gdk::Pixbuf> getImage(std::filesystem::path path, int size);
Glib::RefPtr<Gdk::Pixbuf> getImage(const std::filesystem::path& path, int size);
private:
};
2 changes: 1 addition & 1 deletion include/metadata/implementation/wavreader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class WavReader : public ID3v2Reader {
WavReader();
~WavReader();

Glib::RefPtr<Gdk::Pixbuf> getImage(std::filesystem::path path, int size);
Glib::RefPtr<Gdk::Pixbuf> getImage(const std::filesystem::path& path, int size);
private:
};
2 changes: 1 addition & 1 deletion include/metadata/reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Reader {
public:
virtual ~Reader();

virtual Glib::RefPtr<Gdk::Pixbuf> getImage(std::filesystem::path path, int size) = 0;
virtual Glib::RefPtr<Gdk::Pixbuf> getImage(const std::filesystem::path& path, int size) = 0;
protected:
Glib::RefPtr<Gdk::Pixbuf> getImageFromData(TagLib::ByteVector bytes, int size);
};
2 changes: 1 addition & 1 deletion include/metadata/readerfactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ReaderFactory {
*
* @return Pointer to the image.
*/
static Glib::RefPtr<Gdk::Pixbuf> getImage(std::filesystem::path path, int size, bool* shouldCache);
static Glib::RefPtr<Gdk::Pixbuf> getImage(const std::filesystem::path& path, int size, bool* shouldCache);
private:
ReaderFactory();
~ReaderFactory();
Expand Down
10 changes: 5 additions & 5 deletions include/plugin/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class Settings {
*/
void onUpdate();

std::string getDefaultPath();
int getIconSize();
int getDoubleclickReplace();
int getAlbumAlgorithm();
std::string getDefaultPath() const;
int getIconSize() const;
int getDoubleclickReplace() const;
int getAlbumAlgorithm() const;

std::vector<std::string> getValidExtensions();
std::vector<std::string> getValidExtensions() const;
private:
Settings();

Expand Down
4 changes: 2 additions & 2 deletions src/cache/covers/implementation/coverfirst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace Cache::Covers;
CoverFirst::CoverFirst() {
}

Glib::RefPtr<Gdk::Pixbuf> CoverFirst::getIcon(std::filesystem::path path, uint size) {
Glib::RefPtr<Gdk::Pixbuf> CoverFirst::getIcon(const std::filesystem::path& path, uint size) {
Glib::RefPtr<Gdk::Pixbuf> icon;
static Glib::RefPtr<Gdk::Pixbuf> lastIcon;
static std::string lastDirectory;
Expand Down Expand Up @@ -48,7 +48,7 @@ Glib::RefPtr<Gdk::Pixbuf> CoverFirst::getIcon(std::filesystem::path path, uint s
return icon;
}

bool CoverFirst::isNotChild(std::filesystem::path parent, std::filesystem::path child) {
bool CoverFirst::isNotChild(const std::filesystem::path& parent, const std::filesystem::path& child) const {
return parent == "" || child.string().find(parent) == std::string::npos ||
child.string().size() <= parent.string().size() || child.string()[parent.string().size()] != '/';
}
Expand Down
6 changes: 3 additions & 3 deletions src/cache/covers/implementation/metadatafirst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace Cache::Covers;
MetadataFirst::MetadataFirst() {
}

Glib::RefPtr<Gdk::Pixbuf> MetadataFirst::getIcon(std::filesystem::path path, uint size) {
Glib::RefPtr<Gdk::Pixbuf> MetadataFirst::getIcon(const std::filesystem::path& path, uint size) {
Glib::RefPtr<Gdk::Pixbuf> icon;
static std::string lastDirectory;

Expand Down Expand Up @@ -57,12 +57,12 @@ Glib::RefPtr<Gdk::Pixbuf> MetadataFirst::getIcon(std::filesystem::path path, uin
return icon;
}

bool MetadataFirst::isNotChild(std::filesystem::path parent, std::filesystem::path child) {
bool MetadataFirst::isNotChild(const std::filesystem::path& parent, const std::filesystem::path& child) const {
return parent == "" || child.string().find(parent) == std::string::npos ||
child.string().size() <= parent.string().size() || child.string()[parent.string().size()] != '/';
}

Glib::RefPtr<Gdk::Pixbuf> MetadataFirst::hasChildrenIcon(std::filesystem::path cachePath, std::filesystem::path path, uint size) {
Glib::RefPtr<Gdk::Pixbuf> MetadataFirst::hasChildrenIcon(const std::filesystem::path& cachePath, const std::filesystem::path& path, uint size) {
for (const auto &entry : std::filesystem::recursive_directory_iterator(path)) {
if (entry.is_directory()) {
std::string outputName;
Expand Down
6 changes: 3 additions & 3 deletions src/cache/covers/implementation/metadataonly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace Cache::Covers;
MetadataOnly::MetadataOnly() {
}

Glib::RefPtr<Gdk::Pixbuf> MetadataOnly::getIcon(std::filesystem::path path, uint size) {
Glib::RefPtr<Gdk::Pixbuf> MetadataOnly::getIcon(const std::filesystem::path& path, uint size) {
Glib::RefPtr<Gdk::Pixbuf> icon;
static std::string lastDirectory;

Expand Down Expand Up @@ -45,12 +45,12 @@ Glib::RefPtr<Gdk::Pixbuf> MetadataOnly::getIcon(std::filesystem::path path, uint
return icon;
}

bool MetadataOnly::isNotChild(std::filesystem::path parent, std::filesystem::path child) {
bool MetadataOnly::isNotChild(const std::filesystem::path& parent, const std::filesystem::path& child) const {
return parent == "" || child.string().find(parent) == std::string::npos ||
child.string().size() <= parent.string().size() || child.string()[parent.string().size()] != '/';
}

Glib::RefPtr<Gdk::Pixbuf> MetadataOnly::hasChildrenIcon(std::filesystem::path cachePath, std::filesystem::path path, uint size) {
Glib::RefPtr<Gdk::Pixbuf> MetadataOnly::hasChildrenIcon(const std::filesystem::path& cachePath, const std::filesystem::path& path, uint size) {
for (const auto &entry : std::filesystem::recursive_directory_iterator(path)) {
if (!entry.is_directory()) {
bool useCache = false;
Expand Down
2 changes: 1 addition & 1 deletion src/cache/covers/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using namespace Cache::Covers;

std::filesystem::path Utils::createCachePath(std::filesystem::path path, uint size) {
std::filesystem::path Utils::createCachePath(const std::filesystem::path& path, uint size) {
std::string cache = Cache::Utils::createCacheBasePath().string() + "/icons/" + std::to_string(size) + "/";

if (!std::filesystem::exists(cache)) {
Expand Down
2 changes: 1 addition & 1 deletion src/cache/treemodel/serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void Serializer::load(GUI::FBTreeModel* model) {
}
}

bool Serializer::shouldRecover(std::filesystem::path path) {
bool Serializer::shouldRecover(const std::filesystem::path& path) {
if (!Serializer::exists()) {
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/filebrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "settings.hpp"

std::vector<std::filesystem::directory_entry> Filebrowser::getFileList(std::filesystem::path path, bool sort, bool showHiddenFiles) {
std::vector<std::filesystem::directory_entry> Filebrowser::getFileList(const std::filesystem::path& path, bool sort, bool showHiddenFiles) {
std::vector<std::filesystem::directory_entry> files = {};

for(const auto &entry : std::filesystem::directory_iterator(path)) {
Expand Down Expand Up @@ -54,15 +54,15 @@ std::vector<std::filesystem::directory_entry> Filebrowser::getFileList(std::file

if (sort) {
std::sort(files.begin(), files.end(),
[](const std::filesystem::directory_entry &s1, const std::filesystem::directory_entry &s2) -> bool {
[](const std::filesystem::directory_entry& s1, const std::filesystem::directory_entry& s2) -> bool {
return strcasecmp(s1.path().c_str(), s2.path().c_str()) < 0 ? true : false;
});
}

return files;
}

bool Filebrowser::hasFile(std::filesystem::path directory, std::vector<std::string> acceptedFiles, std::string* outputFile) {
bool Filebrowser::hasFile(const std::filesystem::path& directory, std::vector<std::string> acceptedFiles, std::string* outputFile) {
auto path = directory.string();
for (auto &file : acceptedFiles) {
if (std::filesystem::exists(path + '/' + file)) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/addressbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void Addressbox::setAddress(std::string address) {
this->on_go_button_click();
}

std::string Addressbox::getAddress() {
std::string Addressbox::getAddress() const {
return this->mAddressBar.get_text();
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/dispatcherbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void DispatcherBridge::initialize(Addressbox* addressbox, Searchbar* searchbar,
this->mModel = model;
}

bool DispatcherBridge::inProgress() {
bool DispatcherBridge::inProgress() const {
return this->mInProgress;
}

Expand Down
Loading

0 comments on commit 901046a

Please sign in to comment.