Update the data in photoitems

Update PhotoItem members
 - remove excessive fields in Photo
 - add RsGxsFile to Photo
 - update ShareMode for Album
 - renamed photo.mThumbnail to mLowResImage
Update Photo GUI
 - enable setting of AlbumExtra parameters.
 - added data for Ordering of photos
 - stop showing duplicates in PhotoSlideShow
This commit is contained in:
drbob 2020-03-07 00:13:25 +11:00
parent 70d1d65cbf
commit 88f76c5fbb
17 changed files with 272 additions and 339 deletions

View File

@ -43,6 +43,13 @@ struct RsGxsFile : RsSerializable
RS_SERIAL_PROCESS(mHash);
RS_SERIAL_PROCESS(mSize);
}
void clear()
{
mName.clear();
mHash.clear();
mSize = 0;
}
};
struct RsGxsImage : RsSerializable

View File

@ -34,110 +34,57 @@
class RsPhoto;
extern RsPhoto *rsPhoto;
/******************* NEW STUFF FOR NEW CACHE SYSTEM *********/
#define RSPHOTO_MODE_NEW 1
#define RSPHOTO_MODE_OWN 2
#define RSPHOTO_MODE_REMOTE 3
/* If these flags are no set - the Photo inherits values from the Album
*/
#define RSPHOTO_FLAGS_ATTRIB_TITLE 0x0001
#define RSPHOTO_FLAGS_ATTRIB_CAPTION 0x0002
#define RSPHOTO_FLAGS_ATTRIB_DESC 0x0004
#define RSPHOTO_FLAGS_ATTRIB_PHOTOGRAPHER 0x0008
#define RSPHOTO_FLAGS_ATTRIB_WHERE 0x0010
#define RSPHOTO_FLAGS_ATTRIB_WHEN 0x0020
#define RSPHOTO_FLAGS_ATTRIB_OTHER 0x0040
#define RSPHOTO_FLAGS_ATTRIB_CATEGORY 0x0080
#define RSPHOTO_FLAGS_ATTRIB_HASHTAGS 0x0100
#define RSPHOTO_FLAGS_ATTRIB_ORDER 0x0200
#define RSPHOTO_FLAGS_ATTRIB_THUMBNAIL 0x0400
#define RSPHOTO_FLAGS_ATTRIB_MODE 0x0800
#define RSPHOTO_FLAGS_ATTRIB_AUTHOR 0x1000 // PUSH UP ORDER
#define RSPHOTO_FLAGS_ATTRIB_PHOTO 0x2000 // PUSH UP ORDER.
class RsPhotoPhoto
{
public:
public:
RsMsgMetaData mMeta;
RsMsgMetaData mMeta;
RsPhotoPhoto();
RsPhotoPhoto();
// THESE ARE IN THE META DATA.
//std::string mAlbumId;
//std::string mId;
//std::string mTitle; // only used by Album.
std::string mCaption;
std::string mDescription;
std::string mPhotographer;
std::string mWhere;
std::string mWhen;
std::string mOther;
std::string mCategory;
// V2 PhotoMsg - keep it simple.
// mMeta.mTitle used for Photo Caption.
// mDescription optional field for addtional notes.
// mLowResImage - < 50k jpg of image.
// mPhotoFile - transfer details for original photo.
std::string mDescription;
uint32_t mOrder;
RsGxsImage mLowResImage;
RsGxsFile mPhotoFile;
std::string mHashTags;
uint32_t mSetFlags;
int mOrder;
RsGxsImage mThumbnail;
int mMode;
// These are not saved.
std::string path; // if in Mode NEW.
uint32_t mModFlags;
// These are not saved.
std::string mPath; // if New photo
};
class RsPhotoAlbumShare
{
public:
uint32_t mShareType;
std::string mShareGroupId;
std::string mPublishKey;
uint32_t mCommentMode;
uint32_t mResizeMode;
};
#define RSPHOTO_SHAREMODE_LOWRESONLY (1)
#define RSPHOTO_SHAREMODE_ORIGINAL (2)
#define RSPHOTO_SHAREMODE_DUP_ORIGINAL (3)
#define RSPHOTO_SHAREMODE_DUP_200K (4)
#define RSPHOTO_SHAREMODE_DUP_1M (5)
class RsPhotoAlbum
{
public:
RsPhotoAlbum();
public:
RsPhotoAlbum();
RsGroupMetaData mMeta;
RsGroupMetaData mMeta;
// THESE ARE IN THE META DATA.
//std::string mAlbumId;
//std::string mTitle; // only used by Album.
// V2 Album - keep it simple.
// mMeta.mTitle.
uint32_t mShareMode;
std::string mCaption;
std::string mDescription;
std::string mPhotographer;
std::string mWhere;
std::string mWhen;
std::string mOther;
std::string mCategory;
std::string mCaption;
std::string mDescription;
std::string mPhotographer;
std::string mWhere;
std::string mWhen;
std::string mHashTags;
RsGxsImage mThumbnail;
RsGxsImage mThumbnail;
int mMode;
std::string mPhotoPath;
RsPhotoAlbumShare mShareOptions;
// These aren't saved.
uint32_t mSetFlags;
uint32_t mModFlags;
// Below is not saved.
bool mAutoDownload;
};
std::ostream &operator<<(std::ostream &out, const RsPhotoPhoto &photo);
std::ostream &operator<<(std::ostream &out, const RsPhotoAlbum &album);
@ -145,14 +92,7 @@ typedef std::map<RsGxsGroupId, std::vector<RsPhotoPhoto> > PhotoResult;
class RsPhoto: public RsGxsIfaceHelper, public RsGxsCommentService
{
public:
static const uint32_t FLAG_MSG_TYPE_PHOTO_POST;
static const uint32_t FLAG_MSG_TYPE_PHOTO_COMMENT;
static const uint32_t FLAG_MSG_TYPE_MASK;
explicit RsPhoto(RsGxsIface &gxs) : RsGxsIfaceHelper(gxs) { return; }
virtual ~RsPhoto() { return; }

View File

@ -42,55 +42,44 @@ RsItem *RsGxsPhotoSerialiser::create_item(uint16_t service, uint8_t item_sub_id)
void RsGxsPhotoAlbumItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process<uint32_t>(j,ctx,TLV_TYPE_UINT32_PARAM,album.mShareMode,"mShareMode");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_CAPTION, album.mCaption, "mCaption");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_CATEGORY, album.mCategory, "mCategory");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR, album.mDescription, "mDescription");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_HASH_TAG, album.mHashTags, "mHashTags");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG, album.mOther, "mOther");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_PATH, album.mPhotoPath, "mPhotoPath");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME, album.mPhotographer, "mPhotographer");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DATE, album.mWhen, "mWhen");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_LOCATION, album.mWhere, "mWhere");
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DATE, album.mWhen, "mWhen");
album.mThumbnail.serial_process(j, ctx);
}
void RsGxsPhotoPhotoItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CAPTION, photo.mCaption, "mCaption");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CATEGORY, photo.mCategory, "mCategory");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DESCR, photo.mDescription, "mDescription");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_HASH_TAG, photo.mHashTags, "mHashTags");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_MSG, photo.mOther, "mOther");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_PIC_AUTH, photo.mPhotographer, "mPhotographer");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DATE, photo.mWhen, "mWhen");
RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_LOCATION, photo.mWhere, "mWhere");
photo.mThumbnail.serial_process(j, ctx);
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR, photo.mDescription, "mDescription");
RsTypeSerializer::serial_process<uint32_t>(j,ctx,TLV_TYPE_UINT32_PARAM,photo.mOrder,"mOrder");
photo.mLowResImage.serial_process(j, ctx);
photo.mPhotoFile.serial_process(j, ctx);
}
void RsGxsPhotoAlbumItem::clear()
{
album.mShareMode = RSPHOTO_SHAREMODE_LOWRESONLY;
album.mCaption.clear();
album.mCategory.clear();
album.mDescription.clear();
album.mHashTags.clear();
album.mOther.clear();
album.mPhotoPath.clear();
album.mPhotographer.clear();
album.mWhen.clear();
album.mWhere.clear();
album.mWhen.clear();
album.mThumbnail.clear();
// not saved
album.mAutoDownload = false;
}
void RsGxsPhotoPhotoItem::clear()
{
photo.mCaption.clear();
photo.mCategory.clear();
photo.mDescription.clear();
photo.mHashTags.clear();
photo.mOther.clear();
photo.mPhotographer.clear();
photo.mWhen.clear();
photo.mWhere.clear();
photo.mThumbnail.clear();
photo.mOrder = 0;
photo.mLowResImage.clear();
photo.mPhotoFile.clear();
// not saved
photo.mPath.clear();
}

View File

@ -25,19 +25,14 @@
RsPhoto *rsPhoto = NULL;
const uint32_t RsPhoto::FLAG_MSG_TYPE_MASK = 0x000f;
const uint32_t RsPhoto::FLAG_MSG_TYPE_PHOTO_POST = 0x0001;
const uint32_t RsPhoto::FLAG_MSG_TYPE_PHOTO_COMMENT = 0x0002;
RsPhotoPhoto::RsPhotoPhoto()
:mSetFlags(0), mOrder(0), mMode(0), mModFlags(0)
:mOrder(0)
{
return;
}
RsPhotoAlbum::RsPhotoAlbum()
:mMode(0), mSetFlags(0), mModFlags(0)
:mShareMode(RSPHOTO_SHAREMODE_LOWRESONLY), mAutoDownload(false)
{
return;
}

View File

@ -59,7 +59,6 @@ void AlbumDialog::setUp()
{
ui->lineEdit_Title->setText(QString::fromStdString(mAlbum.mMeta.mGroupName));
ui->lineEdit_Caption->setText(QString::fromStdString(mAlbum.mCaption));
ui->lineEdit_Category->setText(QString::fromStdString(mAlbum.mCategory));
if (mAlbum.mThumbnail.mSize != 0)
{
@ -121,7 +120,7 @@ void AlbumDialog::updateAlbumPhotos()
// flag image as Deleted.
// clear image.
// clear file URL (todo)
photo.mThumbnail.clear();
photo.mLowResImage.clear();
}
break;
}
@ -221,7 +220,6 @@ void AlbumDialog::loadPhotoData(const uint32_t &token)
rsPhoto->getPhoto(token, res);
PhotoResult::iterator mit = res.begin();
for (; mit != res.end(); ++mit)
{
std::vector<RsPhotoPhoto>& photoV = mit->second;
@ -230,8 +228,7 @@ void AlbumDialog::loadPhotoData(const uint32_t &token)
for (; vit != photoV.end(); ++vit)
{
RsPhotoPhoto& photo = *vit;
if (!photo.mThumbnail.empty()) {
if (!photo.mLowResImage.empty()) {
addPhoto(photo);
}
}
@ -287,5 +284,3 @@ void AlbumDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
}
/**************************** Request / Response Filling of Data ************************/

View File

@ -22,16 +22,16 @@
#include "ui_AlbumExtra.h"
AlbumExtra::AlbumExtra(QWidget *parent) :
QWidget(NULL),
ui(new Ui::AlbumExtra)
QWidget(NULL),
ui(new Ui::AlbumExtra)
{
ui->setupUi(this);
setUp();
ui->setupUi(this);
setUp();
}
AlbumExtra::~AlbumExtra()
{
delete ui;
delete ui;
}
void AlbumExtra::setUp()
@ -39,3 +39,53 @@ void AlbumExtra::setUp()
}
void AlbumExtra::setShareMode(uint32_t mode)
{
ui->comboBox_shareMode->setCurrentIndex(mode);
}
void AlbumExtra::setCaption(const std::string &str)
{
ui->lineEdit_Caption->setText(QString::fromStdString(str));
}
void AlbumExtra::setPhotographer(const std::string &str)
{
ui->lineEdit_Photographer->setText(QString::fromStdString(str));
}
void AlbumExtra::setWhere(const std::string &str)
{
ui->lineEdit_Where->setText(QString::fromStdString(str));
}
void AlbumExtra::setWhen(const std::string &str)
{
ui->lineEdit_When->setText(QString::fromStdString(str));
}
uint32_t AlbumExtra::getShareMode()
{
return ui->comboBox_shareMode->currentIndex();
}
std::string AlbumExtra::getCaption()
{
return ui->lineEdit_Caption->text().toStdString();
}
std::string AlbumExtra::getPhotographer()
{
return ui->lineEdit_Photographer->text().toStdString();
}
std::string AlbumExtra::getWhere()
{
return ui->lineEdit_Where->text().toStdString();
}
std::string AlbumExtra::getWhen()
{
return ui->lineEdit_When->text().toStdString();
}

View File

@ -24,21 +24,33 @@
#include <QWidget>
namespace Ui {
class AlbumExtra;
class AlbumExtra;
}
class AlbumExtra : public QWidget
{
Q_OBJECT
Q_OBJECT
public:
explicit AlbumExtra(QWidget *parent = 0);
virtual ~AlbumExtra();
explicit AlbumExtra(QWidget *parent = 0);
virtual ~AlbumExtra();
void setShareMode(uint32_t mode);
void setCaption(const std::string &str);
void setPhotographer(const std::string &str);
void setWhere(const std::string &str);
void setWhen(const std::string &str);
uint32_t getShareMode();
std::string getCaption();
std::string getPhotographer();
std::string getWhere();
std::string getWhen();
private:
void setUp();
void setUp();
private:
Ui::AlbumExtra *ui;
Ui::AlbumExtra *ui;
};
#endif // ALBUMEXTRA_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>513</width>
<height>198</height>
<width>516</width>
<height>199</height>
</rect>
</property>
<property name="sizePolicy">
@ -21,119 +21,73 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Category:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_Category_2">
<item>
<property name="text">
<string>Animals</string>
</property>
</item>
<item>
<property name="text">
<string>Family</string>
</property>
</item>
<item>
<property name="text">
<string>Friends</string>
</property>
</item>
<item>
<property name="text">
<string>Flowers</string>
</property>
</item>
<item>
<property name="text">
<string>Holiday</string>
</property>
</item>
<item>
<property name="text">
<string>Landscapes</string>
</property>
</item>
<item>
<property name="text">
<string>Pets</string>
</property>
</item>
<item>
<property name="text">
<string>Portraits</string>
</property>
</item>
<item>
<property name="text">
<string>Travel</string>
</property>
</item>
<item>
<property name="text">
<string>Work</string>
</property>
</item>
<item>
<property name="text">
<string>Random</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Quality:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox_5">
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_shareMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Embedded Only (&lt;50Kb)</string>
</property>
</item>
<item>
<property name="text">
<string>Share Original Images</string>
</property>
</item>
<item>
<property name="text">
<string>Copy Original Images (extra disk space)</string>
</property>
</item>
<item>
<property name="text">
<string>Resize Images (&lt; 200Kb)</string>
</property>
</item>
<item>
<property name="text">
<string>Resize Images (&lt; 1Mb)</string>
</property>
</item>
<item>
<property name="text">
<string>Resize Images (&lt; 10Mb)</string>
</property>
</item>
<item>
<property name="text">
<string>Send Original Images</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="1" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<widget class="QLabel" name="captionLabel">
<property name="text">
<string>Caption:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_Caption"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Photographer:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_Caption_2"/>
<widget class="QLineEdit" name="lineEdit_Photographer"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_14">
@ -146,14 +100,14 @@
<widget class="QLineEdit" name="lineEdit_Where"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_12">
<widget class="QLabel" name="label">
<property name="text">
<string>Photographer:</string>
<string>When:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEdit_Photographer"/>
<widget class="QLineEdit" name="lineEdit_When"/>
</item>
</layout>
</widget>

View File

@ -26,8 +26,8 @@
#include <iostream>
const uint32_t AlbumCreateEnabledFlags = (
GXS_GROUP_FLAGS_NAME |
GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_NAME |
GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION |
// GXS_GROUP_FLAGS_PUBLISHSIGN |
@ -93,7 +93,8 @@ void AlbumGroupDialog::initUi()
setUiText(UITYPE_CONTACTS_DOCK, tr("Select Album Admins"));
// Inject Extra Widgets.
injectExtraWidget(new AlbumExtra(this));
mAlbumExtra = new AlbumExtra(this);
injectExtraWidget(mAlbumExtra);
}
QPixmap AlbumGroupDialog::serviceImage()
@ -120,11 +121,12 @@ void AlbumGroupDialog::prepareAlbumGroup(RsPhotoAlbum &group, const RsGroupMetaD
group.mThumbnail.clear();
}
// Additional Fields that we need to fill in.
group.mCaption = "Caption goes here";
group.mPhotographer = "photographer";
group.mWhere = "Where?";
// Additional Fields.
group.mShareMode = mAlbumExtra->getShareMode();
group.mCaption = mAlbumExtra->getCaption();
group.mPhotographer = mAlbumExtra->getPhotographer();
group.mWhere = mAlbumExtra->getWhere();
group.mWhen = mAlbumExtra->getWhen();
}
bool AlbumGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
@ -186,6 +188,12 @@ bool AlbumGroupDialog::service_loadGroup(uint32_t token, Mode /*mode*/, RsGroupM
setLogo(QPixmap(":/images/album_create_64.png"));
}
// NEED TO Load additional data....
// Load additional data....
mAlbumExtra->setShareMode(group.mShareMode);
mAlbumExtra->setCaption(group.mCaption);
mAlbumExtra->setPhotographer(group.mPhotographer);
mAlbumExtra->setWhere(group.mWhere);
mAlbumExtra->setWhen(group.mWhen);
return true;
}

View File

@ -25,6 +25,8 @@
#include "gui/gxs/GxsGroupDialog.h"
#include <retroshare/rsphoto.h>
#include "AlbumExtra.h"
class AlbumGroupDialog : public GxsGroupDialog
{
Q_OBJECT
@ -42,6 +44,7 @@ protected:
private:
void prepareAlbumGroup(RsPhotoAlbum &group, const RsGroupMetaData &meta);
AlbumExtra *mAlbumExtra;
};
#endif

View File

@ -50,7 +50,7 @@ PhotoDialog::~PhotoDialog()
void PhotoDialog::setUp()
{
QPixmap qtn;
qtn.loadFromData(mPhotoDetails.mThumbnail.mData, mPhotoDetails.mThumbnail.mSize, "PNG");
qtn.loadFromData(mPhotoDetails.mLowResImage.mData, mPhotoDetails.mLowResImage.mSize);
ui->label_Photo->setPixmap(qtn);
ui->label_Photo->setVisible(true);

View File

@ -48,16 +48,15 @@ class gridIndex
};
#define DEFAULT_ORDER_INCREMENT (100)
PhotoDrop::PhotoDrop(QWidget *parent)
: QWidget(parent)
:QWidget(parent), mLastOrder(0)
{
setAcceptDrops(true);
mSelected = NULL;
checkMoveButtons();
checkMoveButtons();
reorderPhotos();
}
@ -80,7 +79,7 @@ void PhotoDrop::resizeEvent ( QResizeEvent * event )
reorderPhotos();
}
int PhotoDrop::getPhotoCount()
int PhotoDrop::getPhotoCount()
{
std::cerr << "PhotoDrop::getPhotoCount()";
std::cerr << std::endl;
@ -147,7 +146,7 @@ PhotoItem *PhotoDrop::getPhotoIdx(int idx)
void PhotoDrop::getPhotos(QSet<PhotoItem *> &photos)
{
photos = mPhotos;
photos = mPhotos;
}
@ -453,7 +452,7 @@ void PhotoDrop::checkMoveButtons()
int count = alayout->count();
if ((!mSelected) || (count < 2))
{
buttonStatus(PHOTO_SHIFT_NO_BUTTONS);
buttonStatus(PHOTO_SHIFT_NO_BUTTONS);
return;
}
@ -462,7 +461,7 @@ void PhotoDrop::checkMoveButtons()
{
std::cerr << "PhotoDrop::checkMoveButtons() not GridLayout... not much we can do!";
std::cerr << std::endl;
buttonStatus(PHOTO_SHIFT_NO_BUTTONS);
buttonStatus(PHOTO_SHIFT_NO_BUTTONS);
return;
}
@ -477,15 +476,15 @@ void PhotoDrop::checkMoveButtons()
int maxCol = (count - 1) % mColumns;
if ((selectedRow == 0) && (selectedColumn == 0))
{
buttonStatus(PHOTO_SHIFT_RIGHT_ONLY);
buttonStatus(PHOTO_SHIFT_RIGHT_ONLY);
}
else if ((selectedRow == maxRow) && (selectedColumn == maxCol))
{
buttonStatus(PHOTO_SHIFT_LEFT_ONLY);
buttonStatus(PHOTO_SHIFT_LEFT_ONLY);
}
else
{
buttonStatus(PHOTO_SHIFT_BOTH);
buttonStatus(PHOTO_SHIFT_BOTH);
}
}
@ -547,17 +546,6 @@ void PhotoDrop::dragEnterEvent(QDragEnterEvent *event)
std::cerr << "PhotoDrop::dragEnterEvent()";
std::cerr << std::endl;
#if 0
const QStringList& formats = event->mimeData()->formats();
std::cerr << "dragEnterEvent() Formats" << std::endl;
QStringList::const_iterator it;
for (it = formats.begin(); it != formats.end(); ++it) {
std::cerr << "Format: " << (*it).toStdString();
std::cerr << std::endl;
}
#endif
if (event->mimeData()->hasUrls())
{
std::cerr << "PhotoDrop::dragEnterEvent() Accepting";
@ -589,8 +577,8 @@ void PhotoDrop::dragMoveEvent(QDragMoveEvent *event)
std::cerr << "PhotoDrop::dragMoveEvent()";
std::cerr << std::endl;
event->accept();
//event->ignore();
event->accept();
//event->ignore();
}
void PhotoDrop::dropEvent(QDropEvent *event)
@ -611,11 +599,11 @@ void PhotoDrop::dropEvent(QDropEvent *event)
std::cerr << "Whole URL: " << uit->toString().toStdString() << std::endl;
std::cerr << "or As Local File: " << localpath.toStdString() << std::endl;
PhotoItem* item = new PhotoItem(mHolder, localpath);
addPhotoItem(item);
PhotoItem* item = new PhotoItem(mHolder, localpath, mLastOrder+DEFAULT_ORDER_INCREMENT);
addPhotoItem(item);
}
event->setDropAction(Qt::CopyAction);
event->accept();
event->setDropAction(Qt::CopyAction);
event->accept();
// Notify Listeners. (only happens for drop - not programmatically added).
photosChanged();
@ -624,17 +612,17 @@ void PhotoDrop::dropEvent(QDropEvent *event)
{
std::cerr << "PhotoDrop::dropEvent Ignoring";
std::cerr << std::endl;
event->ignore();
event->ignore();
}
checkMoveButtons();
checkMoveButtons();
}
void PhotoDrop::mousePressEvent(QMouseEvent *event)
{
/* see if this is in the space of one of our children */
QPoint pos = event->pos();
QPoint pos = event->pos();
std::cerr << "PhotoDrop::mousePressEvent(" << pos.x() << ", " << pos.y() << ")";
std::cerr << std::endl;
@ -644,7 +632,7 @@ void PhotoDrop::mousePressEvent(QMouseEvent *event)
void PhotoDrop::setPhotoItemHolder(PhotoShareItemHolder *holder)
{
mHolder = holder;
mHolder = holder;
}
void PhotoDrop::addPhotoItem(PhotoItem *item)
@ -652,20 +640,25 @@ void PhotoDrop::addPhotoItem(PhotoItem *item)
std::cerr << "PhotoDrop::addPhotoItem()";
std::cerr << std::endl;
mPhotos.insert(item);
// record lastOrder number
// so any new photos can be added after this.
if (item->getPhotoDetails().mOrder > mLastOrder) {
mLastOrder = item->getPhotoDetails().mOrder;
}
mPhotos.insert(item);
layout()->addWidget(item);
//checkMoveButtons();
//checkMoveButtons();
}
bool PhotoDrop::deletePhoto(PhotoItem *item)
{
if(mPhotos.contains(item)){
mPhotos.remove(item);
layout()->removeWidget(item);
delete item;
}
else
return false;
if (mPhotos.contains(item)) {
mPhotos.remove(item);
layout()->removeWidget(item);
delete item;
}
else
return false;
}

View File

@ -55,7 +55,7 @@ public:
PhotoItem *getPhotoIdx(int idx);
void getPhotos(QSet<PhotoItem*>& photos);
void addPhotoItem(PhotoItem *item);
void addPhotoItem(PhotoItem *item);
void setPhotoItemHolder(PhotoShareItemHolder* holder);
/*!
@ -91,8 +91,9 @@ private:
PhotoItem *mSelected;
int mColumns;
PhotoShareItemHolder* mHolder;
QSet<PhotoItem*> mPhotos;
PhotoShareItemHolder* mHolder;
QSet<PhotoItem*> mPhotos;
uint32_t mLastOrder;
};
#endif

View File

@ -49,7 +49,7 @@ PhotoItem::PhotoItem(PhotoShareItemHolder *holder, const RsPhotoPhoto &photo, QW
ui->idChooser->setVisible(false);
}
PhotoItem::PhotoItem(PhotoShareItemHolder *holder, const QString& path, QWidget *parent) :
PhotoItem::PhotoItem(PhotoShareItemHolder *holder, const QString& path, uint32_t order, QWidget *parent) :
QWidget(parent),
ui(new Ui::PhotoItem), mHolder(holder)
{
@ -57,25 +57,20 @@ PhotoItem::PhotoItem(PhotoShareItemHolder *holder, const QString& path, QWidget
ui->setupUi(this);
mPhotoDetails.mOrder = order;
QPixmap qtn = QPixmap(path);
// TODO need to scale qtn to something reasonable.
// shouldn't be call thumbnail... we can do a lowRes version.
// do we need to to workout what type of file to convert to?
// jpg, png etc.
// seperate fn should handle all of this.
mThumbNail = qtn.scaled(480,480, Qt::KeepAspectRatio, Qt::SmoothTransformation);
mLowResImage = qtn.scaled(512,512, Qt::KeepAspectRatio, Qt::SmoothTransformation);
ui->label_Thumbnail->setPixmap(qtn.scaled(120, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation));
ui->label_Thumbnail->setPixmap(qtn.scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation));
setSelected(false);
getThumbnail(mPhotoDetails.mThumbnail);
getLowResImage(mPhotoDetails.mLowResImage);
connect(ui->lineEdit_Title, SIGNAL(editingFinished()), this, SLOT(setTitle()));
connect(ui->lineEdit_PhotoGrapher, SIGNAL(editingFinished()), this, SLOT(setPhotoGrapher()));
ui->idChooser->loadIds(0, RsGxsId());
}
void PhotoItem::markForDeletion()
@ -114,29 +109,6 @@ void PhotoItem::setSelected(bool selected)
update();
}
bool PhotoItem::getThumbnail(RsGxsImage &image)
{
const QPixmap *tmppix = &mThumbNail;
QByteArray ba;
QBuffer buffer(&ba);
if(!tmppix->isNull())
{
// send chan image
buffer.open(QIODevice::WriteOnly);
tmppix->save(&buffer, "PNG"); // writes image into ba in PNG format
image.copy((uint8_t *) ba.data(), ba.size());
return true;
}
image.clear();
return false;
}
void PhotoItem::setTitle(){
mPhotoDetails.mMeta.mMsgName = ui->lineEdit_Title->text().toStdString();
@ -144,13 +116,11 @@ void PhotoItem::setTitle(){
void PhotoItem::setPhotoGrapher()
{
mPhotoDetails.mPhotographer = ui->lineEdit_PhotoGrapher->text().toStdString();
// mPhotoDetails.mPhotographer = ui->lineEdit_PhotoGrapher->text().toStdString();
}
const RsPhotoPhoto& PhotoItem::getPhotoDetails()
{
if (ui->idChooser->isVisible()) {
RsGxsId id;
switch (ui->idChooser->getChosenId(id)) {
@ -176,18 +146,34 @@ PhotoItem::~PhotoItem()
void PhotoItem::setUp()
{
mTitleLabel = new QLabel();
mPhotoGrapherLabel = new QLabel();
mTitleLabel->setText(QString::fromStdString(mPhotoDetails.mMeta.mMsgName));
mPhotoGrapherLabel->setText(QString::fromStdString(mPhotoDetails.mPhotographer));
ui->editLayOut->addWidget(mPhotoGrapherLabel);
ui->editLayOut->addWidget(mTitleLabel);
updateImage(mPhotoDetails.mThumbnail);
updateImage(mPhotoDetails.mLowResImage);
}
bool PhotoItem::getLowResImage(RsGxsImage &image)
{
const QPixmap *tmppix = &mLowResImage;
QByteArray ba;
QBuffer buffer(&ba);
if(!tmppix->isNull())
{
buffer.open(QIODevice::WriteOnly);
tmppix->save(&buffer, "JPG");
image.copy((uint8_t *) ba.data(), ba.size());
return true;
}
image.clear();
return false;
}
void PhotoItem::updateImage(const RsGxsImage &image)
@ -195,9 +181,9 @@ void PhotoItem::updateImage(const RsGxsImage &image)
if (image.mData != NULL)
{
QPixmap qtn;
qtn.loadFromData(image.mData, image.mSize, "PNG");
ui->label_Thumbnail->setPixmap(qtn.scaled(120, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation));
mThumbNail = qtn;
qtn.loadFromData(image.mData, image.mSize);
ui->label_Thumbnail->setPixmap(qtn.scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation));
mLowResImage = qtn;
}
}

View File

@ -39,12 +39,12 @@ public:
enum State { New, Existing, Modified, Deleted };
PhotoItem(PhotoShareItemHolder *holder, const RsPhotoPhoto& photo, QWidget* parent = 0);
PhotoItem(PhotoShareItemHolder *holder, const QString& path, QWidget* parent = 0); // for new photos.
PhotoItem(PhotoShareItemHolder *holder, const QString& path, uint32_t order, QWidget* parent = 0); // for new photos.
~PhotoItem();
void setSelected(bool selected);
bool isSelected(){ return mSelected; }
const RsPhotoPhoto& getPhotoDetails();
bool getThumbnail(RsGxsImage &image);
bool getLowResImage(RsGxsImage &image);
void markForDeletion();
State getState() { return mState; }
@ -62,9 +62,9 @@ private:
private:
Ui::PhotoItem *ui;
QPixmap mThumbNail;
QPixmap mLowResImage;
QPixmap getPixmap() { return mThumbNail; }
QPixmap getPixmap() { return mLowResImage; }
bool mSelected;
State mState;

View File

@ -436,7 +436,7 @@ void PhotoShare::addAlbum(const RsPhotoAlbum &album)
void PhotoShare::addPhoto(const RsPhotoPhoto &photo)
{
if (!photo.mThumbnail.empty())
if (!photo.mLowResImage.empty())
{
PhotoItem* item = new PhotoItem(this, photo, this);
mPhotoItems.insert(item);

View File

@ -176,10 +176,10 @@ void PhotoSlideShow::loadImage()
if (ptr)
{
/* load into the slot */
if (ptr->mThumbnail.mData != NULL)
if (ptr->mLowResImage.mData != NULL)
{
QPixmap qtn;
GxsIdDetails::loadPixmapFromData(ptr->mThumbnail.mData, ptr->mThumbnail.mSize,qtn, GxsIdDetails::ORIGINAL);
GxsIdDetails::loadPixmapFromData(ptr->mLowResImage.mData, ptr->mLowResImage.mSize,qtn, GxsIdDetails::ORIGINAL);
QPixmap sqtn = qtn.scaled(800, 600, Qt::KeepAspectRatio, Qt::SmoothTransformation);
ui.imgLabel->setPixmap(sqtn);
@ -218,6 +218,7 @@ void PhotoSlideShow::requestPhotos()
{
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
uint32_t token;
std::list<RsGxsGroupId> grpIds;
grpIds.push_back(mAlbum.mMeta.mGroupId);
@ -245,8 +246,7 @@ bool PhotoSlideShow::loadPhotoData(const uint32_t &token)
RsPhotoPhoto *ptr = new RsPhotoPhoto;
*ptr = photo;
ptr->mThumbnail = photo.mThumbnail; // copies data.
ptr->mOrder = i++;
ptr->mLowResImage = photo.mLowResImage; // copies data.
mPhotos[photo.mMeta.mMsgId] = ptr;
mPhotoOrder[ptr->mOrder] = photo.mMeta.mMsgId;