diff --git a/app/abstractcontextmanageritem.h b/app/abstractcontextmanageritem.h index cb3793d2..68db51d8 100644 --- a/app/abstractcontextmanageritem.h +++ b/app/abstractcontextmanageritem.h @@ -1,53 +1,53 @@ /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ABSTRACTCONTEXTMANAGERITEM_H #define ABSTRACTCONTEXTMANAGERITEM_H // Qt #include namespace Gwenview { class ContextManager; struct AbstractContextManagerItemPrivate; class AbstractContextManagerItem : public QObject { Q_OBJECT public: AbstractContextManagerItem(ContextManager*); - virtual ~AbstractContextManagerItem(); + ~AbstractContextManagerItem() override; QWidget* widget() const; ContextManager* contextManager() const; protected: void setWidget(QWidget* widget); private: AbstractContextManagerItemPrivate * const d; }; } // namespace #endif /* ABSTRACTCONTEXTMANAGERITEM_H */ diff --git a/app/fileopscontextmanageritem.h b/app/fileopscontextmanageritem.h index fd3fb0f5..4737c906 100644 --- a/app/fileopscontextmanageritem.h +++ b/app/fileopscontextmanageritem.h @@ -1,103 +1,103 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FILEOPSCONTEXTMANAGERITEM_H #define FILEOPSCONTEXTMANAGERITEM_H // Qt // KDE #include #include // Local #include "abstractcontextmanageritem.h" class QAction; class QMimeData; class QListView; class KActionCollection; class KXMLGUIClient; namespace Gwenview { class SideBarGroup; class FileOpsContextManagerItem : public AbstractContextManagerItem { Q_OBJECT public: FileOpsContextManagerItem(Gwenview::ContextManager* manager, QListView* thumbnailView, KActionCollection* actionCollection, KXMLGUIClient* client); - ~FileOpsContextManagerItem(); + ~FileOpsContextManagerItem() override; private Q_SLOTS: void updateActions(); void updatePasteAction(); void updateSideBarContent(); void cut(); void copy(); void paste(); void rename(); void copyTo(); void moveTo(); void linkTo(); void trash(); void del(); void restore(); void showProperties(); void createFolder(); void populateOpenMenu(); void openWith(QAction* action); void openContainingFolder(); private: QList urlList() const; void updateServiceList(); QMimeData* selectionMimeData(); QUrl pasteTargetUrl() const; QListView* mThumbnailView; KXMLGUIClient* mXMLGUIClient; SideBarGroup* mGroup; QAction * mCutAction; QAction * mCopyAction; QAction * mPasteAction; QAction * mCopyToAction; QAction * mMoveToAction; QAction * mLinkToAction; QAction * mRenameAction; QAction * mTrashAction; QAction * mDelAction; QAction * mRestoreAction; QAction * mShowPropertiesAction; QAction * mCreateFolderAction; QAction * mOpenWithAction; QAction * mOpenContainingFolderAction; QList mRegularFileActionList; QList mTrashFileActionList; KService::List mServiceList; KNewFileMenu * mNewFileMenu; bool mInTrash; }; } // namespace #endif /* FILEOPSCONTEXTMANAGERITEM_H */ diff --git a/app/filtercontroller.h b/app/filtercontroller.h index 97ce01ee..9ea903b9 100644 --- a/app/filtercontroller.h +++ b/app/filtercontroller.h @@ -1,369 +1,369 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef FILTERCONTROLLER_H #define FILTERCONTROLLER_H #include // Qt #include #include #include #include // KDE #include // Local #include #include #include #ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE // KDE #include // Local #include #include #endif class QAction; class QFrame; class QLineEdit; class QComboBox; class KComboBox; namespace Gwenview { class SortedDirModel; /** * An AbstractSortedDirModelFilter which filters on the file names */ class NameFilter : public AbstractSortedDirModelFilter { public: enum Mode { Contains, DoesNotContain }; NameFilter(SortedDirModel* model) : AbstractSortedDirModelFilter(model) , mText() , mMode(Contains) {} bool needsSemanticInfo() const override { return false; } bool acceptsIndex(const QModelIndex& index) const override { if (mText.isEmpty()) { return true; } switch (mMode) { case Contains: return index.data().toString().contains(mText, Qt::CaseInsensitive); default: /*DoesNotContain:*/ return !index.data().toString().contains(mText, Qt::CaseInsensitive); } } void setText(const QString& text) { mText = text; model()->applyFilters(); } void setMode(Mode mode) { mMode = mode; model()->applyFilters(); } private: QString mText; Mode mMode; }; class NameFilterWidget : public QWidget { Q_OBJECT public: NameFilterWidget(SortedDirModel*); - ~NameFilterWidget(); + ~NameFilterWidget() override; private Q_SLOTS: void applyNameFilter(); private: QPointer mFilter; KComboBox* mModeComboBox; QLineEdit* mLineEdit; }; /** * An AbstractSortedDirModelFilter which filters on the file dates */ class DateFilter : public AbstractSortedDirModelFilter { public: enum Mode { GreaterOrEqual, Equal, LessOrEqual }; DateFilter(SortedDirModel* model) : AbstractSortedDirModelFilter(model) , mMode(GreaterOrEqual) {} bool needsSemanticInfo() const override { return false; } bool acceptsIndex(const QModelIndex& index) const override { if (!mDate.isValid()) { return true; } KFileItem fileItem = model()->itemForSourceIndex(index); QDate date = TimeUtils::dateTimeForFileItem(fileItem).date(); switch (mMode) { case GreaterOrEqual: return date >= mDate; case Equal: return date == mDate; default: /* LessOrEqual */ return date <= mDate; } } void setDate(const QDate& date) { mDate = date; model()->applyFilters(); } void setMode(Mode mode) { mMode = mode; model()->applyFilters(); } private: QDate mDate; Mode mMode; }; class DateFilterWidget : public QWidget { Q_OBJECT public: DateFilterWidget(SortedDirModel*); - ~DateFilterWidget(); + ~DateFilterWidget() override; private Q_SLOTS: void applyDateFilter(); private: QPointer mFilter; KComboBox* mModeComboBox; DateWidget* mDateWidget; }; #ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE /** * An AbstractSortedDirModelFilter which filters on file ratings */ class RatingFilter : public AbstractSortedDirModelFilter { public: enum Mode { GreaterOrEqual, Equal, LessOrEqual }; RatingFilter(SortedDirModel* model) : AbstractSortedDirModelFilter(model) , mRating(0) , mMode(GreaterOrEqual) {} bool needsSemanticInfo() const override { return true; } bool acceptsIndex(const QModelIndex& index) const override { SemanticInfo info = model()->semanticInfoForSourceIndex(index); switch (mMode) { case GreaterOrEqual: return info.mRating >= mRating; case Equal: return info.mRating == mRating; default: /* LessOrEqual */ return info.mRating <= mRating; } } void setRating(int value) { mRating = value; model()->applyFilters(); } void setMode(Mode mode) { mMode = mode; model()->applyFilters(); } private: int mRating; Mode mMode; }; class RatingFilterWidget : public QWidget { Q_OBJECT public: RatingFilterWidget(SortedDirModel*); - ~RatingFilterWidget(); + ~RatingFilterWidget() override; private Q_SLOTS: void slotRatingChanged(int value); void updateFilterMode(); private: KComboBox* mModeComboBox; KRatingWidget* mRatingWidget; QPointer mFilter; }; /** * An AbstractSortedDirModelFilter which filters on associated tags */ class TagFilter : public AbstractSortedDirModelFilter { public: TagFilter(SortedDirModel* model) : AbstractSortedDirModelFilter(model) , mWantMatchingTag(true) {} bool needsSemanticInfo() const override { return true; } bool acceptsIndex(const QModelIndex& index) const override { if (mTag.isEmpty()) { return true; } SemanticInfo info = model()->semanticInfoForSourceIndex(index); if (mWantMatchingTag) { return info.mTags.contains(mTag); } else { return !info.mTags.contains(mTag); } } void setTag(const SemanticInfoTag& tag) { mTag = tag; model()->applyFilters(); } void setWantMatchingTag(bool value) { mWantMatchingTag = value; model()->applyFilters(); } private: SemanticInfoTag mTag; bool mWantMatchingTag; }; class TagFilterWidget : public QWidget { Q_OBJECT public: TagFilterWidget(SortedDirModel*); - ~TagFilterWidget(); + ~TagFilterWidget() override; private Q_SLOTS: void updateTagSetFilter(); private: KComboBox* mModeComboBox; QComboBox* mTagComboBox; QPointer mFilter; }; #endif /** * This class manages the filter widgets in the filter frame and assign the * corresponding filters to the SortedDirModel */ class FilterController : public QObject { Q_OBJECT public: FilterController(QFrame* filterFrame, SortedDirModel* model); QList actionList() const; private Q_SLOTS: void addFilterByName(); void addFilterByDate(); #ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE void addFilterByRating(); void addFilterByTag(); #endif void slotFilterWidgetClosed(); private: void addAction(const QString& text, const char* slot); void addFilter(QWidget* widget); FilterController* q; QFrame* mFrame; SortedDirModel* mDirModel; QList mActionList; int mFilterWidgetCount; /**< How many filter widgets are in mFrame */ }; } // namespace #endif /* FILTERCONTROLLER_H */ diff --git a/app/gvcore.h b/app/gvcore.h index ea28b6ad..0aa6da9a 100644 --- a/app/gvcore.h +++ b/app/gvcore.h @@ -1,90 +1,90 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef GVCORE_H #define GVCORE_H // Qt #include // KDE // Local class KJob; class QUrl; class QAbstractItemModel; class QPalette; class QString; namespace Gwenview { class AbstractSemanticInfoBackEnd; class MainWindow; class SortedDirModel; struct GvCorePrivate; class GvCore : public QObject { Q_OBJECT public: GvCore(MainWindow* mainWindow, SortedDirModel*); - ~GvCore(); + ~GvCore() override; enum PaletteType { NormalPalette = 0, NormalViewPalette, FullScreenPalette, FullScreenViewPalette }; QAbstractItemModel* recentFoldersModel() const; QAbstractItemModel* recentFilesModel() const; SortedDirModel* sortedDirModel() const; AbstractSemanticInfoBackEnd* semanticInfoBackEnd() const; void addUrlToRecentFolders(QUrl); void addUrlToRecentFiles(const QUrl &); void clearRecentFilesAndFolders(); QPalette palette(PaletteType type) const; QString fullScreenPaletteName() const; public Q_SLOTS: void saveAll(); void save(const QUrl&); void saveAs(const QUrl&); void rotateLeft(const QUrl&); void rotateRight(const QUrl&); void setRating(const QUrl&, int); private Q_SLOTS: void slotConfigChanged(); void slotSaveResult(KJob*); private: GvCorePrivate* const d; }; } // namespace #endif /* GVCORE_H */ diff --git a/app/imageopscontextmanageritem.h b/app/imageopscontextmanageritem.h index 23f37403..b6658d6b 100644 --- a/app/imageopscontextmanageritem.h +++ b/app/imageopscontextmanageritem.h @@ -1,64 +1,64 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef IMAGEOPSCONTEXTMANAGERITEM_H #define IMAGEOPSCONTEXTMANAGERITEM_H // Qt // KDE // Local #include "abstractcontextmanageritem.h" namespace Gwenview { class AbstractImageOperation; class MainWindow; class ImageOpsContextManagerItem : public AbstractContextManagerItem { Q_OBJECT public: ImageOpsContextManagerItem(ContextManager*, MainWindow*); - ~ImageOpsContextManagerItem(); + ~ImageOpsContextManagerItem() override; private Q_SLOTS: void updateActions(); void updateSideBarContent(); void rotateLeft(); void rotateRight(); void mirror(); void flip(); void resizeImage(); void crop(); void startRedEyeReduction(); void applyImageOperation(AbstractImageOperation*); void restoreDefaultImageViewTool(); private: struct Private; Private* const d; }; } // namespace #endif /* IMAGEOPSCONTEXTMANAGERITEM_H */ diff --git a/app/infocontextmanageritem.h b/app/infocontextmanageritem.h index 13918d03..22a49fde 100644 --- a/app/infocontextmanageritem.h +++ b/app/infocontextmanageritem.h @@ -1,61 +1,61 @@ /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef INFOCONTEXTMANAGERITEM_H #define INFOCONTEXTMANAGERITEM_H // Qt // Local #include "abstractcontextmanageritem.h" class QStringList; class KFileItem; class KFileItemList; namespace Gwenview { struct InfoContextManagerItemPrivate; class InfoContextManagerItem : public AbstractContextManagerItem { Q_OBJECT public: InfoContextManagerItem(ContextManager*); - ~InfoContextManagerItem(); + ~InfoContextManagerItem() override; private Q_SLOTS: void updateSideBarContent(); void updateOneFileInfo(); void showMetaInfoDialog(); void slotPreferredMetaInfoKeyListChanged(const QStringList&); private: void fillOneFileGroup(const KFileItem& item); void fillMultipleItemsGroup(const KFileItemList& itemList); friend struct InfoContextManagerItemPrivate; InfoContextManagerItemPrivate* const d; }; } // namespace #endif /* INFOCONTEXTMANAGERITEM_H */ diff --git a/app/kipiexportaction.h b/app/kipiexportaction.h index eba5767a..f6017eb7 100644 --- a/app/kipiexportaction.h +++ b/app/kipiexportaction.h @@ -1,57 +1,57 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2010 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef KIPIEXPORTACTION_H #define KIPIEXPORTACTION_H // Qt // KDE #include // Local namespace Gwenview { class KIPIInterface; struct KIPIExportActionPrivate; class KIPIExportAction : public KToolBarPopupAction { Q_OBJECT public: explicit KIPIExportAction(QObject* parent); - ~KIPIExportAction(); + ~KIPIExportAction() override; void setKIPIInterface(KIPIInterface*); private Q_SLOTS: void init(); void setDefaultAction(QAction*); void slotPluginTriggered(QAction*); private: KIPIExportActionPrivate* const d; }; } // namespace #endif /* KIPIEXPORTACTION_H */ diff --git a/app/kipiimagecollectionselector.h b/app/kipiimagecollectionselector.h index 1c9e9b17..3b8e02ff 100644 --- a/app/kipiimagecollectionselector.h +++ b/app/kipiimagecollectionselector.h @@ -1,54 +1,54 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef KIPIIMAGECOLLECTIONSELECTOR_H #define KIPIIMAGECOLLECTIONSELECTOR_H // Qt // KDE // KIPI #include #include // Local #include "kipiinterface.h" namespace Gwenview { struct KIPIImageCollectionSelectorPrivate; class KIPIImageCollectionSelector : public KIPI::ImageCollectionSelector { Q_OBJECT public: KIPIImageCollectionSelector(KIPIInterface*, QWidget* parent); - ~KIPIImageCollectionSelector(); + ~KIPIImageCollectionSelector() override; - virtual QList selectedImageCollections() const; + QList selectedImageCollections() const override; private: KIPIImageCollectionSelectorPrivate* const d; }; } // namespace #endif /* KIPIIMAGECOLLECTIONSELECTOR_H */ diff --git a/app/kipiinterface.cpp b/app/kipiinterface.cpp index 89e79109..c3e0072d 100644 --- a/app/kipiinterface.cpp +++ b/app/kipiinterface.cpp @@ -1,515 +1,515 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2000-2008 Aurélien Gâteau Copyright 2008 Angelo Naselli This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #include "kipiinterface.h" // Qt #include #include #include #include #include #include // KDE #include #include #include #include #include #include #include #include // KIPI #include #include #include #include #include // local #include "mainwindow.h" #include "kipiimagecollectionselector.h" #include "kipiuploadwidget.h" #include #include #include #include #include #define KIPI_PLUGINS_URL QStringLiteral("appstream://photolayoutseditor.desktop") namespace Gwenview { #undef ENABLE_LOG #undef LOG //#define ENABLE_LOG #ifdef ENABLE_LOG #define LOG(x) qDebug() << x #else #define LOG(x) ; #endif class KIPIImageInfo : public KIPI::ImageInfoShared { static const QRegExp sExtensionRE; public: KIPIImageInfo(KIPI::Interface* interface, const QUrl &url) : KIPI::ImageInfoShared(interface, url) { KFileItem item(url); mAttributes.insert("name", url.fileName()); mAttributes.insert("comment", comment()); mAttributes.insert("date", TimeUtils::dateTimeForFileItem(item)); mAttributes.insert("orientation", orientation()); mAttributes.insert("title", prettyFileName()); int size = item.size(); if (size > 0) { mAttributes.insert("filesize", size); } } - QMap attributes() { + QMap attributes() override { return mAttributes; } - void delAttributes(const QStringList& attributeNames) + void delAttributes(const QStringList& attributeNames) override { Q_FOREACH(const QString& name, attributeNames) { mAttributes.remove(name); } } - void clearAttributes() + void clearAttributes() override { mAttributes.clear(); } - void addAttributes(const QVariantMap& attributes) + void addAttributes(const QVariantMap& attributes) override { QVariantMap::ConstIterator it = attributes.constBegin(), end = attributes.constEnd(); for (; it != end; ++it) { mAttributes.insert(it.key(), it.value()); } } private: QString prettyFileName() const { QString txt = _url.fileName(); txt.replace('_', ' '); txt.remove(sExtensionRE); return txt; } QString comment() const { if (!_url.isLocalFile()) return QString(); JpegContent content; bool ok = content.load(_url.toLocalFile()); if (!ok) return QString(); return content.comment(); } int orientation() const { #if 0 //PORT QT5 KFileMetaInfo metaInfo(_url); if (!metaInfo.isValid()) { return 0; } const KFileMetaInfoItem& mii = metaInfo.item("http://freedesktop.org/standards/xesam/1.0/core#orientation"); bool ok = false; const Orientation orientation = (Orientation)mii.value().toInt(&ok); if (!ok) { return 0; } switch (orientation) { case NOT_AVAILABLE: case NORMAL: return 0; case ROT_90: return 90; case ROT_180: return 180; case ROT_270: return 270; case HFLIP: case VFLIP: case TRANSPOSE: case TRANSVERSE: qWarning() << "Can't represent an orientation value of" << orientation << "as an angle (" << _url << ')'; return 0; } #endif //qWarning() << "Don't know how to handle an orientation value of" << orientation << '(' << _url << ')'; return 0; } QVariantMap mAttributes; }; const QRegExp KIPIImageInfo::sExtensionRE("\\.[a-z0-9]+$", Qt::CaseInsensitive); struct MenuInfo { QString mName; QList mActions; MenuInfo() {} MenuInfo(const QString& name) : mName(name) {} }; typedef QMap MenuInfoMap; struct KIPIInterfacePrivate { KIPIInterface* q; MainWindow* mMainWindow; QMenu* mPluginMenu; KIPI::PluginLoader* mPluginLoader; KIPI::PluginLoader::PluginList mPluginQueue; MenuInfoMap mMenuInfoMap; QAction * mLoadingAction; QAction * mNoPluginAction; QAction * mInstallPluginAction; QFileSystemWatcher mPluginWatcher; QTimer mPluginLoadTimer; void setupPluginsMenu() { mPluginMenu = static_cast( mMainWindow->factory()->container("plugins", mMainWindow)); QObject::connect(mPluginMenu, &QMenu::aboutToShow, q, &KIPIInterface::loadPlugins); } QAction * createDummyPluginAction(const QString& text) { QAction * action = new QAction(q); action->setText(text); //PORT QT5 action->setShortcutConfigurable(false); action->setEnabled(false); return action; } }; KIPIInterface::KIPIInterface(MainWindow* mainWindow) : KIPI::Interface(mainWindow) , d(new KIPIInterfacePrivate) { d->q = this; d->mMainWindow = mainWindow; d->mPluginLoader = nullptr; d->mLoadingAction = d->createDummyPluginAction(i18n("Loading...")); d->mNoPluginAction = d->createDummyPluginAction(i18n("No Plugin Found")); d->mInstallPluginAction = d->createDummyPluginAction(i18nc("@item:inmenu", "Install Plugins")); connect(&d->mPluginLoadTimer, &QTimer::timeout, this, &KIPIInterface::loadPlugins); d->setupPluginsMenu(); QObject::connect(d->mMainWindow->contextManager(), SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged())); QObject::connect(d->mMainWindow->contextManager(), SIGNAL(currentDirUrlChanged(QUrl)), this, SLOT(slotDirectoryChanged())); #if 0 //TODO instead of delaying can we load them all at start-up to use actions somewhere else? // delay a bit, so that it's called after loadPlugins() QTimer::singleShot(0, this, SLOT(init())); #endif } KIPIInterface::~KIPIInterface() { delete d; } static bool actionLessThan(QAction* a1, QAction* a2) { QString a1Text = a1->text().replace('&', QString()); QString a2Text = a2->text().replace('&', QString()); return QString::compare(a1Text, a2Text, Qt::CaseInsensitive) < 0; } void KIPIInterface::loadPlugins() { // Already done if (d->mPluginLoader) { return; } d->mMenuInfoMap[KIPI::ImagesPlugin] = MenuInfo(i18nc("@title:menu", "Images")); d->mMenuInfoMap[KIPI::ToolsPlugin] = MenuInfo(i18nc("@title:menu", "Tools")); d->mMenuInfoMap[KIPI::ImportPlugin] = MenuInfo(i18nc("@title:menu", "Import")); d->mMenuInfoMap[KIPI::ExportPlugin] = MenuInfo(i18nc("@title:menu", "Export")); d->mMenuInfoMap[KIPI::BatchPlugin] = MenuInfo(i18nc("@title:menu", "Batch Processing")); d->mMenuInfoMap[KIPI::CollectionsPlugin] = MenuInfo(i18nc("@title:menu", "Collections")); d->mPluginLoader = new KIPI::PluginLoader(); d->mPluginLoader->setInterface(this); d->mPluginLoader->init(); d->mPluginQueue = d->mPluginLoader->pluginList(); d->mPluginMenu->addAction(d->mLoadingAction); loadOnePlugin(); } void KIPIInterface::loadOnePlugin() { while (!d->mPluginQueue.isEmpty()) { KIPI::PluginLoader::Info* pluginInfo = d->mPluginQueue.takeFirst(); if (!pluginInfo->shouldLoad()) { continue; } KIPI::Plugin* plugin = pluginInfo->plugin(); if (!plugin) { qWarning() << "Plugin from library" << pluginInfo->library() << "failed to load"; continue; } plugin->setup(d->mMainWindow); QList actions = plugin->actions(); Q_FOREACH(QAction * action, actions) { KIPI::Category category = plugin->category(action); if (!d->mMenuInfoMap.contains(category)) { qWarning() << "Unknown category '" << category; continue; } d->mMenuInfoMap[category].mActions << action; } // FIXME: Port //plugin->actionCollection()->readShortcutSettings(); // If we reach this point, we just loaded one plugin. Go back to the // event loop. We will come back to load the remaining plugins or create // the menu later QMetaObject::invokeMethod(this, "loadOnePlugin", Qt::QueuedConnection); return; } // If we reach this point, all plugins have been loaded. We can fill the // menu MenuInfoMap::Iterator it = d->mMenuInfoMap.begin(), end = d->mMenuInfoMap.end(); for (; it != end; ++it) { MenuInfo& info = it.value(); if (!info.mActions.isEmpty()) { QMenu* menu = d->mPluginMenu->addMenu(info.mName); qSort(info.mActions.begin(), info.mActions.end(), actionLessThan); Q_FOREACH(QAction * action, info.mActions) { menu->addAction(action); } } } d->mPluginMenu->removeAction(d->mLoadingAction); if (d->mPluginMenu->isEmpty()) { if (KIO::DesktopExecParser::hasSchemeHandler(QUrl(KIPI_PLUGINS_URL))) { d->mPluginMenu->addAction(d->mInstallPluginAction); d->mInstallPluginAction->setEnabled(true); QObject::connect(d->mInstallPluginAction, &QAction::triggered, this, [&](){ QDesktopServices::openUrl(QUrl(KIPI_PLUGINS_URL)); d->mPluginWatcher.addPaths(QCoreApplication::libraryPaths()); connect(&d->mPluginWatcher, &QFileSystemWatcher::directoryChanged, this, &KIPIInterface::packageFinished); }); } else { d->mPluginMenu->addAction(d->mNoPluginAction); } } loadingFinished(); } void KIPIInterface::packageFinished() { if (d->mPluginLoader) { delete d->mPluginLoader; d->mPluginLoader = nullptr; } d->mPluginMenu->removeAction(d->mInstallPluginAction); d->mPluginMenu->removeAction(d->mNoPluginAction); d->mPluginLoadTimer.start(1000); } QList KIPIInterface::pluginActions(KIPI::Category category) const { const_cast(this)->loadPlugins(); if (isLoadingFinished()) { QList list = d->mMenuInfoMap.value(category).mActions; if (list.isEmpty()) { if (KIO::DesktopExecParser::hasSchemeHandler(QUrl(KIPI_PLUGINS_URL))) { list << d->mInstallPluginAction; } else { list << d->mNoPluginAction; } } return list; } else { return QList() << d->mLoadingAction; } } bool KIPIInterface::isLoadingFinished() const { if (!d->mPluginLoader) { // Not even started return false; } return d->mPluginQueue.isEmpty(); } void KIPIInterface::init() { slotDirectoryChanged(); slotSelectionChanged(); } KIPI::ImageCollection KIPIInterface::currentAlbum() { LOG(""); const ContextManager* contextManager = d->mMainWindow->contextManager(); const QUrl url = contextManager->currentDirUrl(); const SortedDirModel* model = contextManager->dirModel(); QList list; const int count = model->rowCount(); for (int row = 0; row < count; ++row) { const QModelIndex& index = model->index(row, 0); const KFileItem item = model->itemForIndex(index); if (MimeTypeUtils::fileItemKind(item) == MimeTypeUtils::KIND_RASTER_IMAGE) { list << item.targetUrl(); } } return KIPI::ImageCollection(new ImageCollection(url, url.fileName(), list)); } KIPI::ImageCollection KIPIInterface::currentSelection() { LOG(""); KFileItemList fileList = d->mMainWindow->contextManager()->selectedFileItemList(); QList list = fileList.urlList(); QUrl url = d->mMainWindow->contextManager()->currentUrl(); return KIPI::ImageCollection(new ImageCollection(url, url.fileName(), list)); } QList KIPIInterface::allAlbums() { LOG(""); QList list; list << currentAlbum() << currentSelection(); return list; } KIPI::ImageInfo KIPIInterface::info(const QUrl &url) { LOG(""); return KIPI::ImageInfo(new KIPIImageInfo(this, url)); } int KIPIInterface::features() const { return KIPI::HostAcceptNewImages; } /** * KDirLister will pick up the image if necessary, so no updating is needed * here, it is however necessary to discard caches if the plugin preserves timestamp */ bool KIPIInterface::addImage(const QUrl&, QString&) { //TODO setContext(const QUrl ¤tUrl, const KFileItemList& selection)? //Cache::instance()->invalidate( url ); return true; } void KIPIInterface::delImage(const QUrl&) { //TODO } void KIPIInterface::refreshImages(const QList&) { // TODO } KIPI::ImageCollectionSelector* KIPIInterface::imageCollectionSelector(QWidget *parent) { return new KIPIImageCollectionSelector(this, parent); } KIPI::UploadWidget* KIPIInterface::uploadWidget(QWidget *parent) { return (new KIPIUploadWidget(this, parent)); } void KIPIInterface::slotSelectionChanged() { emit selectionChanged(!d->mMainWindow->contextManager()->selectedFileItemList().isEmpty()); } void KIPIInterface::slotDirectoryChanged() { emit currentAlbumChanged(true); } #ifdef GWENVIEW_KIPI_WITH_CREATE_METHODS KIPI::FileReadWriteLock* KIPIInterface::createReadWriteLock(const QUrl& url) const { Q_UNUSED(url); return NULL; } KIPI::MetadataProcessor* KIPIInterface::createMetadataProcessor() const { return NULL; } #ifdef GWENVIEW_KIPI_WITH_CREATE_RAW_PROCESSOR KIPI::RawProcessor* KIPIInterface::createRawProcessor() const { return NULL; } #endif #endif } //namespace diff --git a/app/kipiinterface.h b/app/kipiinterface.h index 613a4196..2e6b51d7 100644 --- a/app/kipiinterface.h +++ b/app/kipiinterface.h @@ -1,138 +1,138 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2000-2008 Aurélien Gâteau Copyright 2008 Angelo Naselli This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef KIPIINTERFACE_H #define KIPIINTERFACE_H // KIPI #include #include #include #include class QAction; #ifndef KIPI_VERSION_MAJOR #error KIPI_VERSION_MAJOR should be provided. #endif #if KIPI_VERSION_MAJOR >= 5 #define GWENVIEW_KIPI_WITH_CREATE_METHODS #if KIPI_VERSION_MINOR == 0 # define GWENVIEW_KIPI_WITH_CREATE_RAW_PROCESSOR #endif #endif namespace Gwenview { struct KIPIInterfacePrivate; class MainWindow; class KIPIInterface : public KIPI::Interface { Q_OBJECT public: KIPIInterface(MainWindow*); - virtual ~KIPIInterface(); + ~KIPIInterface() override; - KIPI::ImageCollection currentAlbum(); - KIPI::ImageCollection currentSelection(); - QList allAlbums(); - KIPI::ImageInfo info(const QUrl &url); - int features() const; - virtual bool addImage(const QUrl&, QString& err); - virtual void delImage(const QUrl&); - virtual void refreshImages(const QList& urls); + KIPI::ImageCollection currentAlbum() override; + KIPI::ImageCollection currentSelection() override; + QList allAlbums() override; + KIPI::ImageInfo info(const QUrl &url) override; + int features() const override; + bool addImage(const QUrl&, QString& err) override; + void delImage(const QUrl&) override; + void refreshImages(const QList& urls) override; - virtual KIPI::ImageCollectionSelector* imageCollectionSelector(QWidget *parent); - virtual KIPI::UploadWidget* uploadWidget(QWidget *parent); + KIPI::ImageCollectionSelector* imageCollectionSelector(QWidget *parent) override; + KIPI::UploadWidget* uploadWidget(QWidget *parent) override; QList pluginActions(KIPI::Category) const; bool isLoadingFinished() const; #ifdef GWENVIEW_KIPI_WITH_CREATE_METHODS - virtual KIPI::FileReadWriteLock* createReadWriteLock(const QUrl& url) const; - virtual KIPI::MetadataProcessor* createMetadataProcessor() const; + KIPI::FileReadWriteLock* createReadWriteLock(const QUrl& url) const override; + KIPI::MetadataProcessor* createMetadataProcessor() const override; #ifdef GWENVIEW_KIPI_WITH_CREATE_RAW_PROCESSOR virtual KIPI::RawProcessor* createRawProcessor() const; #endif #endif Q_SIGNALS: void loadingFinished(); public Q_SLOTS: void loadPlugins(); private Q_SLOTS: void slotSelectionChanged(); void slotDirectoryChanged(); void packageFinished(); void init(); void loadOnePlugin(); private: KIPIInterfacePrivate* const d; }; class ImageCollection : public KIPI::ImageCollectionShared { public: ImageCollection(QUrl dirURL, const QString& name, const QList& images) : KIPI::ImageCollectionShared() , mDirURL(dirURL) , mName(name) , mImages(images) {} - QString name() { + QString name() override { return mName; } - QString comment() { + QString comment() override { return QString(); } - QList images() { + QList images() override { return mImages; } - QUrl uploadRoot() { + QUrl uploadRoot() { return QUrl("/"); } - QUrl uploadPath() { + QUrl uploadPath() { return mDirURL; } - QString uploadRootName() + QString uploadRootName() override { return "/"; } - bool isDirectory() { + bool isDirectory() override { return true; } private: QUrl mDirURL; QString mName; QList mImages; }; } // namespace #endif /* KIPIINTERFACE_H */ diff --git a/app/kipiuploadwidget.h b/app/kipiuploadwidget.h index cc216e2b..ca8fc6d1 100644 --- a/app/kipiuploadwidget.h +++ b/app/kipiuploadwidget.h @@ -1,53 +1,53 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef KIPIUPLOADWIDGET_H #define KIPIUPLOADWIDGET_H // Qt // KDE // KIPI #include #include // Local namespace Gwenview { class KIPIInterface; class KIPIUploadWidget : public KIPI::UploadWidget { Q_OBJECT public: KIPIUploadWidget(KIPIInterface*, QWidget* parent); - virtual KIPI::ImageCollection selectedImageCollection() const; + KIPI::ImageCollection selectedImageCollection() const override; private: KIPIInterface* mInterface; }; } // namespace #endif /* KIPIUPLOADWIDGET_H */ diff --git a/app/preloader.h b/app/preloader.h index deeb90ba..df5cdbcc 100644 --- a/app/preloader.h +++ b/app/preloader.h @@ -1,61 +1,61 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef PRELOADER_H #define PRELOADER_H // Qt #include // KDE // Local class QSize; class QUrl; namespace Gwenview { struct PreloaderPrivate; /** * This class preloads a document to fit a specific size. */ class Preloader : public QObject { Q_OBJECT public: explicit Preloader(QObject* parent); - ~Preloader(); + ~Preloader() override; void preload(const QUrl&, const QSize&); private Q_SLOTS: void doPreload(); private: PreloaderPrivate* const d; }; } // namespace #endif /* PRELOADER_H */ diff --git a/app/renamedialog.h b/app/renamedialog.h index f233a4f8..d3877de4 100644 --- a/app/renamedialog.h +++ b/app/renamedialog.h @@ -1,54 +1,54 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2018 Aurélien Gâteau Copyright 2018 Peter Mühlenpfordt This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef RENAMEDIALOG_H #define RENAMEDIALOG_H // Qt #include // KDE // Local namespace Gwenview { struct RenameDialogPrivate; class RenameDialog : public QDialog { Q_OBJECT public: explicit RenameDialog(QWidget* parent); - ~RenameDialog(); + ~RenameDialog() override; void setFilename(const QString& filename); QString filename() const; private: RenameDialogPrivate* const d; void updateButtons(); }; } // namespace #endif /* RENAMEDIALOG_H */ diff --git a/app/saveallhelper.h b/app/saveallhelper.h index 231afa31..7f9c5d2a 100644 --- a/app/saveallhelper.h +++ b/app/saveallhelper.h @@ -1,56 +1,56 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2010 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef SAVEALLHELPER_H #define SAVEALLHELPER_H // Qt #include // KDE // Local class KJob; namespace Gwenview { struct SaveAllHelperPrivate; class SaveAllHelper : public QObject { Q_OBJECT public: explicit SaveAllHelper(QWidget* parent); - ~SaveAllHelper(); + ~SaveAllHelper() override; void save(); private Q_SLOTS: void slotCanceled(); void slotResult(KJob*); private: SaveAllHelperPrivate* const d; }; } // namespace #endif /* SAVEALLHELPER_H */ diff --git a/app/savebar.h b/app/savebar.h index 544c1756..0f94fea8 100644 --- a/app/savebar.h +++ b/app/savebar.h @@ -1,69 +1,69 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SAVEBAR_H #define SAVEBAR_H // Qt // KDE // Local #include class KActionCollection; class QUrl; namespace Gwenview { struct SaveBarPrivate; class SaveBar : public SlideContainer { Q_OBJECT public: SaveBar(QWidget* parent, KActionCollection* collection); - ~SaveBar(); + ~SaveBar() override; /** * Init widgets which depend on an initialized actionCollection */ void initActionDependentWidgets(); void setFullScreenMode(bool); public Q_SLOTS: void setCurrentUrl(const QUrl&); Q_SIGNALS: void requestSaveAll(); void goToUrl(const QUrl&); private: SaveBarPrivate* const d; private Q_SLOTS: void updateContent(); void triggerAction(const QString& action); }; } // namespace #endif /* SAVEBAR_H */ diff --git a/app/semanticinfocontextmanageritem.cpp b/app/semanticinfocontextmanageritem.cpp index 23aa9f32..ad347543 100644 --- a/app/semanticinfocontextmanageritem.cpp +++ b/app/semanticinfocontextmanageritem.cpp @@ -1,472 +1,472 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ // Self #include "semanticinfocontextmanageritem.h" // Qt #include #include #include #include #include #include #include #include // KDE #include #include #include #include #include #include #include #include // Local #include "viewmainpage.h" #include "sidebar.h" #include "ui_semanticinfosidebaritem.h" #include "ui_semanticinfodialog.h" #include #include #include #include #include #include #include #include #include namespace Gwenview { static const int RATING_INDICATOR_HIDE_DELAY = 2000; struct SemanticInfoDialog : public QDialog, public Ui_SemanticInfoDialog { SemanticInfoDialog(QWidget* parent) : QDialog(parent) { setLayout(new QVBoxLayout); QWidget* mainWidget = new QWidget; layout()->addWidget(mainWidget); setupUi(mainWidget); mainWidget->layout()->setMargin(0); setWindowTitle(mainWidget->windowTitle()); KWindowConfig::restoreWindowSize(windowHandle(), configGroup()); } - ~SemanticInfoDialog() + ~SemanticInfoDialog() override { KConfigGroup group = configGroup(); KWindowConfig::saveWindowSize(windowHandle(), group); } KConfigGroup configGroup() const { KSharedConfigPtr config = KSharedConfig::openConfig(); return KConfigGroup(config, "SemanticInfoDialog"); } }; /** * A QGraphicsPixmapItem-like class, but which inherits from QGraphicsWidget */ class GraphicsPixmapWidget : public QGraphicsWidget { public: void setPixmap(const QPixmap& pix) { mPix = pix; setMinimumSize(pix.size()); } void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) override { painter->drawPixmap( (size().width() - mPix.width()) / 2, (size().height() - mPix.height()) / 2, mPix); } private: QPixmap mPix; }; class RatingIndicator : public HudWidget { public: RatingIndicator() : HudWidget() , mPixmapWidget(new GraphicsPixmapWidget) , mDeleteTimer(new QTimer(this)) { updatePixmap(0); setOpacity(0); init(mPixmapWidget, OptionNone); mDeleteTimer->setInterval(RATING_INDICATOR_HIDE_DELAY); mDeleteTimer->setSingleShot(true); connect(mDeleteTimer, SIGNAL(timeout()), SLOT(fadeOut())); connect(this, SIGNAL(fadedOut()), SLOT(deleteLater())); } void setRating(int rating) { updatePixmap(rating); update(); mDeleteTimer->start(); fadeIn(); } private: GraphicsPixmapWidget* mPixmapWidget; QTimer* mDeleteTimer; void updatePixmap(int rating) { KRatingPainter ratingPainter; const int iconSize = KIconLoader::global()->currentSize(KIconLoader::Small); QPixmap pix(iconSize * 5 + ratingPainter.spacing() * 4, iconSize); pix.fill(Qt::transparent); { QPainter painter(&pix); ratingPainter.paint(&painter, pix.rect(), rating); } mPixmapWidget->setPixmap(pix); } }; struct SemanticInfoContextManagerItemPrivate : public Ui_SemanticInfoSideBarItem { SemanticInfoContextManagerItem* q; SideBarGroup* mGroup; KActionCollection* mActionCollection; ViewMainPage* mViewMainPage; QPointer mSemanticInfoDialog; TagInfo mTagInfo; QAction * mEditTagsAction; QSignalMapper* mRatingMapper; /** A list of all actions, so that we can disable them when necessary */ QList mActions; QPointer mRatingIndicator; void setupGroup() { mGroup = new SideBarGroup(i18n("Semantic Information"), false); q->setWidget(mGroup); EventWatcher::install(mGroup, QEvent::Show, q, SLOT(update())); QWidget* container = new QWidget; setupUi(container); container->layout()->setMargin(0); mGroup->addWidget(container); formLayout->setContentsMargins(DEFAULT_LAYOUT_MARGIN, 0, 0, 0); QObject::connect(mRatingWidget, SIGNAL(ratingChanged(int)), q, SLOT(slotRatingChanged(int))); QObject::connect(mRatingMapper, SIGNAL(mapped(int)), mRatingWidget, SLOT(setRating(int))); mDescriptionTextEdit->installEventFilter(q); QObject::connect(mTagLabel, SIGNAL(linkActivated(QString)), mEditTagsAction, SLOT(trigger())); } void setupActions() { KActionCategory* edit = new KActionCategory(i18nc("@title actions category", "Edit"), mActionCollection); mEditTagsAction = edit->addAction("edit_tags"); mEditTagsAction->setText(i18nc("@action", "Edit Tags")); mEditTagsAction->setIcon(QIcon::fromTheme("tag")); mActionCollection->setDefaultShortcut(mEditTagsAction, Qt::CTRL + Qt::Key_T); QObject::connect(mEditTagsAction, SIGNAL(triggered()), q, SLOT(showSemanticInfoDialog())); mActions << mEditTagsAction; mRatingMapper = new QSignalMapper(q); for (int rating = 0; rating <= 5; ++rating) { QAction * action = edit->addAction(QStringLiteral("rate_%1").arg(rating)); if (rating == 0) { action->setText(i18nc("@action Rating value of zero", "Zero")); } else { action->setText(QString(rating, QChar(0x22C6))); /* 0x22C6 is the 'star' character */ } mActionCollection->setDefaultShortcut(action, Qt::Key_0 + rating); QObject::connect(action, SIGNAL(triggered()), mRatingMapper, SLOT(map())); mRatingMapper->setMapping(action, rating * 2); mActions << action; } QObject::connect(mRatingMapper, SIGNAL(mapped(int)), q, SLOT(slotRatingChanged(int))); } void updateTagLabel() { if (q->contextManager()->selectedFileItemList().isEmpty()) { mTagLabel->clear(); return; } AbstractSemanticInfoBackEnd* backEnd = q->contextManager()->dirModel()->semanticInfoBackEnd(); TagInfo::ConstIterator it = mTagInfo.constBegin(), end = mTagInfo.constEnd(); QMap labelMap; for (; it != end; ++it) { SemanticInfoTag tag = it.key(); QString label = backEnd->labelForTag(tag); if (!it.value()) { // Tag is not present for all urls label += '*'; } labelMap[label.toLower()] = label; } QStringList labels(labelMap.values()); QString editLink = i18n("Edit"); QString text = labels.join(", ") + QStringLiteral(" %1").arg(editLink); mTagLabel->setText(text); } void updateSemanticInfoDialog() { mSemanticInfoDialog->mTagWidget->setEnabled(!q->contextManager()->selectedFileItemList().isEmpty()); mSemanticInfoDialog->mTagWidget->setTagInfo(mTagInfo); } }; SemanticInfoContextManagerItem::SemanticInfoContextManagerItem(ContextManager* manager, KActionCollection* actionCollection, ViewMainPage* viewMainPage) : AbstractContextManagerItem(manager) , d(new SemanticInfoContextManagerItemPrivate) { d->q = this; d->mActionCollection = actionCollection; d->mViewMainPage = viewMainPage; connect(contextManager(), SIGNAL(selectionChanged()), SLOT(slotSelectionChanged())); connect(contextManager(), SIGNAL(selectionDataChanged()), SLOT(update())); connect(contextManager(), SIGNAL(currentDirUrlChanged(QUrl)), SLOT(update())); d->setupActions(); d->setupGroup(); } SemanticInfoContextManagerItem::~SemanticInfoContextManagerItem() { delete d; } inline int ratingForVariant(const QVariant& variant) { if (variant.isValid()) { return variant.toInt(); } else { return 0; } } void SemanticInfoContextManagerItem::slotSelectionChanged() { update(); } void SemanticInfoContextManagerItem::update() { KFileItemList itemList = contextManager()->selectedFileItemList(); bool first = true; int rating = 0; QString description; SortedDirModel* dirModel = contextManager()->dirModel(); // This hash stores for how many items the tag is present // If you have 3 items, and only 2 have the "Holiday" tag, // then tagHash["Holiday"] will be 2 at the end of the loop. typedef QHash TagHash; TagHash tagHash; Q_FOREACH(const KFileItem & item, itemList) { QModelIndex index = dirModel->indexForItem(item); QVariant value = dirModel->data(index, SemanticInfoDirModel::RatingRole); if (first) { rating = ratingForVariant(value); } else if (rating != ratingForVariant(value)) { // Ratings aren't the same, reset rating = 0; } QString indexDescription = index.data(SemanticInfoDirModel::DescriptionRole).toString(); if (first) { description = indexDescription; } else if (description != indexDescription) { description.clear(); } // Fill tagHash, incrementing the tag count if it's already there TagSet tagSet = TagSet::fromVariant(index.data(SemanticInfoDirModel::TagsRole)); Q_FOREACH(const QString & tag, tagSet) { TagHash::Iterator it = tagHash.find(tag); if (it == tagHash.end()) { tagHash[tag] = 1; } else { ++it.value(); } } first = false; } { SignalBlocker blocker(d->mRatingWidget); d->mRatingWidget->setRating(rating); } d->mDescriptionTextEdit->setText(description); // Init tagInfo from tagHash d->mTagInfo.clear(); int itemCount = itemList.count(); TagHash::ConstIterator it = tagHash.constBegin(), end = tagHash.constEnd(); for (; it != end; ++it) { QString tag = it.key(); int count = it.value(); d->mTagInfo[tag] = count == itemCount; } bool enabled = !contextManager()->selectedFileItemList().isEmpty(); Q_FOREACH(QAction * action, d->mActions) { action->setEnabled(enabled); } d->updateTagLabel(); if (d->mSemanticInfoDialog) { d->updateSemanticInfoDialog(); } } void SemanticInfoContextManagerItem::slotRatingChanged(int rating) { KFileItemList itemList = contextManager()->selectedFileItemList(); // Show rating indicator in view mode, and only if sidebar is not visible if (d->mViewMainPage->isVisible() && !d->mRatingWidget->isVisible()) { if (!d->mRatingIndicator.data()) { d->mRatingIndicator = new RatingIndicator; d->mViewMainPage->showMessageWidget(d->mRatingIndicator, Qt::AlignBottom | Qt::AlignHCenter); } d->mRatingIndicator->setRating(rating); } SortedDirModel* dirModel = contextManager()->dirModel(); Q_FOREACH(const KFileItem & item, itemList) { QModelIndex index = dirModel->indexForItem(item); dirModel->setData(index, rating, SemanticInfoDirModel::RatingRole); } } void SemanticInfoContextManagerItem::storeDescription() { if (!d->mDescriptionTextEdit->document()->isModified()) { return; } d->mDescriptionTextEdit->document()->setModified(false); QString description = d->mDescriptionTextEdit->toPlainText(); KFileItemList itemList = contextManager()->selectedFileItemList(); SortedDirModel* dirModel = contextManager()->dirModel(); Q_FOREACH(const KFileItem & item, itemList) { QModelIndex index = dirModel->indexForItem(item); dirModel->setData(index, description, SemanticInfoDirModel::DescriptionRole); } } void SemanticInfoContextManagerItem::assignTag(const SemanticInfoTag& tag) { KFileItemList itemList = contextManager()->selectedFileItemList(); SortedDirModel* dirModel = contextManager()->dirModel(); Q_FOREACH(const KFileItem & item, itemList) { QModelIndex index = dirModel->indexForItem(item); TagSet tags = TagSet::fromVariant(dirModel->data(index, SemanticInfoDirModel::TagsRole)); if (!tags.contains(tag)) { tags << tag; dirModel->setData(index, tags.toVariant(), SemanticInfoDirModel::TagsRole); } } } void SemanticInfoContextManagerItem::removeTag(const SemanticInfoTag& tag) { KFileItemList itemList = contextManager()->selectedFileItemList(); SortedDirModel* dirModel = contextManager()->dirModel(); Q_FOREACH(const KFileItem & item, itemList) { QModelIndex index = dirModel->indexForItem(item); TagSet tags = TagSet::fromVariant(dirModel->data(index, SemanticInfoDirModel::TagsRole)); if (tags.contains(tag)) { tags.remove(tag); dirModel->setData(index, tags.toVariant(), SemanticInfoDirModel::TagsRole); } } } void SemanticInfoContextManagerItem::showSemanticInfoDialog() { if (!d->mSemanticInfoDialog) { d->mSemanticInfoDialog = new SemanticInfoDialog(d->mGroup); d->mSemanticInfoDialog->setAttribute(Qt::WA_DeleteOnClose, true); connect(d->mSemanticInfoDialog->mPreviousButton, SIGNAL(clicked()), d->mActionCollection->action("go_previous"), SLOT(trigger())); connect(d->mSemanticInfoDialog->mNextButton, SIGNAL(clicked()), d->mActionCollection->action("go_next"), SLOT(trigger())); connect(d->mSemanticInfoDialog->mButtonBox, SIGNAL(rejected()), d->mSemanticInfoDialog, SLOT(close())); AbstractSemanticInfoBackEnd* backEnd = contextManager()->dirModel()->semanticInfoBackEnd(); d->mSemanticInfoDialog->mTagWidget->setSemanticInfoBackEnd(backEnd); connect(d->mSemanticInfoDialog->mTagWidget, SIGNAL(tagAssigned(SemanticInfoTag)), SLOT(assignTag(SemanticInfoTag))); connect(d->mSemanticInfoDialog->mTagWidget, SIGNAL(tagRemoved(SemanticInfoTag)), SLOT(removeTag(SemanticInfoTag))); } d->updateSemanticInfoDialog(); d->mSemanticInfoDialog->show(); } bool SemanticInfoContextManagerItem::eventFilter(QObject*, QEvent* event) { if (event->type() == QEvent::FocusOut) { storeDescription(); } return false; } } // namespace diff --git a/app/sidebar.h b/app/sidebar.h index 757f62b7..17505a0b 100644 --- a/app/sidebar.h +++ b/app/sidebar.h @@ -1,92 +1,92 @@ /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SIDEBAR_H #define SIDEBAR_H // Qt #include #include namespace Gwenview { static const int DEFAULT_LAYOUT_MARGIN = 6; class SideBar; struct SideBarGroupPrivate; class SideBarGroup : public QFrame { Q_OBJECT public: SideBarGroup(const QString& title, bool defaultContainerMarginEnabled = true); ~SideBarGroup() override; void addWidget(QWidget*); void addAction(QAction*); void clear(); protected: void paintEvent(QPaintEvent*) override; private: SideBarGroupPrivate* const d; }; struct SideBarPagePrivate; class SideBarPage : public QWidget { Q_OBJECT public: SideBarPage(const QString& title); - ~SideBarPage(); + ~SideBarPage() override; void addWidget(QWidget*); void addStretch(); const QString& title() const; private: SideBarPagePrivate* const d; }; struct SideBarPrivate; class SideBar : public QTabWidget { Q_OBJECT public: explicit SideBar(QWidget* parent); ~SideBar() override; void addPage(SideBarPage*); QString currentPage() const; void setCurrentPage(const QString& name); void loadConfig(); QSize sizeHint() const override; private: SideBarPrivate* const d; }; } // namespace #endif /* SIDEBAR_H */ diff --git a/importer/dialogpage.h b/importer/dialogpage.h index e31e5286..690ab5e7 100644 --- a/importer/dialogpage.h +++ b/importer/dialogpage.h @@ -1,58 +1,58 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2009 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef DIALOGPAGE_H #define DIALOGPAGE_H // Qt #include // KDE // Local class KGuiItem; namespace Gwenview { struct DialogPagePrivate; class DialogPage : public QWidget { Q_OBJECT public: explicit DialogPage(QWidget* parent = nullptr); - ~DialogPage(); + ~DialogPage() override; void removeButtons(); void setText(const QString&); int addButton(const KGuiItem&); int exec(); private Q_SLOTS: void slotMapped(int); private: DialogPagePrivate* const d; }; } // namespace #endif /* DIALOGPAGE_H */ diff --git a/importer/documentdirfinder.h b/importer/documentdirfinder.h index 05b96236..0d8c4328 100644 --- a/importer/documentdirfinder.h +++ b/importer/documentdirfinder.h @@ -1,77 +1,77 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2009 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef DOCUMENTDIRFINDER_H #define DOCUMENTDIRFINDER_H // Qt #include // KDE #include // Local namespace Gwenview { struct DocumentDirFinderPrivate; /** * This class is a worker which tries to find the document dir given a root * url. This is useful for digital camera cards, which often have a dir * hierarchy like this: * /DCIM * /FOOBAR * /PICT0001.JPG * /PICT0002.JPG * ... * /PICTnnnn.JPG */ class DocumentDirFinder : public QObject { Q_OBJECT public: enum Status { NoDocumentFound, DocumentDirFound, MultipleDirsFound }; DocumentDirFinder(const QUrl& rootUrl); - ~DocumentDirFinder(); + ~DocumentDirFinder() override; void start(); Q_SIGNALS: void done(const QUrl&, DocumentDirFinder::Status); private Q_SLOTS: void slotItemsAdded(const QUrl&, const KFileItemList&); void slotCompleted(); private: DocumentDirFinderPrivate* const d; void finish(const QUrl&, Status); }; } // namespace #endif /* DOCUMENTDIRFINDER_H */ diff --git a/importer/importer.h b/importer/importer.h index 6cce06a7..0ac4c288 100644 --- a/importer/importer.h +++ b/importer/importer.h @@ -1,92 +1,92 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2009 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef IMPORTER_H #define IMPORTER_H // Qt #include #include // KDE // Local class KJob; namespace Gwenview { struct ImporterPrivate; class Importer : public QObject { Q_OBJECT public: explicit Importer(QWidget* authWindow); - ~Importer(); + ~Importer() override; /** * Defines the auto-rename format applied to imported documents * Set to QString() to reset */ void setAutoRenameFormat(const QString&); void start(const QList& list, const QUrl& destUrl); QList importedUrlList() const; /** * Documents which have been skipped during import */ QList skippedUrlList() const; /** * How many documents have been renamed during import */ int renamedCount() const; Q_SIGNALS: void importFinished(); void progressChanged(int); void maximumChanged(int); /** * An error has occurred and caused the whole process to stop without * importing anything */ void error(const QString& message); private Q_SLOTS: void slotCopyDone(KJob*); void slotPercent(KJob*, unsigned long); void emitProgressChanged(); private: friend struct ImporterPrivate; ImporterPrivate* const d; void advance(); void finalizeImport(); }; } // namespace #endif /* IMPORTER_H */ diff --git a/importer/importerconfigdialog.h b/importer/importerconfigdialog.h index 1bb0d627..0f5a8652 100644 --- a/importer/importerconfigdialog.h +++ b/importer/importerconfigdialog.h @@ -1,52 +1,52 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2009 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef IMPORTERCONFIGDIALOG_H #define IMPORTERCONFIGDIALOG_H // Qt // KDE #include // Local namespace Gwenview { struct ImporterConfigDialogPrivate; class ImporterConfigDialog : public KConfigDialog { Q_OBJECT public: explicit ImporterConfigDialog(QWidget*); - ~ImporterConfigDialog(); + ~ImporterConfigDialog() override; private Q_SLOTS: void slotHelpLinkActivated(const QString& keyword); void updatePreview(); private: ImporterConfigDialogPrivate* const d; }; } // namespace #endif /* IMPORTERCONFIGDIALOG_H */ diff --git a/importer/progresspage.h b/importer/progresspage.h index 502d906c..a0b7af9d 100644 --- a/importer/progresspage.h +++ b/importer/progresspage.h @@ -1,50 +1,50 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2009 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef PROGRESSPAGE_H #define PROGRESSPAGE_H // Qt #include // KDE // Local namespace Gwenview { class Importer; struct ProgressPagePrivate; class ProgressPage : public QWidget { Q_OBJECT public: explicit ProgressPage(Importer*); - ~ProgressPage(); + ~ProgressPage() override; private: ProgressPagePrivate* const d; }; } // namespace #endif /* PROGRESSPAGE_H */ diff --git a/importer/thumbnailpage.h b/importer/thumbnailpage.h index 95d50066..2811d767 100644 --- a/importer/thumbnailpage.h +++ b/importer/thumbnailpage.h @@ -1,80 +1,80 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2009 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef THUMBNAILPAGE_H #define THUMBNAILPAGE_H // Qt #include #include #include // KDE // Local #include "documentdirfinder.h" namespace Gwenview { struct ThumbnailPagePrivate; class ThumbnailPage : public QWidget { Q_OBJECT public: ThumbnailPage(); - ~ThumbnailPage(); + ~ThumbnailPage() override; /** * Returns the list of urls to import * Only valid after importRequested() has been emitted */ QList urlList() const; QUrl destinationUrl() const; void setDestinationUrl(const QUrl&); void setSourceUrl(const QUrl&, const QString& icon, const QString& label); Q_SIGNALS: void importRequested(); void rejected(); private Q_SLOTS: void slotImportSelected(); void slotImportAll(); void updateImportButtons(); void openUrl(const QUrl&); void slotDocumentDirFinderDone(const QUrl& url, DocumentDirFinder::Status status); void showConfigDialog(); void openUrlFromIndex(const QModelIndex& index); void setupSrcUrlTreeView(); void toggleSrcUrlTreeView(); void slotSrcUrlModelExpand(const QModelIndex& index); private: friend struct ThumbnailPagePrivate; ThumbnailPagePrivate* const d; void importList(const QModelIndexList&); }; } // namespace #endif /* THUMBNAILPAGE_H */ diff --git a/lib/abstractimageoperation.cpp b/lib/abstractimageoperation.cpp index eb82f75b..10c63679 100644 --- a/lib/abstractimageoperation.cpp +++ b/lib/abstractimageoperation.cpp @@ -1,127 +1,127 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Self #include "abstractimageoperation.h" // Qt #include #include // KDE #include // Local #include "document/documentfactory.h" #include "document/documentjob.h" namespace Gwenview { class ImageOperationCommand : public QUndoCommand { public: ImageOperationCommand(AbstractImageOperation* op) : mOp(op) {} - ~ImageOperationCommand() + ~ImageOperationCommand() override { delete mOp; } void undo() override { mOp->undo(); } void redo() override { mOp->redo(); } private: AbstractImageOperation* mOp; }; struct AbstractImageOperationPrivate { QString mText; QUrl mUrl; ImageOperationCommand* mCommand; }; AbstractImageOperation::AbstractImageOperation() : d(new AbstractImageOperationPrivate) { } AbstractImageOperation::~AbstractImageOperation() { delete d; } void AbstractImageOperation::applyToDocument(Document::Ptr doc) { d->mUrl = doc->url(); d->mCommand = new ImageOperationCommand(this); d->mCommand->setText(d->mText); // QUndoStack::push() executes command by calling its redo() function doc->undoStack()->push(d->mCommand); } Document::Ptr AbstractImageOperation::document() const { Document::Ptr doc = DocumentFactory::instance()->load(d->mUrl); doc->startLoadingFullImage(); return doc; } void AbstractImageOperation::finish(bool ok) { if (ok) { // Give QUndoStack time to update in case the redo/undo is executed immediately // (e.g. undo crop just sets the previous image) QTimer::singleShot(0, document().data(), &Document::imageOperationCompleted); } else { // Remove command from undo stack without executing undo() d->mCommand->setObsolete(true); document()->undoStack()->undo(); } } void AbstractImageOperation::finishFromKJob(KJob* job) { finish(job->error() == KJob::NoError); } void AbstractImageOperation::setText(const QString& text) { d->mText = text; } void AbstractImageOperation::redoAsDocumentJob(DocumentJob* job) { connect(job, SIGNAL(result(KJob*)), SLOT(finishFromKJob(KJob*))); document()->enqueueJob(job); } } // namespace diff --git a/lib/abstractimageoperation.h b/lib/abstractimageoperation.h index 51b09530..52a6f503 100644 --- a/lib/abstractimageoperation.h +++ b/lib/abstractimageoperation.h @@ -1,89 +1,89 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ABSTRACTIMAGEOPERATION_H #define ABSTRACTIMAGEOPERATION_H #include // Qt #include // KDE // Local #include class KJob; namespace Gwenview { struct AbstractImageOperationPrivate; /** * An operation to apply on a document. This class pushes internal instances of * QUndoCommand to the document undo stack, but it only does so if the * operation succeeded. * * Class inheriting from this class should: * - Implement redo() and call finish() or finishFromKJob() when done * - Implement undo() * - Define the operation/command text with setText() */ class GWENVIEWLIB_EXPORT AbstractImageOperation : public QObject { Q_OBJECT public: AbstractImageOperation(); - virtual ~AbstractImageOperation(); + ~AbstractImageOperation() override; void applyToDocument(Document::Ptr); Document::Ptr document() const; protected: virtual void redo() = 0; virtual void undo() {} void setText(const QString&); /** * Convenience method which can be called from redo() if the operation is * implemented as a job */ void redoAsDocumentJob(DocumentJob* job); protected Q_SLOTS: void finish(bool ok); /** * Convenience slot which call finish() correctly if job succeeded */ void finishFromKJob(KJob* job); private: AbstractImageOperationPrivate* const d; friend class ImageOperationCommand; }; } // namespace #endif /* ABSTRACTIMAGEOPERATION_H */ diff --git a/lib/binder.h b/lib/binder.h index 386f06c3..d83d6f81 100644 --- a/lib/binder.h +++ b/lib/binder.h @@ -1,125 +1,125 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2009 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef BINDER_H #define BINDER_H #include // Qt #include namespace Gwenview { /** * @internal * * Necessary helper class because a QObject class cannot be a template */ class GWENVIEWLIB_EXPORT BinderInternal : public QObject { Q_OBJECT public: explicit BinderInternal(QObject* parent); - ~BinderInternal(); + ~BinderInternal() override; protected Q_SLOTS: virtual void callMethod() {} }; /** * The Binder and BinderRef classes make it possible to "connect" a * parameter-less signal with a slot which accepts one argument. The * argument must be known at connection time. * * Example: * * Assuming a class like this: * * class Receiver * { * public: * void doSomething(Param* p); * }; * * This code: * * Binder::bind(emitter, SIGNAL(somethingHappened()), receiver, &Receiver::doSomething, p) * * Will result in receiver->doSomething(p) being called when emitter emits * the somethingHappened() signal. * * Just like a regular QObject connection, the connection will last until * either emitter or receiver are deleted. * * Using this system avoids creating an helper slot and adding a member to * the Receiver class to store the argument of the method to call. * * To call a method which accept a pointer or a value argument, use Binder. * To call a method which accept a const reference argument, use BinderRef. * * Note: the method does not need to be a slot. */ template class BaseBinder : public BinderInternal { public: typedef void (Receiver::*Method)(MethodArg); static void bind(QObject* emitter, const char* signal, Receiver* receiver, Method method, MethodArg arg) { BaseBinder* binder = new BaseBinder(emitter); binder->mReceiver = receiver; binder->mMethod = method; binder->mArg = arg; QObject::connect(emitter, signal, binder, SLOT(callMethod())); QObject::connect(receiver, SIGNAL(destroyed(QObject*)), binder, SLOT(deleteLater())); } protected: void callMethod() override { (mReceiver->*mMethod)(mArg); } private: BaseBinder(QObject* emitter) : BinderInternal(emitter) , mReceiver(0) , mMethod(0) {} Receiver* mReceiver; Method mMethod; Arg mArg; }; template class Binder : public BaseBinder {}; template class BinderRef : public BaseBinder {}; } // namespace #endif /* BINDER_H */ diff --git a/lib/contextmanager.h b/lib/contextmanager.h index 8d6aae1f..6e972faf 100644 --- a/lib/contextmanager.h +++ b/lib/contextmanager.h @@ -1,106 +1,106 @@ /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef CONTEXTMANAGER_H #define CONTEXTMANAGER_H #include // Qt #include // KDE #include #include class QItemSelectionModel; class QModelIndex; namespace Gwenview { class SortedDirModel; struct ContextManagerPrivate; /** * Manages the state of the application. * TODO: Most of GvCore should be merged in this class */ class GWENVIEWLIB_EXPORT ContextManager : public QObject { Q_OBJECT public: ContextManager(SortedDirModel*, QObject* parent); - ~ContextManager(); + ~ContextManager() override; void loadConfig(); void saveConfig() const; QUrl currentUrl() const; void setCurrentDirUrl(const QUrl&); QUrl currentDirUrl() const; void setCurrentUrl(const QUrl ¤tUrl); KFileItemList selectedFileItemList() const; SortedDirModel* dirModel() const; QItemSelectionModel* selectionModel() const; bool currentUrlIsRasterImage() const; QUrl urlToSelect() const; void setUrlToSelect(const QUrl&); QUrl targetDirUrl() const; void setTargetDirUrl(const QUrl&); Q_SIGNALS: void currentDirUrlChanged(const QUrl&); void currentUrlChanged(const QUrl&); void selectionChanged(); void selectionDataChanged(); public Q_SLOTS: void slotSelectionChanged(); private Q_SLOTS: void slotDirModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); void slotCurrentChanged(const QModelIndex&); void emitQueuedSignals(); void slotRowsAboutToBeRemoved(const QModelIndex& /*parent*/, int start, int end); void slotRowsInserted(); void selectUrlToSelect(); void slotDirListerRedirection(const QUrl&); void slotDirListerCompleted(); private: ContextManagerPrivate* const d; }; } // namespace #endif /* CONTEXTMANAGER_H */ diff --git a/lib/crop/cropimageoperation.h b/lib/crop/cropimageoperation.h index df6bdf12..b13efcdb 100644 --- a/lib/crop/cropimageoperation.h +++ b/lib/crop/cropimageoperation.h @@ -1,54 +1,54 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef CROPIMAGEOPERATION_H #define CROPIMAGEOPERATION_H #include // Qt // KDE // Local #include class QRect; namespace Gwenview { struct CropImageOperationPrivate; class GWENVIEWLIB_EXPORT CropImageOperation : public AbstractImageOperation { public: CropImageOperation(const QRect&); - ~CropImageOperation(); + ~CropImageOperation() override; void redo() override; void undo() override; private: CropImageOperationPrivate* const d; }; } // namespace #endif /* CROPIMAGEOPERATION_H */ diff --git a/lib/crop/cropwidget.h b/lib/crop/cropwidget.h index 601753dd..625633ea 100644 --- a/lib/crop/cropwidget.h +++ b/lib/crop/cropwidget.h @@ -1,80 +1,80 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef CROPWIDGET_H #define CROPWIDGET_H #include // Qt #include // KDE // Local #include namespace Gwenview { class CropTool; class RasterImageView; struct CropWidgetPrivate; class GWENVIEWLIB_EXPORT CropWidget : public QWidget { Q_OBJECT public: CropWidget(QWidget* parent, RasterImageView*, CropTool*); - ~CropWidget(); + ~CropWidget() override; void setAdvancedSettingsEnabled(bool enable); bool advancedSettingsEnabled() const; void setPreserveAspectRatio(bool preserve); bool preserveAspectRatio() const; void setCropRatio(QSizeF size); int cropRatioIndex() const; void setCropRatioIndex(int index); QSizeF cropRatio() const; Q_SIGNALS: void cropRequested(); void done(); public Q_SLOTS: void updateCropRatio(); private Q_SLOTS: void slotPositionChanged(); void slotWidthChanged(); void slotHeightChanged(); void setCropRect(const QRect& rect); void slotAdvancedCheckBoxToggled(bool checked); void slotRatioComboBoxChanged(); void applyRatioConstraint(); private: CropWidgetPrivate* const d; }; } // namespace #endif /* CROPWIDGET_H */ diff --git a/lib/datewidget.h b/lib/datewidget.h index aeed2887..627ed736 100644 --- a/lib/datewidget.h +++ b/lib/datewidget.h @@ -1,64 +1,64 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef DATEWIDGET_H #define DATEWIDGET_H #include "gwenviewlib_export.h" // Qt #include // KDE // Local class QDate; namespace Gwenview { struct DateWidgetPrivate; class GWENVIEWLIB_EXPORT DateWidget : public QWidget { Q_OBJECT public: explicit DateWidget(QWidget* parent = nullptr); - ~DateWidget(); + ~DateWidget() override; QDate date() const; Q_SIGNALS: void dateChanged(const QDate&); private Q_SLOTS: void showDatePicker(); void slotDatePickerModified(const QDate& date); void goToPrevious(); void goToNext(); private: friend struct DateWidgetPrivate; DateWidgetPrivate* const d; }; } // namespace #endif /* DATEWIDGET_H */ diff --git a/lib/document/abstractdocumentimpl.h b/lib/document/abstractdocumentimpl.h index 5d6862b8..1f427e60 100644 --- a/lib/document/abstractdocumentimpl.h +++ b/lib/document/abstractdocumentimpl.h @@ -1,123 +1,123 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ABSTRACTDOCUMENTIMPL_H #define ABSTRACTDOCUMENTIMPL_H // Qt #include #include // KDE // Local #include #include class QImage; class QRect; namespace Gwenview { class Document; class DocumentJob; class AbstractDocumentEditor; struct AbstractDocumentImplPrivate; class AbstractDocumentImpl : public QObject { Q_OBJECT public: AbstractDocumentImpl(Document*); - virtual ~AbstractDocumentImpl(); + ~AbstractDocumentImpl() override; /** * This method is called by Document::switchToImpl after it has connected * signals to the object */ virtual void init() = 0; virtual Document::LoadingState loadingState() const = 0; virtual DocumentJob* save(const QUrl&, const QByteArray& /*format*/) { return nullptr; } virtual AbstractDocumentEditor* editor() { return nullptr; } virtual QByteArray rawData() const { return QByteArray(); } virtual bool isEditable() const { return false; } virtual bool isAnimated() const { return false; } virtual void startAnimation() {} virtual void stopAnimation() {} Document* document() const; virtual QSvgRenderer* svgRenderer() const { return nullptr; } Q_SIGNALS: void imageRectUpdated(const QRect&); void metaInfoLoaded(); void loaded(); void loadingFailed(); void isAnimatedUpdated(); void editorUpdated(); protected: void setDocumentImage(const QImage& image); void setDocumentImageSize(const QSize& size); void setDocumentKind(MimeTypeUtils::Kind); void setDocumentFormat(const QByteArray& format); void setDocumentExiv2Image(Exiv2::Image::AutoPtr); void setDocumentDownSampledImage(const QImage&, int invertedZoom); void setDocumentCmsProfile(Cms::Profile::Ptr profile); void setDocumentErrorString(const QString&); void switchToImpl(AbstractDocumentImpl* impl); private: AbstractDocumentImplPrivate* const d; }; } // namespace #endif /* ABSTRACTDOCUMENTIMPL_H */ diff --git a/lib/document/document.h b/lib/document/document.h index 782111d9..c0bb454b 100644 --- a/lib/document/document.h +++ b/lib/document/document.h @@ -1,250 +1,250 @@ /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef DOCUMENT_H #define DOCUMENT_H #include #include #include // Qt #include #include #include // Local #include #include class QImage; class QRect; class QSize; class QSvgRenderer; class QUndoStack; class KJob; class QUrl; namespace Gwenview { class AbstractDocumentEditor; class AbstractDocumentImpl; class DocumentJob; class DocumentFactory; struct DocumentPrivate; class ImageMetaInfoModel; /** * This class represents an image. * * It handles loading and saving the image, applying operations and maintaining * the document undo stack. * * It is capable of loading down sampled versions of an image using * prepareDownSampledImageForZoom() and downSampledImageForZoom(). Down sampled * images load much faster than the full image but you need to load the full * image to manipulate it (use startLoadingFullImage() to do so). * * To get a Document instance for url, ask for one with * DocumentFactory::instance()->load(url); */ class GWENVIEWLIB_EXPORT Document : public QObject, public QSharedData { Q_OBJECT public: /** * Document won't produce down sampled images for any zoom value higher than maxDownSampledZoom(). * * Note: We can't use the enum {} trick to declare this constant, that's * why it's defined as a static method */ static qreal maxDownSampledZoom(); enum LoadingState { Loading, ///< Image is loading KindDetermined, ///< Image is still loading, but kind has been determined MetaInfoLoaded, ///< Image is still loading, but meta info has been loaded Loaded, ///< Full image has been loaded LoadingFailed ///< Image loading has failed }; typedef QExplicitlySharedDataPointer Ptr; - ~Document(); + ~Document() override; /** * Returns a message for the last error which happened */ QString errorString() const; void reload(); void startLoadingFullImage(); /** * Prepare a version of the image down sampled to be a bit bigger than * size() * @a zoom. * Do not ask for a down sampled image for @a zoom >= to MaxDownSampledZoom. * * @return true if the image is ready, false if not. In this case the * downSampledImageReady() signal will be emitted. */ bool prepareDownSampledImageForZoom(qreal zoom); LoadingState loadingState() const; MimeTypeUtils::Kind kind() const; bool isModified() const; const QImage& image() const; const QImage& downSampledImageForZoom(qreal zoom) const; /** * Returns an implementation of AbstractDocumentEditor if this document can * be edited. */ AbstractDocumentEditor* editor(); QUrl url() const; DocumentJob* save(const QUrl &url, const QByteArray& format); QByteArray format() const; void waitUntilLoaded(); QSize size() const; int width() const { return size().width(); } int height() const { return size().height(); } bool hasAlphaChannel() const; ImageMetaInfoModel* metaInfo() const; QUndoStack* undoStack() const; void setKeepRawData(bool); bool keepRawData() const; /** * Returns how much bytes the document is using */ int memoryUsage() const; /** * Returns the compressed version of the document, if it is still * available. */ QByteArray rawData() const; Cms::Profile::Ptr cmsProfile() const; /** * Returns a QSvgRenderer which can be used to render this document if it is * an SVG image. Returns a NULL pointer otherwise. */ QSvgRenderer* svgRenderer() const; /** * Returns true if the image can be edited. * You must ensure it has been fully loaded with startLoadingFullImage() first. */ bool isEditable() const; /** * Returns true if the image is animated (eg: gif or mng format) */ bool isAnimated() const; /** * Starts animation. Only sensible if isAnimated() returns true. */ void startAnimation(); /** * Stops animation. Only sensible if isAnimated() returns true. */ void stopAnimation(); void enqueueJob(DocumentJob*); void imageOperationCompleted(); /** * Returns true if there are queued tasks for this document. */ bool isBusy() const; Q_SIGNALS: void downSampledImageReady(); void imageRectUpdated(const QRect&); void kindDetermined(const QUrl&); void metaInfoLoaded(const QUrl&); void loaded(const QUrl&); void loadingFailed(const QUrl&); void saved(const QUrl &oldUrl, const QUrl& newUrl); void modified(const QUrl&); void metaInfoUpdated(); void isAnimatedUpdated(); void busyChanged(const QUrl&, bool); void allTasksDone(); private Q_SLOTS: void emitMetaInfoLoaded(); void emitLoaded(); void emitLoadingFailed(); void slotSaveResult(KJob*); void slotJobFinished(KJob*); private: friend class AbstractDocumentImpl; friend class DocumentFactory; friend struct DocumentPrivate; friend class DownSamplingJob; void setImageInternal(const QImage&); void setKind(MimeTypeUtils::Kind); void setFormat(const QByteArray&); void setSize(const QSize&); void setExiv2Image(Exiv2::Image::AutoPtr); void setDownSampledImage(const QImage&, int invertedZoom); void switchToImpl(AbstractDocumentImpl* impl); void setErrorString(const QString&); void setCmsProfile(Cms::Profile::Ptr); Document(const QUrl&); DocumentPrivate * const d; }; } // namespace #endif /* DOCUMENT_H */ diff --git a/lib/document/documentfactory.h b/lib/document/documentfactory.h index bd541234..8efaa1b5 100644 --- a/lib/document/documentfactory.h +++ b/lib/document/documentfactory.h @@ -1,96 +1,96 @@ /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef DOCUMENTFACTORY_H #define DOCUMENTFACTORY_H // Qt #include #include class QUndoGroup; class QUrl; namespace Gwenview { struct DocumentFactoryPrivate; /** * This class holds all instances of Document. * * It keeps a cache of recently accessed documents to avoid reloading them. * To do so it keeps a last-access timestamp, which is updated to the * current time every time DocumentFactory::load() is called. */ class GWENVIEWLIB_EXPORT DocumentFactory : public QObject { Q_OBJECT public: static DocumentFactory* instance(); - ~DocumentFactory(); + ~DocumentFactory() override; /** * Loads the document associated with url, or returns an already cached * instance of Document::Ptr if there is any. * This method updates the last-access timestamp. */ Document::Ptr load(const QUrl &url); /** * Returns a document if it has already been loaded once with load(). * This method does not update the last-access timestamp. */ Document::Ptr getCachedDocument(const QUrl&) const; QList modifiedDocumentList() const; bool hasUrl(const QUrl&) const; void clearCache(); QUndoGroup* undoGroup(); /** * Do not keep document whose url is @url in cache even if it has been * modified */ void forget(const QUrl &url); Q_SIGNALS: void modifiedDocumentListChanged(); void documentChanged(const QUrl&); void documentBusyStateChanged(const QUrl&, bool); private Q_SLOTS: void slotLoaded(const QUrl&); void slotSaved(const QUrl&, const QUrl&); void slotModified(const QUrl&); void slotBusyChanged(const QUrl&, bool); private: DocumentFactory(); DocumentFactoryPrivate* const d; }; } // namespace #endif /* DOCUMENTFACTORY_H */ diff --git a/lib/documentview/abstractdocumentviewadapter.h b/lib/documentview/abstractdocumentviewadapter.h index 672dffcd..08e62ee4 100644 --- a/lib/documentview/abstractdocumentviewadapter.h +++ b/lib/documentview/abstractdocumentviewadapter.h @@ -1,203 +1,203 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef ABSTRACTDOCUMENTVIEWADAPTER_H #define ABSTRACTDOCUMENTVIEWADAPTER_H #include // Qt #include #include // KDE // Local #include class QCursor; class QGraphicsWidget; class QRectF; namespace Gwenview { class AbstractImageView; class RasterImageView; /** * Classes inherit from this class so that they can be used inside the * DocumentPanel. */ class GWENVIEWLIB_EXPORT AbstractDocumentViewAdapter : public QObject { Q_OBJECT public: AbstractDocumentViewAdapter(); - virtual ~AbstractDocumentViewAdapter(); + ~AbstractDocumentViewAdapter() override; QGraphicsWidget* widget() const { return mWidget; } virtual MimeTypeUtils::Kind kind() const = 0; virtual AbstractImageView* imageView() const { return nullptr; } virtual RasterImageView* rasterImageView() const { return nullptr; } virtual QCursor cursor() const; virtual void setCursor(const QCursor&); /** * @defgroup zooming functions * @{ */ virtual bool canZoom() const { return false; } // Implementation must emit zoomToFitChanged() virtual void setZoomToFit(bool) {} virtual bool zoomToFit() const { return false; } // Implementation must emit zoomToFillChanged() virtual void setZoomToFill(bool /*on*/, const QPointF& /*center*/ = QPointF(-1, -1)) {} virtual bool zoomToFill() const { return false; } virtual qreal zoom() const { return 0; } virtual void setZoom(qreal /*zoom*/, const QPointF& /*center*/ = QPointF(-1, -1)) {} virtual qreal computeZoomToFit() const { return 1.; } virtual qreal computeZoomToFill() const { return 1.; } /** @} */ virtual Document::Ptr document() const = 0; virtual void setDocument(Document::Ptr) = 0; virtual void loadConfig() {} virtual QPointF scrollPos() const { return QPointF(0, 0); } virtual void setScrollPos(const QPointF& /*pos*/) {} /** * Rectangle within the item which is actually used to show the document. * In item coordinates. */ virtual QRectF visibleDocumentRect() const; protected: void setWidget(QGraphicsWidget* widget) { mWidget = widget; } Q_SIGNALS: /** * @addgroup zooming functions * @{ */ void zoomChanged(qreal); void zoomToFitChanged(bool); void zoomToFillChanged(bool); void zoomInRequested(const QPointF&); void zoomOutRequested(const QPointF&); /** @} */ void scrollPosChanged(); /** * Emitted when the adapter is done showing the document for the first time */ void completed(); void previousImageRequested(); void nextImageRequested(); void toggleFullScreenRequested(); private: QGraphicsWidget* mWidget; }; /** * An empty adapter, used when no document is displayed */ class EmptyAdapter : public AbstractDocumentViewAdapter { Q_OBJECT public: EmptyAdapter(); MimeTypeUtils::Kind kind() const override { return MimeTypeUtils::KIND_UNKNOWN; } Document::Ptr document() const override { return Document::Ptr(); } void setDocument(Document::Ptr) override {} }; } // namespace #endif /* ABSTRACTDOCUMENTVIEWADAPTER_H */ diff --git a/lib/documentview/abstractrasterimageviewtool.h b/lib/documentview/abstractrasterimageviewtool.h index 3c2f41c7..44bf6c1f 100644 --- a/lib/documentview/abstractrasterimageviewtool.h +++ b/lib/documentview/abstractrasterimageviewtool.h @@ -1,92 +1,92 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ABSTRACTRASTERIMAGEVIEWTOOL_H #define ABSTRACTRASTERIMAGEVIEWTOOL_H #include // Qt #include // KDE // Local class QKeyEvent; class QGraphicsSceneHoverEvent; class QGraphicsSceneMouseEvent; class QGraphicsSceneWheelEvent; class QPainter; namespace Gwenview { class RasterImageView; struct AbstractRasterImageViewToolPrivate; class GWENVIEWLIB_EXPORT AbstractRasterImageViewTool : public QObject { Q_OBJECT public: AbstractRasterImageViewTool(RasterImageView* view); - virtual ~AbstractRasterImageViewTool(); + ~AbstractRasterImageViewTool() override; RasterImageView* imageView() const; virtual void paint(QPainter*) {} virtual void mousePressEvent(QGraphicsSceneMouseEvent*) {} virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*) {} virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*) {} virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event); virtual void hoverMoveEvent(QGraphicsSceneHoverEvent*) {} virtual void wheelEvent(QGraphicsSceneWheelEvent* event); virtual void keyPressEvent(QKeyEvent*) {} virtual void keyReleaseEvent(QKeyEvent*) {} virtual void toolActivated() {} virtual void toolDeactivated() {} virtual QWidget* widget() const { return nullptr; } public Q_SLOTS: virtual void onWidgetSlidedIn() {} private: AbstractRasterImageViewToolPrivate * const d; }; } // namespace #endif /* ABSTRACTRASTERIMAGEVIEWTOOL_H */ diff --git a/lib/documentview/documentviewcontroller.h b/lib/documentview/documentviewcontroller.h index 9e50c708..17abce44 100644 --- a/lib/documentview/documentviewcontroller.h +++ b/lib/documentview/documentviewcontroller.h @@ -1,77 +1,77 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2011 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef DOCUMENTVIEWCONTROLLER_H #define DOCUMENTVIEWCONTROLLER_H #include // Local // KDE // Qt #include class KActionCollection; namespace Gwenview { class DocumentView; class SlideContainer; class ZoomWidget; struct DocumentViewControllerPrivate; /** * Handles all DocumentView specific actions like zooming. Calls the * corresponding code on its view, if any. */ class GWENVIEWLIB_EXPORT DocumentViewController : public QObject { Q_OBJECT public: explicit DocumentViewController(KActionCollection*, QObject* parent = nullptr); - ~DocumentViewController(); + ~DocumentViewController() override; DocumentView* view() const; ZoomWidget* zoomWidget() const; void setView(DocumentView*); void setZoomWidget(ZoomWidget* widget); void setToolContainer(SlideContainer* container); void reset(); private Q_SLOTS: void slotAdapterChanged(); void updateZoomToFitActionFromView(); void updateZoomToFillActionFromView(); void updateTool(); private: DocumentViewControllerPrivate* const d; }; } // namespace #endif /* DOCUMENTVIEWCONTROLLER_H */ diff --git a/lib/documentview/documentviewsynchronizer.h b/lib/documentview/documentviewsynchronizer.h index eef4509f..bb9b9bcb 100644 --- a/lib/documentview/documentviewsynchronizer.h +++ b/lib/documentview/documentviewsynchronizer.h @@ -1,69 +1,69 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2011 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef DOCUMENTVIEWSYNCHRONIZER_H #define DOCUMENTVIEWSYNCHRONIZER_H #include // Local // KDE // Qt #include namespace Gwenview { class DocumentView; struct DocumentViewSynchronizerPrivate; /** * A class to synchronize zoom and scroll of DocumentViews */ class GWENVIEWLIB_EXPORT DocumentViewSynchronizer : public QObject { Q_OBJECT public: // We pass a pointer to the view list because we don't want to maintain // a copy of the list itself explicit DocumentViewSynchronizer(const QList* views, QObject* parent = nullptr); - ~DocumentViewSynchronizer(); + ~DocumentViewSynchronizer() override; void setCurrentView(DocumentView* view); public Q_SLOTS: void setActive(bool); private Q_SLOTS: void setZoom(qreal zoom); void setZoomToFit(bool); void setZoomToFill(bool); void updatePosition(); private: DocumentViewSynchronizerPrivate* const d; }; } // namespace #endif /* DOCUMENTVIEWSYNCHRONIZER_H */ diff --git a/lib/documentview/rasterimageviewadapter.h b/lib/documentview/rasterimageviewadapter.h index 64986b86..5874fc51 100644 --- a/lib/documentview/rasterimageviewadapter.h +++ b/lib/documentview/rasterimageviewadapter.h @@ -1,97 +1,97 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef RASTERIMAGEVIEWADAPTER_H #define RASTERIMAGEVIEWADAPTER_H #include // Qt // KDE // Local #include namespace Gwenview { struct RasterImageViewAdapterPrivate; class GWENVIEWLIB_EXPORT RasterImageViewAdapter : public AbstractDocumentViewAdapter { Q_OBJECT public: RasterImageViewAdapter(); ~RasterImageViewAdapter() override; QCursor cursor() const override; void setCursor(const QCursor&) override; MimeTypeUtils::Kind kind() const override { return MimeTypeUtils::KIND_RASTER_IMAGE; } bool canZoom() const override { return true; } void setZoomToFit(bool) override; void setZoomToFill(bool on, const QPointF& center) override; bool zoomToFit() const override; bool zoomToFill() const override; qreal zoom() const override; void setZoom(qreal zoom, const QPointF& center) override; qreal computeZoomToFit() const override; qreal computeZoomToFill() const override; Document::Ptr document() const override; void setDocument(Document::Ptr) override; void loadConfig() override; RasterImageView* rasterImageView() const override; - virtual AbstractImageView* imageView() const override; + AbstractImageView* imageView() const override; QPointF scrollPos() const override; void setScrollPos(const QPointF& pos) override; QRectF visibleDocumentRect() const override; private Q_SLOTS: void slotLoadingFailed(); private: RasterImageViewAdapterPrivate* const d; }; } // namespace #endif /* RASTERIMAGEVIEWADAPTER_H */ diff --git a/lib/documentview/svgviewadapter.h b/lib/documentview/svgviewadapter.h index 4dd7ab78..b726da1d 100644 --- a/lib/documentview/svgviewadapter.h +++ b/lib/documentview/svgviewadapter.h @@ -1,125 +1,125 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef SVGVIEWADAPTER_H #define SVGVIEWADAPTER_H #include // Qt #include // KDE // Local #include #include class QGraphicsSvgItem; namespace Gwenview { class SvgImageView : public AbstractImageView { Q_OBJECT public: explicit SvgImageView(QGraphicsItem* parent = nullptr); void setAlphaBackgroundMode(AlphaBackgroundMode mode) override; void setAlphaBackgroundColor(const QColor& color) override; protected: void loadFromDocument() override; void onZoomChanged() override; void onImageOffsetChanged() override; void onScrollPosChanged(const QPointF& oldPos) override; private Q_SLOTS: void finishLoadFromDocument(); private: QGraphicsSvgItem* mSvgItem; AbstractImageView::AlphaBackgroundMode mAlphaBackgroundMode; QColor mAlphaBackgroundColor; bool mImageFullyLoaded; void adjustItemPos(); void drawAlphaBackground(QPainter* painter); void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override; }; struct SvgViewAdapterPrivate; class GWENVIEWLIB_EXPORT SvgViewAdapter : public AbstractDocumentViewAdapter { Q_OBJECT public: SvgViewAdapter(); - ~SvgViewAdapter(); + ~SvgViewAdapter() override; QCursor cursor() const override; void setCursor(const QCursor&) override; void setDocument(Document::Ptr) override; Document::Ptr document() const override; void loadConfig() override; MimeTypeUtils::Kind kind() const override { return MimeTypeUtils::KIND_SVG_IMAGE; } bool canZoom() const override { return true; } void setZoomToFit(bool) override; void setZoomToFill(bool on, const QPointF& center) override; bool zoomToFit() const override; bool zoomToFill() const override; qreal zoom() const override; void setZoom(qreal /*zoom*/, const QPointF& /*center*/ = QPointF(-1, -1)) override; qreal computeZoomToFit() const override; qreal computeZoomToFill() const override; QPointF scrollPos() const override; void setScrollPos(const QPointF& pos) override; - virtual QRectF visibleDocumentRect() const override; + QRectF visibleDocumentRect() const override; - virtual AbstractImageView* imageView() const override; + AbstractImageView* imageView() const override; private: SvgViewAdapterPrivate* const d; }; } // namespace #endif /* SVGVIEWADAPTER_H */ diff --git a/lib/hud/hudmessagebubble.h b/lib/hud/hudmessagebubble.h index 3d658f07..769b2713 100644 --- a/lib/hud/hudmessagebubble.h +++ b/lib/hud/hudmessagebubble.h @@ -1,61 +1,61 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2009 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef HUDMESSAGEBUBBLE_H #define HUDMESSAGEBUBBLE_H #include // Qt // KDE // Local #include class KGuiItem; namespace Gwenview { class HudButton; struct HudMessageBubblePrivate; /** * Shows a bubble with a QLabel and optional buttons. * Automatically goes away after a while. */ class GWENVIEWLIB_EXPORT HudMessageBubble : public HudWidget { Q_OBJECT public: explicit HudMessageBubble(QGraphicsWidget* parent = nullptr); - ~HudMessageBubble(); + ~HudMessageBubble() override; void setText(const QString& text); HudButton* addButton(const KGuiItem&); private: HudMessageBubblePrivate* const d; }; } // namespace #endif /* HUDMESSAGEBUBBLE_H */ diff --git a/lib/imagescaler.h b/lib/imagescaler.h index bf919987..2d177d73 100644 --- a/lib/imagescaler.h +++ b/lib/imagescaler.h @@ -1,65 +1,65 @@ /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef IMAGESCALER_H #define IMAGESCALER_H // Qt #include // KDE // local #include #include class QImage; class QRect; class QRegion; namespace Gwenview { class Document; struct ImageScalerPrivate; class GWENVIEWLIB_EXPORT ImageScaler : public QObject { Q_OBJECT public: explicit ImageScaler(QObject* parent = nullptr); - ~ImageScaler(); + ~ImageScaler() override; void setDocument(Document::Ptr); void setZoom(qreal); void setDestinationRegion(const QRegion&); Q_SIGNALS: void scaledRect(int left, int top, const QImage&); private: ImageScalerPrivate * const d; void scaleRect(const QRect&); private Q_SLOTS: void doScale(); }; } // namespace #endif /* IMAGESCALER_H */ diff --git a/lib/invisiblebuttongroup.h b/lib/invisiblebuttongroup.h index 2212ca20..d502960f 100644 --- a/lib/invisiblebuttongroup.h +++ b/lib/invisiblebuttongroup.h @@ -1,102 +1,102 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef INVISIBLEBUTTONGROUP_H #define INVISIBLEBUTTONGROUP_H #include // Qt #include // KDE // Local class QAbstractButton; namespace Gwenview { struct InvisibleButtonGroupPrivate; /** * This class makes it possible to create radio buttons without having to put * them in a dedicated QGroupBox or KButtonGroup. This is useful when you do not * want to add visual frames to create a set of radio buttons. * * It is a QWidget so that it can support KConfigXT: it is completely * invisible and does not require the radio buttons to be its children. * The most common way to use it is to create your dialog with Designer, * including the radio buttons, and to instantiate an instance of * InvisibleButtonGroup from your code. * * Example: * * We assume "config" is a KConfigSkeleton object which contains a * "ViewMode" key. This key is an int where 1 means "list" and 2 means * "detail". * We also assume "ui" has been created with Designer and contains two * QRadioButton named "listRadioButton" and "detailRadioButton". * * @code * // Prepare the config dialog * KConfigDialog* dialog(parent, "Settings", config); * * // Create a widget in the dialog * QWidget* pageWidget = new QWidget; * ui->setupUi(pageWidget); * dialog->addPage(pageWidget, i18n("Page Title")); * @endcode * * Now we can setup an InvisibleButtonGroup to handle both radio * buttons and ensure they follow the "ViewMode" config key. * * @code * InvisibleButtonGroup* group = new InvisibleButtonGroup(pageWidget); * group->setObjectName( QLatin1String("kcfg_ViewMode" )); * group->addButton(ui->listRadioButton, 1); * group->addButton(ui->detailRadioButton, 2); * @endcode */ class GWENVIEWLIB_EXPORT InvisibleButtonGroup : public QWidget { Q_OBJECT Q_PROPERTY(int current READ selected WRITE setSelected) public: explicit InvisibleButtonGroup(QWidget* parent = nullptr); - ~InvisibleButtonGroup(); + ~InvisibleButtonGroup() override; int selected() const; void addButton(QAbstractButton* button, int id); public Q_SLOTS: void setSelected(int id); Q_SIGNALS: void selectionChanged(int id); private: InvisibleButtonGroupPrivate* const d; }; } // namespace #endif /* INVISIBLEBUTTONGROUP_H */ diff --git a/lib/print/printoptionspage.h b/lib/print/printoptionspage.h index 1f6c9d22..1ac2d60d 100644 --- a/lib/print/printoptionspage.h +++ b/lib/print/printoptionspage.h @@ -1,75 +1,75 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PRINTOPTIONSPAGE_H #define PRINTOPTIONSPAGE_H // Qt #include // KDE // Local namespace Gwenview { struct PrintOptionsPagePrivate; class PrintOptionsPage : public QWidget { Q_OBJECT public: enum ScaleMode { NoScale, ScaleToPage, ScaleToCustomSize }; // Order should match the content of the unit combbox in the ui file enum Unit { Millimeters, Centimeters, Inches }; PrintOptionsPage(const QSize& imageSize); - ~PrintOptionsPage(); + ~PrintOptionsPage() override; Qt::Alignment alignment() const; ScaleMode scaleMode() const; bool enlargeSmallerImages() const; Unit scaleUnit() const; double scaleWidth() const; double scaleHeight() const; void loadConfig(); void saveConfig(); private Q_SLOTS: void adjustWidthToRatio(); void adjustHeightToRatio(); private: PrintOptionsPagePrivate* const d; }; } // namespace #endif /* PRINTOPTIONSPAGE_H */ diff --git a/lib/resize/resizeimagedialog.h b/lib/resize/resizeimagedialog.h index 71504612..58a46613 100644 --- a/lib/resize/resizeimagedialog.h +++ b/lib/resize/resizeimagedialog.h @@ -1,60 +1,60 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2010 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef RESIZEIMAGEDIALOG_H #define RESIZEIMAGEDIALOG_H #include // Qt #include // KDE // Local namespace Gwenview { struct ResizeImageDialogPrivate; class GWENVIEWLIB_EXPORT ResizeImageDialog : public QDialog { Q_OBJECT public: explicit ResizeImageDialog(QWidget *parent); - ~ResizeImageDialog(); + ~ResizeImageDialog() override; void setOriginalSize(const QSize&); QSize size() const; private Q_SLOTS: void slotWidthChanged(int); void slotHeightChanged(int); void slotWidthPercentChanged(double); void slotHeightPercentChanged(double); void slotKeepAspectChanged(bool); private: ResizeImageDialogPrivate* const d; }; } // namespace #endif /* RESIZEIMAGEDIALOG_H */ diff --git a/lib/semanticinfo/semanticinfodirmodel.h b/lib/semanticinfo/semanticinfodirmodel.h index 6f9577a8..f22a34af 100644 --- a/lib/semanticinfo/semanticinfodirmodel.h +++ b/lib/semanticinfo/semanticinfodirmodel.h @@ -1,84 +1,84 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef SEMANTICINFODIRMODEL_H #define SEMANTICINFODIRMODEL_H // Qt // KDE #include // Local class QUrl; namespace Gwenview { class AbstractSemanticInfoBackEnd; struct SemanticInfo; struct SemanticInfoDirModelPrivate; /** * Extends KDirModel by providing read/write access to image metadata such as * rating, tags and descriptions. */ class SemanticInfoDirModel : public KDirModel { Q_OBJECT public: enum { RatingRole = 0x21a43a51, DescriptionRole = 0x26FB33FA, TagsRole = 0x0462F0A8 }; SemanticInfoDirModel(QObject* parent); - ~SemanticInfoDirModel(); + ~SemanticInfoDirModel() override; void clearSemanticInfoCache(); bool semanticInfoAvailableForIndex(const QModelIndex&) const; void retrieveSemanticInfoForIndex(const QModelIndex&); SemanticInfo semanticInfoForIndex(const QModelIndex&) const; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; bool setData(const QModelIndex& index, const QVariant& data, int role = Qt::EditRole) override; AbstractSemanticInfoBackEnd* semanticInfoBackEnd() const; Q_SIGNALS: void semanticInfoRetrieved(const QUrl&, const SemanticInfo&); private: SemanticInfoDirModelPrivate* const d; private Q_SLOTS: void slotSemanticInfoRetrieved(const QUrl &url, const SemanticInfo&); void slotRowsAboutToBeRemoved(const QModelIndex&, int, int); void slotModelAboutToBeReset(); }; } // namespace #endif /* SEMANTICINFODIRMODEL_H */ diff --git a/lib/semanticinfo/sorteddirmodel.h b/lib/semanticinfo/sorteddirmodel.h index 9765e99b..fd31139f 100644 --- a/lib/semanticinfo/sorteddirmodel.h +++ b/lib/semanticinfo/sorteddirmodel.h @@ -1,133 +1,133 @@ /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SORTEDDIRMODEL_H #define SORTEDDIRMODEL_H #include // Qt #include // KDE #include // Local #include #include class KDirLister; class KFileItem; class QUrl; namespace Gwenview { class AbstractSemanticInfoBackEnd; struct SortedDirModelPrivate; #ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE struct SemanticInfo; #endif class SortedDirModel; class GWENVIEWLIB_EXPORT AbstractSortedDirModelFilter : public QObject { public: AbstractSortedDirModelFilter(SortedDirModel* model); - ~AbstractSortedDirModelFilter(); + ~AbstractSortedDirModelFilter() override; SortedDirModel* model() const { return mModel; } virtual bool needsSemanticInfo() const = 0; /** * Returns true if index should be accepted. * Warning: index is a source index of SortedDirModel */ virtual bool acceptsIndex(const QModelIndex& index) const = 0; private: QPointer mModel; }; /** * This model makes it possible to show all images in a folder. * It can filter images based on name and metadata. */ class GWENVIEWLIB_EXPORT SortedDirModel : public KDirSortFilterProxyModel { Q_OBJECT public: explicit SortedDirModel(QObject* parent = nullptr); ~SortedDirModel() override; KDirLister* dirLister() const; /** * Redefines the dir lister, useful for debugging */ void setDirLister(KDirLister*); KFileItem itemForIndex(const QModelIndex& index) const; QUrl urlForIndex(const QModelIndex& index) const; KFileItem itemForSourceIndex(const QModelIndex& sourceIndex) const; QModelIndex indexForItem(const KFileItem& item) const; QModelIndex indexForUrl(const QUrl &url) const; void setKindFilter(MimeTypeUtils::Kinds); MimeTypeUtils::Kinds kindFilter() const; void adjustKindFilter(MimeTypeUtils::Kinds, bool set); /** * A list of file extensions we should skip */ void setBlackListedExtensions(const QStringList& list); void addFilter(AbstractSortedDirModelFilter*); void removeFilter(AbstractSortedDirModelFilter*); void reload(); AbstractSemanticInfoBackEnd* semanticInfoBackEnd() const; #ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE SemanticInfo semanticInfoForSourceIndex(const QModelIndex& sourceIndex) const; #endif bool hasDocuments() const; public Q_SLOTS: void applyFilters(); protected: bool filterAcceptsRow(int row, const QModelIndex& parent) const override; bool lessThan(const QModelIndex& left, const QModelIndex& right) const override; private Q_SLOTS: void doApplyFilters(); private: friend struct SortedDirModelPrivate; SortedDirModelPrivate * const d; }; } // namespace #endif /* SORTEDDIRMODEL_H */ diff --git a/lib/semanticinfo/tagitemdelegate.h b/lib/semanticinfo/tagitemdelegate.h index 7079e2d0..9bd1fb48 100644 --- a/lib/semanticinfo/tagitemdelegate.h +++ b/lib/semanticinfo/tagitemdelegate.h @@ -1,67 +1,67 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef TAGITEMDELEGATE_H #define TAGITEMDELEGATE_H // KDE #include namespace Gwenview { typedef QString SemanticInfoTag; class TagItemDelegate : public KWidgetItemDelegate { Q_OBJECT public: TagItemDelegate(QAbstractItemView* view); protected: QList createItemWidgets(const QModelIndex &index) const override; - virtual void updateItemWidgets(const QList widgets, - const QStyleOptionViewItem& option, - const QPersistentModelIndex& /*index*/) const override; + void updateItemWidgets(const QList widgets, + const QStyleOptionViewItem& option, + const QPersistentModelIndex& /*index*/) const override; - virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const override; + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const override; - virtual QSize sizeHint(const QStyleOptionViewItem &/*option*/, - const QModelIndex &/*index*/) const override; + QSize sizeHint(const QStyleOptionViewItem &/*option*/, + const QModelIndex &/*index*/) const override; Q_SIGNALS: void removeTagRequested(const SemanticInfoTag& tag); void assignTagToAllRequested(const SemanticInfoTag& tag); private Q_SLOTS: void slotRemoveButtonClicked(); void slotAssignToAllButtonClicked(); private: int mButtonSize; int mMargin; int mSpacing; }; } // namespace #endif /* TAGITEMDELEGATE_H */ diff --git a/lib/semanticinfo/tagmodel.h b/lib/semanticinfo/tagmodel.h index 37d7844f..67a6bfc0 100644 --- a/lib/semanticinfo/tagmodel.h +++ b/lib/semanticinfo/tagmodel.h @@ -1,83 +1,83 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef TAGMODEL_H #define TAGMODEL_H #include // Qt #include // KDE // Local namespace Gwenview { typedef QString SemanticInfoTag; class AbstractSemanticInfoBackEnd; class TagSet; struct TagModelPrivate; class GWENVIEWLIB_EXPORT TagModel : public QStandardItemModel { Q_OBJECT public: explicit TagModel(QObject*); - ~TagModel(); + ~TagModel() override; enum { TagRole = Qt::UserRole, SortRole, AssignmentStatusRole }; enum AssignmentStatus { PartiallyAssigned, FullyAssigned }; void setSemanticInfoBackEnd(AbstractSemanticInfoBackEnd*); void setTagSet(const TagSet& set); /** * Convenience method to create a TagModel showing all tags available in * AbstractSemanticInfoBackEnd */ static TagModel* createAllTagsModel(QObject* parent, AbstractSemanticInfoBackEnd*); public Q_SLOTS: /** * Add a new tag. If label is empty, backend will be queried for it */ void addTag(const SemanticInfoTag& tag, const QString& label = QString(), AssignmentStatus status = FullyAssigned); void removeTag(const SemanticInfoTag& tag); private: TagModelPrivate* const d; }; } // namespace #endif /* TAGMODEL_H */ diff --git a/lib/semanticinfo/tagwidget.h b/lib/semanticinfo/tagwidget.h index 0cfcc6ae..ad6cd255 100644 --- a/lib/semanticinfo/tagwidget.h +++ b/lib/semanticinfo/tagwidget.h @@ -1,65 +1,65 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef TAGWIDGET_H #define TAGWIDGET_H #include // Qt #include #include // KDE // Local #include namespace Gwenview { typedef QMap TagInfo; struct TagWidgetPrivate; class GWENVIEWLIB_EXPORT TagWidget : public QWidget { Q_OBJECT public: explicit TagWidget(QWidget* parent = nullptr); - ~TagWidget(); + ~TagWidget() override; void setTagInfo(const TagInfo&); void setSemanticInfoBackEnd(AbstractSemanticInfoBackEnd*); Q_SIGNALS: void tagAssigned(const SemanticInfoTag&); void tagRemoved(const SemanticInfoTag&); private Q_SLOTS: void addTagFromComboBox(); void assignTag(const SemanticInfoTag& tag); void removeTag(const SemanticInfoTag&); private: TagWidgetPrivate* const d; }; } // namespace #endif /* TAGWIDGET_H */ diff --git a/lib/slideshow.h b/lib/slideshow.h index c05e285e..724af713 100644 --- a/lib/slideshow.h +++ b/lib/slideshow.h @@ -1,95 +1,95 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SLIDESHOW_H #define SLIDESHOW_H #include // Qt #include // KDE #include class QAction; namespace Gwenview { struct SlideShowPrivate; class GWENVIEWLIB_EXPORT SlideShow : public QObject { Q_OBJECT public: explicit SlideShow(QObject* parent); - virtual ~SlideShow(); + ~SlideShow() override; void start(const QList& urls); void pause(); QAction* loopAction() const; QAction* randomAction() const; /** @return true if the slideshow is running */ bool isRunning() const; /** * @return interval in seconds */ int interval() const; /** * @return position in time slot for current image in milliseconds */ int position() const; public Q_SLOTS: void setInterval(int); void setCurrentUrl(const QUrl &url); /** * Resume slideshow and go to next url. */ void resumeAndGoToNextUrl(); Q_SIGNALS: void goToUrl(const QUrl&); /** * Slideshow has been started or paused */ void stateChanged(bool running); /** * Emitted when interval has been changed * @param interval interval in seconds */ void intervalChanged(int interval); private Q_SLOTS: void goToNextUrl(); void updateConfig(); void slotRandomActionToggled(bool on); private: SlideShowPrivate* const d; }; } // namespace #endif // SLIDESHOW_H diff --git a/lib/thumbnailview/abstractthumbnailviewhelper.h b/lib/thumbnailview/abstractthumbnailviewhelper.h index d82d4e04..9b4876ec 100644 --- a/lib/thumbnailview/abstractthumbnailviewhelper.h +++ b/lib/thumbnailview/abstractthumbnailviewhelper.h @@ -1,55 +1,55 @@ /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ABSTRACTTHUMBNAILVIEWHELPER_H #define ABSTRACTTHUMBNAILVIEWHELPER_H #include // Qt #include #include // KDE // Local namespace Gwenview { /** * This class is used by the ThumbnailView to request various things. */ class GWENVIEWLIB_EXPORT AbstractThumbnailViewHelper : public QObject { Q_OBJECT public: explicit AbstractThumbnailViewHelper(QObject* parent); - virtual ~AbstractThumbnailViewHelper(); + ~AbstractThumbnailViewHelper() override; virtual void showContextMenu(QWidget* parent) = 0; virtual void showMenuForUrlDroppedOnViewport(QWidget* parent, const QList&) = 0; virtual void showMenuForUrlDroppedOnDir(QWidget* parent, const QList&, const QUrl&) = 0; }; } // namespace #endif /* ABSTRACTTHUMBNAILVIEWHELPER_H */ diff --git a/lib/thumbnailview/previewitemdelegate.h b/lib/thumbnailview/previewitemdelegate.h index 53b6dcc8..45963ffc 100644 --- a/lib/thumbnailview/previewitemdelegate.h +++ b/lib/thumbnailview/previewitemdelegate.h @@ -1,126 +1,126 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef PREVIEWITEMDELEGATE_H #define PREVIEWITEMDELEGATE_H #include // Qt #include // KDE // Local class QUrl; namespace Gwenview { class ThumbnailView; struct PreviewItemDelegatePrivate; /** * An ItemDelegate which generates thumbnails for images. It also makes sure * all items are of the same size. */ class GWENVIEWLIB_EXPORT PreviewItemDelegate : public QItemDelegate { Q_OBJECT public: PreviewItemDelegate(ThumbnailView*); - ~PreviewItemDelegate(); + ~PreviewItemDelegate() override; enum ContextBarAction { NoAction = 0, SelectionAction = 1, FullScreenAction = 2, RotateAction = 4 }; Q_DECLARE_FLAGS(ContextBarActions, ContextBarAction) enum ThumbnailDetail { FileNameDetail = 1, DateDetail = 2, RatingDetail = 4, ImageSizeDetail = 8, FileSizeDetail = 16 }; // FIXME: Find out why this cause problems with Qt::Alignment in // PreviewItemDelegate! Q_DECLARE_FLAGS(ThumbnailDetails, ThumbnailDetail) /** * Returns which thumbnail details are shown */ ThumbnailDetails thumbnailDetails() const; void setThumbnailDetails(ThumbnailDetails); ContextBarActions contextBarActions() const; void setContextBarActions(ContextBarActions); Qt::TextElideMode textElideMode() const; void setTextElideMode(Qt::TextElideMode); QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override; void setEditorData(QWidget* editor, const QModelIndex& index) const override; void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override; void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override; void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; QSize sizeHint(const QStyleOptionViewItem & /*option*/, const QModelIndex & /*index*/) const override; Q_SIGNALS: void saveDocumentRequested(const QUrl&); void rotateDocumentLeftRequested(const QUrl&); void rotateDocumentRightRequested(const QUrl&); void showDocumentInFullScreenRequested(const QUrl&); void setDocumentRatingRequested(const QUrl&, int rating); private Q_SLOTS: void setThumbnailSize(const QSize&); void slotSaveClicked(); void slotRotateLeftClicked(); void slotRotateRightClicked(); void slotFullScreenClicked(); void slotToggleSelectionClicked(); void slotRowsChanged(); protected: bool eventFilter(QObject*, QEvent*) override; private: PreviewItemDelegatePrivate* const d; friend struct PreviewItemDelegatePrivate; }; } // namespace // See upper Q_DECLARE_OPERATORS_FOR_FLAGS(Gwenview::PreviewItemDelegate::ThumbnailDetails) Q_DECLARE_OPERATORS_FOR_FLAGS(Gwenview::PreviewItemDelegate::ContextBarActions) #endif /* PREVIEWITEMDELEGATE_H */ diff --git a/lib/thumbnailview/thumbnailbarview.h b/lib/thumbnailview/thumbnailbarview.h index 9f604d0e..eff821e9 100644 --- a/lib/thumbnailview/thumbnailbarview.h +++ b/lib/thumbnailview/thumbnailbarview.h @@ -1,89 +1,89 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau Copyright 2008 Ilya Konkov This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef THUMBNAILBARVIEW_H #define THUMBNAILBARVIEW_H #include // Qt #include // KDE // Local #include namespace Gwenview { struct ThumbnailBarItemDelegatePrivate; class GWENVIEWLIB_EXPORT ThumbnailBarItemDelegate : public QAbstractItemDelegate { Q_OBJECT public: ThumbnailBarItemDelegate(ThumbnailView*); ~ThumbnailBarItemDelegate() override; void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; QSize sizeHint(const QStyleOptionViewItem & /*option*/, const QModelIndex & /*index*/) const override; protected: bool eventFilter(QObject*, QEvent*) override; private Q_SLOTS: void toggleSelection(); private: ThumbnailBarItemDelegatePrivate* const d; friend struct ThumbnailBarItemDelegatePrivate; }; struct ThumbnailBarViewPrivate; class GWENVIEWLIB_EXPORT ThumbnailBarView : public ThumbnailView { Q_OBJECT public: ThumbnailBarView(QWidget* = 0); - ~ThumbnailBarView(); + ~ThumbnailBarView() override; Qt::Orientation orientation() const; void setOrientation(Qt::Orientation); int rowCount() const; void setRowCount(int); protected: void resizeEvent(QResizeEvent * event) override; void wheelEvent(QWheelEvent* event) override; void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override; private Q_SLOTS: void slotFrameChanged(int); private: ThumbnailBarViewPrivate* const d; }; } // namespace #endif /* THUMBNAILBARVIEW_H */ diff --git a/lib/thumbnailview/thumbnailslider.h b/lib/thumbnailview/thumbnailslider.h index 4e09258b..e5057eda 100644 --- a/lib/thumbnailview/thumbnailslider.h +++ b/lib/thumbnailview/thumbnailslider.h @@ -1,59 +1,59 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2009 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef THUMBNAILSLIDER_H #define THUMBNAILSLIDER_H #include // Qt // KDE // Local #include namespace Gwenview { struct ThumbnailSliderPrivate; /** * A zoom slider which shows the thumbnail size as a tooltip when it is * adjusted */ class GWENVIEWLIB_EXPORT ThumbnailSlider : public ZoomSlider { Q_OBJECT public: explicit ThumbnailSlider(QWidget* parent = nullptr); - ~ThumbnailSlider(); + ~ThumbnailSlider() override; void updateToolTip(); private Q_SLOTS: void slotActionTriggered(int actionTriggered); private: ThumbnailSliderPrivate* const d; }; } // namespace #endif /* THUMBNAILSLIDER_H */ diff --git a/lib/thumbnailview/thumbnailview.h b/lib/thumbnailview/thumbnailview.h index d6027990..34de32d3 100644 --- a/lib/thumbnailview/thumbnailview.h +++ b/lib/thumbnailview/thumbnailview.h @@ -1,216 +1,216 @@ /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef THUMBNAILVIEW_H #define THUMBNAILVIEW_H #include // Qt #include // KDE #include class KFileItem; class QDragEnterEvent; class QDragMoveEvent; class QDropEvent; class QPixmap; namespace Gwenview { class AbstractDocumentInfoProvider; class AbstractThumbnailViewHelper; class ThumbnailProvider; struct ThumbnailViewPrivate; class GWENVIEWLIB_EXPORT ThumbnailView : public QListView { Q_OBJECT public: enum { MinThumbnailSize = 48, MaxThumbnailSize = 256 }; enum ThumbnailScaleMode { ScaleToSquare, ScaleToHeight, ScaleToWidth, ScaleToFit }; explicit ThumbnailView(QWidget* parent); ~ThumbnailView() override; void setThumbnailViewHelper(AbstractThumbnailViewHelper* helper); AbstractThumbnailViewHelper* thumbnailViewHelper() const; void setDocumentInfoProvider(AbstractDocumentInfoProvider* provider); AbstractDocumentInfoProvider* documentInfoProvider() const; ThumbnailScaleMode thumbnailScaleMode() const; void setThumbnailScaleMode(ThumbnailScaleMode); /** * Returns the thumbnail size. */ QSize thumbnailSize() const; /** * Returns the aspect ratio of the thumbnail. */ qreal thumbnailAspectRatio() const; QPixmap thumbnailForIndex(const QModelIndex&, QSize* fullSize = nullptr); /** * Returns true if the document pointed by the index has been modified * inside Gwenview. */ bool isModified(const QModelIndex&) const; /** * Returns true if the document pointed by the index is currently busy * (loading, saving, rotating...) */ bool isBusy(const QModelIndex& index) const; void setModel(QAbstractItemModel* model) override; void setThumbnailProvider(ThumbnailProvider* thumbnailProvider); /** * Publish this method so that delegates can call it. */ using QListView::scheduleDelayedItemsLayout; /** * Returns the current pixmap to paint when drawing a busy index. */ QPixmap busySequenceCurrentPixmap() const; void reloadThumbnail(const QModelIndex&); void updateThumbnailSize(); void setCreateThumbnailsForRemoteUrls(bool createRemoteThumbs); Q_SIGNALS: /** * It seems we can't use the 'activated()' signal for now because it does * not know about KDE single vs doubleclick settings. The indexActivated() * signal replaces it. */ void indexActivated(const QModelIndex&); void urlListDropped(const QList& lst, const QUrl &destination); void thumbnailSizeChanged(const QSize&); void thumbnailWidthChanged(int); /** * Emitted whenever selectionChanged() is called. * This signal is suffixed with "Signal" because * QAbstractItemView::selectionChanged() is a slot. */ void selectionChangedSignal(const QItemSelection&, const QItemSelection&); /** * Forward some signals from model, so that the delegate can use them */ void rowsRemovedSignal(const QModelIndex& parent, int start, int end); void rowsInsertedSignal(const QModelIndex& parent, int start, int end); public Q_SLOTS: /** * Sets the thumbnail's width, in pixels. Keeps aspect ratio unchanged. */ void setThumbnailWidth(int width); /** * Sets the thumbnail's aspect ratio. Keeps width unchanged. */ void setThumbnailAspectRatio(qreal ratio); void scrollToSelectedIndex(); void generateThumbnailsForItems(); protected: void dragEnterEvent(QDragEnterEvent*) override; void dragMoveEvent(QDragMoveEvent*) override; void dropEvent(QDropEvent*) override; void keyPressEvent(QKeyEvent*) override; void resizeEvent(QResizeEvent*) override; void scrollContentsBy(int dx, int dy) override; void showEvent(QShowEvent*) override; void wheelEvent(QWheelEvent*) override; void startDrag(Qt::DropActions) override; protected Q_SLOTS: void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override; void rowsInserted(const QModelIndex& parent, int start, int end) override; void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override; - virtual void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, - const QVector &roles = QVector()) override; + void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, + const QVector &roles = QVector()) override; private Q_SLOTS: void showContextMenu(); void emitIndexActivatedIfNoModifiers(const QModelIndex&); void setThumbnail(const KFileItem&, const QPixmap&, const QSize&, qulonglong fileSize); void setBrokenThumbnail(const KFileItem&); /** * Generate thumbnail for url. */ void updateThumbnail(const QUrl& url); /** * Tells the view the busy state of the document pointed by the url has changed. */ void updateThumbnailBusyState(const QUrl& url, bool); /* * Cause a repaint of all busy indexes */ void updateBusyIndexes(); void smoothNextThumbnail(); private: friend struct ThumbnailViewPrivate; ThumbnailViewPrivate * const d; }; } // namespace #endif /* THUMBNAILVIEW_H */ diff --git a/lib/zoomslider.h b/lib/zoomslider.h index 7393594b..268dd2b1 100644 --- a/lib/zoomslider.h +++ b/lib/zoomslider.h @@ -1,82 +1,82 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2009 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef ZOOMSLIDER_H #define ZOOMSLIDER_H #include // Qt #include // KDE // Local class QAction; class QSlider; namespace Gwenview { struct ZoomSliderPrivate; /** * A widget featuring an horizontal slider and zoom in/out buttons. * By default zoom in/out buttons will trigger SliderPageStep{Add,Sub}. * Their behavior can be changed with setZoomInAction() and * setZoomOutAction(). */ class GWENVIEWLIB_EXPORT ZoomSlider : public QWidget { Q_OBJECT public: explicit ZoomSlider(QWidget* parent = nullptr); - ~ZoomSlider(); + ~ZoomSlider() override; int value() const; QSlider* slider() const; void setZoomInAction(QAction*); void setZoomOutAction(QAction*); public Q_SLOTS: void setValue(int); void setMinimum(int); void setMaximum(int); Q_SIGNALS: int valueChanged(int); private Q_SLOTS: void slotActionTriggered(int actionTriggered); void zoomOut(); void zoomIn(); private: ZoomSliderPrivate* const d; }; } // namespace #endif /* ZOOMSLIDER_H */ diff --git a/lib/zoomwidget.h b/lib/zoomwidget.h index ce5fe9e9..bad65e99 100644 --- a/lib/zoomwidget.h +++ b/lib/zoomwidget.h @@ -1,67 +1,67 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef ZOOMWIDGET_H #define ZOOMWIDGET_H #include // Qt #include // KDE // Local class QAction; namespace Gwenview { struct ZoomWidgetPrivate; class GWENVIEWLIB_EXPORT ZoomWidget : public QFrame { Q_OBJECT public: explicit ZoomWidget(QWidget* parent = nullptr); - ~ZoomWidget(); + ~ZoomWidget() override; void setActions(QAction* zoomToFitAction, QAction* actualSizeAction, QAction* zoomInAction, QAction* zoomOutAction, QAction* zoomToFillAction); public Q_SLOTS: void setZoom(qreal zoom); void setMinimumZoom(qreal zoom); void setMaximumZoom(qreal zoom); Q_SIGNALS: void zoomChanged(qreal); private Q_SLOTS: void slotZoomSliderActionTriggered(); private: friend struct ZoomWidgetPrivate; ZoomWidgetPrivate* const d; }; } // namespace #endif /* ZOOMWIDGET_H */ diff --git a/part/gvbrowserextension.h b/part/gvbrowserextension.h index da94c882..1f84cbf9 100644 --- a/part/gvbrowserextension.h +++ b/part/gvbrowserextension.h @@ -1,51 +1,51 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2008 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ #ifndef GVBROWSEREXTENSION_H #define GVBROWSEREXTENSION_H // Qt // KDE #include // Local namespace Gwenview { struct GVBrowserExtensionPrivate; class GVBrowserExtension : public KParts::BrowserExtension { Q_OBJECT public: GVBrowserExtension(KParts::ReadOnlyPart*); - ~GVBrowserExtension(); + ~GVBrowserExtension() override; private Q_SLOTS: void print(); private: GVBrowserExtensionPrivate* const d; }; } // namespace #endif /* GVBROWSEREXTENSION_H */ diff --git a/tests/auto/documenttest.cpp b/tests/auto/documenttest.cpp index 99ecea0d..8e2d257a 100644 --- a/tests/auto/documenttest.cpp +++ b/tests/auto/documenttest.cpp @@ -1,894 +1,894 @@ /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Qt #include #include #include // KDE #include #include #include #include #include // Local #include "../lib/abstractimageoperation.h" #include "../lib/document/abstractdocumenteditor.h" #include "../lib/document/documentjob.h" #include "../lib/document/documentfactory.h" #include "../lib/imagemetainfomodel.h" #include "../lib/imageutils.h" #include "../lib/transformimageoperation.h" #include "testutils.h" #include #include "documenttest.h" QTEST_MAIN(DocumentTest) using namespace Gwenview; static void waitUntilMetaInfoLoaded(Document::Ptr doc) { while (doc->loadingState() < Document::MetaInfoLoaded) { QTest::qWait(100); } } static bool waitUntilJobIsDone(DocumentJob* job) { JobWatcher watcher(job); watcher.wait(); return watcher.error() == KJob::NoError; } void DocumentTest::initTestCase() { qRegisterMetaType("QUrl"); } void DocumentTest::init() { DocumentFactory::instance()->clearCache(); } void DocumentTest::testLoad() { QFETCH(QString, fileName); QFETCH(QByteArray, expectedFormat); QFETCH(int, expectedKindInt); QFETCH(bool, expectedIsAnimated); QFETCH(QImage, expectedImage); QFETCH(int, maxHeight); // number of lines to test. -1 to test all lines MimeTypeUtils::Kind expectedKind = MimeTypeUtils::Kind(expectedKindInt); QUrl url = urlForTestFile(fileName); // testing RAW loading. For raw, QImage directly won't work -> load it using KDCRaw QByteArray mFormatHint = url.fileName().section('.', -1).toLocal8Bit().toLower(); if (KDcrawIface::KDcraw::rawFilesList().contains(QString(mFormatHint))) { if (!KDcrawIface::KDcraw::loadEmbeddedPreview(expectedImage, url.toLocalFile())) { QSKIP("Not running this test: failed to get expectedImage. Try running ./fetch_testing_raw.sh\ in the tests/data directory and then rerun the tests."); } } if (expectedKind != MimeTypeUtils::KIND_SVG_IMAGE) { if (expectedImage.isNull()) { QSKIP("Not running this test: QImage failed to load the test image"); } } Document::Ptr doc = DocumentFactory::instance()->load(url); QSignalSpy spy(doc.data(), SIGNAL(isAnimatedUpdated())); doc->waitUntilLoaded(); QCOMPARE(doc->loadingState(), Document::Loaded); QCOMPARE(doc->kind(), expectedKind); QCOMPARE(doc->isAnimated(), expectedIsAnimated); QCOMPARE(spy.count(), doc->isAnimated() ? 1 : 0); if (doc->kind() == MimeTypeUtils::KIND_RASTER_IMAGE) { QImage image = doc->image(); if (maxHeight > -1) { QRect poiRect(0, 0, image.width(), maxHeight); image = image.copy(poiRect); expectedImage = expectedImage.copy(poiRect); } QCOMPARE(image, expectedImage); QCOMPARE(QString(doc->format()), QString(expectedFormat)); } } static void testLoad_newRow( const char* fileName, const QByteArray& format, MimeTypeUtils::Kind kind = MimeTypeUtils::KIND_RASTER_IMAGE, bool isAnimated = false, int maxHeight = -1 ) { QTest::newRow(fileName) << fileName << QByteArray(format) << int(kind) << isAnimated << QImage(pathForTestFile(fileName), format) << maxHeight; } void DocumentTest::testLoad_data() { QTest::addColumn("fileName"); QTest::addColumn("expectedFormat"); QTest::addColumn("expectedKindInt"); QTest::addColumn("expectedIsAnimated"); QTest::addColumn("expectedImage"); QTest::addColumn("maxHeight"); testLoad_newRow("test.png", "png"); testLoad_newRow("160216_no_size_before_decoding.eps", "eps"); testLoad_newRow("160382_corrupted.jpeg", "jpeg", MimeTypeUtils::KIND_RASTER_IMAGE, false, 55); testLoad_newRow("1x10k.png", "png"); testLoad_newRow("1x10k.jpg", "jpeg"); testLoad_newRow("test.xcf", "xcf"); testLoad_newRow("188191_does_not_load.tga", "tga"); testLoad_newRow("289819_does_not_load.png", "png"); testLoad_newRow("png-with-jpeg-extension.jpg", "png"); testLoad_newRow("jpg-with-gif-extension.gif", "jpeg"); // RAW preview testLoad_newRow("CANON-EOS350D-02.CR2", "cr2", MimeTypeUtils::KIND_RASTER_IMAGE, false); testLoad_newRow("dsc_0093.nef", "nef", MimeTypeUtils::KIND_RASTER_IMAGE, false); // SVG testLoad_newRow("test.svg", "", MimeTypeUtils::KIND_SVG_IMAGE); // FIXME: Test svgz // Animated testLoad_newRow("4frames.gif", "gif", MimeTypeUtils::KIND_RASTER_IMAGE, true); testLoad_newRow("1frame.gif", "gif", MimeTypeUtils::KIND_RASTER_IMAGE, false); testLoad_newRow("185523_1frame_with_graphic_control_extension.gif", "gif", MimeTypeUtils::KIND_RASTER_IMAGE, false); } void DocumentTest::testLoadTwoPasses() { QUrl url = urlForTestFile("test.png"); QImage image; bool ok = image.load(url.toLocalFile()); QVERIFY2(ok, "Could not load 'test.png'"); Document::Ptr doc = DocumentFactory::instance()->load(url); waitUntilMetaInfoLoaded(doc); QVERIFY2(doc->image().isNull(), "Image shouldn't have been loaded at this time"); QCOMPARE(doc->format().data(), "png"); doc->waitUntilLoaded(); QCOMPARE(image, doc->image()); } void DocumentTest::testLoadEmpty() { QUrl url = urlForTestFile("empty.png"); Document::Ptr doc = DocumentFactory::instance()->load(url); while (doc->loadingState() <= Document::KindDetermined) { QTest::qWait(100); } QCOMPARE(doc->loadingState(), Document::LoadingFailed); } #define NEW_ROW(fileName) QTest::newRow(fileName) << fileName void DocumentTest::testLoadDownSampled_data() { QTest::addColumn("fileName"); NEW_ROW("orient6.jpg"); NEW_ROW("1x10k.jpg"); } #undef NEW_ROW void DocumentTest::testLoadDownSampled() { // Note: for now we only support down sampling on jpeg, do not use test.png // here QFETCH(QString, fileName); QUrl url = urlForTestFile(fileName); QImage image; bool ok = image.load(url.toLocalFile()); QVERIFY2(ok, "Could not load test image"); Document::Ptr doc = DocumentFactory::instance()->load(url); QSignalSpy downSampledImageReadySpy(doc.data(), SIGNAL(downSampledImageReady())); QSignalSpy loadingFailedSpy(doc.data(), SIGNAL(loadingFailed(QUrl))); QSignalSpy loadedSpy(doc.data(), SIGNAL(loaded(QUrl))); bool ready = doc->prepareDownSampledImageForZoom(0.2); QVERIFY2(!ready, "There should not be a down sampled image at this point"); while (downSampledImageReadySpy.count() == 0 && loadingFailedSpy.count() == 0 && loadedSpy.count() == 0) { QTest::qWait(100); } QImage downSampledImage = doc->downSampledImageForZoom(0.2); QVERIFY2(!downSampledImage.isNull(), "Down sampled image should not be null"); QSize expectedSize = doc->size() / 2; if (expectedSize.isEmpty()) { expectedSize = image.size(); } QCOMPARE(downSampledImage.size(), expectedSize); } /** * Down sampling is not supported on png. We should get a complete image * instead. */ void DocumentTest::testLoadDownSampledPng() { QUrl url = urlForTestFile("test.png"); QImage image; bool ok = image.load(url.toLocalFile()); QVERIFY2(ok, "Could not load test image"); Document::Ptr doc = DocumentFactory::instance()->load(url); LoadingStateSpy stateSpy(doc); connect(doc.data(), SIGNAL(loaded(QUrl)), &stateSpy, SLOT(readState())); bool ready = doc->prepareDownSampledImageForZoom(0.2); QVERIFY2(!ready, "There should not be a down sampled image at this point"); doc->waitUntilLoaded(); QCOMPARE(stateSpy.mCallCount, 1); QCOMPARE(stateSpy.mState, Document::Loaded); } void DocumentTest::testLoadRemote() { QUrl url = setUpRemoteTestDir("test.png"); if (!url.isValid()) { QSKIP("Not running this test: failed to setup remote test dir."); } url = url.adjusted(QUrl::StripTrailingSlash); url.setPath(url.path() + '/' + "test.png"); QVERIFY2(KIO::stat(url, KIO::StatJob::SourceSide, 0)->exec(), "test url not found"); Document::Ptr doc = DocumentFactory::instance()->load(url); doc->waitUntilLoaded(); QImage image = doc->image(); QCOMPARE(image.width(), 150); QCOMPARE(image.height(), 100); } void DocumentTest::testLoadAnimated() { QUrl srcUrl = urlForTestFile("40frames.gif"); Document::Ptr doc = DocumentFactory::instance()->load(srcUrl); QSignalSpy spy(doc.data(), SIGNAL(imageRectUpdated(QRect))); doc->waitUntilLoaded(); QVERIFY(doc->isAnimated()); // Test we receive only one imageRectUpdated() until animation is started // (the imageRectUpdated() is triggered by the loading of the first image) QTest::qWait(1000); QCOMPARE(spy.count(), 1); // Test we now receive some imageRectUpdated() doc->startAnimation(); QTest::qWait(1000); int count = spy.count(); doc->stopAnimation(); QVERIFY2(count > 0, "No imageRectUpdated() signal received"); // Test we do not receive imageRectUpdated() anymore QTest::qWait(1000); QCOMPARE(count, spy.count()); // Start again, we should receive imageRectUpdated() again doc->startAnimation(); QTest::qWait(1000); QVERIFY2(spy.count() > count, "No imageRectUpdated() signal received after restarting"); } void DocumentTest::testPrepareDownSampledAfterFailure() { QUrl url = urlForTestFile("empty.png"); Document::Ptr doc = DocumentFactory::instance()->load(url); doc->waitUntilLoaded(); QCOMPARE(doc->loadingState(), Document::LoadingFailed); bool ready = doc->prepareDownSampledImageForZoom(0.25); QVERIFY2(!ready, "Down sampled image should not be ready"); } void DocumentTest::testSaveRemote() { QUrl dstUrl = setUpRemoteTestDir(); if (!dstUrl.isValid()) { QSKIP("Not running this test: failed to setup remote test dir."); } QUrl srcUrl = urlForTestFile("test.png"); Document::Ptr doc = DocumentFactory::instance()->load(srcUrl); doc->waitUntilLoaded(); dstUrl = dstUrl.adjusted(QUrl::StripTrailingSlash); dstUrl.setPath(dstUrl.path() + '/' + "testSaveRemote.png"); QVERIFY(waitUntilJobIsDone(doc->save(dstUrl, "png"))); } /** * Check that deleting a document while it is loading does not crash */ void DocumentTest::testDeleteWhileLoading() { { QUrl url = urlForTestFile("test.png"); QImage image; bool ok = image.load(url.toLocalFile()); QVERIFY2(ok, "Could not load 'test.png'"); Document::Ptr doc = DocumentFactory::instance()->load(url); } DocumentFactory::instance()->clearCache(); // Wait two seconds. If the test fails we will get a segfault while waiting QTest::qWait(2000); } void DocumentTest::testLoadRotated() { QUrl url = urlForTestFile("orient6.jpg"); QImage image; bool ok = image.load(url.toLocalFile()); QVERIFY2(ok, "Could not load 'orient6.jpg'"); QMatrix matrix = ImageUtils::transformMatrix(ROT_90); image = image.transformed(matrix); Document::Ptr doc = DocumentFactory::instance()->load(url); doc->waitUntilLoaded(); QCOMPARE(image, doc->image()); // RAW preview on rotated image url = urlForTestFile("dsd_1838.nef"); if (!KDcrawIface::KDcraw::loadEmbeddedPreview(image, url.toLocalFile())) { QSKIP("Not running this test: failed to get image. Try running ./fetch_testing_raw.sh\ in the tests/data directory and then rerun the tests."); } matrix = ImageUtils::transformMatrix(ROT_270); image = image.transformed(matrix); doc = DocumentFactory::instance()->load(url); doc->waitUntilLoaded(); QCOMPARE(image, doc->image()); } /** * Checks that asking the DocumentFactory the same document twice in a row does * not load it twice */ void DocumentTest::testMultipleLoads() { QUrl url = urlForTestFile("orient6.jpg"); Document::Ptr doc1 = DocumentFactory::instance()->load(url); Document::Ptr doc2 = DocumentFactory::instance()->load(url); QCOMPARE(doc1.data(), doc2.data()); } void DocumentTest::testSaveAs() { QUrl url = urlForTestFile("orient6.jpg"); DocumentFactory* factory = DocumentFactory::instance(); Document::Ptr doc = factory->load(url); QSignalSpy savedSpy(doc.data(), SIGNAL(saved(QUrl,QUrl))); QSignalSpy modifiedDocumentListChangedSpy(factory, SIGNAL(modifiedDocumentListChanged())); QSignalSpy documentChangedSpy(factory, SIGNAL(documentChanged(QUrl))); doc->startLoadingFullImage(); QUrl destUrl = urlForTestOutputFile("result.png"); QVERIFY(waitUntilJobIsDone(doc->save(destUrl, "png"))); QCOMPARE(doc->format().data(), "png"); QCOMPARE(doc->url(), destUrl); QCOMPARE(doc->metaInfo()->getValueForKey("General.Name"), destUrl.fileName()); QVERIFY2(doc->loadingState() == Document::Loaded, "Document is supposed to finish loading before saving" ); QTest::qWait(100); // saved() is emitted asynchronously QCOMPARE(savedSpy.count(), 1); QVariantList args = savedSpy.takeFirst(); QCOMPARE(args.at(0).value(), url); QCOMPARE(args.at(1).value(), destUrl); QImage image("result.png", "png"); QCOMPARE(doc->image(), image); QVERIFY(!DocumentFactory::instance()->hasUrl(url)); QVERIFY(DocumentFactory::instance()->hasUrl(destUrl)); QCOMPARE(modifiedDocumentListChangedSpy.count(), 0); // No changes were made QCOMPARE(documentChangedSpy.count(), 1); args = documentChangedSpy.takeFirst(); QCOMPARE(args.at(0).value(), destUrl); } void DocumentTest::testLosslessSave() { QUrl url1 = urlForTestFile("orient6.jpg"); Document::Ptr doc = DocumentFactory::instance()->load(url1); doc->startLoadingFullImage(); QUrl url2 = urlForTestOutputFile("orient1.jpg"); QVERIFY(waitUntilJobIsDone(doc->save(url2, "jpeg"))); QImage image1; QVERIFY(image1.load(url1.toLocalFile())); QImage image2; QVERIFY(image2.load(url2.toLocalFile())); QCOMPARE(image1, image2); } void DocumentTest::testLosslessRotate() { // Generate test image QImage image1(200, 96, QImage::Format_RGB32); { QPainter painter(&image1); QConicalGradient gradient(QPointF(100, 48), 100); gradient.setColorAt(0, Qt::white); gradient.setColorAt(1, Qt::blue); painter.fillRect(image1.rect(), gradient); } QUrl url1 = urlForTestOutputFile("lossless1.jpg"); QVERIFY(image1.save(url1.toLocalFile(), "jpeg")); // Load it as a Gwenview document Document::Ptr doc = DocumentFactory::instance()->load(url1); doc->waitUntilLoaded(); // Rotate one time QVERIFY(doc->editor()); doc->editor()->applyTransformation(ROT_90); // Save it QUrl url2 = urlForTestOutputFile("lossless2.jpg"); waitUntilJobIsDone(doc->save(url2, "jpeg")); // Load the saved image doc = DocumentFactory::instance()->load(url2); doc->waitUntilLoaded(); // Rotate the other way QVERIFY(doc->editor()); doc->editor()->applyTransformation(ROT_270); waitUntilJobIsDone(doc->save(url2, "jpeg")); // Compare the saved images QVERIFY(image1.load(url1.toLocalFile())); QImage image2; QVERIFY(image2.load(url2.toLocalFile())); QCOMPARE(image1, image2); } void DocumentTest::testModifyAndSaveAs() { QVariantList args; class TestOperation : public AbstractImageOperation { public: - void redo() + void redo() override { QImage image(10, 10, QImage::Format_ARGB32); image.fill(QColor(Qt::white).rgb()); document()->editor()->setImage(image); finish(true); } }; QUrl url = urlForTestFile("orient6.jpg"); DocumentFactory* factory = DocumentFactory::instance(); Document::Ptr doc = factory->load(url); QSignalSpy savedSpy(doc.data(), SIGNAL(saved(QUrl,QUrl))); QSignalSpy modifiedDocumentListChangedSpy(factory, SIGNAL(modifiedDocumentListChanged())); QSignalSpy documentChangedSpy(factory, SIGNAL(documentChanged(QUrl))); doc->waitUntilLoaded(); QVERIFY(!doc->isModified()); QCOMPARE(modifiedDocumentListChangedSpy.count(), 0); // Modify image QVERIFY(doc->editor()); TestOperation* op = new TestOperation; op->applyToDocument(doc); QTest::qWait(100); QVERIFY(doc->isModified()); QCOMPARE(modifiedDocumentListChangedSpy.count(), 1); modifiedDocumentListChangedSpy.clear(); QList lst = factory->modifiedDocumentList(); QCOMPARE(lst.count(), 1); QCOMPARE(lst.first(), url); QCOMPARE(documentChangedSpy.count(), 1); args = documentChangedSpy.takeFirst(); QCOMPARE(args.at(0).value(), url); // Save it under a new name QUrl destUrl = urlForTestOutputFile("modify.png"); QVERIFY(waitUntilJobIsDone(doc->save(destUrl, "png"))); // Wait a bit because save() will clear the undo stack when back to the // event loop QTest::qWait(100); QVERIFY(!doc->isModified()); QVERIFY(!factory->hasUrl(url)); QVERIFY(factory->hasUrl(destUrl)); QCOMPARE(modifiedDocumentListChangedSpy.count(), 1); QVERIFY(DocumentFactory::instance()->modifiedDocumentList().isEmpty()); QCOMPARE(documentChangedSpy.count(), 2); QList modifiedUrls = QList() << url << destUrl; QVERIFY(modifiedUrls.contains(url)); QVERIFY(modifiedUrls.contains(destUrl)); } void DocumentTest::testMetaInfoJpeg() { QUrl url = urlForTestFile("orient6.jpg"); Document::Ptr doc = DocumentFactory::instance()->load(url); // We cleared the cache, so the document should not be loaded Q_ASSERT(doc->loadingState() <= Document::KindDetermined); // Wait until we receive the metaInfoUpdated() signal QSignalSpy metaInfoUpdatedSpy(doc.data(), SIGNAL(metaInfoUpdated())); while (metaInfoUpdatedSpy.count() == 0) { QTest::qWait(100); } // Extract an exif key QString value = doc->metaInfo()->getValueForKey("Exif.Image.Make"); QCOMPARE(value, QString::fromUtf8("Canon")); } void DocumentTest::testMetaInfoBmp() { QUrl url = urlForTestOutputFile("metadata.bmp"); const int width = 200; const int height = 100; QImage image(width, height, QImage::Format_ARGB32); image.fill(Qt::black); image.save(url.toLocalFile(), "BMP"); Document::Ptr doc = DocumentFactory::instance()->load(url); QSignalSpy metaInfoUpdatedSpy(doc.data(), SIGNAL(metaInfoUpdated())); waitUntilMetaInfoLoaded(doc); Q_ASSERT(metaInfoUpdatedSpy.count() >= 1); QString value = doc->metaInfo()->getValueForKey("General.ImageSize"); QString expectedValue = QStringLiteral("%1x%2").arg(width).arg(height); QCOMPARE(value, expectedValue); } void DocumentTest::testForgetModifiedDocument() { QSignalSpy spy(DocumentFactory::instance(), SIGNAL(modifiedDocumentListChanged())); DocumentFactory::instance()->forget(QUrl("file://does/not/exist.png")); QCOMPARE(spy.count(), 0); // Generate test image QImage image1(200, 96, QImage::Format_RGB32); { QPainter painter(&image1); QConicalGradient gradient(QPointF(100, 48), 100); gradient.setColorAt(0, Qt::white); gradient.setColorAt(1, Qt::blue); painter.fillRect(image1.rect(), gradient); } QUrl url = urlForTestOutputFile("testForgetModifiedDocument.png"); QVERIFY(image1.save(url.toLocalFile(), "png")); // Load it as a Gwenview document Document::Ptr doc = DocumentFactory::instance()->load(url); doc->waitUntilLoaded(); // Modify it TransformImageOperation* op = new TransformImageOperation(ROT_90); op->applyToDocument(doc); QTest::qWait(100); QCOMPARE(spy.count(), 1); QList lst = DocumentFactory::instance()->modifiedDocumentList(); QCOMPARE(lst.length(), 1); QCOMPARE(lst.first(), url); // Forget it DocumentFactory::instance()->forget(url); QCOMPARE(spy.count(), 2); lst = DocumentFactory::instance()->modifiedDocumentList(); QVERIFY(lst.isEmpty()); } void DocumentTest::testModifiedAndSavedSignals() { TransformImageOperation* op; QUrl url = urlForTestFile("orient6.jpg"); Document::Ptr doc = DocumentFactory::instance()->load(url); QSignalSpy modifiedSpy(doc.data(), SIGNAL(modified(QUrl))); QSignalSpy savedSpy(doc.data(), SIGNAL(saved(QUrl,QUrl))); doc->waitUntilLoaded(); QCOMPARE(modifiedSpy.count(), 0); QCOMPARE(savedSpy.count(), 0); op = new TransformImageOperation(ROT_90); op->applyToDocument(doc); QTest::qWait(100); QCOMPARE(modifiedSpy.count(), 1); op = new TransformImageOperation(ROT_90); op->applyToDocument(doc); QTest::qWait(100); QCOMPARE(modifiedSpy.count(), 2); doc->undoStack()->undo(); QTest::qWait(100); QCOMPARE(modifiedSpy.count(), 3); doc->undoStack()->undo(); QTest::qWait(100); QCOMPARE(savedSpy.count(), 1); } class TestJob : public DocumentJob { public: TestJob(QString* str, char ch) : mStr(str) , mCh(ch) {} protected: - virtual void doStart() + void doStart() override { *mStr += mCh; emitResult(); } private: QString* mStr; char mCh; }; void DocumentTest::testJobQueue() { QUrl url = urlForTestFile("orient6.jpg"); Document::Ptr doc = DocumentFactory::instance()->load(url); QSignalSpy spy(doc.data(), SIGNAL(busyChanged(QUrl,bool))); QString str; doc->enqueueJob(new TestJob(&str, 'a')); doc->enqueueJob(new TestJob(&str, 'b')); doc->enqueueJob(new TestJob(&str, 'c')); QVERIFY(doc->isBusy()); QEventLoop loop; connect(doc.data(), SIGNAL(allTasksDone()), &loop, SLOT(quit())); loop.exec(); QVERIFY(!doc->isBusy()); QCOMPARE(spy.count(), 2); QVariantList row = spy.takeFirst(); QCOMPARE(row.at(0).value(), url); QVERIFY(row.at(1).toBool()); row = spy.takeFirst(); QCOMPARE(row.at(0).value(), url); QVERIFY(!row.at(1).toBool()); QCOMPARE(str, QStringLiteral("abc")); } class TestCheckDocumentEditorJob : public DocumentJob { public: TestCheckDocumentEditorJob(int* hasEditor) : mHasEditor(hasEditor) { *mHasEditor = -1; } protected: - virtual void doStart() + void doStart() override { document()->waitUntilLoaded(); *mHasEditor = checkDocumentEditor() ? 1 : 0; emitResult(); } private: int* mHasEditor; }; class TestUiDelegate : public KJobUiDelegate { public: TestUiDelegate(bool* showErrorMessageCalled) : mShowErrorMessageCalled(showErrorMessageCalled) { setAutoErrorHandlingEnabled(true); *mShowErrorMessageCalled = false; } - virtual void showErrorMessage() + void showErrorMessage() override { //qDebug(); *mShowErrorMessageCalled = true; } private: bool* mShowErrorMessageCalled; }; /** * Test that an error is reported when a DocumentJob fails because there is no * document editor available */ void DocumentTest::testCheckDocumentEditor() { int hasEditor; bool showErrorMessageCalled; QEventLoop loop; Document::Ptr doc; TestCheckDocumentEditorJob* job; doc = DocumentFactory::instance()->load(urlForTestFile("orient6.jpg")); job = new TestCheckDocumentEditorJob(&hasEditor); job->setUiDelegate(new TestUiDelegate(&showErrorMessageCalled)); doc->enqueueJob(job); connect(doc.data(), SIGNAL(allTasksDone()), &loop, SLOT(quit())); loop.exec(); QVERIFY(!showErrorMessageCalled); QCOMPARE(hasEditor, 1); doc = DocumentFactory::instance()->load(urlForTestFile("test.svg")); job = new TestCheckDocumentEditorJob(&hasEditor); job->setUiDelegate(new TestUiDelegate(&showErrorMessageCalled)); doc->enqueueJob(job); connect(doc.data(), SIGNAL(allTasksDone()), &loop, SLOT(quit())); loop.exec(); QVERIFY(showErrorMessageCalled); QCOMPARE(hasEditor, 0); } /** * An operation should only pushed to the document undo stack if it succeed */ void DocumentTest::testUndoStackPush() { class SuccessOperation : public AbstractImageOperation { protected: - virtual void redo() + void redo() override { QMetaObject::invokeMethod(this, "finish", Qt::QueuedConnection, Q_ARG(bool, true)); } }; class FailureOperation : public AbstractImageOperation { protected: - virtual void redo() + void redo() override { QMetaObject::invokeMethod(this, "finish", Qt::QueuedConnection, Q_ARG(bool, false)); } }; AbstractImageOperation* op; Document::Ptr doc = DocumentFactory::instance()->load(urlForTestFile("orient6.jpg")); // A successful operation should be added to the undo stack op = new SuccessOperation; op->applyToDocument(doc); QTest::qWait(100); QVERIFY(!doc->undoStack()->isClean()); // Reset doc->undoStack()->undo(); QVERIFY(doc->undoStack()->isClean()); // A failed operation should not be added to the undo stack op = new FailureOperation; op->applyToDocument(doc); QTest::qWait(100); QVERIFY(doc->undoStack()->isClean()); } void DocumentTest::testUndoRedo() { class SuccessOperation : public AbstractImageOperation { public: int mRedoCount = 0; int mUndoCount = 0; protected: - virtual void redo() + void redo() override { mRedoCount++; finish(true); } - virtual void undo() + void undo() override { mUndoCount++; finish(true); } }; Document::Ptr doc = DocumentFactory::instance()->load(urlForTestFile("orient6.jpg")); QSignalSpy modifiedSpy(doc.data(), &Document::modified); QSignalSpy savedSpy(doc.data(), &Document::saved); SuccessOperation* op = new SuccessOperation; QCOMPARE(op->mRedoCount, 0); QCOMPARE(op->mUndoCount, 0); // Apply (redo) operation op->applyToDocument(doc); QVERIFY(modifiedSpy.wait()); QCOMPARE(op->mRedoCount, 1); QCOMPARE(op->mUndoCount, 0); QCOMPARE(doc->undoStack()->count(), 1); QVERIFY(!doc->undoStack()->isClean()); // Undo operation doc->undoStack()->undo(); QVERIFY(savedSpy.wait()); QCOMPARE(op->mRedoCount, 1); QCOMPARE(op->mUndoCount, 1); QCOMPARE(doc->undoStack()->count(), 1); QVERIFY(doc->undoStack()->isClean()); // Redo operation doc->undoStack()->redo(); QVERIFY(modifiedSpy.wait()); QCOMPARE(op->mRedoCount, 2); QCOMPARE(op->mUndoCount, 1); QCOMPARE(doc->undoStack()->count(), 1); QVERIFY(!doc->undoStack()->isClean()); // Undo operation again doc->undoStack()->undo(); QVERIFY(savedSpy.wait()); QCOMPARE(op->mRedoCount, 2); QCOMPARE(op->mUndoCount, 2); QCOMPARE(doc->undoStack()->count(), 1); QVERIFY(doc->undoStack()->isClean()); }