Skip to content
Snippets Groups Projects
Commit 7aadfa9e authored by Edric Milaret's avatar Edric Milaret Committed by Alexandre Lision
Browse files

fix ringtone model path

Tuleap: #339
Change-Id: I71783ee048bde01b4696752fe651801fa33478b2
parent 0c8ce959
No related branches found
No related tags found
No related merge requests found
......@@ -120,15 +120,16 @@ bool LocalRingtoneCollection::load()
#elif defined(Q_OS_WIN)
QDir ringtonesDir(QFileInfo(QCoreApplication::applicationFilePath()).path()+"/ringtones/");
#elif defined(Q_OS_OSX)
QDir ringtonesDir(QFileInfo(QCoreApplication::applicationFilePath()).path()+"/ringtones/"); //FIXME
QDir ringtonesDir(QCoreApplication::applicationDirPath());
ringtonesDir.cdUp();
ringtonesDir.cd("Resources/ringtones/");
#endif
if(!ringtonesDir.exists())
return true;
const QStringList entries = ringtonesDir.entryList({"*.wav", "*.ul", "*.au", ".mp3", ".flac"}, QDir::Files);
const QStringList entries = ringtonesDir.entryList({"*.wav", "*.ul", "*.au", "*.flac"}, QDir::Files);
for (const QString& item : entries) {
QFileInfo fileinfo(ringtonesDir.absolutePath()+item);
QFileInfo fileinfo(ringtonesDir.absolutePath()+"/"+item);
Ringtone* info = new Ringtone();
info->setPath(fileinfo.absoluteFilePath());
info->setName(item);
......@@ -270,7 +271,7 @@ void Serializable::RingtoneNode::read(const QJsonObject &json)
void Serializable::RingtoneNode::write(QJsonObject& json)
{
json["path"] = ringtone->path().path();
json["path"] = ringtone->path();
json["name"] = ringtone->name();
}
......
......@@ -19,6 +19,7 @@
//Qt
#include <QtCore/QUrl>
#include <QtCore/QDir>
class RingtonePrivate
{
......@@ -44,7 +45,7 @@ Ringtone::~Ringtone()
delete d_ptr;
}
QUrl Ringtone::path() const
QString Ringtone::path() const
{
return d_ptr->m_Path;
}
......@@ -55,9 +56,9 @@ QString Ringtone::name() const
}
void Ringtone::setPath(const QUrl& url)
void Ringtone::setPath(const QString& path)
{
d_ptr->m_Path = url.path();
d_ptr->m_Path = QDir::toNativeSeparators(path);
}
void Ringtone::setName(const QString& name)
......
......@@ -30,12 +30,12 @@ public:
virtual ~Ringtone();
//Getter
QUrl path () const;
QString path () const;
QString name () const;
bool isPlaying() const;
//Setter
void setPath (const QUrl& url );
void setPath (const QString& path );
void setName (const QString& name );
void setIsPlaying(const bool value);
......
......@@ -71,8 +71,6 @@ RingtoneModel::RingtoneModel(QObject* parent)
, CollectionManagerInterface<Ringtone>(this)
, d_ptr(new RingtoneModelPrivate(this))
{
// ConfigurationManagerInterface& configurationManager = ConfigurationManager::instance();
d_ptr->m_pCollection = addCollection<LocalRingtoneCollection>();
}
......@@ -175,10 +173,10 @@ int RingtoneModelPrivate::currentIndex(Account* a) const
const QString rt = a->ringtonePath();
for (int i=0;i<m_lRingtone.size();i++) {
Ringtone* info = m_lRingtone[i];
if (info->path().path() == rt)
if (info->path() == rt)
return i;
}
return -1;
return 0;
}
QItemSelectionModel* RingtoneModel::selectionModel(Account* a) const
......@@ -189,7 +187,7 @@ QItemSelectionModel* RingtoneModel::selectionModel(Account* a) const
connect(d_ptr->m_hSelectionModels[a],&QItemSelectionModel::currentChanged, [a,this](const QModelIndex& idx) {
if (idx.isValid()) {
a->setRingtonePath(d_ptr->m_lRingtone[idx.row()]->path().path());
a->setRingtonePath(d_ptr->m_lRingtone[idx.row()]->path());
}
});
......@@ -207,7 +205,7 @@ void RingtoneModel::play(const QModelIndex& idx)
return;
}
CallManagerInterface& callManager = CallManager::instance();
Q_NOREPLY callManager.startRecordedFilePlayback(info->path().path());
Q_NOREPLY callManager.startRecordedFilePlayback(info->path());
if (!d_ptr->m_pTimer) {
d_ptr->m_pTimer = new QTimer(this);
d_ptr->m_pTimer->setInterval(10000);
......@@ -227,7 +225,7 @@ void RingtoneModelPrivate::slotStopTimer()
{
if (m_pCurrent) {
CallManagerInterface& callManager = CallManager::instance();
callManager.stopRecordedFilePlayback(m_pCurrent->path().path());
callManager.stopRecordedFilePlayback(m_pCurrent->path());
m_pCurrent->setIsPlaying(false);
const QModelIndex& idx = q_ptr->index(m_lRingtone.indexOf(m_pCurrent),0);
emit q_ptr->dataChanged(idx,q_ptr->index(idx.row(),1));
......@@ -248,12 +246,12 @@ bool RingtoneModel::addItemCallback(const Ringtone* item)
d_ptr->m_lRingtone << const_cast<Ringtone*>(item);
endInsertRows();
if (Account* a = d_ptr->m_hPendingSelection[item]) {
if (auto a = d_ptr->m_hPendingSelection[item]) {
if (auto sm = d_ptr->m_hSelectionModels[a])
sm->setCurrentIndex(index(rowCount()-1,0), QItemSelectionModel::ClearAndSelect);
else
a->setRingtonePath(item->path().path());
a->setRingtonePath(item->path());
d_ptr->m_hPendingSelection[item] = nullptr;
}
......@@ -270,8 +268,8 @@ bool RingtoneModel::removeItemCallback(const Ringtone* item)
bool RingtoneModel::add(const QUrl& path, Account* autoSelect)
{
auto r = new Ringtone(this);
r->setPath(path);
r->setName(QFile(path.path()).fileName());
r->setPath(path.toLocalFile());
r->setName(QFile(path.toLocalFile()).fileName());
if (autoSelect)
d_ptr->m_hPendingSelection[r] = autoSelect;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment