Remove mountpoint when storing folders to talk.

When using Rockbox Utility some later time the mountpoint might have changed.
This would invalidate the list of folders to voice even if the folders are
still present on the player. Remove the mountpoint part before storing the
folders, and add it when loading the settings.

Change-Id: Ic4ed98b205d20f6a0b3a1e1da396bbdcd02c255e
This commit is contained in:
Dominik Riebeling 2012-06-14 22:51:32 +02:00
parent 537dfe482f
commit 96f63e6078

View file

@ -52,11 +52,13 @@ InstallTalkWindow::InstallTalkWindow(QWidget *parent) : QDialog(parent)
void InstallTalkWindow::saveSettings(void)
{
QString mp = RbSettings::value(RbSettings::Mountpoint).toString();
QModelIndexList si = ui.treeView->selectionModel()->selectedIndexes();
QStringList foldersToTalk;
for(int i = 0; i < si.size(); i++) {
if(si.at(i).column() == 0) {
foldersToTalk.append(fsm->filePath(si.at(i)));
QString current = fsm->filePath(si.at(i));
foldersToTalk.append(current.remove(QRegExp("^" + mp)));
}
}
RbSettings::setValue(RbSettings::TalkFolders, foldersToTalk);
@ -118,6 +120,7 @@ void InstallTalkWindow::accept()
void InstallTalkWindow::updateSettings(void)
{
QString mp = RbSettings::value(RbSettings::Mountpoint).toString();
QString ttsName = RbSettings::value(RbSettings::Tts).toString();
TTSBase* tts = TTSBase::getTTS(this,ttsName);
if(tts->configOk())
@ -129,7 +132,7 @@ void InstallTalkWindow::updateSettings(void)
QStringList folders = RbSettings::value(RbSettings::TalkFolders).toStringList();
for(int i = 0; i < folders.size(); ++i) {
QModelIndex mi = fsm->index(folders.at(i));
QModelIndex mi = fsm->index(mp + folders.at(i));
ui.treeView->selectionModel()->select(mi, QItemSelectionModel::Select);
// make sure all parent items are expanded.
while((mi = mi.parent()) != QModelIndex()) {