mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-14 02:14:21 +01:00
Watch subdirectories in the library
This commit is contained in:
parent
4108dc7c73
commit
541f3be7ba
2
TODO
2
TODO
@ -8,7 +8,7 @@
|
||||
- Clicking play plays selected item
|
||||
|
||||
- Edit tags in playlist view
|
||||
- Watch subdirectories in library
|
||||
- Disabled fields in tag editor
|
||||
|
||||
Long-term:
|
||||
- iPod
|
||||
|
@ -27,6 +27,9 @@
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>title</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
@ -37,6 +40,9 @@
|
||||
<property name="text">
|
||||
<string>Album</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>album</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
@ -47,6 +53,9 @@
|
||||
<property name="text">
|
||||
<string>Artist</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>artist</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
@ -57,6 +66,9 @@
|
||||
<property name="text">
|
||||
<string>Genre</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>genre</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
@ -67,6 +79,9 @@
|
||||
<property name="text">
|
||||
<string>Track</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>track</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
@ -92,6 +107,9 @@
|
||||
<property name="text">
|
||||
<string>Year</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>year</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -117,6 +135,9 @@
|
||||
<property name="text">
|
||||
<string>Comment</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>comment</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
@ -168,6 +189,17 @@
|
||||
<header>lineedit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
<tabstop>title</tabstop>
|
||||
<tabstop>album</tabstop>
|
||||
<tabstop>artist</tabstop>
|
||||
<tabstop>genre</tabstop>
|
||||
<tabstop>track</tabstop>
|
||||
<tabstop>year</tabstop>
|
||||
<tabstop>comment</tabstop>
|
||||
<tabstop>filename</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
@ -177,8 +209,8 @@
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
<x>591</x>
|
||||
<y>262</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
@ -193,8 +225,8 @@
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
<x>591</x>
|
||||
<y>268</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
|
@ -35,6 +35,16 @@ void LibraryWatcher::AddDirectories(const DirectoryList& directories) {
|
||||
|
||||
// Start monitoring this directory for more changes
|
||||
fs_watcher_->addPath(dir.path);
|
||||
|
||||
// And all the subdirectories
|
||||
QDirIterator it(dir.path,
|
||||
QDir::NoDotAndDotDot | QDir::Dirs,
|
||||
QDirIterator::Subdirectories);
|
||||
while (it.hasNext()) {
|
||||
QString subdir(it.next());
|
||||
fs_watcher_->addPath(subdir);
|
||||
paths_watched_[subdir] = dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,6 +53,16 @@ void LibraryWatcher::RemoveDirectories(const DirectoryList &directories) {
|
||||
fs_watcher_->removePath(dir.path);
|
||||
paths_watched_.remove(dir.path);
|
||||
paths_needing_rescan_.removeAll(dir.path);
|
||||
|
||||
// And all the subdirectories
|
||||
QDirIterator it(dir.path,
|
||||
QDir::NoDotAndDotDot | QDir::Dirs,
|
||||
QDirIterator::Subdirectories);
|
||||
while (it.hasNext()) {
|
||||
QString subdir(it.next());
|
||||
fs_watcher_->removePath(subdir);
|
||||
paths_watched_.remove(subdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,6 +160,7 @@ bool LibraryWatcher::FindSongByPath(const SongList& list, const QString& path, S
|
||||
}
|
||||
|
||||
void LibraryWatcher::DirectoryChanged(const QString &path) {
|
||||
qDebug() << path;
|
||||
if (!paths_needing_rescan_.contains(path))
|
||||
paths_needing_rescan_ << path;
|
||||
|
||||
|
11
src/song.cpp
11
src/song.cpp
@ -1,5 +1,7 @@
|
||||
#include "song.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <taglib/fileref.h>
|
||||
#include <taglib/tag.h>
|
||||
#include <taglib/tstring.h>
|
||||
@ -315,5 +317,12 @@ bool Song::Save() const {
|
||||
ref.tag()->setYear(d->year_);
|
||||
ref.tag()->setTrack(d->track_);
|
||||
|
||||
return ref.save();
|
||||
bool ret = ref.save();
|
||||
if (ret) {
|
||||
// Linux: inotify doesn't seem to notice the change to the file unless we
|
||||
// change the timestamps as well. (this is what touch does)
|
||||
utimensat(0, QFile::encodeName(d->filename_).constData(), NULL, 0);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user