diff options
Diffstat (limited to 'digikam/libs/imageproperties/imagepropertiessidebarcamgui.cpp')
-rw-r--r-- | digikam/libs/imageproperties/imagepropertiessidebarcamgui.cpp | 209 |
1 files changed, 209 insertions, 0 deletions
diff --git a/digikam/libs/imageproperties/imagepropertiessidebarcamgui.cpp b/digikam/libs/imageproperties/imagepropertiessidebarcamgui.cpp new file mode 100644 index 0000000..e388f1d --- /dev/null +++ b/digikam/libs/imageproperties/imagepropertiessidebarcamgui.cpp @@ -0,0 +1,209 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2006-02-08 + * Description : simple image properties side bar used by + * camera gui. + * + * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com> + * + * 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, 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. + * + * ============================================================ */ + +// Qt includes. + +#include <qsplitter.h> + +// KDE includes. + +#include <klocale.h> +#include <kconfig.h> +#include <kapplication.h> +#include <kcursor.h> +#include <kglobal.h> +#include <kiconloader.h> + +// Local includes. + +#include "ddebug.h" +#include "dmetadata.h" +#include "gpiteminfo.h" +#include "cameraiconview.h" +#include "cameraiconitem.h" +#include "cameraitempropertiestab.h" +#include "imagepropertiesmetadatatab.h" +#include "statusnavigatebar.h" +#include "navigatebarwidget.h" +#include "imagepropertiessidebarcamgui.h" +#include "imagepropertiessidebarcamgui.moc" + +namespace Digikam +{ + +class ImagePropertiesSideBarCamGuiPriv +{ +public: + + ImagePropertiesSideBarCamGuiPriv() + { + dirtyMetadataTab = false; + dirtyCameraItemTab = false; + metadataTab = 0; + cameraItemTab = 0; + itemInfo = 0; + cameraView = 0; + cameraItem = 0; + exifData = QByteArray(); + currentURL = KURL(); + } + + bool dirtyMetadataTab; + bool dirtyCameraItemTab; + + QByteArray exifData; + + KURL currentURL; + + GPItemInfo *itemInfo; + + ImagePropertiesMetaDataTab *metadataTab; + + CameraIconView *cameraView; + + CameraIconViewItem *cameraItem; + + CameraItemPropertiesTab *cameraItemTab; +}; + +ImagePropertiesSideBarCamGui::ImagePropertiesSideBarCamGui(QWidget *parent, const char *name, + QSplitter *splitter, Side side, + bool mimimizedDefault) + : Sidebar(parent, name, side, mimimizedDefault) +{ + d = new ImagePropertiesSideBarCamGuiPriv; + d->cameraItemTab = new CameraItemPropertiesTab(parent, true); + d->metadataTab = new ImagePropertiesMetaDataTab(parent, true); + + setSplitter(splitter); + + appendTab(d->cameraItemTab, SmallIcon("info"), i18n("Properties")); + appendTab(d->metadataTab, SmallIcon("exifinfo"), i18n("Metadata")); + + // ---------------------------------------------------------- + + connectNavigateSignals(d->cameraItemTab); + connectNavigateSignals(d->metadataTab); + + connect(this, SIGNAL(signalChangedTab(QWidget*)), + this, SLOT(slotChangedTab(QWidget*))); +} + +ImagePropertiesSideBarCamGui::~ImagePropertiesSideBarCamGui() +{ + delete d; +} + +void ImagePropertiesSideBarCamGui::connectNavigateSignals(NavigateBarTab *tab) +{ + connect(tab, SIGNAL(signalFirstItem()), + this, SIGNAL(signalFirstItem())); + + connect(tab, SIGNAL(signalPrevItem()), + this, SIGNAL(signalPrevItem())); + + connect(tab, SIGNAL(signalNextItem()), + this, SIGNAL(signalNextItem())); + + connect(tab, SIGNAL(signalLastItem()), + this, SIGNAL(signalLastItem())); +} + +void ImagePropertiesSideBarCamGui::itemChanged(GPItemInfo* itemInfo, const KURL& url, + const QByteArray& exifData, + CameraIconView* view, CameraIconViewItem* item) +{ + if (!itemInfo) + return; + + d->exifData = exifData; + d->itemInfo = itemInfo; + d->currentURL = url; + d->dirtyMetadataTab = false; + d->dirtyCameraItemTab = false; + d->cameraView = view; + d->cameraItem = item; + + if (d->exifData.isEmpty()) + { + DMetadata metaData(d->currentURL.path()); + d->exifData = metaData.getExif(); + } + + slotChangedTab( getActiveTab() ); +} + +void ImagePropertiesSideBarCamGui::slotNoCurrentItem(void) +{ + d->itemInfo = 0; + d->cameraItem = 0; + d->exifData = QByteArray(); + d->currentURL = KURL(); + d->dirtyMetadataTab = false; + d->dirtyCameraItemTab = false; + + d->cameraItemTab->setCurrentItem(); + d->metadataTab->setCurrentURL(); +} + +void ImagePropertiesSideBarCamGui::slotChangedTab(QWidget* tab) +{ + if (!d->itemInfo) + return; + + setCursor(KCursor::waitCursor()); + + if (tab == d->cameraItemTab && !d->dirtyCameraItemTab) + { + d->cameraItemTab->setCurrentItem(d->itemInfo, + d->cameraItem->getDownloadName(), d->exifData, + d->currentURL); + + d->dirtyCameraItemTab = true; + } + else if (tab == d->metadataTab && !d->dirtyMetadataTab) + { + d->metadataTab->setCurrentData(d->exifData, QByteArray(), + d->itemInfo->name); + + d->dirtyMetadataTab = true; + } + + // setting of NavigateBar, common for all tabs + NavigateBarTab *navtab = dynamic_cast<NavigateBarTab *>(tab); + if (navtab) + { + int currentItemType = StatusNavigateBar::ItemCurrent; + if (d->cameraView->firstItem() == d->cameraItem) + currentItemType = StatusNavigateBar::ItemFirst; + else if (d->cameraView->lastItem() == d->cameraItem) + currentItemType = StatusNavigateBar::ItemLast; + + navtab->setNavigateBarState(currentItemType); + navtab->setNavigateBarFileName(); + } + unsetCursor(); +} + +} // NameSpace Digikam |