mirror of
https://github.com/QuasarApp/SoundBand.git
synced 2025-05-12 15:09:35 +00:00
add new functions
This commit is contained in:
commit
2709a70365
@ -13,7 +13,15 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += main.cpp \
|
||||
syncengine.cpp
|
||||
syncengine.cpp \
|
||||
../sync/chronotime.cpp \
|
||||
../sync/ETcpSocket.cpp \
|
||||
../sync/LocalScanner.cpp \
|
||||
../sync/mysql.cpp \
|
||||
../sync/node.cpp \
|
||||
../sync/player.cpp \
|
||||
../sync/song.cpp \
|
||||
../sync/sync.cpp
|
||||
|
||||
RESOURCES += qml.qrc
|
||||
|
||||
@ -31,4 +39,14 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
DISTFILES +=
|
||||
|
||||
HEADERS += \
|
||||
syncengine.h
|
||||
syncengine.h \
|
||||
../sync/chronotime.h \
|
||||
../sync/config.h \
|
||||
../sync/ETcpSocket.h \
|
||||
../sync/exaptions.h \
|
||||
../sync/LocalScanner.h \
|
||||
../sync/mysql.h \
|
||||
../sync/node.h \
|
||||
../sync/player.h \
|
||||
../sync/song.h \
|
||||
../sync/sync.h
|
||||
|
@ -1,33 +1,37 @@
|
||||
#include "syncengine.h"
|
||||
|
||||
/*QPixmap ColorImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize){
|
||||
|
||||
QStringList params;
|
||||
|
||||
int index = 0;
|
||||
int oldIndex;
|
||||
while((index = id.indexOf('/', index + 1)) != -1){
|
||||
index ++;
|
||||
params.push_back(id.mid(oldIndex, index));
|
||||
oldIndex = index;
|
||||
}
|
||||
|
||||
QString comand = params.first();
|
||||
|
||||
if(comand == CURENT_SONG){
|
||||
|
||||
}
|
||||
|
||||
if(comand == SONG_BY_ID && params.size() > ){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
SyncEngine::SyncEngine()
|
||||
{
|
||||
sync = new syncLib::Sync();
|
||||
sqlApi = sync->getSqlApi();
|
||||
}
|
||||
|
||||
const QString& SyncEngine::curentSong()const{
|
||||
return sync->getCurentSong()->name;
|
||||
}
|
||||
|
||||
const QStringList& SyncEngine::curentPlayList() const{
|
||||
|
||||
QStringList &result = tempList;
|
||||
result.clear();
|
||||
|
||||
QList<syncLib::SongHeader> *list = sync->getPlayList();
|
||||
|
||||
for(QString & name : list){
|
||||
result.push_back(name);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const QString& SyncEngine::curentPlayListName() const{
|
||||
return _curentPlayListName;
|
||||
}
|
||||
|
||||
const QStringList& SyncEngine::allPlayLists()const{
|
||||
|
||||
}
|
||||
const QString& SyncEngine::curentSong()const{
|
||||
return "";
|
||||
|
||||
SyncEngine::~SyncEngine(){
|
||||
delete sync;
|
||||
}
|
||||
|
@ -19,9 +19,12 @@ class SyncEngine : public QObject
|
||||
|
||||
private:
|
||||
syncLib::Sync *sync;
|
||||
|
||||
syncLib::MySql * sqlApi;
|
||||
QString _curentPlayListName;
|
||||
QStringList tempList;
|
||||
public:
|
||||
SyncEngine();
|
||||
~SyncEngine();
|
||||
public slots:
|
||||
/**
|
||||
* @brief curentSong
|
||||
@ -33,7 +36,7 @@ public slots:
|
||||
* @brief curentPlayList
|
||||
* @return return curent Play List
|
||||
*/
|
||||
const QStringList& curentPlayList()const;
|
||||
const QStringList &curentPlayList()const;
|
||||
|
||||
/**
|
||||
* @brief curentPlayListName
|
||||
@ -45,7 +48,7 @@ public slots:
|
||||
* @brief allPlayLists
|
||||
* @return names of all play lists
|
||||
*/
|
||||
const QStringList allPlayLists();
|
||||
const QStringList &allPlayLists()const;
|
||||
|
||||
/**
|
||||
* @brief curentSongImage
|
||||
@ -127,7 +130,7 @@ public slots:
|
||||
* @brief pos
|
||||
* @return posistion of curent song on double
|
||||
*/
|
||||
const double pos()const;
|
||||
double pos()const;
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -228,6 +228,20 @@ bool MySql::updateAvailableSongs(QList<SongHeader>& list, const QString& playLis
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MySql::updateAvailableSongs(QStringList& list, const QString& playList){
|
||||
|
||||
QList<SongHeader> tempList;
|
||||
|
||||
if(!updateAvailableSongs(tempList, playList))
|
||||
return false;
|
||||
|
||||
for(SongHeader &header : tempList){
|
||||
list.push_back(header.name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MySql::removeSong(const SongHeader &header){
|
||||
if(header.id > -1){
|
||||
QString qyer = QString("DELETE from songs where id=%0").arg(header.id);
|
||||
|
@ -63,6 +63,14 @@ public:
|
||||
*/
|
||||
bool updateAvailableSongs(QList<SongHeader>& list, const QString &playList = "");
|
||||
|
||||
/**
|
||||
* @brief updateAvelableSongs will update the list of participants of songs.
|
||||
* @param list - [out value] list of avelable song.
|
||||
* @param playList - play list of songs (string).
|
||||
* @return true if all done
|
||||
*/
|
||||
bool updateAvailableSongs(QStringList& list, const QString &playList = "");
|
||||
|
||||
/**
|
||||
* @brief removeSong - remove song from local database.
|
||||
* @param header - heder removing song. first : song removed by id,
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace syncLib{
|
||||
|
||||
Sync::Sync(const QString address, int port, const QString &datadir):
|
||||
Sync::Sync(const QString &address, int port, const QString &datadir):
|
||||
node(nullptr),
|
||||
player(nullptr),
|
||||
curentSong(nullptr)
|
||||
@ -37,6 +37,10 @@ Sync::Sync(const QString address, int port, const QString &datadir):
|
||||
connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(endPlay(QMediaPlayer::State)));
|
||||
}
|
||||
|
||||
MySql* Sync::getSqlApi(){
|
||||
return sql;
|
||||
}
|
||||
|
||||
bool Sync::findHeader(const Song &song){
|
||||
|
||||
for(SongHeader & header: playList){
|
||||
|
14
sync/sync.h
14
sync/sync.h
@ -72,6 +72,13 @@ private slots:
|
||||
void endPlay(QMediaPlayer::State state);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief getSqlApi
|
||||
* @return pointer of sql api
|
||||
*/
|
||||
MySql* getSqlApi();
|
||||
|
||||
/**
|
||||
* @brief Play song in this device, if device has not supported playning media data this method throw MediaExcrption.
|
||||
* @param header of song
|
||||
@ -152,6 +159,11 @@ public:
|
||||
*/
|
||||
const QList<ETcpSocket*>& getServersList() const;
|
||||
|
||||
/**
|
||||
* @brief listen - a server
|
||||
* @param server - host
|
||||
* @return true id all done
|
||||
*/
|
||||
bool listen(ETcpSocket* server);
|
||||
|
||||
/**
|
||||
@ -206,7 +218,7 @@ public:
|
||||
*/
|
||||
int addNewSong(const QString &url);
|
||||
|
||||
Sync(const QString address = DEFAULT_ADRESS, int port = DEFAULT_PORT, const QString& datadir = DATABASE_NAME);
|
||||
Sync(const QString &address = DEFAULT_ADRESS, int port = DEFAULT_PORT, const QString& datadir = DATABASE_NAME);
|
||||
~Sync();
|
||||
|
||||
signals:
|
||||
|
Loading…
x
Reference in New Issue
Block a user