Major improvements to the PhotoSharing Application.

- Editing of Photo Descriptions & Album descriptions.
	- Photo versions.
	- Default to Album description, if Photo not filled in.
	- Album Cover images.
	- SlideShow.

Todo:
	- Deletion of Photos & Albums.
	- Handle Photo Files (only thumbnails at the moment).
	- Searching.
	- Sharing options.
	- Image processing.
	- +lots more.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@5239 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-06-21 15:52:49 +00:00
parent 8af268e8c8
commit 03e2ee72e0
17 changed files with 1860 additions and 159 deletions

View File

@ -18,9 +18,13 @@ RCC_DIR = temp/qrc
UI_DIR = temp/ui UI_DIR = temp/ui
MOC_DIR = temp/moc MOC_DIR = temp/moc
#CONFIG += debug CONFIG += debug
debug { debug {
QMAKE_CFLAGS += -g QMAKE_CFLAGS += -g
QMAKE_CXXFLAGS -= -O2
QMAKE_CXXFLAGS += -O0
QMAKE_CFLAGS -= -O2
QMAKE_CFLAGS += -O0
} }
minimal { minimal {
@ -863,17 +867,20 @@ photoshare {
gui/PhotoShare/PhotoAddDialog.h \ gui/PhotoShare/PhotoAddDialog.h \
gui/PhotoShare/PhotoDetailsDialog.h \ gui/PhotoShare/PhotoDetailsDialog.h \
gui/PhotoShare/PhotoDrop.h \ gui/PhotoShare/PhotoDrop.h \
gui/PhotoShare/PhotoSlideShow.h \
FORMS += gui/PhotoShare/PhotoItem.ui \ FORMS += gui/PhotoShare/PhotoItem.ui \
gui/PhotoShare/PhotoDialog.ui \ gui/PhotoShare/PhotoDialog.ui \
gui/PhotoShare/PhotoAddDialog.ui \ gui/PhotoShare/PhotoAddDialog.ui \
gui/PhotoShare/PhotoDetailsDialog.ui \ gui/PhotoShare/PhotoDetailsDialog.ui \
gui/PhotoShare/PhotoSlideShow.ui \
SOURCES += gui/PhotoShare/PhotoItem.cpp \ SOURCES += gui/PhotoShare/PhotoItem.cpp \
gui/PhotoShare/PhotoDialog.cpp \ gui/PhotoShare/PhotoDialog.cpp \
gui/PhotoShare/PhotoAddDialog.cpp \ gui/PhotoShare/PhotoAddDialog.cpp \
gui/PhotoShare/PhotoDetailsDialog.cpp \ gui/PhotoShare/PhotoDetailsDialog.cpp \
gui/PhotoShare/PhotoDrop.cpp \ gui/PhotoShare/PhotoDrop.cpp \
gui/PhotoShare/PhotoSlideShow.cpp \
} }

View File

@ -37,11 +37,20 @@ PhotoAddDialog::PhotoAddDialog(QWidget *parent)
connect(ui.pushButton_ShiftLeft, SIGNAL( clicked( void ) ), ui.scrollAreaWidgetContents, SLOT( moveLeft( void ) ) ); connect(ui.pushButton_ShiftLeft, SIGNAL( clicked( void ) ), ui.scrollAreaWidgetContents, SLOT( moveLeft( void ) ) );
connect(ui.pushButton_ShiftRight, SIGNAL( clicked( void ) ), ui.scrollAreaWidgetContents, SLOT( moveRight( void ) ) ); connect(ui.pushButton_ShiftRight, SIGNAL( clicked( void ) ), ui.scrollAreaWidgetContents, SLOT( moveRight( void ) ) );
connect(ui.pushButton_EditPhotoDetails, SIGNAL( clicked( void ) ), this, SLOT( showPhotoDetails( void ) ) ); connect(ui.pushButton_EditPhotoDetails, SIGNAL( clicked( void ) ), this, SLOT( showPhotoDetails( void ) ) );
connect(ui.pushButton_EditAlbumDetails, SIGNAL( clicked( void ) ), this, SLOT( showAlbumDetails( void ) ) );
connect(ui.pushButton_DeleteAlbum, SIGNAL( clicked( void ) ), this, SLOT( deleteAlbum( void ) ) );
connect(ui.pushButton_DeletePhoto, SIGNAL( clicked( void ) ), this, SLOT( deletePhoto( void ) ) );
connect(ui.pushButton_Publish, SIGNAL( clicked( void ) ), this, SLOT( publishAlbum( void ) ) ); connect(ui.pushButton_Publish, SIGNAL( clicked( void ) ), this, SLOT( publishAlbum( void ) ) );
mPhotoDetails = NULL; mPhotoDetails = NULL;
mPhotoQueue = new TokenQueue(rsPhoto, this);
ui.AlbumDrop->setSingleImage();
connect(ui.AlbumDrop, SIGNAL( photosChanged( void ) ), this, SLOT( albumImageChanged( void ) ) );
connect(ui.scrollAreaWidgetContents, SIGNAL( photosChanged( void ) ), this, SLOT( photoImageChanged( void ) ) );
} }
@ -72,23 +81,212 @@ void PhotoAddDialog::updateMoveButtons(uint32_t status)
} }
bool PhotoAddDialog::updateAlbumDetails(const RsPhotoAlbum &album)
{
std::cerr << "PhotoAddDialog::updateAlbumDetails()";
std::cerr << " (Copy data to mAlbumData + Add PhotoItem)";
std::cerr << std::endl;
// cleanup old image first.
mAlbumData.mThumbnail.deleteImage();
mAlbumData = album;
// copy photo too.
mAlbumData.mThumbnail.data = 0;
mAlbumData.mThumbnail.copyFrom(album.mThumbnail);
/* show iterate through all the photos and update them too - except normally they haven't arrived yet */
ui.lineEdit_Title->setText(QString::fromUtf8(album.mMeta.mGroupName.c_str()));
ui.lineEdit_Caption->setText(QString::fromUtf8(album.mCaption.c_str()));
ui.lineEdit_Where->setText(QString::fromUtf8(album.mWhere.c_str()));
ui.lineEdit_When->setText(QString::fromUtf8(album.mWhen.c_str()));
PhotoItem *item = new PhotoItem(NULL, mAlbumData);
ui.AlbumDrop->addPhotoItem(item);
// called via callback AlbumChanged.
//setAlbumDataToPhotos();
return true;
}
bool PhotoAddDialog::setAlbumDataToPhotos()
{
std::cerr << "PhotoAddDialog::setAlbumDataToPhotos()";
std::cerr << std::endl;
int photoCount = ui.scrollAreaWidgetContents->getPhotoCount();
for(int i = 0; i < photoCount; i++)
{
PhotoItem *item = ui.scrollAreaWidgetContents->getPhotoIdx(i);
item->updateAlbumText(mAlbumData);
}
return true;
}
void PhotoAddDialog::showPhotoDetails() void PhotoAddDialog::showPhotoDetails()
{ {
std::cerr << "PhotoAddDialog::showPhotoDetails()"; std::cerr << "PhotoAddDialog::showPhotoDetails()";
std::cerr << std::endl; std::cerr << std::endl;
if (!mPhotoDetails)
{
mPhotoDetails = new PhotoDetailsDialog(NULL);
}
PhotoItem *item = ui.scrollAreaWidgetContents->getSelectedPhotoItem(); PhotoItem *item = ui.scrollAreaWidgetContents->getSelectedPhotoItem();
if (item)
mPhotoDetails->setPhotoItem(item); {
mPhotoDetails->show(); if (!mPhotoDetails)
{
mPhotoDetails = new PhotoDetailsDialog(NULL);
connect(mPhotoDetails, SIGNAL( editingDone( void ) ), this, SLOT( editingStageDone( void ) ) );
}
mPhotoDetails->setPhotoItem(item);
mPhotoDetails->show();
mEditingModeAlbum = false;
}
} }
void PhotoAddDialog::showAlbumDetails()
{
std::cerr << "PhotoAddDialog::showAlbumDetails()";
std::cerr << std::endl;
/* grab the image from the AlbumDrop */
PhotoItem *item = NULL;
if (ui.AlbumDrop->getPhotoCount() > 0)
{
item = ui.AlbumDrop->getPhotoIdx(0);
}
if (item)
{
if (!mPhotoDetails)
{
mPhotoDetails = new PhotoDetailsDialog(NULL);
connect(mPhotoDetails, SIGNAL( editingDone( void ) ), this, SLOT( editingStageDone( void ) ) );
}
mPhotoDetails->setPhotoItem(item);
mPhotoDetails->show();
mEditingModeAlbum = true;
}
else
{
std::cerr << "PhotoAddDialog::showAlbumDetails() PhotoItem Invalid";
std::cerr << std::endl;
}
}
/* Callback when AlbumDrop gets new image */
void PhotoAddDialog::albumImageChanged()
{
std::cerr << "PhotoAddDialog::albumImageChanged()";
std::cerr << std::endl;
/* must update the data from the reference stuff */
PhotoItem *item = NULL;
if (ui.AlbumDrop->getPhotoCount() > 0)
{
item = ui.AlbumDrop->getPhotoIdx(0);
}
if (!item)
{
std::cerr << "PhotoAddDialog::albumImageChanged() ERROR no Album PhotoItem";
std::cerr << std::endl;
return;
}
std::cerr << "PhotoAddDialog::albumImageChanged() PRE: AlbumDrop: " << item->mAlbumDetails;
std::cerr << std::endl;
std::cerr << "PhotoAddDialog::albumImageChanged() PRE: mAlbumData: " << mAlbumData;
std::cerr << std::endl;
item->mIsPhoto = false; // Force to Album mode.
/* now AlbumDrop has the image, but AlbumData has the other stuff */
item->getPhotoThumbnail(mAlbumData.mThumbnail);
item->updateAlbumText(mAlbumData);
/* if we are in editing mode -> update it */
if ((mEditingModeAlbum) && (mPhotoDetails))
{
std::cerr << "PhotoAddDialog::albumImageChanged() Updating PhotoDetails -> PhotoItem";
std::cerr << std::endl;
mPhotoDetails->setPhotoItem(item);
}
std::cerr << "PhotoAddDialog::albumImageChanged() POST: AlbumDrop: " << item->mAlbumDetails;
std::cerr << std::endl;
std::cerr << "PhotoAddDialog::albumImageChanged() POST: mAlbumData: " << mAlbumData;
std::cerr << std::endl;
}
/* This is called back once PhotoDetailsDialog Finishes */
void PhotoAddDialog::editingStageDone()
{
std::cerr << "PhotoAddDialog::editingStageDone()";
std::cerr << std::endl;
if (mEditingModeAlbum)
{
/* need to resolve Album Data, repopulate entries
*/
/* grab the image from the AlbumDrop (This is where PhotoDetailsDialog stores the data) */
PhotoItem *item = NULL;
if (ui.AlbumDrop->getPhotoCount() > 0)
{
item = ui.AlbumDrop->getPhotoIdx(0);
}
if (!item)
{
std::cerr << "PhotoAddDialog::editingStageDone() ERROR no Album PhotoItem";
std::cerr << std::endl;
}
/* Total Hack here Copy from AlbumDrop to Reference Data */
// cleanup old image first.
mAlbumData.mThumbnail.deleteImage();
mAlbumData = item->mAlbumDetails;
item->getPhotoThumbnail(mAlbumData.mThumbnail);
// Push Back data -> to trigger Text Update.
item->updateAlbumText(mAlbumData);
mEditingModeAlbum = false;
// Update GUI too.
ui.lineEdit_Title->setText(QString::fromUtf8(mAlbumData.mMeta.mGroupName.c_str()));
ui.lineEdit_Caption->setText(QString::fromUtf8(mAlbumData.mCaption.c_str()));
ui.lineEdit_Where->setText(QString::fromUtf8(mAlbumData.mWhere.c_str()));
ui.lineEdit_When->setText(QString::fromUtf8(mAlbumData.mWhen.c_str()));
}
else
{
std::cerr << "PhotoAddDialog::editingStageDone() ERROR not EditingModeAlbum";
std::cerr << std::endl;
}
// This forces item update -> though the AlbumUpdate is only needed if we edited Album.
setAlbumDataToPhotos();
}
/* Callback when PhotoDrop gets new image */
void PhotoAddDialog::photoImageChanged()
{
setAlbumDataToPhotos();
}
void PhotoAddDialog::publishAlbum() void PhotoAddDialog::publishAlbum()
@ -98,8 +296,8 @@ void PhotoAddDialog::publishAlbum()
/* we need to iterate through each photoItem, and extract the details */ /* we need to iterate through each photoItem, and extract the details */
RsPhotoAlbum album = mAlbumData;
RsPhotoAlbum album; album.mThumbnail.data = 0;
album.mShareOptions.mShareType = 0; album.mShareOptions.mShareType = 0;
album.mShareOptions.mShareGroupId = "unknown"; album.mShareOptions.mShareGroupId = "unknown";
@ -107,13 +305,38 @@ void PhotoAddDialog::publishAlbum()
album.mShareOptions.mCommentMode = 0; album.mShareOptions.mCommentMode = 0;
album.mShareOptions.mResizeMode = 0; album.mShareOptions.mResizeMode = 0;
album.mMeta.mGroupName = ui.lineEdit_Title->text().toStdString(); //album.mMeta.mGroupName = ui.lineEdit_Title->text().toStdString();
album.mCategory = "Unknown"; //album.mCategory = "Unknown";
album.mCaption = ui.lineEdit_Caption->text().toStdString(); //album.mCaption = ui.lineEdit_Caption->text().toStdString();
album.mWhere = ui.lineEdit_Where->text().toStdString(); //album.mWhere = ui.lineEdit_Where->text().toStdString();
album.mWhen = ui.lineEdit_When->text().toStdString(); //album.mWhen = ui.lineEdit_When->text().toStdString();
if (rsPhoto->submitAlbumDetails(album)) /* grab the image from the AlbumDrop */
if (ui.AlbumDrop->getPhotoCount() > 0)
{
PhotoItem *item = ui.AlbumDrop->getPhotoIdx(0);
item->getPhotoThumbnail(album.mThumbnail);
}
bool isAlbumOk = false;
// For the moment, only submit albums Once.
if (mAlbumEdit)
{
std::cerr << "PhotoAddDialog::publishAlbum() AlbumEdit Mode";
std::cerr << std::endl;
isAlbumOk = true;
}
else if (rsPhoto->submitAlbumDetails(album, true))
{
std::cerr << "PhotoAddDialog::publishAlbum() New Album Mode";
std::cerr << std::endl;
isAlbumOk = true;
}
if (isAlbumOk)
{ {
/* now have path and album id */ /* now have path and album id */
int photoCount = ui.scrollAreaWidgetContents->getPhotoCount(); int photoCount = ui.scrollAreaWidgetContents->getPhotoCount();
@ -130,11 +353,41 @@ void PhotoAddDialog::publishAlbum()
} }
photo = item->mPhotoDetails; photo = item->mPhotoDetails;
photo.mThumbnail.data = 0; // do proper data copy.
item->getPhotoThumbnail(photo.mThumbnail); item->getPhotoThumbnail(photo.mThumbnail);
photo.mMeta.mGroupId = album.mMeta.mGroupId; bool isNewPhoto = false;
bool isModifiedPhoto = false;
if (mAlbumEdit)
{
// can have modFlags and be New... so the order is important.
if (photo.mMeta.mGroupId.length() < 1)
{
/* new photo - flag in mods */
photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_PHOTO;
photo.mMeta.mGroupId = album.mMeta.mGroupId;
isNewPhoto = true;
}
else if (photo.mModFlags)
{
isModifiedPhoto = true;
}
}
else
{
/* new album - update GroupId, all photos are new */
photo.mMeta.mGroupId = album.mMeta.mGroupId;
isNewPhoto = true;
}
photo.mOrder = i; photo.mOrder = i;
std::cerr << "PhotoAddDialog::publishAlbum() Photo(" << i << ")";
std::cerr << " mSetFlags: " << photo.mSetFlags;
std::cerr << " mModFlags: " << photo.mModFlags;
std::cerr << std::endl;
/* scale photo if needed */ /* scale photo if needed */
if (album.mShareOptions.mResizeMode) if (album.mShareOptions.mResizeMode)
{ {
@ -144,7 +397,22 @@ void PhotoAddDialog::publishAlbum()
/* save image to album path */ /* save image to album path */
photo.path = "unknown"; photo.path = "unknown";
rsPhoto->submitPhoto(photo); std::cerr << "PhotoAddDialog::publishAlbum() Photo(" << i << ") ";
if (isNewPhoto)
{
std::cerr << "Is a New Photo";
rsPhoto->submitPhoto(photo, true);
}
else if (isModifiedPhoto)
{
std::cerr << "Is Updated";
rsPhoto->submitPhoto(photo, false);
}
else
{
std::cerr << "Is Unchanged";
}
std::cerr << std::endl;
} }
} }
@ -154,6 +422,20 @@ void PhotoAddDialog::publishAlbum()
} }
void PhotoAddDialog::deleteAlbum()
{
std::cerr << "PhotoAddDialog::deleteAlbum() Not Implemented Yet";
std::cerr << std::endl;
}
void PhotoAddDialog::deletePhoto()
{
std::cerr << "PhotoAddDialog::deletePhoto() Not Implemented Yet";
std::cerr << std::endl;
}
void PhotoAddDialog::clearDialog() void PhotoAddDialog::clearDialog()
{ {
ui.lineEdit_Title->setText(QString("title")); ui.lineEdit_Title->setText(QString("title"));
@ -162,6 +444,122 @@ void PhotoAddDialog::clearDialog()
ui.lineEdit_When->setText(QString("When")); ui.lineEdit_When->setText(QString("When"));
ui.scrollAreaWidgetContents->clearPhotos(); ui.scrollAreaWidgetContents->clearPhotos();
ui.AlbumDrop->clearPhotos();
/* clean up album image */
mAlbumData.mThumbnail.deleteImage();
RsPhotoAlbum emptyAlbum;
mAlbumData = emptyAlbum;
/* add empty image */
PhotoItem *item = new PhotoItem(NULL, mAlbumData);
ui.AlbumDrop->addPhotoItem(item);
mAlbumEdit = false;
} }
void PhotoAddDialog::loadAlbum(const std::string &albumId)
{
/* much like main load fns */
clearDialog();
mAlbumEdit = true;
RsTokReqOptions opts;
uint32_t token;
std::list<std::string> albumIds;
albumIds.push_back(albumId);
// We need both Album and Photo Data.
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, albumIds, 0);
}
bool PhotoAddDialog::loadPhotoData(const uint32_t &token)
{
std::cerr << "PhotoAddDialog::loadPhotoData()";
std::cerr << std::endl;
bool moreData = true;
while(moreData)
{
RsPhotoPhoto photo;
if (rsPhoto->getPhoto(token, photo))
{
std::cerr << "PhotoDialog::addAddPhoto() AlbumId: " << photo.mMeta.mGroupId;
std::cerr << " PhotoId: " << photo.mMeta.mMsgId;
std::cerr << std::endl;
PhotoItem *item = new PhotoItem(NULL, photo, mAlbumData);
ui.scrollAreaWidgetContents->addPhotoItem(item);
}
else
{
moreData = false;
}
}
return true;
}
bool PhotoAddDialog::loadAlbumData(const uint32_t &token)
{
std::cerr << "PhotoAddDialog::loadAlbumData()";
std::cerr << std::endl;
bool moreData = true;
while(moreData)
{
RsPhotoAlbum album;
if (rsPhoto->getAlbum(token, album))
{
std::cerr << " PhotoAddDialog::loadAlbumData() AlbumId: " << album.mMeta.mGroupId << std::endl;
updateAlbumDetails(album);
RsTokReqOptions opts;
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
uint32_t token;
std::list<std::string> albumIds;
albumIds.push_back(album.mMeta.mGroupId);
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, albumIds, 0);
}
else
{
moreData = false;
}
}
return true;
}
void PhotoAddDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{
std::cerr << "PhotoDialog::loadRequest()";
std::cerr << std::endl;
if (queue == mPhotoQueue)
{
/* now switch on req */
switch(req.mType)
{
case TOKENREQ_GROUPINFO:
loadAlbumData(req.mToken);
break;
case TOKENREQ_MSGINFO:
loadPhotoData(req.mToken);
break;
default:
std::cerr << "PhotoAddDialog::loadRequest() ERROR: GROUP: INVALID ANS TYPE";
std::cerr << std::endl;
break;
}
}
}

View File

@ -26,24 +26,49 @@
#include "ui_PhotoAddDialog.h" #include "ui_PhotoAddDialog.h"
#include <retroshare/rsphoto.h>
#include "util/TokenQueue.h"
class PhotoDetailsDialog; class PhotoDetailsDialog;
class PhotoAddDialog : public QWidget class PhotoAddDialog : public QWidget, public TokenResponse
{ {
Q_OBJECT Q_OBJECT
public: public:
PhotoAddDialog(QWidget *parent = 0); PhotoAddDialog(QWidget *parent = 0);
void loadAlbum(const std::string &albumId);
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
void clearDialog();
private slots: private slots:
void showPhotoDetails(); void showPhotoDetails();
void showAlbumDetails();
void editingStageDone();
// From PhotoDrops...
void albumImageChanged();
void photoImageChanged();
void updateMoveButtons(uint32_t status); void updateMoveButtons(uint32_t status);
void publishAlbum(); void publishAlbum();
void clearDialog();
void deleteAlbum();
void deletePhoto();
private:
bool updateAlbumDetails(const RsPhotoAlbum &album);
bool setAlbumDataToPhotos();
bool loadPhotoData(const uint32_t &token);
bool loadAlbumData(const uint32_t &token);
TokenQueue *mPhotoQueue;
protected: protected:
bool mAlbumEdit; // Editing or New.
bool mEditingModeAlbum; // Changing Album or Photo Details.
RsPhotoAlbum mAlbumData;
PhotoDetailsDialog *mPhotoDetails; PhotoDetailsDialog *mPhotoDetails;
Ui::PhotoAddDialog ui; Ui::PhotoAddDialog ui;

View File

@ -162,7 +162,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="albumGroup">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -174,16 +174,8 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QLabel" name="label"> <widget class="PhotoDrop" name="AlbumDrop" native="true">
<property name="text"> <layout class="QGridLayout" name="gridLayout_5"/>
<string>Album Thumbnail.........
Drag and Drop an Image
from the Picture List
to make it the Album
Image
1
2</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -198,11 +190,14 @@ Image
</sizepolicy> </sizepolicy>
</property> </property>
<property name="title"> <property name="title">
<string>Basic Details</string> <string>Summary</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_Title"> <widget class="QLineEdit" name="lineEdit_Title">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -220,6 +215,9 @@ Image
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QComboBox" name="comboBox_Category"> <widget class="QComboBox" name="comboBox_Category">
<property name="enabled">
<bool>false</bool>
</property>
<item> <item>
<property name="text"> <property name="text">
<string>Travel</string> <string>Travel</string>
@ -261,6 +259,9 @@ Image
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_Caption"> <widget class="QLineEdit" name="lineEdit_Caption">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -278,6 +279,9 @@ Image
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_Where"> <widget class="QLineEdit" name="lineEdit_Where">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -288,6 +292,9 @@ Image
</item> </item>
<item row="4" column="1"> <item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_When"> <widget class="QLineEdit" name="lineEdit_When">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -376,8 +383,8 @@ Image
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>822</width> <width>830</width>
<height>76</height> <height>83</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
@ -393,6 +400,26 @@ Image
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton_DeletePhoto">
<property name="text">
<string>Delete Photo</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QPushButton" name="pushButton_EditPhotoDetails"> <widget class="QPushButton" name="pushButton_EditPhotoDetails">
<property name="text"> <property name="text">

View File

@ -24,6 +24,8 @@
#include "gui/PhotoShare/PhotoDetailsDialog.h" #include "gui/PhotoShare/PhotoDetailsDialog.h"
#include "gui/PhotoShare/PhotoItem.h" #include "gui/PhotoShare/PhotoItem.h"
#include <iostream>
/** Constructor */ /** Constructor */
PhotoDetailsDialog::PhotoDetailsDialog(QWidget *parent) PhotoDetailsDialog::PhotoDetailsDialog(QWidget *parent)
: QWidget(parent) : QWidget(parent)
@ -50,10 +52,10 @@ void PhotoDetailsDialog::setPhotoItem(PhotoItem *item)
void PhotoDetailsDialog::refreshDetails() void PhotoDetailsDialog::refreshDetails()
{ {
blankDetails();
if(!mPhotoItem) if (!mPhotoItem)
{ {
blankDetails(); return;
} }
ui.label_Headline->setText(QString("Photo Description")); ui.label_Headline->setText(QString("Photo Description"));
@ -62,25 +64,126 @@ void PhotoDetailsDialog::refreshDetails()
if (mPhotoItem->mIsPhoto) if (mPhotoItem->mIsPhoto)
{ {
ui.lineEdit_Caption->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mCaption)); // THIS is tedious!
ui.textEdit_Description->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mDescription));
ui.lineEdit_Photographer->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mPhotographer)); RsPhotoPhoto &photo = mPhotoItem->mPhotoDetails;
ui.lineEdit_Where->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mWhere)); RsPhotoAlbum &album = mPhotoItem->mAlbumDetails;
ui.lineEdit_When->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mWhen));
ui.lineEdit_Other->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mOther)); if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_TITLE)
ui.lineEdit_Title->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mMeta.mMsgName)); {
ui.lineEdit_HashTags->setText(QString::fromStdString(mPhotoItem->mPhotoDetails.mHashTags)); ui.lineEdit_Title->setText(QString::fromUtf8(photo.mMeta.mMsgName.c_str()));
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_TITLE)
{
ui.lineEdit_Title->setText(QString::fromUtf8(album.mMeta.mGroupName.c_str()));
}
if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_CAPTION)
{
ui.lineEdit_Caption->setText(QString::fromUtf8(photo.mCaption.c_str()));
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_CAPTION)
{
ui.lineEdit_Caption->setText(QString::fromUtf8(album.mCaption.c_str()));
}
if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_DESC)
{
ui.textEdit_Description->setText(QString::fromUtf8(photo.mDescription.c_str()));
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_DESC)
{
ui.textEdit_Description->setText(QString::fromUtf8(album.mDescription.c_str()));
}
if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER)
{
ui.lineEdit_Photographer->setText(QString::fromUtf8(photo.mPhotographer.c_str()));
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER)
{
ui.lineEdit_Photographer->setText(QString::fromUtf8(album.mPhotographer.c_str()));
}
if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE)
{
ui.lineEdit_Where->setText(QString::fromUtf8(photo.mWhere.c_str()));
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE)
{
ui.lineEdit_Where->setText(QString::fromUtf8(album.mWhere.c_str()));
}
if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHEN)
{
ui.lineEdit_When->setText(QString::fromUtf8(photo.mWhen.c_str()));
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHEN)
{
ui.lineEdit_When->setText(QString::fromUtf8(album.mWhen.c_str()));
}
if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_OTHER)
{
ui.lineEdit_Other->setText(QString::fromUtf8(photo.mOther.c_str()));
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_OTHER)
{
ui.lineEdit_Other->setText(QString::fromUtf8(album.mOther.c_str()));
}
if (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_HASHTAGS)
{
ui.lineEdit_HashTags->setText(QString::fromUtf8(photo.mHashTags.c_str()));
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_HASHTAGS)
{
ui.lineEdit_HashTags->setText(QString::fromUtf8(album.mHashTags.c_str()));
}
} }
else else
{ {
ui.lineEdit_Caption->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mCaption)); RsPhotoAlbum &album = mPhotoItem->mAlbumDetails;
ui.textEdit_Description->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mDescription));
ui.lineEdit_Photographer->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mPhotographer)); if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_TITLE)
ui.lineEdit_Where->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mWhere)); {
ui.lineEdit_When->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mWhen)); ui.lineEdit_Title->setText(QString::fromUtf8(album.mMeta.mGroupName.c_str()));
ui.lineEdit_Other->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mOther)); }
ui.lineEdit_Title->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mMeta.mGroupName));
ui.lineEdit_HashTags->setText(QString::fromStdString(mPhotoItem->mAlbumDetails.mHashTags)); if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_CAPTION)
{
ui.lineEdit_Caption->setText(QString::fromUtf8(album.mCaption.c_str()));
}
if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_DESC)
{
ui.textEdit_Description->setText(QString::fromUtf8(album.mDescription.c_str()));
}
if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER)
{
ui.lineEdit_Photographer->setText(QString::fromUtf8(album.mPhotographer.c_str()));
}
if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE)
{
ui.lineEdit_Where->setText(QString::fromUtf8(album.mWhere.c_str()));
}
if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHEN)
{
ui.lineEdit_When->setText(QString::fromUtf8(album.mWhen.c_str()));
}
if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_OTHER)
{
ui.lineEdit_Other->setText(QString::fromUtf8(album.mOther.c_str()));
}
if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_HASHTAGS)
{
ui.lineEdit_HashTags->setText(QString::fromUtf8(album.mHashTags.c_str()));
}
} }
const QPixmap *qtn = mPhotoItem->getPixmap(); const QPixmap *qtn = mPhotoItem->getPixmap();
@ -94,14 +197,14 @@ void PhotoDetailsDialog::blankDetails()
//ui.comboBox_Category= mPhotoItem->mDetails.mCaption; //ui.comboBox_Category= mPhotoItem->mDetails.mCaption;
ui.lineEdit_Caption->setText(QString("N/A")); ui.lineEdit_Title->setText(QString(""));
ui.textEdit_Description->setText(QString("N/A")); ui.lineEdit_Caption->setText(QString(""));
ui.lineEdit_Photographer->setText(QString("N/A")); ui.textEdit_Description->setText(QString(""));
ui.lineEdit_Where->setText(QString("N/A")); ui.lineEdit_Photographer->setText(QString(""));
ui.lineEdit_When->setText(QString("N/A")); ui.lineEdit_Where->setText(QString(""));
ui.lineEdit_Other->setText(QString("N/A")); ui.lineEdit_When->setText(QString(""));
ui.lineEdit_Title->setText(QString("N/A")); ui.lineEdit_Other->setText(QString(""));
ui.lineEdit_HashTags->setText(QString("N/A")); ui.lineEdit_HashTags->setText(QString(""));
//QPixmap qtn = mPhotoItem->getPixmap(); //QPixmap qtn = mPhotoItem->getPixmap();
//ui.label_Photo->setPixmap(qtn); //ui.label_Photo->setPixmap(qtn);
@ -112,6 +215,9 @@ void PhotoDetailsDialog::updateDetails()
{ {
saveDetails(); saveDetails();
// Notify Listeners.
editingDone();
hide(); hide();
} }
@ -123,30 +229,290 @@ void PhotoDetailsDialog::saveDetails()
return; return;
} }
//mPhotoItem->mDetails.mCaption = ui.comboBox_Category; RsPhotoPhoto &photo = mPhotoItem->mPhotoDetails;
RsPhotoAlbum &album = mPhotoItem->mAlbumDetails;
std::string txt = ui.lineEdit_Title->text().toUtf8().constData();
bool setName = false;
if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_TITLE))
{
if (txt != photo.mMeta.mMsgName)
setName = true;
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_TITLE)
{
if (txt != album.mMeta.mGroupName)
setName = true;
}
else if (txt.length() != 0)
{
setName = true;
}
if (setName)
{
if (mPhotoItem->mIsPhoto)
{
photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_TITLE;
photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_TITLE;
photo.mMeta.mMsgName = txt;
}
else
{
album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_TITLE;
album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_TITLE;
album.mMeta.mGroupName = txt;
}
}
txt = ui.lineEdit_Caption->text().toUtf8().constData();
setName = false;
if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_CAPTION))
{
if (txt != photo.mCaption)
setName = true;
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_CAPTION)
{
if (txt != album.mCaption)
setName = true;
}
else if (txt.length() != 0)
{
setName = true;
}
if (setName)
{
if (mPhotoItem->mIsPhoto)
{
photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_CAPTION;
photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_CAPTION;
photo.mCaption = txt;
}
else
{
album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_CAPTION;
album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_CAPTION;
album.mCaption = txt;
}
}
txt = ui.textEdit_Description->toPlainText().toUtf8().constData();
setName = false;
if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_DESC))
{
if (txt != photo.mDescription)
setName = true;
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_DESC)
{
if (txt != album.mDescription)
setName = true;
}
else if (txt.length() != 0)
{
setName = true;
}
if (setName)
{
if (mPhotoItem->mIsPhoto)
{
photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_DESC;
photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_DESC;
photo.mDescription = txt;
}
else
{
album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_DESC;
album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_DESC;
album.mDescription = txt;
}
}
txt = ui.lineEdit_Photographer->text().toUtf8().constData();
setName = false;
if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER))
{
if (txt != photo.mPhotographer)
setName = true;
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER)
{
if (txt != album.mPhotographer)
setName = true;
}
else if (txt.length() != 0)
{
setName = true;
}
if (setName)
{
if (mPhotoItem->mIsPhoto)
{
photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER;
photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER;
photo.mPhotographer = txt;
}
else
{
album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER;
album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER;
album.mPhotographer = txt;
}
}
txt = ui.lineEdit_Where->text().toUtf8().constData();
setName = false;
if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE))
{
if (txt != photo.mWhere)
setName = true;
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE)
{
if (txt != album.mWhere)
setName = true;
}
else if (txt.length() != 0)
{
setName = true;
}
if (setName)
{
if (mPhotoItem->mIsPhoto)
{
photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_WHERE;
photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_WHERE;
photo.mWhere = txt;
}
else
{
album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_WHERE;
album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_WHERE;
album.mWhere = txt;
}
}
txt = ui.lineEdit_When->text().toUtf8().constData();
setName = false;
if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHEN))
{
if (txt != photo.mWhen)
setName = true;
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHEN)
{
if (txt != album.mWhen)
setName = true;
}
else if (txt.length() != 0)
{
setName = true;
}
if (setName)
{
if (mPhotoItem->mIsPhoto)
{
photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_WHEN;
photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_WHEN;
photo.mWhen = txt;
}
else
{
album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_WHEN;
album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_WHEN;
album.mWhen = txt;
}
}
txt = ui.lineEdit_HashTags->text().toUtf8().constData();
setName = false;
if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_HASHTAGS))
{
if (txt != photo.mHashTags)
setName = true;
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_HASHTAGS)
{
if (txt != album.mHashTags)
setName = true;
}
else if (txt.length() != 0)
{
setName = true;
}
if (setName)
{
if (mPhotoItem->mIsPhoto)
{
photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_HASHTAGS;
photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_HASHTAGS;
photo.mHashTags = txt;
}
else
{
album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_HASHTAGS;
album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_HASHTAGS;
album.mHashTags = txt;
}
}
txt = ui.lineEdit_Other->text().toUtf8().constData();
setName = false;
if ((mPhotoItem->mIsPhoto) && (photo.mSetFlags & RSPHOTO_FLAGS_ATTRIB_OTHER))
{
if (txt != photo.mOther)
setName = true;
}
else if (album.mSetFlags & RSPHOTO_FLAGS_ATTRIB_OTHER)
{
if (txt != album.mOther)
setName = true;
}
else if (txt.length() != 0)
{
setName = true;
}
if (setName)
{
if (mPhotoItem->mIsPhoto)
{
photo.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_OTHER;
photo.mModFlags |= RSPHOTO_FLAGS_ATTRIB_OTHER;
photo.mOther = txt;
}
else
{
album.mSetFlags |= RSPHOTO_FLAGS_ATTRIB_OTHER;
album.mModFlags |= RSPHOTO_FLAGS_ATTRIB_OTHER;
album.mOther = txt;
}
}
std::cerr << "PhotoDetailsDialog::saveDetails() ";
if (mPhotoItem->mIsPhoto) if (mPhotoItem->mIsPhoto)
{ {
mPhotoItem->mPhotoDetails.mCaption = ui.lineEdit_Caption->text().toStdString(); std::cerr << " photo.mSetFlags: " << mPhotoItem->mPhotoDetails.mSetFlags;
mPhotoItem->mPhotoDetails.mDescription = ui.textEdit_Description->toPlainText().toStdString(); std::cerr << " photo.mModFlags: " << mPhotoItem->mPhotoDetails.mModFlags;
mPhotoItem->mPhotoDetails.mPhotographer = ui.lineEdit_Photographer->text().toStdString();
mPhotoItem->mPhotoDetails.mWhere = ui.lineEdit_Where->text().toStdString();
mPhotoItem->mPhotoDetails.mWhen = ui.lineEdit_When->text().toStdString();
mPhotoItem->mPhotoDetails.mOther = ui.lineEdit_Other->text().toStdString();
mPhotoItem->mPhotoDetails.mMeta.mMsgName = ui.lineEdit_Title->text().toStdString();
mPhotoItem->mPhotoDetails.mHashTags = ui.lineEdit_HashTags->text().toStdString();
}
else
{
mPhotoItem->mAlbumDetails.mCaption = ui.lineEdit_Caption->text().toStdString();
mPhotoItem->mAlbumDetails.mDescription = ui.textEdit_Description->toPlainText().toStdString();
mPhotoItem->mAlbumDetails.mPhotographer = ui.lineEdit_Photographer->text().toStdString();
mPhotoItem->mAlbumDetails.mWhere = ui.lineEdit_Where->text().toStdString();
mPhotoItem->mAlbumDetails.mWhen = ui.lineEdit_When->text().toStdString();
mPhotoItem->mAlbumDetails.mOther = ui.lineEdit_Other->text().toStdString();
mPhotoItem->mAlbumDetails.mMeta.mGroupName = ui.lineEdit_Title->text().toStdString();
mPhotoItem->mAlbumDetails.mHashTags = ui.lineEdit_HashTags->text().toStdString();
} }
std::cerr << " album.mSetFlags: " << mPhotoItem->mAlbumDetails.mSetFlags;
std::cerr << " album.mModFlags: " << mPhotoItem->mAlbumDetails.mModFlags;
std::cerr << std::endl;
//QPixmap qtn = mPhotoItem->getPixmap(); //QPixmap qtn = mPhotoItem->getPixmap();
//ui.label_Photo->setPixmap(qtn); //ui.label_Photo->setPixmap(qtn);

View File

@ -37,6 +37,9 @@ public:
void setPhotoItem(PhotoItem *item); void setPhotoItem(PhotoItem *item);
signals:
void editingDone();
private: private:
void saveDetails(); void saveDetails();
void refreshDetails(); void refreshDetails();

View File

@ -30,6 +30,7 @@
#include <sstream> #include <sstream>
#include <QTimer> #include <QTimer>
#include <QMessageBox>
/****** /******
* #define PHOTO_DEBUG 1 * #define PHOTO_DEBUG 1
@ -66,8 +67,11 @@ PhotoDialog::PhotoDialog(QWidget *parent)
mAddDialog = NULL; mAddDialog = NULL;
mAlbumSelected = NULL; mAlbumSelected = NULL;
mPhotoSelected = NULL; mPhotoSelected = NULL;
mSlideShow = NULL;
connect( ui.toolButton_NewAlbum, SIGNAL(clicked()), this, SLOT(OpenOrShowPhotoAddDialog())); connect( ui.toolButton_NewAlbum, SIGNAL(clicked()), this, SLOT(OpenOrShowPhotoAddDialog()));
connect( ui.toolButton_EditAlbum, SIGNAL(clicked()), this, SLOT(OpenPhotoEditDialog()));
connect( ui.toolButton_SlideShow, SIGNAL(clicked()), this, SLOT(OpenSlideShow()));
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate())); timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
@ -148,6 +152,45 @@ void PhotoDialog::checkUpdate()
} }
/*************** New Photo Dialog ***************/
void PhotoDialog::OpenSlideShow()
{
// TODO.
if (!mAlbumSelected)
{
// ALERT.
int ret = QMessageBox::information(this, tr("PhotoShare"),
tr("Please select an album before\n"
"requesting to edit it!"),
QMessageBox::Ok);
return;
}
if (mAlbumSelected->mIsPhoto)
{
std::cerr << "PhotoDialog::OpenPhotoEditDialog() MAJOR ERROR!";
std::cerr << std::endl;
return;
}
std::string albumId = mAlbumSelected->mAlbumDetails.mMeta.mGroupId;
if (mSlideShow)
{
mSlideShow->show();
}
else
{
mSlideShow = new PhotoSlideShow(NULL);
mSlideShow->show();
}
mSlideShow->loadAlbum(albumId);
}
/*************** New Photo Dialog ***************/ /*************** New Photo Dialog ***************/
void PhotoDialog::OpenOrShowPhotoAddDialog() void PhotoDialog::OpenOrShowPhotoAddDialog()
@ -161,6 +204,50 @@ void PhotoDialog::OpenOrShowPhotoAddDialog()
mAddDialog = new PhotoAddDialog(NULL); mAddDialog = new PhotoAddDialog(NULL);
mAddDialog->show(); mAddDialog->show();
} }
mAddDialog->clearDialog();
}
/*************** Edit Photo Dialog ***************/
void PhotoDialog::OpenPhotoEditDialog()
{
/* check if we have an album selected */
// THE TWO MessageBoxes - should be handled by disabling the Button!.
// TODO.
if (!mAlbumSelected)
{
// ALERT.
int ret = QMessageBox::information(this, tr("PhotoShare"),
tr("Please select an album before\n"
"requesting to edit it!"),
QMessageBox::Ok);
return;
}
if (mAlbumSelected->mIsPhoto)
{
std::cerr << "PhotoDialog::OpenPhotoEditDialog() MAJOR ERROR!";
std::cerr << std::endl;
}
std::string albumId = mAlbumSelected->mAlbumDetails.mMeta.mGroupId;
#if 0
uint32_t flags = mAlbumSelected->mAlbumDetails.mMeta.mGroupFlags;
if (!(flags & OWN))
{
// ALERT.
int ret = QMessageBox::information(this, tr("PhotoShare"),
tr("Cannot Edit Someone Else's Album"),
QMessageBox::Ok);
return;
}
#endif
OpenOrShowPhotoAddDialog();
mAddDialog->loadAlbum(albumId);
} }
@ -320,7 +407,10 @@ void PhotoDialog::addPhoto(const RsPhotoPhoto &photo)
std::cerr << " PhotoId: " << photo.mMeta.mMsgId; std::cerr << " PhotoId: " << photo.mMeta.mMsgId;
std::cerr << std::endl; std::cerr << std::endl;
PhotoItem *item = new PhotoItem(this, photo); RsPhotoAlbum dummyAlbum;
dummyAlbum.mSetFlags = 0;
PhotoItem *item = new PhotoItem(this, photo, dummyAlbum);
QLayout *alayout = ui.scrollAreaWidgetContents_2->layout(); QLayout *alayout = ui.scrollAreaWidgetContents_2->layout();
alayout->addWidget(item); alayout->addWidget(item);
@ -411,6 +501,7 @@ void PhotoDialog::requestPhotoList(const std::string &albumId)
std::list<std::string> ids; std::list<std::string> ids;
ids.push_back(albumId); ids.push_back(albumId);
RsTokReqOptions opts; RsTokReqOptions opts;
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
uint32_t token; uint32_t token;
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, ids, 0); mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, ids, 0);
} }
@ -452,13 +543,11 @@ void PhotoDialog::loadPhotoData(const uint32_t &token)
if (rsPhoto->getPhoto(token, photo)) if (rsPhoto->getPhoto(token, photo))
{ {
std::cerr << "PhotoDialog::addPhoto() AlbumId: " << photo.mMeta.mGroupId; std::cerr << "PhotoDialog::loadPhotoData() AlbumId: " << photo.mMeta.mGroupId;
std::cerr << " PhotoId: " << photo.mMeta.mMsgId; std::cerr << " PhotoId: " << photo.mMeta.mMsgId;
std::cerr << std::endl; std::cerr << std::endl;
PhotoItem *item = new PhotoItem(this, photo); addPhoto(photo);
QLayout *alayout = ui.scrollAreaWidgetContents_2->layout();
alayout->addWidget(item);
} }
else else
{ {

View File

@ -33,6 +33,7 @@
#include "gui/PhotoShare/PhotoItem.h" #include "gui/PhotoShare/PhotoItem.h"
#include "gui/PhotoShare/PhotoAddDialog.h" #include "gui/PhotoShare/PhotoAddDialog.h"
#include "gui/PhotoShare/PhotoSlideShow.h"
#include "util/TokenQueue.h" #include "util/TokenQueue.h"
class PhotoDialog : public MainPage, public PhotoHolder, public TokenResponse class PhotoDialog : public MainPage, public PhotoHolder, public TokenResponse
@ -52,7 +53,8 @@ private slots:
void checkUpdate(); void checkUpdate();
void OpenOrShowPhotoAddDialog(); void OpenOrShowPhotoAddDialog();
void OpenPhotoEditDialog();
void OpenSlideShow();
private: private:
/* Request Response Functions for loading data */ /* Request Response Functions for loading data */
@ -94,6 +96,7 @@ private:
void clearPhotos(); void clearPhotos();
PhotoAddDialog *mAddDialog; PhotoAddDialog *mAddDialog;
PhotoSlideShow *mSlideShow;
PhotoItem *mAlbumSelected; PhotoItem *mAlbumSelected;
PhotoItem *mPhotoSelected; PhotoItem *mPhotoSelected;

View File

@ -122,8 +122,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>746</width> <width>754</width>
<height>227</height> <height>234</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
@ -165,8 +165,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>746</width> <width>754</width>
<height>227</height> <height>233</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
@ -193,13 +193,6 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QToolButton" name="toolButton_RemovePicture">
<property name="text">
<string>Remove Picture</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QToolButton" name="toolButton_SlideShow"> <widget class="QToolButton" name="toolButton_SlideShow">
<property name="text"> <property name="text">
@ -214,13 +207,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="toolButton_EditPictureDetails">
<property name="text">
<string>Edit Picture Details</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QToolButton" name="toolButton_NewAlbum"> <widget class="QToolButton" name="toolButton_NewAlbum">
<property name="text"> <property name="text">

View File

@ -57,6 +57,8 @@ PhotoDrop::PhotoDrop(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
setAcceptDrops(true); setAcceptDrops(true);
mIsSingleImageDrop = false;
mSelected = NULL; mSelected = NULL;
checkMoveButtons(); checkMoveButtons();
reorderPhotos(); reorderPhotos();
@ -84,6 +86,11 @@ void PhotoDrop::clear()
{ {
} }
void PhotoDrop::setSingleImage()
{
mIsSingleImageDrop = true;
}
PhotoItem *PhotoDrop::getSelectedPhotoItem() PhotoItem *PhotoDrop::getSelectedPhotoItem()
{ {
@ -248,6 +255,11 @@ void PhotoDrop::reorderPhotos()
} }
int space = width(); int space = width();
mColumns = space / minWidth; mColumns = space / minWidth;
// incase its too thin!
if (mColumns < 1)
{
mColumns = 1;
}
std::cerr << "PhotoDrop::reorderPhotos() minWidth: " << minWidth << " space: " << space; std::cerr << "PhotoDrop::reorderPhotos() minWidth: " << minWidth << " space: " << space;
std::cerr << " columns: " << mColumns; std::cerr << " columns: " << mColumns;
@ -627,11 +639,15 @@ void PhotoDrop::dropEvent(QDropEvent *event)
PhotoItem *item = new PhotoItem(this, localpath.toStdString()); PhotoItem *item = new PhotoItem(this, localpath.toStdString());
addPhotoItem(item);
//mPhotos.push_back(item); //mPhotos.push_back(item);
layout()->addWidget(item); //layout()->addWidget(item);
} }
event->setDropAction(Qt::CopyAction); event->setDropAction(Qt::CopyAction);
event->accept(); event->accept();
// Notify Listeners. (only happens for drop - not programmatically added).
photosChanged();
} }
else else
{ {
@ -641,6 +657,7 @@ void PhotoDrop::dropEvent(QDropEvent *event)
} }
checkMoveButtons(); checkMoveButtons();
} }
void PhotoDrop::mousePressEvent(QMouseEvent *event) void PhotoDrop::mousePressEvent(QMouseEvent *event)
@ -655,3 +672,21 @@ void PhotoDrop::mousePressEvent(QMouseEvent *event)
} }
void PhotoDrop::addPhotoItem(PhotoItem *item)
{
std::cerr << "PhotoDrop::addPhotoItem()";
std::cerr << std::endl;
if (mIsSingleImageDrop)
{
clearPhotos();
}
item->updateParent(this);
layout()->addWidget(item);
//checkMoveButtons();
}

View File

@ -50,6 +50,7 @@ class PhotoDrop : public QWidget, public PhotoHolder
public: public:
PhotoDrop(QWidget *parent = 0); PhotoDrop(QWidget *parent = 0);
void clear(); void clear();
void setSingleImage();
virtual void deletePhotoItem(PhotoItem *, uint32_t type); virtual void deletePhotoItem(PhotoItem *, uint32_t type);
virtual void notifySelection(PhotoItem *item, int ptype); virtual void notifySelection(PhotoItem *item, int ptype);
@ -57,6 +58,7 @@ virtual void notifySelection(PhotoItem *item, int ptype);
PhotoItem *getSelectedPhotoItem(); PhotoItem *getSelectedPhotoItem();
int getPhotoCount(); int getPhotoCount();
PhotoItem *getPhotoIdx(int idx); PhotoItem *getPhotoIdx(int idx);
void addPhotoItem(PhotoItem *item);
public slots: public slots:
void moveLeft(); void moveLeft();
@ -66,6 +68,7 @@ public slots:
signals: signals:
void buttonStatus(uint32_t status); void buttonStatus(uint32_t status);
void photosChanged();
protected: protected:
@ -77,11 +80,13 @@ protected:
void dragMoveEvent(QDragMoveEvent *event); void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event); void dropEvent(QDropEvent *event);
private: private:
void reorderPhotos(); void reorderPhotos();
PhotoItem *mSelected; PhotoItem *mSelected;
int mColumns; int mColumns;
bool mIsSingleImageDrop;
}; };
#endif #endif

View File

@ -47,15 +47,15 @@ PhotoItem::PhotoItem(PhotoHolder *parent, const RsPhotoAlbum &album)
setAttribute ( Qt::WA_DeleteOnClose, true ); setAttribute ( Qt::WA_DeleteOnClose, true );
mIsPhoto = false; mIsPhoto = false;
mAlbumDetails = album; setDummyText();
updateAlbumText(album); updateAlbumText(album); // saves: mAlbumDetails = album;
updateImage(album.mThumbnail); updateImage(album.mThumbnail);
setSelected(false); setSelected(false);
} }
PhotoItem::PhotoItem(PhotoHolder *parent, const RsPhotoPhoto &photo) PhotoItem::PhotoItem(PhotoHolder *parent, const RsPhotoPhoto &photo, const RsPhotoAlbum &album)
:QWidget(NULL), mParent(parent), mType(PHOTO_ITEM_TYPE_PHOTO) :QWidget(NULL), mParent(parent), mType(PHOTO_ITEM_TYPE_PHOTO)
{ {
setupUi(this); setupUi(this);
@ -63,9 +63,11 @@ PhotoItem::PhotoItem(PhotoHolder *parent, const RsPhotoPhoto &photo)
setAttribute ( Qt::WA_DeleteOnClose, true ); setAttribute ( Qt::WA_DeleteOnClose, true );
mIsPhoto = true; mIsPhoto = true;
mPhotoDetails = photo;
updatePhotoText(photo); setDummyText();
updatePhotoText(photo); // saves: mPhotoDetails = photo;
updateAlbumText(album); // saves: mAlbumDetails = album;
updateImage(photo.mThumbnail); updateImage(photo.mThumbnail);
setSelected(false); setSelected(false);
@ -79,20 +81,9 @@ PhotoItem::PhotoItem(PhotoHolder *parent, std::string path) // for new photos.
setAttribute ( Qt::WA_DeleteOnClose, true ); setAttribute ( Qt::WA_DeleteOnClose, true );
QString dummyString("dummytext"); setDummyText();
titleLabel->setText(QString("NEW PHOTO"));
mIsPhoto = true; mIsPhoto = true;
fromBoldLabel->setText(QString("From:"));
fromLabel->setText(QString("Ourselves"));
statusBoldLabel->setText(QString("Status:"));
statusLabel->setText(QString("new photo"));
dateBoldLabel->setText(QString("Date:"));
dateLabel->setText(QString("now"));
int width = 120; int width = 120;
int height = 120; int height = 120;
@ -102,46 +93,94 @@ PhotoItem::PhotoItem(PhotoHolder *parent, std::string path) // for new photos.
setSelected(false); setSelected(false);
} }
void PhotoItem::updateParent(PhotoHolder *parent) // for external construction.
{
mParent = parent;
}
void PhotoItem::setDummyText()
{
titleLabel->setText(QString("Unknown"));
fromBoldLabel->setText(QString("By:"));
fromLabel->setText(QString("Unknown"));
statusBoldLabel->setText(QString("Where:"));
statusLabel->setText(QString("Unknown"));
dateBoldLabel->setText(QString("When:"));
dateLabel->setText(QString("Unknown"));
}
void PhotoItem::updateAlbumText(const RsPhotoAlbum &album) void PhotoItem::updateAlbumText(const RsPhotoAlbum &album)
{ {
QString dummyString("dummytext"); mAlbumDetails = album;
titleLabel->setText(QString("TITLE")); mAlbumDetails.mThumbnail.data = 0;
updateText();
fromBoldLabel->setText(QString("From:"));
fromLabel->setText(QString("Unknown"));
statusBoldLabel->setText(QString("Status:"));
statusLabel->setText(QString("new photo"));
dateBoldLabel->setText(QString("Date:"));
dateLabel->setText(QString("now"));
//QDateTime qtime;
//qtime.setTime_t(msg.ts);
//QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm");
//timestamplabel->setText(timestamp);
dateBoldLabel->setText(dummyString);
dateLabel->setText(dummyString);
} }
void PhotoItem::updatePhotoText(const RsPhotoPhoto &photo) void PhotoItem::updatePhotoText(const RsPhotoPhoto &photo)
{ {
QString dummyString("dummytext"); // Save new Photo details.
titleLabel->setText(QString("TITLE")); mPhotoDetails = photo;
mPhotoDetails.mThumbnail.data = 0;
fromBoldLabel->setText(QString("From:")); updateText();
fromLabel->setText(QString("Unknown"));
statusBoldLabel->setText(QString("Status:"));
statusLabel->setText(QString("new photo"));
dateBoldLabel->setText(QString("Date:"));
dateLabel->setText(QString("now"));
} }
void PhotoItem::updateText()
{
// SET Album Values first -> then overwrite with Photo Values.
if (mAlbumDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_TITLE)
{
titleLabel->setText(QString::fromUtf8(mAlbumDetails.mMeta.mGroupName.c_str()));
}
// This needs to be fixed!! TODO
fromLabel->setText(QString::fromStdString(mAlbumDetails.mMeta.mGroupId));
if (mAlbumDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_AUTHOR)
{
// This needs to be fixed!! TODO
fromLabel->setText(QString::fromStdString(mAlbumDetails.mMeta.mGroupId));
}
if (mAlbumDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE)
{
statusLabel->setText(QString::fromUtf8(mAlbumDetails.mWhere.c_str()));
}
if (mAlbumDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHEN)
{
dateLabel->setText(QString::fromUtf8(mAlbumDetails.mWhen.c_str()));
}
// NOW Photo Bits.
if (mIsPhoto)
{
if (mPhotoDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_TITLE)
{
titleLabel->setText(QString::fromUtf8(mPhotoDetails.mMeta.mMsgName.c_str()));
}
if (mPhotoDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_AUTHOR)
{
// This needs to be fixed!! TODO
fromLabel->setText(QString::fromStdString(mPhotoDetails.mMeta.mAuthorId));
}
if (mPhotoDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHERE)
{
statusLabel->setText(QString::fromUtf8(mPhotoDetails.mWhere.c_str()));
}
if (mPhotoDetails.mSetFlags & RSPHOTO_FLAGS_ATTRIB_WHEN)
{
dateLabel->setText(QString::fromUtf8(mPhotoDetails.mWhen.c_str()));
}
}
}
void PhotoItem::updateImage(const RsPhotoThumbnail &thumbnail) void PhotoItem::updateImage(const RsPhotoThumbnail &thumbnail)
{ {
if (thumbnail.data != NULL) if (thumbnail.data != NULL)

View File

@ -48,9 +48,14 @@ class PhotoItem : public QWidget, private Ui::PhotoItem
public: public:
PhotoItem(PhotoHolder *parent, const RsPhotoAlbum &album); PhotoItem(PhotoHolder *parent, const RsPhotoAlbum &album);
PhotoItem(PhotoHolder *parent, const RsPhotoPhoto &photo); PhotoItem(PhotoHolder *parent, const RsPhotoPhoto &photo, const RsPhotoAlbum &album);
PhotoItem(PhotoHolder *parent, std::string url); // for new photos. PhotoItem(PhotoHolder *parent, std::string url); // for new photos.
void setDummyText();
void updateParent(PhotoHolder *parent); // for external construction.
void updateAlbumText(const RsPhotoAlbum &album);
void updatePhotoText(const RsPhotoPhoto &photo);
void updateText();
bool getPhotoThumbnail(RsPhotoThumbnail &nail); bool getPhotoThumbnail(RsPhotoThumbnail &nail);
void removeItem(); void removeItem();
@ -62,6 +67,7 @@ public:
// details are public - so that can be easily edited. // details are public - so that can be easily edited.
bool mIsPhoto; bool mIsPhoto;
bool mWasModified;
RsPhotoPhoto mPhotoDetails; RsPhotoPhoto mPhotoDetails;
RsPhotoAlbum mAlbumDetails; RsPhotoAlbum mAlbumDetails;
@ -72,8 +78,6 @@ protected:
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event);
private: private:
void updateAlbumText(const RsPhotoAlbum &album);
void updatePhotoText(const RsPhotoPhoto &photo);
void updateImage(const RsPhotoThumbnail &thumbnail); void updateImage(const RsPhotoThumbnail &thumbnail);
PhotoHolder *mParent; PhotoHolder *mParent;

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PhotoSlideDetails</class>
<widget class="QWidget" name="PhotoSlideDetails">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>667</width>
<height>707</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Caption:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_Caption"/>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Photographer:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="lineEdit_Photographer"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item row="2" column="1" rowspan="3">
<widget class="QTextEdit" name="textEdit_Description"/>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Where:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="lineEdit_Where"/>
</item>
<item row="3" column="2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>When</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLineEdit" name="lineEdit_When"/>
</item>
<item row="4" column="2">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Other 1:</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLineEdit" name="lineEdit_Other"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>HashTags:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEdit_HashTags"/>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Image #</string>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QLineEdit" name="lineEdit_ImageNo"/>
</item>
<item row="0" column="1" colspan="3">
<widget class="QLineEdit" name="lineEdit_Name">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QTreeView" name="treeView"/>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../LinksCloud/images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,349 @@
/*
* Retroshare Photo Plugin.
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "gui/PhotoShare/PhotoSlideShow.h"
#include "gui/PhotoShare/PhotoDrop.h"
#include <iostream>
/** Constructor */
PhotoSlideShow::PhotoSlideShow(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
connect(ui.pushButton_ShiftLeft, SIGNAL( clicked( void ) ), this, SLOT( moveLeft( void ) ) );
connect(ui.pushButton_ShiftRight, SIGNAL( clicked( void ) ), this, SLOT( moveRight( void ) ) );
connect(ui.pushButton_ShowDetails, SIGNAL( clicked( void ) ), this, SLOT( showPhotoDetails( void ) ) );
connect(ui.pushButton_StartStop, SIGNAL( clicked( void ) ), this, SLOT( StartStop( void ) ) );
connect(ui.pushButton_Close, SIGNAL( clicked( void ) ), this, SLOT( closeShow( void ) ) );
mPhotoQueue = new TokenQueue(rsPhoto, this);
mRunning = true;
mShotActive = true;
mImageIdx = 0;
//loadImage();
//QTimer::singleShot(5000, this, SLOT(timerEvent()));
}
void PhotoSlideShow::showPhotoDetails()
{
}
void PhotoSlideShow::moveLeft()
{
if (mRunning)
{
return;
}
mImageIdx--;
if (mImageIdx < 0)
{
mImageIdx = mPhotos.size() - 1;
}
loadImage();
}
void PhotoSlideShow::moveRight()
{
if (mRunning)
{
return;
}
mImageIdx++;
if (mImageIdx >= mPhotos.size())
{
mImageIdx = 0;
}
loadImage();
}
void PhotoSlideShow::StartStop()
{
if (mRunning)
{
mRunning = false;
}
else
{
mRunning = true;
if (!mShotActive) // make sure only one timer running
{
mShotActive = true;
QTimer::singleShot(5000, this, SLOT(timerEvent()));
}
}
}
void PhotoSlideShow::timerEvent()
{
if (!mRunning)
{
mShotActive = false;
return;
}
mImageIdx++;
if (mImageIdx >= mPhotos.size())
{
mImageIdx = 0;
}
loadImage();
QTimer::singleShot(5000, this, SLOT(timerEvent()));
}
void PhotoSlideShow::closeShow()
{
mRunning = false;
hide();
}
void PhotoSlideShow::loadImage()
{
/* get the image */
int i = 0;
bool found = false;
std::string msgId;
//std::map<std::string, RsPhotoPhoto *>::iterator it;
std::map<int, std::string>::iterator it;
for(it = mPhotoOrder.begin(); it != mPhotoOrder.end(); it++, i++)
{
if (i == mImageIdx)
{
msgId = it->second;
found = true;
break;
}
}
RsPhotoPhoto *ptr = NULL;
if (found)
{
ptr = mPhotos[msgId];
}
if (ptr)
{
/* load into the slot */
if (ptr->mThumbnail.data != NULL)
{
QPixmap qtn;
// copy the data for Qpixmap to use.
RsPhotoThumbnail tn;
tn.copyFrom(ptr->mThumbnail);
qtn.loadFromData(tn.data, tn.size, tn.type.c_str());
tn.data = 0;
//ui.imgLabel->setPixmap(qtn);
QPixmap sqtn = qtn.scaled(ui.albumLabel->width(), ui.imgLabel->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
ui.imgLabel->setPixmap(sqtn);
}
}
}
void PhotoSlideShow::updateMoveButtons(uint32_t status)
{
std::cerr << "PhotoSlideShow::updateMoveButtons(" << status << ")";
std::cerr << std::endl;
switch(status)
{
case PHOTO_SHIFT_NO_BUTTONS:
ui.pushButton_ShiftLeft->setEnabled(false);
ui.pushButton_ShiftRight->setEnabled(false);
break;
case PHOTO_SHIFT_LEFT_ONLY:
ui.pushButton_ShiftLeft->setEnabled(true);
ui.pushButton_ShiftRight->setEnabled(false);
break;
case PHOTO_SHIFT_RIGHT_ONLY:
ui.pushButton_ShiftLeft->setEnabled(false);
ui.pushButton_ShiftRight->setEnabled(true);
break;
case PHOTO_SHIFT_BOTH:
ui.pushButton_ShiftLeft->setEnabled(true);
ui.pushButton_ShiftRight->setEnabled(true);
break;
}
}
void PhotoSlideShow::clearDialog()
{
#if 0
ui.lineEdit_Title->setText(QString("title"));
ui.lineEdit_Caption->setText(QString("Caption"));
ui.lineEdit_Where->setText(QString("Where"));
ui.lineEdit_When->setText(QString("When"));
ui.scrollAreaWidgetContents->clearPhotos();
ui.AlbumDrop->clearPhotos();
/* clean up album image */
mAlbumData.mThumbnail.deleteImage();
RsPhotoAlbum emptyAlbum;
mAlbumData = emptyAlbum;
/* add empty image */
PhotoItem *item = new PhotoItem(NULL, mAlbumData);
ui.AlbumDrop->addPhotoItem(item);
mAlbumEdit = false;
#endif
}
void PhotoSlideShow::loadAlbum(const std::string &albumId)
{
/* much like main load fns */
clearDialog();
RsTokReqOptions opts;
uint32_t token;
std::list<std::string> albumIds;
albumIds.push_back(albumId);
// We need both Album and Photo Data.
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, albumIds, 0);
}
bool PhotoSlideShow::loadPhotoData(const uint32_t &token)
{
std::cerr << "PhotoSlideShow::loadPhotoData()";
std::cerr << std::endl;
bool moreData = true;
while(moreData)
{
RsPhotoPhoto photo;
if (rsPhoto->getPhoto(token, photo))
{
RsPhotoPhoto *ptr = new RsPhotoPhoto;
*ptr = photo;
ptr->mThumbnail.data = 0;
ptr->mThumbnail.copyFrom(photo.mThumbnail);
mPhotos[photo.mMeta.mMsgId] = ptr;
mPhotoOrder[ptr->mOrder] = photo.mMeta.mMsgId;
std::cerr << "PhotoSlideShow::addAddPhoto() AlbumId: " << photo.mMeta.mGroupId;
std::cerr << " PhotoId: " << photo.mMeta.mMsgId;
std::cerr << std::endl;
}
else
{
moreData = false;
}
}
// Load and Start.
loadImage();
QTimer::singleShot(5000, this, SLOT(timerEvent()));
return true;
}
bool PhotoSlideShow::loadAlbumData(const uint32_t &token)
{
std::cerr << "PhotoSlideShow::loadAlbumData()";
std::cerr << std::endl;
bool moreData = true;
while(moreData)
{
RsPhotoAlbum album;
if (rsPhoto->getAlbum(token, album))
{
std::cerr << " PhotoSlideShow::loadAlbumData() AlbumId: " << album.mMeta.mGroupId << std::endl;
//updateAlbumDetails(album);
RsTokReqOptions opts;
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
uint32_t token;
std::list<std::string> albumIds;
albumIds.push_back(album.mMeta.mGroupId);
mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, albumIds, 0);
}
else
{
moreData = false;
}
}
return true;
}
void PhotoSlideShow::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{
std::cerr << "PhotoSlideShow::loadRequest()";
std::cerr << std::endl;
if (queue == mPhotoQueue)
{
/* now switch on req */
switch(req.mType)
{
case TOKENREQ_GROUPINFO:
loadAlbumData(req.mToken);
break;
case TOKENREQ_MSGINFO:
loadPhotoData(req.mToken);
break;
default:
std::cerr << "PhotoSlideShow::loadRequest() ERROR: GROUP: INVALID ANS TYPE";
std::cerr << std::endl;
break;
}
}
}

View File

@ -0,0 +1,92 @@
/*
* Retroshare Photo Plugin.
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef MRK_PHOTO_SLIDE_SHOW_H
#define MRK_PHOTO_SLIDE_SHOW_H
#include "ui_PhotoSlideShow.h"
#include <retroshare/rsphoto.h>
#include "util/TokenQueue.h"
class PhotoSlideShow : public QWidget, public TokenResponse
{
Q_OBJECT
public:
PhotoSlideShow(QWidget *parent = 0);
void loadAlbum(const std::string &albumId);
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
void clearDialog();
private slots:
void showPhotoDetails();
void moveLeft();
void moveRight();
void StartStop();
void timerEvent();
void closeShow();
private:
void loadImage();
void updateMoveButtons(uint32_t status);
bool loadPhotoData(const uint32_t &token);
bool loadAlbumData(const uint32_t &token);
//protected:
std::map<std::string, RsPhotoPhoto *> mPhotos;
std::map<int, std::string> mPhotoOrder;
bool mRunning;
int mImageIdx;
bool mShotActive;
TokenQueue *mPhotoQueue;
Ui::PhotoSlideShow ui;
};
#endif

View File

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PhotoSlideShow</class>
<widget class="QWidget" name="PhotoSlideShow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>747</width>
<height>671</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="albumLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Album Name</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QLabel" name="imgLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Image</string>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton_ShowDetails">
<property name="text">
<string>Show/Hide Details</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>68</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_ShiftLeft">
<property name="text">
<string>&lt;&lt;</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_StartStop">
<property name="text">
<string>Stop/Run</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_ShiftRight">
<property name="text">
<string>&gt;&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>68</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_Close">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../LinksCloud/images.qrc"/>
</resources>
<connections/>
</ui>