diff --git a/libretroshare/src/retroshare/rsgxscommon.h b/libretroshare/src/retroshare/rsgxscommon.h index 126c2b51f..723731e88 100644 --- a/libretroshare/src/retroshare/rsgxscommon.h +++ b/libretroshare/src/retroshare/rsgxscommon.h @@ -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 diff --git a/libretroshare/src/retroshare/rsphoto.h b/libretroshare/src/retroshare/rsphoto.h index 9c41e5377..8109164a7 100644 --- a/libretroshare/src/retroshare/rsphoto.h +++ b/libretroshare/src/retroshare/rsphoto.h @@ -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 > 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; } diff --git a/libretroshare/src/rsitems/rsphotoitems.cc b/libretroshare/src/rsitems/rsphotoitems.cc index 77a920fd6..f9200a83c 100644 --- a/libretroshare/src/rsitems/rsphotoitems.cc +++ b/libretroshare/src/rsitems/rsphotoitems.cc @@ -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(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(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(); } diff --git a/libretroshare/src/services/p3photoservice.cc b/libretroshare/src/services/p3photoservice.cc index 7a0e3bd9c..469fee65e 100644 --- a/libretroshare/src/services/p3photoservice.cc +++ b/libretroshare/src/services/p3photoservice.cc @@ -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; } diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumDialog.cpp b/retroshare-gui/src/gui/PhotoShare/AlbumDialog.cpp index 2115e5899..e163e7104 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumDialog.cpp +++ b/retroshare-gui/src/gui/PhotoShare/AlbumDialog.cpp @@ -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& 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 ************************/ - - diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumExtra.cpp b/retroshare-gui/src/gui/PhotoShare/AlbumExtra.cpp index c6ddf6e17..010e7ded2 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumExtra.cpp +++ b/retroshare-gui/src/gui/PhotoShare/AlbumExtra.cpp @@ -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(); +} + diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumExtra.h b/retroshare-gui/src/gui/PhotoShare/AlbumExtra.h index 1a932bcaa..bea24f4b3 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumExtra.h +++ b/retroshare-gui/src/gui/PhotoShare/AlbumExtra.h @@ -24,21 +24,33 @@ #include 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 diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumExtra.ui b/retroshare-gui/src/gui/PhotoShare/AlbumExtra.ui index 09780a77a..23b0a462f 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumExtra.ui +++ b/retroshare-gui/src/gui/PhotoShare/AlbumExtra.ui @@ -6,8 +6,8 @@ 0 0 - 513 - 198 + 516 + 199 @@ -21,119 +21,73 @@ - - - Category: - - - - - - - - Animals - - - - - Family - - - - - Friends - - - - - Flowers - - - - - Holiday - - - - - Landscapes - - - - - Pets - - - - - Portraits - - - - - Travel - - - - - Work - - - - - Random - - - - - Quality: - - + + 0 0 + + + Embedded Only (<50Kb) + + + + + Share Original Images + + + + + Copy Original Images (extra disk space) + + + + + Resize Images (< 200Kb) + + Resize Images (< 1Mb) - - - Resize Images (< 10Mb) - - - - - Send Original Images - - - + Qt::Horizontal - + Caption: + + + + + + + Photographer: + + + - + @@ -146,14 +100,14 @@ - + - Photographer: + When: - + diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.cpp b/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.cpp index b4bd3634f..760a6586f 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.cpp +++ b/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.cpp @@ -26,8 +26,8 @@ #include 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; } diff --git a/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.h b/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.h index a06ce3461..565363f85 100644 --- a/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.h +++ b/retroshare-gui/src/gui/PhotoShare/AlbumGroupDialog.h @@ -25,6 +25,8 @@ #include "gui/gxs/GxsGroupDialog.h" #include +#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 diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp index 6251dc38f..3aee8e110 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoDialog.cpp @@ -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); diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoDrop.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoDrop.cpp index f092d2e02..d8fc76e0f 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoDrop.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoDrop.cpp @@ -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 &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; } diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoDrop.h b/retroshare-gui/src/gui/PhotoShare/PhotoDrop.h index 4b862eaf6..0b2ed55bc 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoDrop.h +++ b/retroshare-gui/src/gui/PhotoShare/PhotoDrop.h @@ -55,7 +55,7 @@ public: PhotoItem *getPhotoIdx(int idx); void getPhotos(QSet& 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 mPhotos; + PhotoShareItemHolder* mHolder; + QSet mPhotos; + uint32_t mLastOrder; }; #endif diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp index f98346e00..e30c321dd 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoItem.cpp @@ -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; } } diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoItem.h b/retroshare-gui/src/gui/PhotoShare/PhotoItem.h index bdf03375e..376973a11 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoItem.h +++ b/retroshare-gui/src/gui/PhotoShare/PhotoItem.h @@ -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; diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoShare.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoShare.cpp index 042430fa6..3fe022bde 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoShare.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoShare.cpp @@ -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); diff --git a/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp b/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp index 7e5fb6d00..545d84894 100644 --- a/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp +++ b/retroshare-gui/src/gui/PhotoShare/PhotoSlideShow.cpp @@ -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 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;