Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bfb9cf0
Aggiunta interfaccia database
May 19, 2025
8adc866
Aggiunto tutti i gli operatori==
Steva0 May 19, 2025
90b9ddb
Prima implementazione della classe database
May 19, 2025
ef60e26
Prima implementazione della classe database
May 19, 2025
0c72eab
Aggiornamento .gitignore
May 19, 2025
dc603fc
Aggiunto metodo Filter per la classe Media
Steva0 May 20, 2025
6f4fbc3
Aggiunta interfaccia metodi filtra
Steva0 May 20, 2025
1c9d4f2
Tolto il virtual
Steva0 May 20, 2025
c74688d
Metodo filter per Novel
Steva0 May 20, 2025
090cf24
Sistemato filtro per Novel
Steva0 May 20, 2025
0f5cf13
Aggiunti parametri di default
Steva0 May 20, 2025
ac28661
SIstemata la cartella di git
Steva0 May 20, 2025
36fe7d7
Modficia .gitignore
Steva0 May 20, 2025
2886b13
Metodi filter aggiunti ovunque
Steva0 May 20, 2025
60a6ad8
Modificato nome programma .pro
Steva0 May 20, 2025
a6dab30
Modificato nome .pro
Steva0 May 20, 2025
15db58b
Sistemati nomi file
Steva0 May 20, 2025
91e29ab
Sistemati #ifndef
Steva0 May 20, 2025
b7a3624
Sistemato interfacce e parte di Filtri
Steva0 May 20, 2025
548e73c
Sistemato riferimenti
Steva0 May 20, 2025
b8723b4
Merge branch 'Database' into MediaContainer
Steva0 May 20, 2025
85d9c12
Merge pull request #7 from Steva0:MediaContainer
Steva0 May 20, 2025
f9a5cf8
Modificato sostanzialmente tutti i metodi filter
Steva0 May 20, 2025
4078e0f
Sistemato gli include giusti
Steva0 May 20, 2025
869ef10
Corretto cosa filter Media
Steva0 May 20, 2025
79bc9d1
Solo per compilazione aggiunto {} metodi static
Steva0 May 20, 2025
a556464
Modfichi con indici
Steva0 May 20, 2025
b58dc98
Aggiunta classe Enum
Steva0 May 20, 2025
c6ecd1a
Aggiornato in privato
Steva0 May 20, 2025
ccaac5e
prima implementazione classe Database
May 21, 2025
1bfe4a8
Modifica firma metodo
Steva0 May 21, 2025
8b3c513
tolti size_t messi int
Steva0 May 21, 2025
68f2f1e
Aggiunto metodo clone e tolto slicing
Steva0 May 21, 2025
d7f1916
Tolto doppio clone in add MEdia
Steva0 May 21, 2025
c9e4506
mantenuto file database.h e database.cpp e modificato file mediaconta…
May 21, 2025
a34686e
Merge pull request #9 from Steva0/Database
May 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.cache
.qmake.stash
./src

# C++ objects and libs
*.slo
*.lo
Expand All @@ -9,13 +13,18 @@
*.so.*
*.dll
*.dylib
Build
checks.json
.vscode
build

# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
src/*.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
Expand Down
43 changes: 0 additions & 43 deletions CMakeLists.txt

This file was deleted.

63 changes: 63 additions & 0 deletions src/Media/Album.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,67 @@ const std::vector<std::string> &Album::getBandMembers() const {
return band_members_;
}
const std::vector<std::string> &Album::getSongs() const { return songs_; }
bool Album::operator==(const Media &other) const {
const Album *other_album = dynamic_cast<const Album *>(&other);
if (other_album) {
return Media::operator==(*other_album) && band_ == other_album->band_ &&
band_members_ == other_album->band_members_ &&
songs_ == other_album->songs_;
}
return false;
}

std::unique_ptr<Media> Album::clone() const {
return std::make_unique<Album>(*this);
}


bool Album::filter(const Media& album) const {
// Riutilizzo filtro base di Media
if (!Media::filter(album))
return false;

// Cast to Album to access Album-specific members
const Album* albumPtr = dynamic_cast<const Album*>(&album);
if (!albumPtr)
return false;

// Band
if (!band_.empty() && !stringContainsIgnoreCase(albumPtr->getBand(), band_))
return false;

// Band members (ogni membro richiesto deve matchare almeno uno esistente)
if (!band_members_.empty()) {
for (const auto& memberFilter : band_members_) {
bool found = false;
for (const auto& m : albumPtr->getBandMembers()) {
if (stringContainsIgnoreCase(m, memberFilter)) {
found = true;
break;
}
}
if (!found) {
return false;
}
}
}

// Songs (ogni canzone richiesta deve matchare almeno una esistente)
if (!songs_.empty()) {
for (const auto& songFilter : songs_) {
bool found = false;
for (const auto& s : albumPtr->getSongs()) {
if (stringContainsIgnoreCase(s, songFilter)) {
found = true;
break;
}
}
if (!found) {
return false;
}
}
}
return true;
}

} // namespace media
11 changes: 9 additions & 2 deletions src/Media/Album.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ class Album : public Media {
Album(const std::string &title, int release, const std::string &language,
bool favourite, const std::vector<std::string> &genres,
const std::string &img_path, const std::string &notes,
const std::string &band, const std::vector<std::string> &band_members,
const std::vector<std::string> &songs);
const std::string &band = "", const std::vector<std::string> &band_members = {},
const std::vector<std::string> &songs = {});
const std::string &getBand() const;
const std::vector<std::string> &getBandMembers() const;
const std::vector<std::string> &getSongs() const;
bool operator==(const Media &other) const override;

std::unique_ptr<Media> clone() const override;

bool filter(const Media& album) const override;

};
} // namespace media

#endif
30 changes: 28 additions & 2 deletions src/Media/AudioBook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@ AudioBook::AudioBook(const std::string& title, int publicationYear, const std::s
narrator_(narrator), streamingService_(streamingService) {}


void AudioBook::accept(IConstMediaVisitor& v) const {
v.visit(*this);
bool AudioBook::operator==(const Media& other) const {
const AudioBook* otherAudioBook = dynamic_cast<const AudioBook*>(&other);
if (otherAudioBook) {
return Novel::operator==(*otherAudioBook) && narrator_ == otherAudioBook->narrator_ &&
streamingService_ == otherAudioBook->streamingService_;
}
return false;
}

std::unique_ptr<Media> AudioBook::clone() const {
return std::make_unique<AudioBook>(*this);
}

std::string AudioBook::getNarrator() const {
Expand All @@ -32,4 +41,21 @@ void AudioBook::setStreamingService(const std::string& service) {
streamingService_ = service;
}

bool AudioBook::filter(const Media& input) const {
if (!Novel::filter(input))
return false;
const AudioBook* audiobookPtr = dynamic_cast<const AudioBook*>(&input);
if (!audiobookPtr)
return false; // Protegge da cast fallito

// Filtro specifico AudioBook
if (!narrator_.empty() && !stringContainsIgnoreCase(audiobookPtr->getNarrator(), narrator_))
return false;

if (!streamingService_.empty() && !stringContainsIgnoreCase(audiobookPtr->getStreamingService(), streamingService_))
return false;

return true;
}

}
15 changes: 10 additions & 5 deletions src/Media/AudioBook.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef AudioBook_H
#define AudioBook_H
#ifndef MEDIA_AUDIOBOOK_H
#define MEDIA_AUDIOBOOK_H

#include "Novel.h"

Expand All @@ -11,21 +11,26 @@ class AudioBook : public Novel {
std::string streamingService_;

public:
//durata è in minuti e usa il campo dati pagine di Novel
AudioBook(const std::string& title, int publicationYear, const std::string& language,
bool favorite, const std::vector<std::string>& genres, const std::string& imagePath, const std::string& notes,
const std::string& author, const std::string& publisher,
unsigned int duration, const std::string& series, const std::string& isbn,
const std::string& narrator, const std::string& streamingService);
const std::string& narrator = "", const std::string& streamingService = "");

void accept(IConstMediaVisitor& v) const override;
bool operator==(const Media& other) const override;

std::string getNarrator() const;
std::string getStreamingService() const;

void setNarrator(const std::string& narrator);
void setStreamingService(const std::string& service);

std::unique_ptr<Media> clone() const override;

bool filter(const Media& audiobook) const override;
};

}

#endif // AudioBook_H
#endif // MEDIA_AUDIOBOOK_H
35 changes: 32 additions & 3 deletions src/Media/Ebook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ Ebook::Ebook(const std::string& title, int publicationYear, const std::string& l
author, publisher, pages, series, isbn),
fileSizeBytes_(fileSizeBytes), drm_(drm) {}

void Ebook::accept(IConstMediaVisitor& v) const {
v.visit(*this);
}
bool Ebook::operator==(const Media& other) const {
const Ebook* otherEbook = dynamic_cast<const Ebook*>(&other);
if (otherEbook) {
return Novel::operator==(*otherEbook) && fileSizeBytes_ == otherEbook->fileSizeBytes_ &&
drm_ == otherEbook->drm_;
}
return false;
}

unsigned int Ebook::getFileSizeBytes() const {
return fileSizeBytes_;
Expand All @@ -31,4 +36,28 @@ void Ebook::setDrm(bool drm) {
drm_ = drm;
}

std::unique_ptr<Media> Ebook::clone() const {
return std::make_unique<Ebook>(*this);
}

bool Ebook::filter(const Media& input) const {
// Riutilizzo filtro base di Novel
if (!Novel::filter(input))
return false;
// Cast to Ebook to access Ebook-specific members
const Ebook* ebookPtr = dynamic_cast<const Ebook*>(&input);
if (!ebookPtr)
return false;

// File size filter
if (fileSizeBytes_ > 0 && ebookPtr->getFileSizeBytes() != fileSizeBytes_)
return false;

// DRM filter
if (drm_ && ebookPtr->hasDrm() != drm_)
return false;

return true;
}

}
15 changes: 10 additions & 5 deletions src/Media/Ebook.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef EBOOK_H
#define EBOOK_H
#ifndef MEDIA_EBOOK_H
#define MEDIA_EBOOK_H

#include "Novel.h"

Expand All @@ -15,17 +15,22 @@ class Ebook : public Novel {
bool favorite, const std::vector<std::string>& genres, const std::string& imagePath, const std::string& notes,
const std::string& author, const std::string& publisher,
unsigned int pages, const std::string& series, const std::string& isbn,
unsigned int fileSizeBytes, bool drm);
unsigned int fileSizeBytes = 0, bool drm = false);

void accept(IConstMediaVisitor& v) const override;
bool operator==(const Media& other) const override;

unsigned int getFileSizeBytes() const;
bool hasDrm() const;

void setFileSizeBytes(unsigned int size);
void setDrm(bool drm);

std::unique_ptr<Media> clone() const override;

bool filter(const Media& ebook) const override;

};

}

#endif // EBOOK_H
#endif // MEDIA_EBOOK_H
8 changes: 3 additions & 5 deletions src/Media/IMedia.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#ifndef IMedia_H
#define IMedia_H
#ifndef MEDIA_IMedia_H
#define MEDIA_IMedia_H

#include "IConstMediaVisitor.h"


namespace media {


class IMedia {
virtual void accept(IConstMediaVisitor &) const = 0;
virtual bool open() = 0;
virtual std::unique_ptr<Media> clone() const = 0;
};

}


#endif
Loading
Loading