mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-17 04:06:26 +01:00
Implement file import sorting
This commit is contained in:
parent
edd7800009
commit
f174c3a1a1
2 changed files with 29 additions and 0 deletions
|
|
@ -1440,10 +1440,29 @@ SoundFileBrowser::get_paths ()
|
||||||
vector<string> filenames = chooser.get_filenames();
|
vector<string> filenames = chooser.get_filenames();
|
||||||
vector<string>::iterator i;
|
vector<string>::iterator i;
|
||||||
|
|
||||||
|
std::map<std::string, int64_t> im;
|
||||||
|
|
||||||
for (i = filenames.begin(); i != filenames.end(); ++i) {
|
for (i = filenames.begin(); i != filenames.end(); ++i) {
|
||||||
GStatBuf buf;
|
GStatBuf buf;
|
||||||
if ((!g_stat((*i).c_str(), &buf)) && S_ISREG(buf.st_mode)) {
|
if ((!g_stat((*i).c_str(), &buf)) && S_ISREG(buf.st_mode)) {
|
||||||
results.push_back (*i);
|
results.push_back (*i);
|
||||||
|
im[*i] = buf.st_mtime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sort_order () == FileMtime) {
|
||||||
|
results.clear ();
|
||||||
|
std::multimap<int64_t, std::string> im2;
|
||||||
|
std::transform (im.begin (), im.end (),
|
||||||
|
std::inserter (im2, im2.begin ()),
|
||||||
|
[](std::pair<std::string, int64_t>i) {return std::pair<int64_t, std::string>(i.second, i.first);});
|
||||||
|
|
||||||
|
for (auto const& i : im2) {
|
||||||
|
results.push_back (i.second);
|
||||||
|
}
|
||||||
|
} else if (sort_order () == FileName) {
|
||||||
|
results.clear ();
|
||||||
|
for (auto const& i : im) {
|
||||||
|
results.push_back (i.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,16 @@ protected:
|
||||||
void on_show();
|
void on_show();
|
||||||
bool on_key_press_event (GdkEventKey*);
|
bool on_key_press_event (GdkEventKey*);
|
||||||
virtual void do_something(int action);
|
virtual void do_something(int action);
|
||||||
|
|
||||||
|
enum SortOrder {
|
||||||
|
SelectionOrder,
|
||||||
|
FileName,
|
||||||
|
FileMtime
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual SortOrder sort_order () const {
|
||||||
|
return SelectionOrder;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SoundFileChooser : public SoundFileBrowser
|
class SoundFileChooser : public SoundFileBrowser
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue