mirror of
https://github.com/QuasarApp/SoundBand.git
synced 2025-04-26 15:24:31 +00:00
added select options into playlistmodel
This commit is contained in:
parent
ffd1faa1a1
commit
ad11f78182
@ -87,3 +87,58 @@ void PlayListModel::setNewPlayList(const QString &playList){
|
||||
playListName = playList;
|
||||
onPlayListChanged();
|
||||
}
|
||||
|
||||
bool PlayListModel::select(int id){
|
||||
if(!playList)
|
||||
return false;
|
||||
|
||||
for(QList<syncLib::SongHeader>::Iterator i = 0; i < playList->end(); i++){
|
||||
if(i->id == id){
|
||||
return i->isSelected = true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PlayListModel::unSelect(int id){
|
||||
if(!playList)
|
||||
return false;
|
||||
|
||||
for(QList<syncLib::SongHeader>::Iterator i = 0; i < playList->end(); i++){
|
||||
if(i->id == id){
|
||||
i->isSelected = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<int> PlayListModel::getSelected(){
|
||||
QList<int> result;
|
||||
|
||||
if(!playList)
|
||||
return result;
|
||||
|
||||
for(QList<syncLib::SongHeader>::Iterator i = 0; i < playList->end(); i++){
|
||||
if(i->isSelected){
|
||||
result.push_back(i->id);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool PlayListModel::isSelected(int id){
|
||||
if(!playList)
|
||||
return false;
|
||||
|
||||
for(QList<syncLib::SongHeader>::Iterator i = 0; i < playList->end(); i++){
|
||||
if(i->id == id){
|
||||
return i->isSelected;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,33 @@ public slots:
|
||||
* @param playList - name of playlist
|
||||
*/
|
||||
void setNewPlayList(const QString &playList);
|
||||
|
||||
/**
|
||||
* @brief select a song from playList;
|
||||
* @param id - if of song
|
||||
* @return true if all done
|
||||
*/
|
||||
bool select(int id);
|
||||
|
||||
/**
|
||||
* @brief unselect a song from playList;
|
||||
* @param id - if of song
|
||||
* @return true if all done
|
||||
*/
|
||||
bool unSelect(int id);
|
||||
|
||||
/**
|
||||
* @brief getSelected
|
||||
* @return list of selected songs
|
||||
*/
|
||||
QList<int> getSelected();
|
||||
|
||||
/**
|
||||
* @brief isSelected
|
||||
* @param id - id of checked song
|
||||
* @return true if song selected
|
||||
*/
|
||||
bool isSelected(int id);
|
||||
};
|
||||
|
||||
#endif // PLAYLISTMODEL_H
|
||||
|
@ -5,6 +5,7 @@ namespace syncLib{
|
||||
static const QStringList ValidSongs = {".mp3", ".wav", ".ogg"};
|
||||
SongHeader::SongHeader()
|
||||
{
|
||||
this->isSelected = false;
|
||||
this->id = -1;
|
||||
this->name = "";
|
||||
this->size = 0;
|
||||
|
@ -26,6 +26,7 @@ struct Syncer
|
||||
class SongHeader{
|
||||
|
||||
public:
|
||||
bool isSelected;
|
||||
int id;
|
||||
QString name;
|
||||
int size;
|
||||
@ -36,6 +37,14 @@ public:
|
||||
bool isNameValid() const;
|
||||
virtual bool isValid() const;
|
||||
virtual ~SongHeader();
|
||||
|
||||
/**
|
||||
* serialize data:
|
||||
* id,
|
||||
* size,
|
||||
* and,
|
||||
* name
|
||||
*/
|
||||
friend QDataStream& operator << (QDataStream& stream, const SongHeader& song);
|
||||
friend QDataStream& operator >> (QDataStream& stream, SongHeader& song);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user