File indexing completed on 2024-04-28 04:20:50
0001 // SPDX-FileCopyrightText: 2003-2013 Jesper K. Pedersen <jesper.pedersen@kdab.com> 0002 // SPDX-FileCopyrightText: 2005 Stephan Binner <binner@kde.org> 0003 // SPDX-FileCopyrightText: 2005-2007 Dirk Mueller <mueller@kde.org> 0004 // SPDX-FileCopyrightText: 2007 Laurent Montel <montel@kde.org> 0005 // SPDX-FileCopyrightText: 2007 Tuomas Suutari <tuomas@nepnep.net> 0006 // SPDX-FileCopyrightText: 2007-2008 Jan Kundrát <jkt@flaska.net> 0007 // SPDX-FileCopyrightText: 2009 Hassan Ibraheem <hasan.ibraheem@gmail.com> 0008 // SPDX-FileCopyrightText: 2011-2012 Miika Turkia <miika.turkia@gmail.com> 0009 // SPDX-FileCopyrightText: 2012 Andreas Neustifter <andreas.neustifter@gmail.com> 0010 // SPDX-FileCopyrightText: 2012-2023 Johannes Zarl-Zierl <johannes@zarl-zierl.at> 0011 // SPDX-FileCopyrightText: 2013 Dominik Broj <broj.dominik@gmail.com> 0012 // SPDX-FileCopyrightText: 2014 David Edmundson <kde@davidedmundson.co.uk> 0013 // SPDX-FileCopyrightText: 2014-2022 Tobias Leupold <tl@stonemx.de> 0014 // SPDX-FileCopyrightText: 2017-2020 Robert Krawitz <rlk@alum.mit.edu> 0015 // 0016 // SPDX-License-Identifier: GPL-2.0-or-later 0017 0018 #ifndef ANNOTATIONDIALOG_DIALOG_H 0019 #define ANNOTATIONDIALOG_DIALOG_H 0020 0021 #include <kpabase/config-kpa-marble.h> 0022 0023 #include "ImagePreviewWidget.h" 0024 #include "ListSelect.h" 0025 0026 #include <DB/Category.h> 0027 #include <DB/ImageInfoList.h> 0028 #include <DB/search/ImageSearchInfo.h> 0029 #include <kpabase/StringSet.h> 0030 #include <kpabase/enums.h> 0031 0032 #include <QCheckBox> 0033 #include <QDialog> 0034 #include <QList> 0035 #include <QSpinBox> 0036 0037 class DockWidget; 0038 class KActionCollection; 0039 class KComboBox; 0040 class KLineEdit; 0041 class KRatingWidget; 0042 class KTextEdit; 0043 class QCloseEvent; 0044 class QDockWidget; 0045 class QMainWindow; 0046 class QMoveEvent; 0047 class QProgressBar; 0048 class QPushButton; 0049 class QResizeEvent; 0050 class QSplitter; 0051 class QStackedWidget; 0052 class QTimeEdit; 0053 0054 namespace Viewer 0055 { 0056 class ViewerWidget; 0057 } 0058 0059 namespace DB 0060 { 0061 class ImageInfo; 0062 } 0063 0064 namespace Map 0065 { 0066 class MapView; 0067 } 0068 0069 namespace AnnotationDialog 0070 { 0071 class ImagePreview; 0072 class DateEdit; 0073 class DescriptionEdit; 0074 class ShortCutManager; 0075 class ResizableFrame; 0076 0077 class Dialog : public QDialog 0078 { 0079 Q_OBJECT 0080 public: 0081 explicit Dialog(QWidget *parent); 0082 ~Dialog() override; 0083 int configure(DB::ImageInfoList list, bool oneAtATime); 0084 DB::ImageSearchInfo search(DB::ImageSearchInfo *search = nullptr); 0085 KActionCollection *actions(); 0086 QPair<QString, QString> lastSelectedPositionableTag() const; 0087 QList<QPair<QString, QString>> positionableTagCandidates() const; 0088 void addTagToCandidateList(QString category, QString tag); 0089 void removeTagFromCandidateList(QString category, QString tag); 0090 void checkProposedTagData(QPair<QString, QString> tagData, ResizableFrame *areaToExclude) const; 0091 void areaChanged(); 0092 bool positionableTagAvailable(const QString &category, const QString &tag) const; 0093 QSet<QString> positionedTags(const QString &category) const; 0094 /** 0095 * @return A list of all ResizableFrame objects on the current image 0096 */ 0097 QList<ResizableFrame *> areas() const; 0098 /** 0099 * @brief taggedAreas creates a map of all the currently tagged areas. 0100 * This is different from areas(), which also contains untagged areas. 0101 * This is different from \code m_editList[m_current].areas()\endcode, which 0102 * does not include newly added (or deleted) areas. 0103 * @return a map of currently tagged areas 0104 */ 0105 DB::TaggedAreas taggedAreas() const; 0106 ListSelect *listSelectForCategory(const QString &category); 0107 0108 protected Q_SLOTS: 0109 void slotRevert(); 0110 void slotIndexChanged(int index); 0111 void doneTagging(); 0112 void continueLater(); 0113 void slotClearSearchForm(); 0114 void slotOptions(); 0115 void slotSaveWindowSetup(); 0116 void slotDeleteOption(DB::Category *, const QString &); 0117 void slotRenameOption(DB::Category *, const QString &, const QString &); 0118 void reject() override; 0119 void rotate(int angle); 0120 void slotSetFuzzyDate(); 0121 void slotResetLayout(); 0122 void slotStartDateChanged(const DB::ImageDate &); 0123 void slotCopyPrevious(); 0124 void slotShowAreas(bool showAreas); 0125 void slotRatingChanged(int); 0126 void togglePreview(); 0127 void descriptionPageUpDownPressed(QKeyEvent *event); 0128 void slotNewArea(AnnotationDialog::ResizableFrame *area); 0129 void positionableTagSelected(QString category, QString tag); 0130 void positionableTagDeselected(QString category, QString tag); 0131 void positionableTagRenamed(QString category, QString oldTag, QString newTag); 0132 #ifdef HAVE_MARBLE 0133 void setCancelMapLoading(); 0134 void annotationMapVisibilityChanged(bool visible); 0135 void populateMap(); 0136 #endif 0137 void showEvent(QShowEvent *event) override; 0138 void hideEvent(QHideEvent *event) override; 0139 /** 0140 * @brief slotDiscardFiles removes a list of files from the annotation dialog as if they were discarded. 0141 * The main usage is to remove files from the dialog if they are deleted, avoiding stale image data from showing up. 0142 * 0143 * Files that are not currently in the list of annotated files are silently ignored. 0144 * @param files 0145 */ 0146 void slotDiscardFiles(const DB::FileNameList &files); 0147 0148 Q_SIGNALS: 0149 void imageRotated(const DB::FileName &id); 0150 0151 protected: 0152 QDockWidget *createDock(const QString &title, const QString &name, Qt::DockWidgetArea location, QWidget *widget); 0153 QWidget *createDateWidget(ShortCutManager &shortCutManager); 0154 QWidget *createPreviewWidget(); 0155 ListSelect *createListSel(const DB::CategoryPtr &category); 0156 0157 void load(); 0158 void writeToInfo(); 0159 void setup(); 0160 void loadInfo(const DB::ImageSearchInfo &); 0161 int exec() override; 0162 void closeEvent(QCloseEvent *) override; 0163 void showFloatingWindows(); 0164 void hideFloatingWindows(); 0165 bool hasChanges(); 0166 StringSet changedOptions(const ListSelect *); 0167 void showHelpDialog(UsageMode); 0168 void resizeEvent(QResizeEvent *) override; 0169 void moveEvent(QMoveEvent *) override; 0170 void setupFocus(); 0171 void closeDialog(); 0172 void loadWindowLayout(); 0173 void setupActions(); 0174 void setUpCategoryListBoxForMultiImageSelection(ListSelect *, const DB::ImageInfoList &images); 0175 std::tuple<Utilities::StringSet, Utilities::StringSet, Utilities::StringSet> selectionForMultiSelect(const ListSelect *, const DB::ImageInfoList &images); 0176 void saveAndClose(); 0177 void ShowHideSearch(bool show); 0178 #ifdef HAVE_MARBLE 0179 void clearMapData(); 0180 #endif 0181 0182 private: 0183 QStackedWidget *m_stack; 0184 Viewer::ViewerWidget *m_fullScreenPreview; 0185 DB::ImageInfoList m_origList; 0186 QList<DB::ImageInfo> m_editList; 0187 int m_current; 0188 UsageMode m_setup; 0189 QList<ListSelect *> m_optionList; 0190 DB::ImageSearchInfo m_oldSearch; 0191 int m_accept; 0192 QList<QDockWidget *> m_dockWidgets; 0193 // "special" named dockWidgets (used to set default layout): 0194 QDockWidget *m_generalDock; 0195 QDockWidget *m_previewDock; 0196 QDockWidget *m_descriptionDock; 0197 0198 // Widgets 0199 QMainWindow *m_dockWindow; 0200 KLineEdit *m_imageLabel; 0201 DateEdit *m_startDate; 0202 DateEdit *m_endDate; 0203 QLabel *m_endDateLabel; 0204 QLabel *m_imageFilePatternLabel; 0205 KLineEdit *m_imageFilePattern; 0206 0207 ImagePreviewWidget *m_preview; 0208 QPushButton *m_revertBut; 0209 QPushButton *m_clearBut; 0210 QPushButton *m_okBut; 0211 QPushButton *m_continueLaterBut; 0212 DescriptionEdit *m_description; 0213 QTimeEdit *m_time; 0214 QLabel *m_timeLabel; 0215 QCheckBox *m_isFuzzyDate; 0216 KRatingWidget *m_rating; 0217 KComboBox *m_ratingSearchMode; 0218 QLabel *m_ratingSearchLabel; 0219 bool m_ratingChanged; 0220 QSpinBox *m_megapixel; 0221 QLabel *m_megapixelLabel; 0222 QSpinBox *m_max_megapixel; 0223 QLabel *m_max_megapixelLabel; 0224 QCheckBox *m_searchRAW; 0225 QString m_conflictText; 0226 QString m_firstDescription; 0227 0228 KActionCollection *m_actions; 0229 0230 /** Clean state of the dock window. 0231 * 0232 * Used in slotResetLayout(). 0233 */ 0234 QByteArray m_dockWindowCleanState; 0235 void tidyAreas(); 0236 QPair<QString, QString> m_lastSelectedPositionableTag; 0237 QList<QPair<QString, QString>> m_positionableTagCandidates; 0238 QMap<QString, ListSelect *> m_listSelectList; 0239 0240 bool m_positionableCategories; 0241 bool m_areasChanged; 0242 0243 #ifdef HAVE_MARBLE 0244 QDockWidget *m_mapDock; 0245 QWidget *m_annotationMapContainer; 0246 Map::MapView *m_annotationMap; 0247 void updateMapForCurrentImage(); 0248 QProgressBar *m_mapLoadingProgress; 0249 QPushButton *m_cancelMapLoadingButton; 0250 void mapLoadingFinished(bool mapHasImages, bool allImagesHaveCoordinates); 0251 bool m_cancelMapLoading; 0252 bool m_mapIsPopulated; 0253 #endif 0254 }; 0255 } 0256 0257 #endif /* ANNOTATIONDIALOG_DIALOG_H */ 0258 0259 // vi:expandtab:tabstop=4 shiftwidth=4: