* Use mtime as fallback timestamp for files without EXIF data As suggested in #6449, with date-based sorting it can be useful to have at least *some* sort of time-relevant information for EXIF-less files, to prevent them from falling back to getting sorted alphabetically all the time. This commit simply defaults the file timestamp to the file's mtime as returned by g_stat. For annoying reasons, it doesn't suffice to merely forward the timestamp to the FileData structs - we also need to keep track of it inside FilesData to cover the case of a file with 0 frames in it. * Add DateTime to Thumbnail Putting it here facilitate easier sorting without having to re-construct the DateTime on every comparison. To simplify things moving forwards, use the Glib::DateTime struct right away. This struct also contains timezone information, but we don't currently care about timezone - so just use the local timezone as the best approximation. (Nothing currently depends on getting the timezone right, anyway) In addition to the above, this commit also changes the logic to allow generating datetime strings even for files with missing EXIF (which makes sense as a result of the previous commit allowing the use of mtime instead). * Implement file sorting in thumbnail view For simplicity, I decided to only implement the attributes that I could verily easily reach from the existing metadata exported by Thumbnail. Ideally, I would also like to be able to sort by "last modified" but I'm not sure of the best way to reach this from this place in the code. It's worth pointing out that, with the current implementation, the list will not dynamically re-sort itself until you re-select the sorting method - even if you make changes to the files that would otherwise affect the sorting (e.g. changing the rank while sorting by rank). One might even call this a feature, not a bug, since it prevents thumbnails from moving around while you're trying to re-label them. You can always re-select "sort by ..." from the context menu to force a re-sort. Fixes #3317 Co-authored-by: Thanatomanic <6567747+Thanatomanic@users.noreply.github.com>
224 lines
7.1 KiB
C++
224 lines
7.1 KiB
C++
/*
|
|
* This file is part of RawTherapee.
|
|
*
|
|
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
|
|
*
|
|
* RawTherapee is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* RawTherapee is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
#pragma once
|
|
|
|
#include <map>
|
|
|
|
#include <gtkmm.h>
|
|
|
|
#include "browserfilter.h"
|
|
#include "exportpanel.h"
|
|
#include "extprog.h"
|
|
#include "filebrowserentry.h"
|
|
#include "lwbutton.h"
|
|
#include "partialpastedlg.h"
|
|
#include "pparamschangelistener.h"
|
|
#include "../rtengine/profilestore.h"
|
|
#include "thumbbrowserbase.h"
|
|
|
|
#include "../rtengine/noncopyable.h"
|
|
|
|
class FileBrowser;
|
|
class FileBrowserEntry;
|
|
class ProfileStoreLabel;
|
|
|
|
class FileBrowserListener
|
|
{
|
|
public:
|
|
virtual ~FileBrowserListener() = default;
|
|
virtual void filterApplied() = 0;
|
|
virtual void openRequested(const std::vector<Thumbnail*>& tbe) = 0;
|
|
virtual void developRequested(const std::vector<FileBrowserEntry*>& tbe, bool fastmode) = 0;
|
|
virtual void renameRequested(const std::vector<FileBrowserEntry*>& tbe) = 0;
|
|
virtual void deleteRequested(const std::vector<FileBrowserEntry*>& tbe, bool inclBatchProcessed, bool onlySelected) = 0;
|
|
virtual void copyMoveRequested(const std::vector<FileBrowserEntry*>& tbe, bool moveRequested) = 0;
|
|
virtual void selectionChanged(const std::vector<Thumbnail*>& tbe) = 0;
|
|
virtual void clearFromCacheRequested(const std::vector<FileBrowserEntry*>& tbe, bool leavenotrace) = 0;
|
|
virtual bool isInTabMode() const = 0;
|
|
};
|
|
|
|
/*
|
|
* Class handling actions common to all thumbnails of the file browser
|
|
*/
|
|
class FileBrowser final : public ThumbBrowserBase,
|
|
public LWButtonListener,
|
|
public ExportPanelListener,
|
|
public ProfileStoreListener,
|
|
public rtengine::NonCopyable
|
|
{
|
|
private:
|
|
typedef sigc::signal<void> type_trash_changed;
|
|
|
|
using ThumbBrowserBase::redrawNeeded;
|
|
|
|
IdleRegister idle_register;
|
|
unsigned int session_id_;
|
|
|
|
protected:
|
|
Gtk::MenuItem* rank[6];
|
|
MyImageMenuItem* colorlabel[6];
|
|
Gtk::MenuItem* trash;
|
|
Gtk::MenuItem* untrash;
|
|
Gtk::MenuItem* develop;
|
|
Gtk::MenuItem* developfast;
|
|
Gtk::MenuItem* rename;
|
|
Gtk::MenuItem* remove;
|
|
Gtk::MenuItem* removeInclProc;
|
|
Gtk::MenuItem* open;
|
|
Gtk::MenuItem* inspect;
|
|
Gtk::MenuItem* selall;
|
|
Gtk::RadioMenuItem* sortMethod[Options::SORT_METHOD_COUNT];
|
|
Gtk::RadioMenuItem* sortOrder[2];
|
|
Gtk::MenuItem* copyTo;
|
|
Gtk::MenuItem* moveTo;
|
|
|
|
Gtk::MenuItem* menuSort;
|
|
Gtk::MenuItem* menuRank;
|
|
Gtk::MenuItem* menuLabel;
|
|
Gtk::MenuItem* menuFileOperations;
|
|
Gtk::MenuItem* menuProfileOperations;
|
|
Gtk::MenuItem* menuExtProg;
|
|
Gtk::MenuItem** amiExtProg;
|
|
Gtk::MenuItem* miOpenDefaultViewer;
|
|
std::map<Glib::ustring, const ExtProgAction*> mMenuExtProgs; // key is menuitem label
|
|
|
|
Gtk::MenuItem* menuDF;
|
|
Gtk::MenuItem* selectDF;
|
|
Gtk::MenuItem* thisIsDF;
|
|
Gtk::MenuItem* autoDF;
|
|
|
|
Gtk::MenuItem* menuFF;
|
|
Gtk::MenuItem* selectFF;
|
|
Gtk::MenuItem* thisIsFF;
|
|
Gtk::MenuItem* autoFF;
|
|
|
|
Gtk::MenuItem* copyprof;
|
|
Gtk::MenuItem* pasteprof;
|
|
Gtk::MenuItem* partpasteprof;
|
|
Gtk::MenuItem* applyprof;
|
|
Gtk::MenuItem* applypartprof;
|
|
Gtk::MenuItem* resetdefaultprof;
|
|
Gtk::MenuItem* clearprof;
|
|
Gtk::MenuItem* cachemenu;
|
|
Gtk::MenuItem* clearFromCache;
|
|
Gtk::MenuItem* clearFromCacheFull;
|
|
Gtk::Menu* pmenu;
|
|
|
|
MyImageMenuItem* colorlabel_pop[6];
|
|
Gtk::Menu* pmenuColorLabels;
|
|
void* colorLabel_actionData;
|
|
void menuColorlabelActivated (Gtk::MenuItem* m); // use only when menu is invoked via FileBrowser::buttonPressed to pass actionData
|
|
|
|
Glib::RefPtr<Gtk::AccelGroup> pmaccelgroup;
|
|
|
|
BatchPParamsChangeListener* bppcl;
|
|
FileBrowserListener* tbl;
|
|
BrowserFilter filter;
|
|
int numFiltered;
|
|
|
|
void toTrashRequested (std::vector<FileBrowserEntry*> tbe);
|
|
void fromTrashRequested (std::vector<FileBrowserEntry*> tbe);
|
|
void sortMethodRequested (int method);
|
|
void sortOrderRequested (int order);
|
|
void rankingRequested (std::vector<FileBrowserEntry*> tbe, int rank);
|
|
void colorlabelRequested (std::vector<FileBrowserEntry*> tbe, int colorlabel);
|
|
void requestRanking (int rank);
|
|
void requestColorLabel(int colorlabel);
|
|
void notifySelectionListener ();
|
|
void openRequested( std::vector<FileBrowserEntry*> mselected);
|
|
void inspectRequested( std::vector<FileBrowserEntry*> mselected);
|
|
ExportPanel* exportPanel;
|
|
|
|
type_trash_changed m_trash_changed;
|
|
|
|
public:
|
|
FileBrowser ();
|
|
~FileBrowser () override;
|
|
|
|
void addEntry (FileBrowserEntry* entry); // can be called from any thread
|
|
void addEntry_ (FileBrowserEntry* entry); // this must be executed inside the gtk thread
|
|
FileBrowserEntry* delEntry (const Glib::ustring& fname); // return the entry if found here return NULL otherwise
|
|
void close ();
|
|
|
|
unsigned int session_id() const { return session_id_; }
|
|
|
|
void setBatchPParamsChangeListener (BatchPParamsChangeListener* l)
|
|
{
|
|
bppcl = l;
|
|
}
|
|
void setFileBrowserListener (FileBrowserListener* l)
|
|
{
|
|
tbl = l;
|
|
}
|
|
|
|
void menuItemActivated (Gtk::MenuItem* m);
|
|
void applyMenuItemActivated (ProfileStoreLabel *label);
|
|
void applyPartialMenuItemActivated (ProfileStoreLabel *label);
|
|
|
|
void applyFilter (const BrowserFilter& filter);
|
|
int getNumFiltered()
|
|
{
|
|
return numFiltered;
|
|
}
|
|
|
|
void buttonPressed (LWButton* button, int actionCode, void* actionData) override;
|
|
void redrawNeeded (LWButton* button) override;
|
|
bool checkFilter (ThumbBrowserEntryBase* entry) const override;
|
|
void rightClicked () override;
|
|
void doubleClicked (ThumbBrowserEntryBase* entry) override;
|
|
bool keyPressed (GdkEventKey* event) override;
|
|
|
|
void saveThumbnailHeight (int height) override;
|
|
int getThumbnailHeight () override;
|
|
|
|
|
|
void enableTabMode(bool enable);
|
|
bool isInTabMode() override
|
|
{
|
|
return tbl ? tbl->isInTabMode() : false;
|
|
}
|
|
|
|
void openNextImage();
|
|
void openPrevImage();
|
|
void selectImage(const Glib::ustring& fname, bool doScroll = true);
|
|
|
|
void copyProfile ();
|
|
void pasteProfile ();
|
|
void partPasteProfile ();
|
|
void openNextPreviousEditorImage(const Glib::ustring& fname, eRTNav eNextPrevious);
|
|
|
|
#ifdef WIN32
|
|
void openDefaultViewer (int destination);
|
|
#endif
|
|
|
|
void thumbRearrangementNeeded () override;
|
|
|
|
void selectionChanged () override;
|
|
|
|
void setExportPanel (ExportPanel* expanel);
|
|
// exportpanel interface
|
|
void exportRequested() override;
|
|
|
|
void storeCurrentValue() override;
|
|
void updateProfileList() override;
|
|
void restoreValue() override;
|
|
|
|
type_trash_changed trash_changed();
|
|
};
|