Merge branch 'master' into support_new_upload_endpoint
This commit is contained in:
@@ -12,13 +12,16 @@
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
class ActionManager
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
|
||||
class ActionManager
|
||||
{
|
||||
public:
|
||||
ActionManager(char**, int);
|
||||
|
||||
Models::IcarusAction retrieveIcarusAction() const;
|
||||
private:
|
||||
private:
|
||||
constexpr std::array<const char*, 16> supportedFlags() noexcept
|
||||
{
|
||||
constexpr std::array<const char*, 16> allFlags{"-u", "-p", "-t", "-h", "-s",
|
||||
@@ -72,8 +75,6 @@ namespace Managers
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> parsedFlags();
|
||||
|
||||
void printAction() noexcept;
|
||||
void printFlags() noexcept;
|
||||
|
||||
@@ -83,7 +84,8 @@ namespace Managers
|
||||
|
||||
char **params;
|
||||
int paramCount;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -14,13 +14,15 @@
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
class CommitManager
|
||||
{
|
||||
public:
|
||||
|
||||
class CommitManager
|
||||
{
|
||||
public:
|
||||
CommitManager(Models::IcarusAction&);
|
||||
|
||||
void commitAction();
|
||||
|
||||
|
||||
enum class RetrieveTypes
|
||||
{
|
||||
songs
|
||||
@@ -44,13 +46,11 @@ namespace Managers
|
||||
std::vector<Models::Song> songs;
|
||||
};
|
||||
|
||||
private:
|
||||
private:
|
||||
enum class ActionValues;
|
||||
|
||||
std::map<std::string, ActionValues> mapActions() noexcept;
|
||||
|
||||
Models::Token parseToken(Models::API);
|
||||
|
||||
void deleteSong();
|
||||
void downloadSong();
|
||||
void retrieveObjects();
|
||||
@@ -204,7 +204,9 @@ namespace Managers
|
||||
|
||||
|
||||
Models::IcarusAction icaAction;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
class FileManager
|
||||
{
|
||||
public:
|
||||
|
||||
class FileManager
|
||||
{
|
||||
public:
|
||||
FileManager();
|
||||
FileManager(std::string);
|
||||
|
||||
@@ -16,14 +17,15 @@ namespace Managers
|
||||
|
||||
char* retrieveFileBuffer() const;
|
||||
int retrieveFileBufferLength() const;
|
||||
private:
|
||||
private:
|
||||
void readFile();
|
||||
|
||||
std::string filePath;
|
||||
char* fileBuffer;
|
||||
bool fileRead;
|
||||
int fileBufferLength;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,17 +7,19 @@
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
class TokenManager
|
||||
{
|
||||
public:
|
||||
|
||||
class TokenManager
|
||||
{
|
||||
public:
|
||||
TokenManager(const Models::User&);
|
||||
TokenManager(const Models::User&, Models::API&);
|
||||
|
||||
Models::Token requestToken();
|
||||
private:
|
||||
private:
|
||||
Models::API api;
|
||||
Models::User user;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,19 +8,21 @@
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
class UserManager
|
||||
{
|
||||
public:
|
||||
|
||||
class UserManager
|
||||
{
|
||||
public:
|
||||
UserManager(Models::User);
|
||||
UserManager(const Models::IcarusAction);
|
||||
|
||||
Models::User retrieveUser() const;
|
||||
private:
|
||||
private:
|
||||
void parseUserFromActions();
|
||||
|
||||
Models::User user;
|
||||
Models::IcarusAction icaAction;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,12 +5,15 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct API
|
||||
{
|
||||
|
||||
class API
|
||||
{
|
||||
public:
|
||||
std::string url;
|
||||
std::string endpoint;
|
||||
std::string version;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+13
-4
@@ -5,12 +5,21 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
class Flags
|
||||
{
|
||||
public:
|
||||
|
||||
class Flags
|
||||
{
|
||||
public:
|
||||
std::string flag;
|
||||
std::string value;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
struct Flags
|
||||
{
|
||||
std::string flag;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
class IcarusAction
|
||||
{
|
||||
public:
|
||||
|
||||
class IcarusAction
|
||||
{
|
||||
public:
|
||||
std::string retrieveFlagValue(const std::string_view flag)
|
||||
{
|
||||
std::string value;
|
||||
@@ -45,7 +46,8 @@ namespace Models
|
||||
|
||||
std::string action;
|
||||
std::vector<Flags> flags;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+10
-8
@@ -7,9 +7,10 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
class Song
|
||||
{
|
||||
public:
|
||||
|
||||
class Song
|
||||
{
|
||||
public:
|
||||
Song() = default;
|
||||
|
||||
void printInfo()
|
||||
@@ -32,15 +33,16 @@ namespace Models
|
||||
int disc;
|
||||
std::string data;
|
||||
std::string songPath;
|
||||
};
|
||||
};
|
||||
|
||||
class CoverArt
|
||||
{
|
||||
public:
|
||||
class CoverArt
|
||||
{
|
||||
public:
|
||||
int id;
|
||||
std::string title;
|
||||
std::string path;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct Token
|
||||
{
|
||||
|
||||
struct Token
|
||||
{
|
||||
std::string accessToken;
|
||||
std::string tokenType;
|
||||
int expiration;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct UploadForm
|
||||
{
|
||||
|
||||
struct UploadForm
|
||||
{
|
||||
std::string url;
|
||||
std::string filePath;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
|
||||
namespace Models
|
||||
{
|
||||
struct User
|
||||
{
|
||||
|
||||
struct User
|
||||
{
|
||||
std::string username;
|
||||
std::string password;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,18 +6,20 @@
|
||||
|
||||
namespace Parsers
|
||||
{
|
||||
class APIParser
|
||||
{
|
||||
public:
|
||||
|
||||
class APIParser
|
||||
{
|
||||
public:
|
||||
APIParser(Models::IcarusAction);
|
||||
|
||||
Models::API retrieveAPI() const;
|
||||
private:
|
||||
private:
|
||||
void parseAPI();
|
||||
|
||||
Models::API api;
|
||||
Models::IcarusAction icaAct;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,15 +9,17 @@
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class Delete : SyncerBase
|
||||
{
|
||||
public:
|
||||
|
||||
class Delete : SyncerBase
|
||||
{
|
||||
public:
|
||||
Delete(Models::API);
|
||||
|
||||
void deleteSong(const Models::Token, Models::Song);
|
||||
private:
|
||||
private:
|
||||
std::string retrieveUrl(Models::Song);
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,20 +12,22 @@
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class Download : SyncerBase
|
||||
{
|
||||
public:
|
||||
|
||||
class Download : SyncerBase
|
||||
{
|
||||
public:
|
||||
Download();
|
||||
Download(Models::API);
|
||||
Download(std::string);
|
||||
|
||||
void downloadSong(const Models::Token token, Models::Song);
|
||||
private:
|
||||
private:
|
||||
std::string retrieveUrl(Models::Song);
|
||||
|
||||
std::string downloadFilePath;
|
||||
void saveSong(Models::Song&);
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,19 +8,21 @@
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class RetrieveRecords: public SyncerBase
|
||||
{
|
||||
public:
|
||||
|
||||
class RetrieveRecords: public SyncerBase
|
||||
{
|
||||
public:
|
||||
RetrieveRecords();
|
||||
RetrieveRecords(Models::API, Models::Token);
|
||||
|
||||
void retrieve(Managers::CommitManager::RetrieveTypes);
|
||||
private:
|
||||
private:
|
||||
void fetchSongs();
|
||||
|
||||
Models::API api;
|
||||
Models::Token token;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class SyncerBase
|
||||
{
|
||||
protected:
|
||||
|
||||
class SyncerBase
|
||||
{
|
||||
protected:
|
||||
Models::API api;
|
||||
const int OK = 200;
|
||||
const int UNAUTHORIZED = 401;
|
||||
@@ -21,7 +22,8 @@ namespace Syncers
|
||||
UNAUTHORIZED = 401,
|
||||
NOTFOUND = 404
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,9 +19,10 @@ namespace fs = std::filesystem;
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
class Upload
|
||||
{
|
||||
public:
|
||||
|
||||
class Upload
|
||||
{
|
||||
public:
|
||||
Upload(Models::API api, Models::Token token) : m_token(token), api(api)
|
||||
{
|
||||
this->api.endpoint = "song/data";
|
||||
@@ -30,7 +31,7 @@ namespace Syncers
|
||||
Models::Song uploadSong(Models::Song&);
|
||||
void uploadSongsFromDirectory(const std::string&, const bool, bool);
|
||||
void uploadSongWithMetadata(Managers::CommitManager::Album&, Models::Song&, Models::CoverArt&);
|
||||
private:
|
||||
private:
|
||||
Managers::FileManager fMgr;
|
||||
Models::API api;
|
||||
Models::Song song;
|
||||
@@ -46,7 +47,8 @@ namespace Syncers
|
||||
void printSongDetails();
|
||||
void printSongDetails(std::vector<Models::Song>&);
|
||||
void printJsonData(const nlohmann::json&);
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,22 +13,24 @@
|
||||
|
||||
namespace UI
|
||||
{
|
||||
class AboutWindow: public QDialog, public CommonWindow
|
||||
{
|
||||
|
||||
class AboutWindow: public QDialog, public CommonWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
public:
|
||||
AboutWindow(QWidget* parent=0);
|
||||
~AboutWindow() = default;
|
||||
|
||||
private:
|
||||
private:
|
||||
void connections();
|
||||
void setupWindow();
|
||||
|
||||
std::unique_ptr<QLabel> appName;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void closeWindow();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
#include<QPushButton>
|
||||
|
||||
|
||||
namespace UI
|
||||
{
|
||||
|
||||
class CommonWindow
|
||||
{
|
||||
public:
|
||||
@@ -24,4 +27,7 @@ protected:
|
||||
std::unique_ptr<QVBoxLayout> subLayoutTwoQt;
|
||||
int windowHeight, windowWidth;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,13 +22,14 @@
|
||||
|
||||
namespace UI
|
||||
{
|
||||
class MainWindow: public QMainWindow, public CommonWindow
|
||||
{
|
||||
|
||||
class MainWindow: public QMainWindow, public CommonWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
public:
|
||||
MainWindow();
|
||||
~MainWindow() = default;
|
||||
private:
|
||||
private:
|
||||
void configureDownloadSection();
|
||||
void configureUploadSection();
|
||||
void configureWindowDimensions();
|
||||
@@ -70,13 +71,14 @@ namespace UI
|
||||
std::unique_ptr<QAction> aboutApplicationQt;
|
||||
|
||||
std::unique_ptr<AboutWindow> aboutWindow;
|
||||
signals:
|
||||
private slots:
|
||||
signals:
|
||||
private slots:
|
||||
void uploadSong();
|
||||
void exitApplication();
|
||||
void displaySoftwareInformation();
|
||||
void setCurrentIndex(int);
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
namespace Utilities
|
||||
{
|
||||
class Conversions
|
||||
{
|
||||
public:
|
||||
Conversions();
|
||||
|
||||
class Conversions
|
||||
{
|
||||
public:
|
||||
Conversions();
|
||||
|
||||
static void toLowerChar(char &c)
|
||||
{
|
||||
@@ -21,11 +21,9 @@ namespace Utilities
|
||||
}
|
||||
|
||||
void initializeValues();
|
||||
private:
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void printValue(T);
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,38 +16,46 @@ using Models::IcarusAction;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
#pragma
|
||||
ActionManager::ActionManager(char **param, int paramCount) :
|
||||
|
||||
#pragma region Constructors
|
||||
ActionManager::ActionManager(char **param, int paramCount) :
|
||||
params(std::move(param)), paramCount(paramCount)
|
||||
{
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
#pragma Constructors
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma
|
||||
IcarusAction ActionManager::retrieveIcarusAction() const
|
||||
{
|
||||
#pragma region Functions
|
||||
IcarusAction ActionManager::retrieveIcarusAction() const
|
||||
{
|
||||
IcarusAction icarusAction;
|
||||
icarusAction.flags = flags;
|
||||
icarusAction.action = action;
|
||||
|
||||
return icarusAction;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ActionManager::initialize()
|
||||
bool ActionManager::isNumber(string_view val) noexcept
|
||||
{
|
||||
return !val.empty() && std::find_if(val.begin(),
|
||||
val.end(), [](char c)
|
||||
{
|
||||
return !std::isdigit(c);
|
||||
}) == val.end();
|
||||
}
|
||||
|
||||
|
||||
void ActionManager::initialize()
|
||||
{
|
||||
validateFlags();
|
||||
|
||||
action = std::move(string{params[1]});
|
||||
transform(action.begin(), action.end(),
|
||||
action.begin(), ::tolower);
|
||||
}
|
||||
|
||||
void ActionManager::validateFlags()
|
||||
{
|
||||
}
|
||||
void ActionManager::validateFlags()
|
||||
{
|
||||
cout<<"Validating flags\n";
|
||||
|
||||
const auto flagVals = parsedFlags();
|
||||
@@ -76,25 +84,24 @@ namespace Managers
|
||||
|
||||
flags.emplace_back(std::move(flg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> ActionManager::parsedFlags()
|
||||
{
|
||||
vector<string> parsed;
|
||||
parsed.reserve(paramCount);
|
||||
vector<string> ActionManager::parsedFlags()
|
||||
{
|
||||
auto parsed = vector<string>();
|
||||
|
||||
for (auto i = 2; i < paramCount; ++i)
|
||||
{
|
||||
const std::string flag(std::move(*(params + i)));
|
||||
parsed.emplace_back(std::move(flag));
|
||||
parsed.push_back(std::move(flag));
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma
|
||||
void ActionManager::printAction() noexcept
|
||||
{
|
||||
#pragma region Testing
|
||||
void ActionManager::printAction() noexcept
|
||||
{
|
||||
if (action.empty())
|
||||
{
|
||||
printf("Action is empty\n");
|
||||
@@ -103,16 +110,17 @@ namespace Managers
|
||||
{
|
||||
cout<<"Action is "<<action<<endl;
|
||||
}
|
||||
}
|
||||
void ActionManager::printFlags() noexcept
|
||||
{
|
||||
}
|
||||
void ActionManager::printFlags() noexcept
|
||||
{
|
||||
cout<<"\nPrinting flags..."<<endl;
|
||||
for (auto flag: flags)
|
||||
{
|
||||
cout<<"flag "<<flag.flag<<endl;
|
||||
cout<<"value "<<flag.value<<endl;
|
||||
}
|
||||
}
|
||||
#pragma Testing
|
||||
#pragma Functions
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -40,15 +40,16 @@ namespace filesystem = std::filesystem;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
#pragma
|
||||
CommitManager::CommitManager(IcarusAction& icaAct) : icaAction(std::move(icaAct))
|
||||
{ }
|
||||
#pragma Constructors
|
||||
|
||||
#pragma region Constructors
|
||||
CommitManager::CommitManager(IcarusAction& icaAct) : icaAction(std::move(icaAct))
|
||||
{ }
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma
|
||||
void CommitManager::commitAction()
|
||||
{
|
||||
#pragma region Functions
|
||||
void CommitManager::commitAction()
|
||||
{
|
||||
auto action = icaAction.action;
|
||||
cout<<"Commiting "<<action<<" action"<<endl;
|
||||
|
||||
@@ -72,14 +73,16 @@ namespace Managers
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum class ActionValues;
|
||||
|
||||
std::map<std::string, CommitManager::ActionValues>
|
||||
|
||||
|
||||
|
||||
std::map<std::string, CommitManager::ActionValues>
|
||||
CommitManager::mapActions() noexcept
|
||||
{
|
||||
{
|
||||
const std::map<std::string, ActionValues> actions{
|
||||
{"delete", ActionValues::deleteAct},
|
||||
{"download", ActionValues::downloadAct},
|
||||
@@ -89,11 +92,13 @@ namespace Managers
|
||||
};
|
||||
|
||||
return actions;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Token CommitManager::parseToken(API api)
|
||||
{
|
||||
|
||||
|
||||
Token CommitManager::parseToken(API api)
|
||||
{
|
||||
cout<<"fetching token\n";
|
||||
UserManager usrMgr{icaAction};
|
||||
auto user = usrMgr.retrieveUser();
|
||||
@@ -101,10 +106,10 @@ namespace Managers
|
||||
TokenManager tk{user, api};
|
||||
|
||||
return tk.requestToken();
|
||||
}
|
||||
}
|
||||
|
||||
void CommitManager::deleteSong()
|
||||
{
|
||||
void CommitManager::deleteSong()
|
||||
{
|
||||
APIParser apiPrs{icaAction};
|
||||
auto api = apiPrs.retrieveAPI();
|
||||
|
||||
@@ -126,9 +131,9 @@ namespace Managers
|
||||
Delete del{api};
|
||||
cout<<"Deleting song..."<<endl;
|
||||
del.deleteSong(token, song);
|
||||
}
|
||||
void CommitManager::downloadSong()
|
||||
{
|
||||
}
|
||||
void CommitManager::downloadSong()
|
||||
{
|
||||
cout<<"Starting downloading process..."<<endl;
|
||||
|
||||
APIParser apiPrs{icaAction};
|
||||
@@ -156,9 +161,9 @@ namespace Managers
|
||||
Download dnld{api};
|
||||
cout<<"downloading song"<<endl;
|
||||
dnld.downloadSong(token, song);
|
||||
}
|
||||
void CommitManager::retrieveObjects()
|
||||
{
|
||||
}
|
||||
void CommitManager::retrieveObjects()
|
||||
{
|
||||
cout<<"Starting retrieve process..."<<endl;
|
||||
|
||||
APIParser apiPrs{icaAction};
|
||||
@@ -185,9 +190,10 @@ namespace Managers
|
||||
RetrieveRecords songs{api, token};
|
||||
songs.retrieve(retrieveType);
|
||||
|
||||
}
|
||||
void CommitManager::uploadSong()
|
||||
{
|
||||
}
|
||||
|
||||
void CommitManager::uploadSong()
|
||||
{
|
||||
auto uploadSingleSong = true;
|
||||
auto recursiveDirectory = false;
|
||||
const auto noConfirm = checkForNoConfirm();
|
||||
@@ -232,10 +238,12 @@ namespace Managers
|
||||
cout<<"Uploading songs from " << songDirectory << endl;
|
||||
upld.uploadSongsFromDirectory(songDirectory, noConfirm, recursiveDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommitManager::uploadSongWithMetadata()
|
||||
{
|
||||
|
||||
|
||||
void CommitManager::uploadSongWithMetadata()
|
||||
{
|
||||
cout<<"Uploading single song with metadata\n\n";
|
||||
|
||||
// Either the set of "-s", "-m", "-ca", "-t" flags or "-smca" must exist with values
|
||||
@@ -269,12 +277,12 @@ namespace Managers
|
||||
{
|
||||
multiTargetUpload(uni);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CommitManager::singTargetUpload(const std::string &songPath, const std::string &trackID,
|
||||
void CommitManager::singTargetUpload(const std::string &songPath, const std::string &trackID,
|
||||
const std::string &metaPath, const std::string &coverPath)
|
||||
{
|
||||
{
|
||||
APIParser apiPrs(icaAction);
|
||||
auto api = apiPrs.retrieveAPI();
|
||||
const auto token = parseToken(api);
|
||||
@@ -308,10 +316,10 @@ namespace Managers
|
||||
|
||||
Upload up(api, token);
|
||||
up.uploadSongWithMetadata(album, song, cover);
|
||||
}
|
||||
}
|
||||
|
||||
void CommitManager::multiTargetUpload(const std::string &sourcePath)
|
||||
{
|
||||
void CommitManager::multiTargetUpload(const std::string &sourcePath)
|
||||
{
|
||||
APIParser apiPrs(icaAction);
|
||||
auto api = apiPrs.retrieveAPI();
|
||||
const auto token = parseToken(api);
|
||||
@@ -362,11 +370,11 @@ namespace Managers
|
||||
{
|
||||
up.uploadSongWithMetadata(album, song, cover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma region private
|
||||
CommitManager::Album CommitManager::retrieveMetadata(const std::string_view path)
|
||||
{
|
||||
#pragma region private
|
||||
CommitManager::Album CommitManager::retrieveMetadata(const std::string_view path)
|
||||
{
|
||||
CommitManager::Album album;
|
||||
const auto fileContent = retrieveFileContent(path);
|
||||
cout<<"Parsing...\n";
|
||||
@@ -396,10 +404,10 @@ namespace Managers
|
||||
}
|
||||
|
||||
return album;
|
||||
}
|
||||
}
|
||||
|
||||
string CommitManager::retrieveFileContent(const std::string_view path)
|
||||
{
|
||||
string CommitManager::retrieveFileContent(const std::string_view path)
|
||||
{
|
||||
string path_str(path);
|
||||
string value;
|
||||
|
||||
@@ -411,11 +419,11 @@ namespace Managers
|
||||
value.assign(buffer.str());
|
||||
|
||||
return value;
|
||||
}
|
||||
#pragma endregion
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
void CommitManager::Album::printInfo()
|
||||
{
|
||||
void CommitManager::Album::printInfo()
|
||||
{
|
||||
std::cout<<"Album: "<<this->album<<"\n";
|
||||
std::cout<<"Album Artist: "<<this->albumArtist<<"\n";
|
||||
std::cout<<"Genre: "<<this->genre<<"\n";
|
||||
@@ -423,7 +431,8 @@ namespace Managers
|
||||
std::cout<<"Track count: "<<this->trackCount<<"\n";
|
||||
std::cout<<"Disc count: "<<this->discCount<<"\n";
|
||||
std::cout<<"\n";
|
||||
}
|
||||
|
||||
#pragma Functions
|
||||
}
|
||||
|
||||
#pragma region Functions
|
||||
|
||||
}
|
||||
|
||||
@@ -11,26 +11,30 @@ using std::string;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
FileManager::FileManager() {}
|
||||
FileManager::FileManager(string filePath)
|
||||
{
|
||||
|
||||
#pragma region Constructors
|
||||
FileManager::FileManager() {}
|
||||
FileManager::FileManager(string filePath)
|
||||
{
|
||||
this->filePath = filePath;
|
||||
readFile();
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
void FileManager::saveFile(string newFilePath)
|
||||
{
|
||||
#pragma region Functions
|
||||
void FileManager::saveFile(string newFilePath)
|
||||
{
|
||||
if (!fileRead)
|
||||
readFile();
|
||||
|
||||
ofstream of{newFilePath, ofstream::binary};
|
||||
of.write(fileBuffer, fileBufferLength);
|
||||
of.close();
|
||||
}
|
||||
}
|
||||
|
||||
void FileManager::readFile()
|
||||
{
|
||||
void FileManager::readFile()
|
||||
{
|
||||
ifstream is{filePath, ifstream::binary};
|
||||
if (is)
|
||||
{
|
||||
@@ -51,16 +55,19 @@ namespace Managers
|
||||
is.close();
|
||||
fileRead = true;
|
||||
}
|
||||
}
|
||||
void FileManager::modifyFilePath(string filePath)
|
||||
{
|
||||
this->filePath = filePath;
|
||||
}
|
||||
|
||||
char* FileManager::retrieveFileBuffer() const
|
||||
{
|
||||
return fileBuffer;
|
||||
}
|
||||
|
||||
int FileManager::retrieveFileBufferLength() const { return fileBufferLength; }
|
||||
}
|
||||
void FileManager::modifyFilePath(string filePath)
|
||||
{
|
||||
this->filePath = filePath;
|
||||
}
|
||||
|
||||
char* FileManager::retrieveFileBuffer() const
|
||||
{
|
||||
return fileBuffer;
|
||||
}
|
||||
|
||||
int FileManager::retrieveFileBufferLength() const { return fileBufferLength; }
|
||||
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -17,24 +17,25 @@ using Models::User;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
#pragma
|
||||
TokenManager::TokenManager(const User& user)
|
||||
{
|
||||
|
||||
#pragma region Constructors
|
||||
TokenManager::TokenManager(const User& user)
|
||||
{
|
||||
this->user = user;
|
||||
}
|
||||
TokenManager::TokenManager(const User& user, API& api)
|
||||
{
|
||||
}
|
||||
TokenManager::TokenManager(const User& user, API& api)
|
||||
{
|
||||
this->user = user;
|
||||
this->api = api;
|
||||
this->api.endpoint = "api/" + api.version
|
||||
+ "/login";
|
||||
}
|
||||
#pragma Constructors
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma
|
||||
Token TokenManager::requestToken()
|
||||
{
|
||||
#pragma region Functions
|
||||
Token TokenManager::requestToken()
|
||||
{
|
||||
Token token{};
|
||||
json usrObj;
|
||||
|
||||
@@ -55,6 +56,7 @@ namespace Managers
|
||||
cout<<"status code "<<r.status_code<<endl;
|
||||
|
||||
return token;
|
||||
}
|
||||
#pragma Functions
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -12,28 +12,29 @@ using Models::User;
|
||||
|
||||
namespace Managers
|
||||
{
|
||||
#pragma
|
||||
UserManager::UserManager(User user)
|
||||
{
|
||||
|
||||
#pragma region Constructors
|
||||
UserManager::UserManager(User user)
|
||||
{
|
||||
this->user = user;
|
||||
}
|
||||
UserManager::UserManager(const IcarusAction icaAct)
|
||||
{
|
||||
}
|
||||
UserManager::UserManager(const IcarusAction icaAct)
|
||||
{
|
||||
this->icaAction = icaAct;
|
||||
this->user = User{};
|
||||
parseUserFromActions();
|
||||
}
|
||||
#pragma Constructors
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma
|
||||
User UserManager::retrieveUser() const
|
||||
{
|
||||
#pragma region Functions
|
||||
User UserManager::retrieveUser() const
|
||||
{
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
void UserManager::parseUserFromActions()
|
||||
{
|
||||
void UserManager::parseUserFromActions()
|
||||
{
|
||||
auto args = icaAction.flags;
|
||||
|
||||
for (auto arg : args)
|
||||
@@ -48,6 +49,7 @@ namespace Managers
|
||||
user.password = arg.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma Functions
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
+21
-17
@@ -1,6 +1,6 @@
|
||||
#include"Parsers/APIParser.h"
|
||||
#include "Parsers/APIParser.h"
|
||||
|
||||
#include<iostream>
|
||||
#include <iostream>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
@@ -10,25 +10,26 @@ using Models::IcarusAction;
|
||||
|
||||
namespace Parsers
|
||||
{
|
||||
#pragma
|
||||
APIParser::APIParser(IcarusAction icaAct) : icaAct(icaAct)
|
||||
{
|
||||
|
||||
#pragma region Constructors
|
||||
APIParser::APIParser(IcarusAction icaAct) : icaAct(icaAct)
|
||||
{
|
||||
api = API{};
|
||||
parseAPI();
|
||||
}
|
||||
#pragma endregion
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma
|
||||
API APIParser::retrieveAPI() const
|
||||
{
|
||||
#pragma region Functions
|
||||
API APIParser::retrieveAPI() const
|
||||
{
|
||||
return api;
|
||||
}
|
||||
}
|
||||
|
||||
void APIParser::parseAPI()
|
||||
{
|
||||
void APIParser::parseAPI()
|
||||
{
|
||||
auto flags = icaAct.flags;
|
||||
cout<<"Parsing api"<<endl;
|
||||
cout << "Parsing api" << endl;
|
||||
|
||||
for (auto i =0; i < flags.size(); ++i)
|
||||
{
|
||||
@@ -40,10 +41,13 @@ namespace Parsers
|
||||
api.url = (value[value.size()-1] == '/') ? value : value + "/";
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO: For now I will hard code
|
||||
// the api version since I am only
|
||||
// on version 1
|
||||
api.version = "v1";
|
||||
}
|
||||
#pragma functions
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
+19
-17
@@ -1,9 +1,9 @@
|
||||
#include"Syncers/Delete.h"
|
||||
#include "Syncers/Delete.h"
|
||||
|
||||
#include<exception>
|
||||
#include<iostream>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
|
||||
#include<cpr/cpr.h>
|
||||
#include <cpr/cpr.h>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
@@ -16,18 +16,19 @@ using Models::Token;
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
#pragma
|
||||
Delete::Delete(API api)
|
||||
{
|
||||
|
||||
#pragma region Constructors
|
||||
Delete::Delete(API api)
|
||||
{
|
||||
this->api = api;
|
||||
this->api.endpoint = "song/data";
|
||||
}
|
||||
#pragma Constructors
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma
|
||||
void Delete::deleteSong(const Token token, Song song)
|
||||
{
|
||||
#pragma region Functions
|
||||
void Delete::deleteSong(const Token token, Song song)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto url = retrieveUrl(song);
|
||||
@@ -46,10 +47,10 @@ namespace Syncers
|
||||
cout<<msg<<endl;
|
||||
}
|
||||
cout<<"Finished"<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
string Delete::retrieveUrl(Song song)
|
||||
{
|
||||
string Delete::retrieveUrl(Song song)
|
||||
{
|
||||
string url{api.url + "api/" + api.version + "/" +
|
||||
api.endpoint + "/"};
|
||||
|
||||
@@ -57,6 +58,7 @@ namespace Syncers
|
||||
cout<<"url "<<url<<endl;
|
||||
|
||||
return url;
|
||||
}
|
||||
#pragma Functions
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
+27
-25
@@ -1,10 +1,10 @@
|
||||
#include"Syncers/Download.h"
|
||||
#include "Syncers/Download.h"
|
||||
|
||||
#include<exception>
|
||||
#include<iostream>
|
||||
#include<fstream>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include<cpr/cpr.h>
|
||||
#include <cpr/cpr.h>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
@@ -18,23 +18,24 @@ using Models::Token;
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
#pragma
|
||||
Download::Download() { }
|
||||
Download::Download(API api)
|
||||
{
|
||||
|
||||
#pragma region Constructors
|
||||
Download::Download() { }
|
||||
Download::Download(API api)
|
||||
{
|
||||
this->api = api;
|
||||
this->api.endpoint = "song/data";
|
||||
}
|
||||
Download::Download(string filePath)
|
||||
{
|
||||
}
|
||||
Download::Download(string filePath)
|
||||
{
|
||||
downloadFilePath = filePath;
|
||||
}
|
||||
#pragma Constructors
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma
|
||||
void Download::downloadSong(const Token token, Song song)
|
||||
{
|
||||
#pragma region Functions
|
||||
void Download::downloadSong(const Token token, Song song)
|
||||
{
|
||||
try
|
||||
{
|
||||
string url = retrieveUrl(song);
|
||||
@@ -63,10 +64,10 @@ namespace Syncers
|
||||
auto msg = e.what();
|
||||
cout<<msg<<endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string Download::retrieveUrl(Song song)
|
||||
{
|
||||
string Download::retrieveUrl(Song song)
|
||||
{
|
||||
string url{api.url + "api/" + api.version + "/" +
|
||||
api.endpoint + "/"};
|
||||
|
||||
@@ -74,10 +75,10 @@ namespace Syncers
|
||||
cout<<"url "<<url<<endl;
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
void Download::saveSong(Song& song)
|
||||
{
|
||||
void Download::saveSong(Song& song)
|
||||
{
|
||||
cout<<"\nSaving song to: "<<song.songPath<<endl;
|
||||
int bufferLength = song.data.length();
|
||||
const char *data = song.data.c_str();
|
||||
@@ -86,6 +87,7 @@ namespace Syncers
|
||||
ofstream saveSong{song.songPath, std::ios::binary};
|
||||
saveSong.write(data, bufferLength);
|
||||
saveSong.close();
|
||||
}
|
||||
#pragma Functions
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -20,12 +20,15 @@ using Utilities::Conversions;
|
||||
namespace Syncers
|
||||
{
|
||||
|
||||
RetrieveRecords::RetrieveRecords() { }
|
||||
RetrieveRecords::RetrieveRecords(API api, Token token)
|
||||
#pragma region Constructors
|
||||
RetrieveRecords::RetrieveRecords() { }
|
||||
RetrieveRecords::RetrieveRecords(API api, Token token)
|
||||
: token(token), api(api) { }
|
||||
#pragma endregion
|
||||
|
||||
void RetrieveRecords::retrieve(CommitManager::RetrieveTypes type)
|
||||
{
|
||||
#pragma region Functions
|
||||
void RetrieveRecords::retrieve(CommitManager::RetrieveTypes type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CommitManager::RetrieveTypes::songs:
|
||||
@@ -34,9 +37,9 @@ namespace Syncers
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
void RetrieveRecords::fetchSongs()
|
||||
{
|
||||
}
|
||||
void RetrieveRecords::fetchSongs()
|
||||
{
|
||||
cout<<"fetching songs"<<endl;
|
||||
auto url = api.url + "api/" + api.version + "/" + "song";
|
||||
|
||||
@@ -58,5 +61,7 @@ namespace Syncers
|
||||
writeData.open("songs.json");
|
||||
writeData<<songData.dump(4);
|
||||
writeData.close();
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
+44
-41
@@ -25,9 +25,19 @@ using namespace cpr;
|
||||
|
||||
namespace Syncers
|
||||
{
|
||||
#pragma region Functions
|
||||
Song Upload::uploadSong(Song& song)
|
||||
{
|
||||
|
||||
#pragma region Constructors
|
||||
Upload::Upload() { }
|
||||
Upload::Upload(API api) : api(api)
|
||||
{
|
||||
this->api.endpoint = "song/data";
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Functions
|
||||
Song Upload::uploadSong(Song& song)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto url = retrieveUrl();
|
||||
@@ -63,11 +73,11 @@ namespace Syncers
|
||||
}
|
||||
|
||||
return song;
|
||||
}
|
||||
}
|
||||
|
||||
void Upload::uploadSongsFromDirectory(const std::string& directory,
|
||||
void Upload::uploadSongsFromDirectory(const std::string& directory,
|
||||
const bool noConfirm, bool recursive = false)
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
auto songs = retrieveAllSongsFromDirectory(directory, recursive);
|
||||
@@ -89,8 +99,9 @@ namespace Syncers
|
||||
|
||||
if (!confirmUpload)
|
||||
{
|
||||
cout << "exiting...\n";
|
||||
std::exit(-1);
|
||||
confirmUpload = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cout << "uploading songs\n";
|
||||
@@ -103,11 +114,11 @@ namespace Syncers
|
||||
{
|
||||
cout<<e.what()<<endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Upload::uploadSongWithMetadata(Managers::CommitManager::Album &album, Models::Song& song, Models::CoverArt &cover)
|
||||
{
|
||||
void Upload::uploadSongWithMetadata(Managers::CommitManager::Album &album, Models::Song& song, Models::CoverArt &cover)
|
||||
{
|
||||
this->api.endpoint.assign("song/data/upload/with/data");
|
||||
|
||||
try
|
||||
@@ -153,10 +164,10 @@ namespace Syncers
|
||||
auto msg = e.what();
|
||||
cout<<"Error: "<<msg<<"\n";
|
||||
}
|
||||
}
|
||||
std::vector<Song> Upload::retrieveAllSongsFromDirectory(const std::string& directory,
|
||||
}
|
||||
std::vector<Song> Upload::retrieveAllSongsFromDirectory(const std::string& directory,
|
||||
bool recursive)
|
||||
{
|
||||
{
|
||||
std::vector<Song> allSongs;
|
||||
|
||||
if (recursive)
|
||||
@@ -179,20 +190,20 @@ namespace Syncers
|
||||
}
|
||||
|
||||
return allSongs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string Upload::retrieveUrl()
|
||||
{
|
||||
string Upload::retrieveUrl()
|
||||
{
|
||||
const string url{api.url + "api/" + api.version + "/" +
|
||||
api.endpoint};
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Song Upload::retrieveSongPath(fs::directory_entry& dirEntry)
|
||||
{
|
||||
Song Upload::retrieveSongPath(fs::directory_entry& dirEntry)
|
||||
{
|
||||
constexpr auto mp3Ext = ".mp3";
|
||||
Song song;
|
||||
if (fs::is_regular_file(dirEntry.path()))
|
||||
@@ -206,23 +217,13 @@ namespace Syncers
|
||||
}
|
||||
|
||||
return song;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma region Testing
|
||||
void Upload::printSongDetails()
|
||||
{
|
||||
cout<<"Song details: "<<endl;
|
||||
cout<<"Id: "<<song.id<<endl;
|
||||
cout<<"Title: "<<song.title<<endl;
|
||||
cout<<"Artist: "<<song.artist<<endl;
|
||||
cout<<"Album: "<<song.album<<endl;
|
||||
cout<<"Genre: "<<song.genre<<endl;
|
||||
cout<<"Year: "<<song.year<<endl;
|
||||
cout<<"Duration: "<<song.duration<<endl;
|
||||
}
|
||||
void Upload::printSongDetails(std::vector<Song>& songs)
|
||||
{
|
||||
#pragma region Testing
|
||||
|
||||
void Upload::printSongDetails(std::vector<Song>& songs)
|
||||
{
|
||||
for (auto& song: songs)
|
||||
{
|
||||
cout<<"Song details: "<<endl;
|
||||
@@ -235,9 +236,10 @@ namespace Syncers
|
||||
cout<<"Duration: "<<song.duration<<endl;
|
||||
cout<<"Path: "<<song.songPath<<endl;
|
||||
}
|
||||
}
|
||||
void Upload::printJsonData(const json& obj)
|
||||
{
|
||||
}
|
||||
|
||||
void Upload::printJsonData(const json& obj)
|
||||
{
|
||||
cout<<endl<<endl<<"JSon data: "<<endl;
|
||||
cout<<"id: "<<obj["id"]<<endl;
|
||||
cout<<"title: "<<obj["title"]<<endl;
|
||||
@@ -249,7 +251,8 @@ namespace Syncers
|
||||
cout<<"song_data: "<<obj["song_data"]<<endl;
|
||||
|
||||
cout<<endl<<endl;;
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
+21
-16
@@ -1,17 +1,20 @@
|
||||
#include"UI/AboutWindow.h"
|
||||
#include "UI/AboutWindow.h"
|
||||
|
||||
using std::unique_ptr;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
AboutWindow::AboutWindow(QWidget* parent): QDialog(parent)
|
||||
{
|
||||
#pragma region Constructors
|
||||
AboutWindow::AboutWindow(QWidget* parent): QDialog(parent)
|
||||
{
|
||||
setupWindow();
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
void AboutWindow::setupWindow()
|
||||
{
|
||||
#pragma region Functions
|
||||
void AboutWindow::setupWindow()
|
||||
{
|
||||
windowWidth = 250;
|
||||
windowHeight = 300;
|
||||
|
||||
@@ -32,16 +35,18 @@ namespace UI
|
||||
setWindowTitle("About");
|
||||
|
||||
connections();
|
||||
}
|
||||
void AboutWindow::connections()
|
||||
{
|
||||
}
|
||||
void AboutWindow::connections()
|
||||
{
|
||||
QObject::connect(actionButtonQt.get(), SIGNAL(clicked()), this,
|
||||
SLOT(closeWindow()));
|
||||
}
|
||||
|
||||
|
||||
void AboutWindow::closeWindow()
|
||||
{
|
||||
this->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AboutWindow::closeWindow()
|
||||
{
|
||||
this->hide();
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
+54
-48
@@ -1,11 +1,11 @@
|
||||
#include"UI/MainWindow.h"
|
||||
#include "UI/MainWindow.h"
|
||||
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include"Models/UploadForm.h"
|
||||
#include"Syncers/Upload.h"
|
||||
#include"Utilities/Conversions.h"
|
||||
#include "Models/UploadForm.h"
|
||||
#include "Syncers/Upload.h"
|
||||
#include "Utilities/Conversions.h"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
@@ -17,18 +17,22 @@ using Syncers::Upload;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
|
||||
#pragma region Constructors
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
setupMainWindow();
|
||||
aboutWindow = unique_ptr<AboutWindow>{new AboutWindow};
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
void MainWindow::configureDownloadSection()
|
||||
{
|
||||
}
|
||||
void MainWindow::configureUploadSection()
|
||||
{
|
||||
#pragma region Functions
|
||||
void MainWindow::configureDownloadSection()
|
||||
{
|
||||
}
|
||||
void MainWindow::configureUploadSection()
|
||||
{
|
||||
uploadSongQt = unique_ptr<QPushButton>{new QPushButton(tr("Upload"))};
|
||||
urlQt = unique_ptr<QTextEdit>{new QTextEdit()};
|
||||
sourceFilePathQt = unique_ptr<QTextEdit>{new QTextEdit()};
|
||||
@@ -49,20 +53,20 @@ namespace UI
|
||||
subLayoutOneQt.get()->addLayout(urlPortion.get());
|
||||
subLayoutOneQt->addLayout(songPathPortion.get());
|
||||
mainLayoutQt.get()->addLayout(subLayoutOneQt.get());
|
||||
}
|
||||
void MainWindow::configureWindowDimensions()
|
||||
{
|
||||
}
|
||||
void MainWindow::configureWindowDimensions()
|
||||
{
|
||||
windowWidth = 450;
|
||||
windowHeight = 450;
|
||||
}
|
||||
void MainWindow::configureWindowProperties()
|
||||
{
|
||||
}
|
||||
void MainWindow::configureWindowProperties()
|
||||
{
|
||||
setWindowTitle("IcarusDownloadManager");
|
||||
setFixedHeight(windowHeight);
|
||||
setFixedWidth(windowWidth);
|
||||
}
|
||||
void MainWindow::connections()
|
||||
{
|
||||
}
|
||||
void MainWindow::connections()
|
||||
{
|
||||
QObject::connect(uploadSongQt.get(), SIGNAL(clicked()), this, SLOT(uploadSong()));
|
||||
QObject::connect(closeApplicationQt.get(), SIGNAL(triggered()), this,
|
||||
SLOT(exitApplication()));
|
||||
@@ -70,9 +74,9 @@ namespace UI
|
||||
SLOT(displaySoftwareInformation()));
|
||||
QObject::connect(windowComboBox.get(), SIGNAL(activated(int)),
|
||||
this, SLOT(setCurrentIndex(int)));
|
||||
}
|
||||
void MainWindow::createMenus()
|
||||
{
|
||||
}
|
||||
void MainWindow::createMenus()
|
||||
{
|
||||
fileMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("File"))};
|
||||
editMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("Edit"))};
|
||||
helpMenuQt = unique_ptr<QMenu>{menuBar()->addMenu(tr("Help"))};
|
||||
@@ -86,9 +90,9 @@ namespace UI
|
||||
fileMenuQt->addAction(closeApplicationQt.get());
|
||||
helpMenuQt->addAction(aboutApplicationQt.get());
|
||||
|
||||
}
|
||||
void MainWindow::setupMainWidget()
|
||||
{
|
||||
}
|
||||
void MainWindow::setupMainWidget()
|
||||
{
|
||||
mainWidgetQt = unique_ptr<QWidget>{new QWidget};
|
||||
|
||||
windowComboBox = unique_ptr<QComboBox>{new QComboBox};
|
||||
@@ -104,9 +108,9 @@ namespace UI
|
||||
stackLayout->addWidget(uploadSongWidgetQt.get());
|
||||
|
||||
mainWidgetQt->setLayout(stackLayout.get());
|
||||
}
|
||||
void MainWindow::setupMainWindow()
|
||||
{
|
||||
}
|
||||
void MainWindow::setupMainWindow()
|
||||
{
|
||||
configureWindowDimensions();
|
||||
|
||||
mainLayoutQt = unique_ptr<QVBoxLayout>{new QVBoxLayout};
|
||||
@@ -130,34 +134,34 @@ namespace UI
|
||||
configureWindowProperties();
|
||||
|
||||
connections();
|
||||
}
|
||||
void MainWindow::setupWindowLists()
|
||||
{
|
||||
}
|
||||
void MainWindow::setupWindowLists()
|
||||
{
|
||||
windowComboBox->addItem(tr("Upload song"));
|
||||
windowComboBox->addItem(tr("Download song"));
|
||||
windowComboBox->addItem(tr("Display all songs"));
|
||||
windowComboBox->addItem(tr("Display songs"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::exitApplication()
|
||||
{
|
||||
void MainWindow::exitApplication()
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
void MainWindow::displaySoftwareInformation()
|
||||
{
|
||||
}
|
||||
void MainWindow::displaySoftwareInformation()
|
||||
{
|
||||
aboutWindow->show();
|
||||
}
|
||||
void MainWindow::setCurrentIndex(int index)
|
||||
{
|
||||
}
|
||||
void MainWindow::setCurrentIndex(int index)
|
||||
{
|
||||
cout<<"index "<<index<<endl;
|
||||
QString qText = windowComboBox->itemText(index);
|
||||
auto cnvert = Utilities::Conversions(qText);
|
||||
auto convertedStr = cnvert.convertQStringToString();
|
||||
cout<<"item text"<<endl;
|
||||
}
|
||||
void MainWindow::uploadSong()
|
||||
{
|
||||
}
|
||||
void MainWindow::uploadSong()
|
||||
{
|
||||
uploadSongQt->setEnabled(false);
|
||||
|
||||
string url = urlQt->toPlainText().toUtf8().constData();
|
||||
@@ -170,5 +174,7 @@ namespace UI
|
||||
upld.uploadSong();
|
||||
|
||||
uploadSongQt->setEnabled(true);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
#include"Utilities/Conversions.h"
|
||||
#include "Utilities/Conversions.h"
|
||||
|
||||
#include<iostream>
|
||||
#include <iostream>
|
||||
|
||||
using std::string;
|
||||
using std::unique_ptr;
|
||||
|
||||
namespace Utilities
|
||||
{
|
||||
Conversions::Conversions()
|
||||
{
|
||||
initializeValues();
|
||||
}
|
||||
|
||||
void Conversions::initializeValues()
|
||||
{
|
||||
}
|
||||
template <typename T>
|
||||
void Conversions::printValue(T val)
|
||||
{
|
||||
Conversions::Conversions()
|
||||
{
|
||||
initializeValues();
|
||||
}
|
||||
|
||||
void Conversions::initializeValues()
|
||||
{
|
||||
}
|
||||
template <typename T>
|
||||
void Conversions::printValue(T val)
|
||||
{
|
||||
std::cout<<"going to print value"<<std::endl;
|
||||
std::cout<<val<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user