Added PhotoShare Plugin to Retroshare.

- Like the Wiki, this is GUI without a backend.... so we can get this part right first.
	- Added Bits to compile into Retroshare too.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@4888 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-02-04 14:06:37 +00:00
parent 42acb5007e
commit 35ab646aa2
18 changed files with 3516 additions and 1 deletions

View File

@ -1,4 +1,6 @@
CONFIG += qt gui uic qrc resources uitools idle bitdht # framecatcher# blogs CONFIG += qt gui uic qrc resources uitools idle bitdht
CONFIG += photoshare wikipoos
QT += network xml script QT += network xml script
TEMPLATE = app TEMPLATE = app
@ -843,3 +845,45 @@ minimal {
util/stringutil.h \ util/stringutil.h \
lang/languagesupport.h lang/languagesupport.h
} }
photoshare {
HEADERS += gui/PhotoShare/PhotoItem.h \
gui/PhotoShare/PhotoDialog.h \
gui/PhotoShare/PhotoAddDialog.h \
gui/PhotoShare/PhotoDetailsDialog.h \
gui/PhotoShare/PhotoDrop.h \
FORMS += gui/PhotoShare/PhotoItem.ui \
gui/PhotoShare/PhotoDialog.ui \
gui/PhotoShare/PhotoAddDialog.ui \
gui/PhotoShare/PhotoDetailsDialog.ui \
SOURCES += gui/PhotoShare/PhotoItem.cpp \
gui/PhotoShare/PhotoDialog.cpp \
gui/PhotoShare/PhotoAddDialog.cpp \
gui/PhotoShare/PhotoDetailsDialog.cpp \
gui/PhotoShare/PhotoDrop.cpp \
}
wikipoos {
HEADERS += gui/WikiPoos/WikiDialog.h \
gui/WikiPoos/WikiAddDialog.h \
gui/WikiPoos/WikiEditDialog.h \
FORMS += gui/WikiPoos/WikiDialog.ui \
gui/WikiPoos/WikiAddDialog.ui \
gui/WikiPoos/WikiEditDialog.ui \
SOURCES += gui/WikiPoos/WikiDialog.cpp \
gui/WikiPoos/WikiAddDialog.cpp \
gui/WikiPoos/WikiEditDialog.cpp \
}

View File

@ -57,6 +57,10 @@
#include "chat/PopupChatDialog.h" #include "chat/PopupChatDialog.h"
#include "RetroShareLink.h" #include "RetroShareLink.h"
// New Cache Classes -
#include "gui/PhotoShare/PhotoDialog.h"
#include "gui/WikiPoos/WikiDialog.h"
#ifdef UNFINISHED #ifdef UNFINISHED
#include "unfinished/ApplicationWindow.h" #include "unfinished/ApplicationWindow.h"
#endif #endif
@ -316,6 +320,17 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
} }
#endif #endif
// New Cache Classes -
MainPage *photoPage = NULL;
ui.stackPages->add(photoPage = new PhotoDialog(ui.stackPages),
createPageAction(QIcon(IMG_HELP), tr("PhotoShare"), grp));
// New Cache Classes -
MainPage *wikiPage = NULL;
ui.stackPages->add(wikiPage = new WikiDialog(ui.stackPages),
createPageAction(QIcon(IMG_HELP), tr("WikiPoos"), grp));
/* Create the toolbar */ /* Create the toolbar */
ui.toolBar->addActions(grp->actions()); ui.toolBar->addActions(grp->actions());

View File

@ -0,0 +1,162 @@
/*
* 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/PhotoAddDialog.h"
#include "gui/PhotoShare/PhotoDetailsDialog.h"
#include "gui/PhotoShare/PhotoDrop.h"
#include <iostream>
/** Constructor */
PhotoAddDialog::PhotoAddDialog(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
connect(ui.scrollAreaWidgetContents, SIGNAL( buttonStatus( uint32_t ) ), this, SLOT( updateMoveButtons( uint32_t ) ) );
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_EditPhotoDetails, SIGNAL( clicked( void ) ), this, SLOT( showPhotoDetails( void ) ) );
connect(ui.pushButton_Publish, SIGNAL( clicked( void ) ), this, SLOT( publishAlbum( void ) ) );
mPhotoDetails = NULL;
}
void PhotoAddDialog::updateMoveButtons(uint32_t status)
{
std::cerr << "PhotoAddDialog::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 PhotoAddDialog::showPhotoDetails()
{
std::cerr << "PhotoAddDialog::showPhotoDetails()";
std::cerr << std::endl;
if (!mPhotoDetails)
{
mPhotoDetails = new PhotoDetailsDialog(NULL);
}
PhotoItem *item = ui.scrollAreaWidgetContents->getSelectedPhotoItem();
mPhotoDetails->setPhotoItem(item);
mPhotoDetails->show();
}
void PhotoAddDialog::publishAlbum()
{
std::cerr << "PhotoAddDialog::publishAlbum()";
std::cerr << std::endl;
/* we need to iterate through each photoItem, and extract the details */
RsPhotoAlbum album;
RsPhotoThumbnail albumThumb;
album.mShareOptions.mShareType = 0;
album.mShareOptions.mShareGroupId = "unknown";
album.mShareOptions.mPublishKey = "unknown";
album.mShareOptions.mCommentMode = 0;
album.mShareOptions.mResizeMode = 0;
album.mTitle = ui.lineEdit_Title->text().toStdString();
album.mCategory = "Unknown";
album.mCaption = ui.lineEdit_Caption->text().toStdString();
album.mWhere = ui.lineEdit_Where->text().toStdString();
album.mWhen = ui.lineEdit_When->text().toStdString();
if (rsPhoto->submitAlbumDetails(album, albumThumb))
{
/* now have path and album id */
int photoCount = ui.scrollAreaWidgetContents->getPhotoCount();
for(int i = 0; i < photoCount; i++)
{
RsPhotoPhoto photo;
RsPhotoThumbnail thumbnail;
PhotoItem *item = ui.scrollAreaWidgetContents->getPhotoIdx(i);
photo = item->mDetails;
item->getPhotoThumbnail(thumbnail);
photo.mAlbumId = album.mAlbumId;
photo.mOrder = i;
/* scale photo if needed */
if (album.mShareOptions.mResizeMode)
{
/* */
}
/* save image to album path */
photo.path = "unknown";
rsPhoto->submitPhoto(photo, thumbnail);
}
}
clearDialog();
hide();
}
void PhotoAddDialog::clearDialog()
{
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();
}

View File

@ -0,0 +1,53 @@
/*
* 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_ADD_DIALOG_H
#define MRK_PHOTO_ADD_DIALOG_H
#include "ui_PhotoAddDialog.h"
class PhotoDetailsDialog;
class PhotoAddDialog : public QWidget
{
Q_OBJECT
public:
PhotoAddDialog(QWidget *parent = 0);
private slots:
void showPhotoDetails();
void updateMoveButtons(uint32_t status);
void publishAlbum();
void clearDialog();
protected:
PhotoDetailsDialog *mPhotoDetails;
Ui::PhotoAddDialog ui;
};
#endif

View File

@ -0,0 +1,466 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PhotoAddDialog</class>
<widget class="QWidget" name="PhotoAddDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>852</width>
<height>383</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Share Options</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QComboBox" name="comboBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Public</string>
</property>
</item>
<item>
<property name="text">
<string>All Friends</string>
</property>
</item>
<item>
<property name="text">
<string>Restricted</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>N/A</string>
</property>
</item>
<item>
<property name="text">
<string>University Friends</string>
</property>
</item>
<item>
<property name="text">
<string>Family</string>
</property>
</item>
<item>
<property name="text">
<string>This List Contains</string>
</property>
</item>
<item>
<property name="text">
<string>All your Groups</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QComboBox" name="comboBox_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<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">
<widget class="QComboBox" name="comboBox_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>No Comments Allowed</string>
</property>
</item>
<item>
<property name="text">
<string>Authenticated Comments</string>
</property>
</item>
<item>
<property name="text">
<string>Any Comments Allowed</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QComboBox" name="comboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Publish with XXX Key</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="2">
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Album Thumbnail</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Album Thumbnail.........
Drag and Drop an Image
from the Picture List
to make it the Album
Image
1
2</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="3" rowspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>10</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Basic Details</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_Title">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Category:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox_Category">
<item>
<property name="text">
<string>Travel</string>
</property>
</item>
<item>
<property name="text">
<string>Holiday</string>
</property>
</item>
<item>
<property name="text">
<string>Friends</string>
</property>
</item>
<item>
<property name="text">
<string>Family</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="2" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Caption</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_Caption">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Where:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_Where">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_When">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Album Title:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>When</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton_DeleteAlbum">
<property name="text">
<string>Delete Album</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>78</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_EditAlbumDetails">
<property name="text">
<string>Edit Album Details</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,10">
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>HELP: Drag &amp; Drop to insert, and re-order pictures. Click on a picture to edit details below.</string>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollAreaPhotos">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<widget class="PhotoDrop" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>822</width>
<height>76</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
</property>
<layout class="QGridLayout" name="gridLayout_2"/>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton_EditPhotoDetails">
<property name="text">
<string>Edit Photo 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_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_Publish">
<property name="text">
<string>Publish Album</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>PhotoDrop</class>
<extends>QWidget</extends>
<header>gui/PhotoShare/PhotoDrop.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../LinksCloud/images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,127 @@
/*
* 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/PhotoDetailsDialog.h"
#include "gui/PhotoShare/PhotoItem.h"
/** Constructor */
PhotoDetailsDialog::PhotoDetailsDialog(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
connect( ui.pushButton_Update, SIGNAL( clicked() ), this, SLOT( updateDetails () ) );
}
void PhotoDetailsDialog::setPhotoItem(PhotoItem *item)
{
if (mPhotoItem == item)
{
return;
}
mPhotoItem = item;
/* update fields from the edit fields */
refreshDetails();
}
void PhotoDetailsDialog::refreshDetails()
{
if(!mPhotoItem)
{
blankDetails();
}
ui.label_Headline->setText(QString("Photo Description"));
//ui.comboBox_Category= mPhotoItem->mDetails.mCaption;
ui.lineEdit_Caption->setText(QString::fromStdString(mPhotoItem->mDetails.mCaption));
ui.textEdit_Description->setText(QString::fromStdString(mPhotoItem->mDetails.mDescription));
ui.lineEdit_Photographer->setText(QString::fromStdString(mPhotoItem->mDetails.mPhotographer));
ui.lineEdit_Where->setText(QString::fromStdString(mPhotoItem->mDetails.mWhere));
ui.lineEdit_When->setText(QString::fromStdString(mPhotoItem->mDetails.mWhen));
ui.lineEdit_Other->setText(QString::fromStdString(mPhotoItem->mDetails.mOther));
ui.lineEdit_Title->setText(QString::fromStdString(mPhotoItem->mDetails.mTitle));
ui.lineEdit_HashTags->setText(QString::fromStdString(mPhotoItem->mDetails.mHashTags));
const QPixmap *qtn = mPhotoItem->getPixmap();
QPixmap cpy(*qtn);
ui.label_Photo->setPixmap(cpy);
}
void PhotoDetailsDialog::blankDetails()
{
ui.label_Headline->setText(QString("Nothing"));
//ui.comboBox_Category= mPhotoItem->mDetails.mCaption;
ui.lineEdit_Caption->setText(QString("N/A"));
ui.textEdit_Description->setText(QString("N/A"));
ui.lineEdit_Photographer->setText(QString("N/A"));
ui.lineEdit_Where->setText(QString("N/A"));
ui.lineEdit_When->setText(QString("N/A"));
ui.lineEdit_Other->setText(QString("N/A"));
ui.lineEdit_Title->setText(QString("N/A"));
ui.lineEdit_HashTags->setText(QString("N/A"));
//QPixmap qtn = mPhotoItem->getPixmap();
//ui.label_Photo->setPixmap(qtn);
}
void PhotoDetailsDialog::updateDetails()
{
saveDetails();
hide();
}
void PhotoDetailsDialog::saveDetails()
{
if(!mPhotoItem)
{
return;
}
//mPhotoItem->mDetails.mCaption = ui.comboBox_Category;
mPhotoItem->mDetails.mCaption = ui.lineEdit_Caption->text().toStdString();
mPhotoItem->mDetails.mDescription = ui.textEdit_Description->toPlainText().toStdString();
mPhotoItem->mDetails.mPhotographer = ui.lineEdit_Photographer->text().toStdString();
mPhotoItem->mDetails.mWhere = ui.lineEdit_Where->text().toStdString();
mPhotoItem->mDetails.mWhen = ui.lineEdit_When->text().toStdString();
mPhotoItem->mDetails.mOther = ui.lineEdit_Other->text().toStdString();
mPhotoItem->mDetails.mTitle = ui.lineEdit_Title->text().toStdString();
mPhotoItem->mDetails.mHashTags = ui.lineEdit_HashTags->text().toStdString();
//QPixmap qtn = mPhotoItem->getPixmap();
//ui.label_Photo->setPixmap(qtn);
}

View File

@ -0,0 +1,56 @@
/*
* 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_DETAILS_DIALOG_H
#define MRK_PHOTO_DETAILS_DIALOG_H
#include "ui_PhotoDetailsDialog.h"
class PhotoItem;
class PhotoDetailsDialog : public QWidget
{
Q_OBJECT
public:
PhotoDetailsDialog(QWidget *parent = 0);
void setPhotoItem(PhotoItem *item);
private:
void saveDetails();
void refreshDetails();
private slots:
void updateDetails();
void blankDetails();
private:
PhotoItem *mPhotoItem;
Ui::PhotoDetailsDialog ui;
};
#endif

View File

@ -0,0 +1,221 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PhotoDetailsDialog</class>
<widget class="QWidget" name="PhotoDetailsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>683</width>
<height>415</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_Headline">
<property name="font">
<font>
<pointsize>18</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Album Description</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Album Name:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_Title"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Category:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBox_Category">
<item>
<property name="text">
<string>Travel</string>
</property>
</item>
<item>
<property name="text">
<string>Holiday</string>
</property>
</item>
<item>
<property name="text">
<string>Friends</string>
</property>
</item>
<item>
<property name="text">
<string>Family</string>
</property>
</item>
<item>
<property name="text">
<string>Work</string>
</property>
</item>
<item>
<property name="text">
<string>Random</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_Photo">
<property name="text">
<string>Thumbnail
Here
Dummy
Text
1
2
3
...................................</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Caption:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_Caption"/>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Photographer:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="lineEdit_Photographer"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item row="1" column="1" rowspan="3">
<widget class="QTextEdit" name="textEdit_Description"/>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Where:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="lineEdit_Where"/>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>When</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="lineEdit_When"/>
</item>
<item row="3" column="2">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Other 1:</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLineEdit" name="lineEdit_Other"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>HashTags:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_HashTags"/>
</item>
<item row="4" column="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>598</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_Update">
<property name="text">
<string>Update Details</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../LinksCloud/images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,461 @@
/*
* 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 "PhotoDialog.h"
#include <retroshare/rspeers.h>
#include <retroshare/rsphoto.h>
#include <iostream>
#include <sstream>
#include <QTimer>
/******
* #define PHOTO_DEBUG 1
*****/
/****************************************************************
* New Photo Display Widget.
*
* This has two 'lists'.
* Top list shows Albums.
* Lower list is photos from the selected Album.
*
* Notes:
* Each Item will be an AlbumItem, which contains a thumbnail & random details.
* We will limit Items to < 100. With a 'Filter to see more message.
*
* Thumbnails will come from Service.
* Option to Share albums / pictures onward (if permissions allow).
* Option to Download the albums to a specified directory. (is this required if sharing an album?)
*
* Will introduce a FullScreen SlideShow later... first get basics happening.
*/
/** Constructor */
PhotoDialog::PhotoDialog(QWidget *parent)
: MainPage(parent)
{
ui.setupUi(this);
mAddDialog = NULL;
mAlbumSelected = NULL;
mPhotoSelected = NULL;
connect( ui.toolButton_NewAlbum, SIGNAL(clicked()), this, SLOT(OpenOrShowPhotoAddDialog()));
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
timer->start(1000);
}
void PhotoDialog::notifySelection(PhotoItem *item, int ptype)
{
std::cerr << "PhotoDialog::notifySelection() from : " << ptype << " " << item;
std::cerr << std::endl;
switch(ptype)
{
default:
case PHOTO_ITEM_TYPE_ALBUM:
notifyAlbumSelection(item);
break;
case PHOTO_ITEM_TYPE_PHOTO:
notifyPhotoSelection(item);
break;
}
}
void PhotoDialog::notifyAlbumSelection(PhotoItem *item)
{
std::cerr << "PhotoDialog::notifyAlbumSelection() from : " << item;
std::cerr << std::endl;
if (mAlbumSelected)
{
std::cerr << "PhotoDialog::notifyAlbumSelection() unselecting old one : " << mAlbumSelected;
std::cerr << std::endl;
mAlbumSelected->setSelected(false);
}
mAlbumSelected = item;
insertPhotosForSelectedAlbum();
}
void PhotoDialog::notifyPhotoSelection(PhotoItem *item)
{
std::cerr << "PhotoDialog::notifyPhotoSelection() from : " << item;
std::cerr << std::endl;
if (mPhotoSelected)
{
std::cerr << "PhotoDialog::notifyPhotoSelection() unselecting old one : " << mPhotoSelected;
std::cerr << std::endl;
mPhotoSelected->setSelected(false);
}
mPhotoSelected = item;
}
void PhotoDialog::checkUpdate()
{
/* update */
if (!rsPhoto)
return;
if (rsPhoto->updated())
{
insertAlbums();
}
return;
}
/*************** New Photo Dialog ***************/
void PhotoDialog::OpenOrShowPhotoAddDialog()
{
if (mAddDialog)
{
mAddDialog->show();
}
else
{
mAddDialog = new PhotoAddDialog(NULL);
mAddDialog->show();
}
}
bool PhotoDialog::matchesAlbumFilter(const RsPhotoAlbum &album)
{
return true;
}
double PhotoDialog::AlbumScore(const RsPhotoAlbum &album)
{
return 1;
}
bool PhotoDialog::matchesPhotoFilter(const RsPhotoPhoto &photo)
{
return true;
}
double PhotoDialog::PhotoScore(const RsPhotoPhoto &photo)
{
return 1;
}
bool PhotoDialog::FilterNSortAlbums(const std::list<std::string> &albumIds, std::list<std::string> &filteredAlbumIds, int count)
{
std::multimap<double, std::string> sortedAlbums;
std::multimap<double, std::string>::iterator sit;
std::list<std::string>::const_iterator it;
for(it = albumIds.begin(); it != albumIds.end(); it++)
{
RsPhotoAlbum album;
rsPhoto->getAlbum(*it, album);
if (matchesAlbumFilter(album))
{
double score = AlbumScore(album);
sortedAlbums.insert(std::make_pair(score, *it));
}
}
int i;
for (sit = sortedAlbums.begin(), i = 0; (sit != sortedAlbums.end()) && (i < count); sit++, i++)
{
filteredAlbumIds.push_back(sit->second);
}
return true;
}
bool PhotoDialog::FilterNSortPhotos(const std::list<std::string> &photoIds, std::list<std::string> &filteredPhotoIds, int count)
{
std::multimap<double, std::string> sortedPhotos;
std::multimap<double, std::string>::iterator sit;
std::list<std::string>::const_iterator it;
int i = 0;
for(it = photoIds.begin(); it != photoIds.end(); it++, i++)
{
RsPhotoPhoto photo;
rsPhoto->getPhoto(*it, photo);
if (matchesPhotoFilter(photo))
{
double score = i; //PhotoScore(album);
sortedPhotos.insert(std::make_pair(score, *it));
}
}
for (sit = sortedPhotos.begin(), i = 0; (sit != sortedPhotos.end()) && (i < count); sit++, i++)
{
filteredPhotoIds.push_back(sit->second);
}
return true;
}
void PhotoDialog::insertAlbums()
{
/* clear it all */
clearAlbums();
//ui.albumLayout->clear();
/* create a list of albums */
std::list<std::string> albumIds;
std::list<std::string> filteredAlbumIds;
std::list<std::string>::iterator it;
rsPhoto->getAlbumList(albumIds);
/* Filter Albums */ /* Sort Albums */
#define MAX_ALBUMS 50
int count = MAX_ALBUMS;
FilterNSortAlbums(albumIds, filteredAlbumIds, count);
for(it = filteredAlbumIds.begin(); it != filteredAlbumIds.end(); it++)
{
addAlbum(*it);
}
insertPhotosForAlbum(filteredAlbumIds);
}
void PhotoDialog::insertPhotosForSelectedAlbum()
{
std::cerr << "PhotoDialog::insertPhotosForSelectedAlbum()";
std::cerr << std::endl;
clearPhotos();
std::list<std::string> albumIds;
if (mAlbumSelected)
{
albumIds.push_back(mAlbumSelected->mDetails.mAlbumId);
std::cerr << "PhotoDialog::insertPhotosForSelectedAlbum() AlbumId: " << mAlbumSelected->mDetails.mAlbumId;
std::cerr << std::endl;
}
insertPhotosForAlbum(albumIds);
}
void PhotoDialog::addAlbum(const std::string &id)
{
RsPhotoAlbum album;
rsPhoto->getAlbum(id, album);
RsPhotoThumbnail thumbnail;
rsPhoto->getAlbumThumbnail(id, thumbnail);
std::cerr << " PhotoDialog::addAlbum() AlbumId: " << album.mAlbumId << std::endl;
PhotoItem *item = new PhotoItem(this, album, thumbnail);
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
alayout->addWidget(item);
}
void PhotoDialog::clearAlbums()
{
std::cerr << "PhotoDialog::clearAlbums()" << std::endl;
std::list<PhotoItem *> photoItems;
std::list<PhotoItem *>::iterator pit;
QLayout *alayout = ui.scrollAreaWidgetContents->layout();
int count = alayout->count();
for(int i = 0; i < count; i++)
{
QLayoutItem *litem = alayout->itemAt(i);
if (!litem)
{
std::cerr << "PhotoDialog::clearAlbums() missing litem";
std::cerr << std::endl;
continue;
}
PhotoItem *item = dynamic_cast<PhotoItem *>(litem->widget());
if (item)
{
std::cerr << "PhotoDialog::clearAlbums() item: " << item;
std::cerr << std::endl;
photoItems.push_back(item);
}
else
{
std::cerr << "PhotoDialog::clearAlbums() Found Child, which is not a PhotoItem???";
std::cerr << std::endl;
}
}
for(pit = photoItems.begin(); pit != photoItems.end(); pit++)
{
PhotoItem *item = *pit;
alayout->removeWidget(item);
delete item;
}
mAlbumSelected = NULL;
}
void PhotoDialog::clearPhotos()
{
std::cerr << "PhotoDialog::clearPhotos()" << std::endl;
std::list<PhotoItem *> photoItems;
std::list<PhotoItem *>::iterator pit;
QLayout *alayout = ui.scrollAreaWidgetContents_2->layout();
int count = alayout->count();
for(int i = 0; i < count; i++)
{
QLayoutItem *litem = alayout->itemAt(i);
if (!litem)
{
std::cerr << "PhotoDialog::clearPhotos() missing litem";
std::cerr << std::endl;
continue;
}
PhotoItem *item = dynamic_cast<PhotoItem *>(litem->widget());
if (item)
{
std::cerr << "PhotoDialog::clearPhotos() item: " << item;
std::cerr << std::endl;
photoItems.push_back(item);
}
else
{
std::cerr << "PhotoDialog::clearPhotos() Found Child, which is not a PhotoItem???";
std::cerr << std::endl;
}
}
for(pit = photoItems.begin(); pit != photoItems.end(); pit++)
{
PhotoItem *item = *pit;
alayout->removeWidget(item);
delete item;
}
mPhotoSelected = NULL;
}
void PhotoDialog::insertPhotosForAlbum(const std::list<std::string> &albumIds)
{
/* clear it all */
clearPhotos();
//ui.photoLayout->clear();
/* create a list of albums */
std::list<std::string> ids;
std::list<std::string> photoIds;
std::list<std::string> filteredPhotoIds;
std::list<std::string>::const_iterator it;
for(it = albumIds.begin(); it != albumIds.end(); it++)
{
rsPhoto->getPhotoList(*it, photoIds);
}
/* Filter Albums */ /* Sort Albums */
#define MAX_PHOTOS 50
int count = MAX_PHOTOS;
FilterNSortPhotos(photoIds, filteredPhotoIds, MAX_PHOTOS);
for(it = filteredPhotoIds.begin(); it != filteredPhotoIds.end(); it++)
{
addPhoto(*it);
}
}
void PhotoDialog::addPhoto(const std::string &id)
{
RsPhotoPhoto photo;
rsPhoto->getPhoto(id,photo);
RsPhotoThumbnail thumbnail;
rsPhoto->getPhotoThumbnail(id, thumbnail);
std::cerr << "PhotoDialog::addPhoto() AlbumId: " << photo.mAlbumId;
std::cerr << " PhotoId: " << photo.mId;
std::cerr << std::endl;
PhotoItem *item = new PhotoItem(this, photo, thumbnail);
QLayout *alayout = ui.scrollAreaWidgetContents_2->layout();
alayout->addWidget(item);
}
void PhotoDialog::deletePhotoItem(PhotoItem *item, uint32_t type)
{
return;
}

View File

@ -0,0 +1,93 @@
/*
* 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_DIALOG_H
#define MRK_PHOTO_DIALOG_H
#include "gui/mainpage.h"
#include "ui_PhotoDialog.h"
#include <retroshare/rsphoto.h>
#include <map>
#include "gui/PhotoShare/PhotoItem.h"
#include "gui/PhotoShare/PhotoAddDialog.h"
class PhotoDialog : public MainPage, public PhotoHolder
{
Q_OBJECT
public:
PhotoDialog(QWidget *parent = 0);
virtual void deletePhotoItem(PhotoItem *, uint32_t type);
virtual void notifySelection(PhotoItem *item, int ptype);
void notifyAlbumSelection(PhotoItem *item);
void notifyPhotoSelection(PhotoItem *item);
private slots:
void checkUpdate();
void OpenOrShowPhotoAddDialog();
private:
/* TODO: These functions must be filled in for proper filtering to work
* and tied to the GUI input
*/
bool matchesAlbumFilter(const RsPhotoAlbum &album);
double AlbumScore(const RsPhotoAlbum &album);
bool matchesPhotoFilter(const RsPhotoPhoto &photo);
double PhotoScore(const RsPhotoPhoto &photo);
/* Grunt work of setting up the GUI */
bool FilterNSortAlbums(const std::list<std::string> &albumIds, std::list<std::string> &filteredAlbumIds, int count);
bool FilterNSortPhotos(const std::list<std::string> &photoIds, std::list<std::string> &filteredPhotoIds, int count);
void insertAlbums();
void insertPhotosForAlbum(const std::list<std::string> &albumIds);
void insertPhotosForSelectedAlbum();
void addAlbum(const std::string &id);
void addPhoto(const std::string &id);
void clearAlbums();
void clearPhotos();
PhotoAddDialog *mAddDialog;
PhotoItem *mAlbumSelected;
PhotoItem *mPhotoSelected;
/* UI - from Designer */
Ui::PhotoDialog ui;
};
#endif

View File

@ -0,0 +1,239 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PhotoDialog</class>
<widget class="QWidget" name="PhotoDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>774</width>
<height>608</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Filter</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>Source</string>
</property>
</item>
<item>
<property name="text">
<string>Category</string>
</property>
</item>
<item>
<property name="text">
<string>Rating</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="text">
<string>[ - ]</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_2">
<property name="text">
<string>[ + ]</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QComboBox" name="comboBox_2">
<item>
<property name="text">
<string>Source</string>
</property>
</item>
<item>
<property name="text">
<string>Category</string>
</property>
</item>
<item>
<property name="text">
<string>Rating</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_2"/>
</item>
<item>
<widget class="QToolButton" name="toolButton_3">
<property name="text">
<string>[ - ]</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_4">
<property name="text">
<string>[ + ]</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>746</width>
<height>227</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>139</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<widget class="QScrollArea" name="scrollArea_2">
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>746</width>
<height>227</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>426</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QToolButton" name="toolButton_RemovePicture">
<property name="text">
<string>Remove Picture</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_SlideShow">
<property name="text">
<string>Slide Show</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_EditAlbum">
<property name="text">
<string>Edit Album</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_EditPictureDetails">
<property name="text">
<string>Edit Picture Details</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_NewAlbum">
<property name="text">
<string>New Album</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../LinksCloud/images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,273 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PhotoDialog</class>
<widget class="QWidget" name="PhotoDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>774</width>
<height>608</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Filter</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>Source</string>
</property>
</item>
<item>
<property name="text">
<string>Category</string>
</property>
</item>
<item>
<property name="text">
<string>Rating</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="text">
<string>[ - ]</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_2">
<property name="text">
<string>[ + ]</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QComboBox" name="comboBox_2">
<item>
<property name="text">
<string>Source</string>
</property>
</item>
<item>
<property name="text">
<string>Category</string>
</property>
</item>
<item>
<property name="text">
<string>Rating</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_2"/>
</item>
<item>
<widget class="QToolButton" name="toolButton_3">
<property name="text">
<string>[ - ]</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_4">
<property name="text">
<string>[ + ]</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>746</width>
<height>227</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QHBoxLayout" name="albumLayout"/>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Album 1</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Album 2</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Album 3</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Album 4 </string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>139</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<widget class="QScrollArea" name="scrollArea_2">
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>746</width>
<height>227</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QHBoxLayout" name="photoLayout"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>PICTURE 1</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>426</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QToolButton" name="toolButton_RemovePicture">
<property name="text">
<string>Remove Picture</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_SlideShow">
<property name="text">
<string>Slide Show</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_EditAlbum">
<property name="text">
<string>Edit Album</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_EditPictureDetails">
<property name="text">
<string>Edit Picture Details</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_NewAlbum">
<property name="text">
<string>New Album</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../LinksCloud/images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,641 @@
/*
* 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 <QtGui>
#include "PhotoDrop.h"
#include <iostream>
// Helper Class
class gridIndex
{
public:
gridIndex()
:row(0), column(0) { return; }
gridIndex(int in_row, int in_column)
:row(in_row), column(in_column) { return; }
bool operator<(const gridIndex &other) const
{
if (row == other.row)
{
return (column < other.column);
}
return (row < other.row);
}
int row, column;
};
PhotoDrop::PhotoDrop(QWidget *parent)
: QWidget(parent)
{
setAcceptDrops(true);
mSelected = NULL;
checkMoveButtons();
reorderPhotos();
}
void PhotoDrop::notifySelection(PhotoItem *item, int ptype)
{
std::cerr << "PhotoDrop::notifySelection() from : " << ptype << " " << item;
std::cerr << std::endl;
if (mSelected)
{
std::cerr << "PhotoDrop::notifySelection() unselecting old one : " << mSelected;
std::cerr << std::endl;
mSelected->setSelected(false);
}
mSelected = item;
checkMoveButtons();
}
void PhotoDrop::clear()
{
}
PhotoItem *PhotoDrop::getSelectedPhotoItem()
{
return mSelected;
}
void PhotoDrop::deletePhotoItem(PhotoItem *, uint32_t type)
{
return;
}
void PhotoDrop::resizeEvent ( QResizeEvent * event )
{
/* calculate the preferred number of columns for the PhotoItems */
reorderPhotos();
}
int PhotoDrop::getPhotoCount()
{
std::cerr << "PhotoDrop::getPhotoCount()";
std::cerr << std::endl;
/* grab the first PhotoItem - and get it size */
const QObjectList &items = children();
QObjectList::const_iterator qit;
int count = 0;
for(qit = items.begin(); qit != items.end(); qit++)
{
PhotoItem *item = dynamic_cast<PhotoItem *>(*qit);
if (item)
{
std::cerr << "PhotoDrop::getPhotoCount() item: " << item;
std::cerr << std::endl;
count++;
}
else
{
std::cerr << "PhotoDrop::getPhotoCount() Found Child, which is not a PhotoItem???";
std::cerr << std::endl;
}
}
return count;
}
PhotoItem *PhotoDrop::getPhotoIdx(int idx)
{
std::cerr << "PhotoDrop::getPhotoIdx(" << idx << ")";
std::cerr << std::endl;
/* grab the first PhotoItem - and get it size */
const QObjectList &items = children();
QObjectList::const_iterator qit;
int count = 0;
for(qit = items.begin(); qit != items.end(); qit++)
{
PhotoItem *item = dynamic_cast<PhotoItem *>(*qit);
if (item)
{
std::cerr << "PhotoDrop::getPhotoIdx() item: " << item;
std::cerr << std::endl;
if (count == idx)
{
return item;
}
count++;
}
else
{
std::cerr << "PhotoDrop::getPhotoIdx() Found Child, which is not a PhotoItem???";
std::cerr << std::endl;
}
}
return NULL;
}
void PhotoDrop::reorderPhotos()
{
std::cerr << "PhotoDrop::reorderPhotos()";
std::cerr << std::endl;
/* now move the qwidgets around */
QLayout *alayout = layout();
QGridLayout *glayout = dynamic_cast<QGridLayout *>(alayout);
if (!glayout)
{
std::cerr << "PhotoDrop::reorderPhotos() not GridLayout... not much we can do!";
std::cerr << std::endl;
return;
}
/* grab the first PhotoItem - and get it size */
std::map<gridIndex, PhotoItem *> photoItems;
std::map<gridIndex, PhotoItem *>::iterator pit;
int count = glayout->count();
int i = 0;
for(i = 0; i < count; i++)
{
QLayoutItem *litem = glayout->itemAt(i);
if (!litem)
{
std::cerr << "PhotoDrop::reorderPhotos() missing litem";
std::cerr << std::endl;
continue;
}
PhotoItem *item = dynamic_cast<PhotoItem *>(litem->widget());
if (item)
{
int selectedRow;
int selectedColumn;
int rowSpan;
int colSpan;
glayout->getItemPosition(i, &selectedRow, &selectedColumn, &rowSpan, &colSpan);
std::cerr << "PhotoDrop::reorderPhotos() item: " << item;
std::cerr << " layoutIdx: " << i;
std::cerr << " item pos(" << selectedRow << ", " << selectedColumn;
std::cerr << ")" << std::endl;
gridIndex idx(selectedRow, selectedColumn);
photoItems[idx] = item;
}
else
{
std::cerr << "PhotoDrop::reorderPhotos() Found Child, which is not a PhotoItem???";
std::cerr << std::endl;
}
}
pit = photoItems.begin();
if (pit == photoItems.end())
{
std::cerr << "PhotoDrop::reorderPhotos() No PhotoItems.";
std::cerr << std::endl;
mColumns = 1;
// no PhotoItems here.
return;
}
int minWidth = (pit->second)->minimumWidth();
#define EXPECTED_WIDTH (200)
if (minWidth < EXPECTED_WIDTH)
{
minWidth = EXPECTED_WIDTH;
}
int space = width();
mColumns = space / minWidth;
std::cerr << "PhotoDrop::reorderPhotos() minWidth: " << minWidth << " space: " << space;
std::cerr << " columns: " << mColumns;
std::cerr << std::endl;
std::cerr << "PhotoDrop::reorderPhotos() Getting ordered Items from Layout";
std::cerr << std::endl;
for(pit = photoItems.begin(); pit != photoItems.end(); pit++)
{
glayout->removeWidget(pit->second);
}
for(pit = photoItems.begin(), i = 0; pit != photoItems.end(); pit++, i++)
{
int row = i / mColumns;
int column = i % mColumns;
std::cerr << "Inserting item: " << pit->second << " at (" << row << "," << column << ")";
std::cerr << std::endl;
glayout->addWidget(pit->second, row, column, Qt::AlignCenter);
}
}
void PhotoDrop::moveLeft()
{
std::cerr << "PhotoDrop::moveLeft()";
std::cerr << std::endl;
QLayout *alayout = layout();
if (!alayout)
{
std::cerr << "PhotoDrop::moveLeft() No Layout";
std::cerr << std::endl;
return;
}
QGridLayout *glayout = dynamic_cast<QGridLayout *>(alayout);
if (!glayout)
{
std::cerr << "PhotoDrop::moveLeft() not GridLayout... not much we can do!";
std::cerr << std::endl;
return;
}
int count = alayout->count();
if ((!mSelected) || (count < 2))
{
std::cerr << "PhotoDrop::moveLeft() Not enough items";
std::cerr << std::endl;
return;
}
int index = alayout->indexOf(mSelected);
int selectedRow;
int selectedColumn;
int rowSpan;
int colSpan;
glayout->getItemPosition(index, &selectedRow, &selectedColumn, &rowSpan, &colSpan);
if ((selectedRow == 0) && (selectedColumn == 0))
{
std::cerr << "PhotoDrop::moveLeft() Selected is first item";
std::cerr << std::endl;
return;
}
int swapRow = selectedRow;
int swapColumn = selectedColumn - 1;
if (swapColumn < 0)
{
swapRow--;
swapColumn = mColumns - 1;
}
std::cerr << "PhotoDrop::moveLeft() Trying to swap (" << selectedRow << ",";
std::cerr << selectedColumn << ") <-> (" << swapRow;
std::cerr << "," << swapColumn << ")";
std::cerr << std::endl;
QLayoutItem *litem = glayout->itemAtPosition(swapRow, swapColumn);
if (!litem)
{
std::cerr << "PhotoDrop::moveLeft() No layout item to the right";
std::cerr << std::endl;
return;
}
QWidget *widget = litem->widget();
if (!widget)
{
std::cerr << "PhotoDrop::moveLeft() No item to the left";
std::cerr << std::endl;
return;
}
/* grab both items, and switch */
std::cerr << "PhotoDrop::moveLeft() could move index: " << index;
std::cerr << std::endl;
glayout->removeWidget(widget);
glayout->removeWidget(mSelected);
glayout->addWidget(widget, selectedRow, selectedColumn, Qt::AlignCenter);
glayout->addWidget(mSelected, swapRow, swapColumn, Qt::AlignCenter);
checkMoveButtons();
}
void PhotoDrop::moveRight()
{
std::cerr << "PhotoDrop::moveRight()";
std::cerr << std::endl;
QLayout *alayout = layout();
if (!alayout)
{
std::cerr << "PhotoDrop::moveRight() No Layout";
std::cerr << std::endl;
return;
}
QGridLayout *glayout = dynamic_cast<QGridLayout *>(alayout);
if (!glayout)
{
std::cerr << "PhotoDrop::moveRight() not GridLayout... not much we can do!";
std::cerr << std::endl;
return;
}
int count = alayout->count();
if ((!mSelected) || (count < 2))
{
std::cerr << "PhotoDrop::moveRight() Not enough items";
std::cerr << std::endl;
return;
}
int index = alayout->indexOf(mSelected);
int selectedRow;
int selectedColumn;
int rowSpan;
int colSpan;
glayout->getItemPosition(index, &selectedRow, &selectedColumn, &rowSpan, &colSpan);
int maxRow = (count - 1) / mColumns;
int maxCol = (count - 1) % mColumns;
if ((selectedRow == maxRow) && (selectedColumn == maxCol))
{
std::cerr << "PhotoDrop::moveRight() Selected is last item";
std::cerr << std::endl;
return;
}
int swapRow = selectedRow;
int swapColumn = selectedColumn + 1;
if (swapColumn == mColumns)
{
swapRow++;
swapColumn = 0;
}
std::cerr << "PhotoDrop::moveRight() Trying to swap (" << selectedRow << ",";
std::cerr << selectedColumn << ") <-> (" << swapRow;
std::cerr << "," << swapColumn << ")";
std::cerr << std::endl;
QLayoutItem *litem = glayout->itemAtPosition(swapRow, swapColumn);
if (!litem)
{
std::cerr << "PhotoDrop::moveRight() No layout item to the right";
std::cerr << std::endl;
return;
}
QWidget *widget = litem->widget();
if (!widget)
{
std::cerr << "PhotoDrop::moveRight() No item to the right";
std::cerr << std::endl;
return;
}
/* grab both items, and switch */
std::cerr << "PhotoDrop::moveRight() could move index: " << index;
std::cerr << std::endl;
glayout->removeWidget(widget);
glayout->removeWidget(mSelected);
glayout->addWidget(widget, selectedRow, selectedColumn, Qt::AlignCenter);
glayout->addWidget(mSelected, swapRow, swapColumn, Qt::AlignCenter);
checkMoveButtons();
}
void PhotoDrop::checkMoveButtons()
{
std::cerr << "PhotoDrop::checkMoveButtons()";
std::cerr << std::endl;
/* locate mSelected in the set */
QLayout *alayout = layout();
if (!alayout)
{
std::cerr << "PhotoDrop::checkMoveButtons() No Layout";
std::cerr << std::endl;
return;
}
int count = alayout->count();
if ((!mSelected) || (count < 2))
{
buttonStatus(PHOTO_SHIFT_NO_BUTTONS);
return;
}
QGridLayout *glayout = dynamic_cast<QGridLayout *>(alayout);
if (!glayout)
{
std::cerr << "PhotoDrop::checkMoveButtons() not GridLayout... not much we can do!";
std::cerr << std::endl;
buttonStatus(PHOTO_SHIFT_NO_BUTTONS);
return;
}
int index = alayout->indexOf(mSelected);
int selectedRow;
int selectedColumn;
int rowSpan;
int colSpan;
glayout->getItemPosition(index, &selectedRow, &selectedColumn, &rowSpan, &colSpan);
int maxRow = (count - 1) / mColumns;
int maxCol = (count - 1) % mColumns;
if ((selectedRow == 0) && (selectedColumn == 0))
{
buttonStatus(PHOTO_SHIFT_RIGHT_ONLY);
}
else if ((selectedRow == maxRow) && (selectedColumn == maxCol))
{
buttonStatus(PHOTO_SHIFT_LEFT_ONLY);
}
else
{
buttonStatus(PHOTO_SHIFT_BOTH);
}
}
void PhotoDrop::clearPhotos()
{
std::cerr << "PhotoDrop::clearPhotos()";
std::cerr << std::endl;
/* grab the first PhotoItem - and get it size */
const QObjectList &items = children();
QObjectList::const_iterator qit;
std::list<PhotoItem *> photoItems;
std::list<PhotoItem *>::iterator pit;
for(qit = items.begin(); qit != items.end(); qit++)
{
PhotoItem *item = dynamic_cast<PhotoItem *>(*qit);
if (item)
{
photoItems.push_back(item);
std::cerr << "PhotoDrop::clearPhotos() item: " << item;
std::cerr << std::endl;
}
else
{
std::cerr << "PhotoDrop::clearPhotos() Found Child, which is not a PhotoItem???";
std::cerr << std::endl;
}
}
QLayout *alayout = layout();
QGridLayout *glayout = dynamic_cast<QGridLayout *>(alayout);
if (!glayout)
{
std::cerr << "PhotoDrop::clearPhotos() not GridLayout... not much we can do!";
std::cerr << std::endl;
return;
}
for(pit = photoItems.begin(); pit != photoItems.end(); pit++)
{
PhotoItem *item = *pit;
glayout->removeWidget(item);
delete item;
}
mSelected = NULL;
}
void PhotoDrop::dragEnterEvent(QDragEnterEvent *event)
{
// Only Accept DragEntetEvents from the Disk / URLs.
// TODO: check that the data is suitable - and a photo
std::cerr << "PhotoDrop::dragEnterEvent()";
std::cerr << std::endl;
//if (event->mimeData()->hasFormat("image/x-photo-item"))
if (event->mimeData()->hasUrls())
{
event->accept();
}
else
{
event->ignore();
}
}
void PhotoDrop::dragLeaveEvent(QDragLeaveEvent *event)
{
// We can drag an existing Image to the "Album Spot" (or elsewhere).
// But we cannot drag anything else out.
std::cerr << "PhotoDrop::dragLeaveEvent()";
std::cerr << std::endl;
event->ignore();
}
void PhotoDrop::dragMoveEvent(QDragMoveEvent *event)
{
std::cerr << "PhotoDrop::dragMoveEvent()";
std::cerr << std::endl;
//event->accept();
event->ignore();
}
void PhotoDrop::dropEvent(QDropEvent *event)
{
std::cerr << "PhotoDrop::dropEvent()";
std::cerr << std::endl;
if (event->mimeData()->hasUrls())
{
std::cerr << "PhotoDrop::dropEvent() Urls:" << std::endl;
QList<QUrl> urls = event->mimeData()->urls();
QList<QUrl>::iterator uit;
for (uit = urls.begin(); uit != urls.end(); ++uit)
{
QString localpath = uit->toLocalFile();
std::cerr << "Whole URL: " << uit->toString().toStdString() << std::endl;
std::cerr << "or As Local File: " << localpath.toStdString() << std::endl;
PhotoItem *item = new PhotoItem(this, localpath.toStdString());
//mPhotos.push_back(item);
layout()->addWidget(item);
}
event->setDropAction(Qt::CopyAction);
event->accept();
}
else
{
event->ignore();
}
checkMoveButtons();
}
void PhotoDrop::mousePressEvent(QMouseEvent *event)
{
/* see if this is in the space of one of our children */
QPoint pos = event->pos();
std::cerr << "PhotoDrop::mousePressEvent(" << pos.x() << ", " << pos.y() << ")";
std::cerr << std::endl;
QWidget::mousePressEvent(event);
}

View File

@ -0,0 +1,87 @@
/*
* 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_DROP_H
#define MRK_PHOTO_DROP_H
#include <QList>
#include <QPoint>
#include <QPixmap>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QDragEnterEvent;
class QDropEvent;
class QMouseEvent;
QT_END_NAMESPACE
#include "gui/PhotoShare/PhotoItem.h"
#define PHOTO_SHIFT_NO_BUTTONS 0
#define PHOTO_SHIFT_LEFT_ONLY 1
#define PHOTO_SHIFT_RIGHT_ONLY 2
#define PHOTO_SHIFT_BOTH 3
class PhotoDrop : public QWidget, public PhotoHolder
{
Q_OBJECT
public:
PhotoDrop(QWidget *parent = 0);
void clear();
virtual void deletePhotoItem(PhotoItem *, uint32_t type);
virtual void notifySelection(PhotoItem *item, int ptype);
PhotoItem *getSelectedPhotoItem();
int getPhotoCount();
PhotoItem *getPhotoIdx(int idx);
public slots:
void moveLeft();
void moveRight();
void checkMoveButtons();
void clearPhotos();
signals:
void buttonStatus(uint32_t status);
protected:
void resizeEvent(QResizeEvent *event);
void mousePressEvent(QMouseEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dragLeaveEvent(QDragLeaveEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
private:
void reorderPhotos();
PhotoItem *mSelected;
int mColumns;
};
#endif

View File

@ -0,0 +1,239 @@
/*
* 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 <QDateTime>
#include <QMessageBox>
#include <QMouseEvent>
#include <QBuffer>
#include "PhotoItem.h"
#include <retroshare/rsphoto.h>
#include <algorithm>
#include <iostream>
/****
* #define DEBUG_ITEM 1
****/
/** Constructor */
PhotoItem::PhotoItem(PhotoHolder *parent, const RsPhotoAlbum &album, const RsPhotoThumbnail &thumbnail)
:QWidget(NULL), mParent(parent), mType(PHOTO_ITEM_TYPE_ALBUM)
{
setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
mDetails = *( (RsPhotoPhoto *) &(album));
updateAlbumText(album);
updateImage(thumbnail);
setSelected(false);
}
PhotoItem::PhotoItem(PhotoHolder *parent, const RsPhotoPhoto &photo, const RsPhotoThumbnail &thumbnail)
:QWidget(NULL), mParent(parent), mType(PHOTO_ITEM_TYPE_PHOTO)
{
setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
mDetails = *( (RsPhotoPhoto *) &(photo));
updatePhotoText(photo);
updateImage(thumbnail);
setSelected(false);
}
PhotoItem::PhotoItem(PhotoHolder *parent, std::string path) // for new photos.
:QWidget(NULL), mParent(parent), mType(PHOTO_ITEM_TYPE_NEW)
{
setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
QString dummyString("dummytext");
titleLabel->setText(QString("NEW PHOTO"));
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 height = 120;
//QPixmap qtn = QPixmap(QString::fromStdString(path)).scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
QPixmap qtn = QPixmap(QString::fromStdString(path)).scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
imgLabel->setPixmap(qtn);
setSelected(false);
}
void PhotoItem::updateAlbumText(const RsPhotoAlbum &album)
{
QString dummyString("dummytext");
titleLabel->setText(QString("TITLE"));
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)
{
QString dummyString("dummytext");
titleLabel->setText(QString("TITLE"));
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"));
}
void PhotoItem::updateImage(const RsPhotoThumbnail &thumbnail)
{
if (thumbnail.data != NULL)
{
QPixmap qtn;
qtn.loadFromData(thumbnail.data, thumbnail.size, thumbnail.type.c_str());
imgLabel->setPixmap(qtn);
}
}
bool PhotoItem::getPhotoThumbnail(RsPhotoThumbnail &nail)
{
const QPixmap *tmppix = imgLabel->pixmap();
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
RsPhotoThumbnail tmpnail;
tmpnail.data = (uint8_t *) ba.data();
tmpnail.size = ba.size();
nail.copyFrom(tmpnail);
return true;
}
nail.data = NULL;
nail.size = 0;
return false;
}
void PhotoItem::removeItem()
{
#ifdef DEBUG_ITEM
std::cerr << "PhotoItem::removeItem()";
std::cerr << std::endl;
#endif
hide();
if (mParent)
{
mParent->deletePhotoItem(this, mType);
}
}
void PhotoItem::setSelected(bool on)
{
mSelected = on;
if (mSelected)
{
mParent->notifySelection(this, mType);
frame->setStyleSheet("QFrame#frame{border: 2px solid #55CC55;\nbackground: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #55EE55, stop: 1 #CCCCCC);\nborder-radius: 10px}");
}
else
{
frame->setStyleSheet("QFrame#frame{border: 2px solid #CCCCCC;\nbackground: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #EEEEEE, stop: 1 #CCCCCC);\nborder-radius: 10px}");
}
update();
}
bool PhotoItem::isSelected()
{
return mSelected;
}
void PhotoItem::mousePressEvent(QMouseEvent *event)
{
/* We can be very cunning here?
* grab out position.
* flag ourselves as selected.
* then pass the mousePressEvent up for handling by the parent
*/
QPoint pos = event->pos();
std::cerr << "PhotoItem::mousePressEvent(" << pos.x() << ", " << pos.y() << ")";
std::cerr << std::endl;
setSelected(true);
QWidget::mousePressEvent(event);
}
const QPixmap *PhotoItem::getPixmap()
{
return imgLabel->pixmap();
}

View File

@ -0,0 +1,86 @@
/*
* 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_PHOTO_ITEM_H
#define MRK_PHOTO_PHOTO_ITEM_H
#include "ui_PhotoItem.h"
#include <retroshare/rsphoto.h>
class PhotoItem;
class PhotoHolder
{
public:
virtual void deletePhotoItem(PhotoItem *, uint32_t ptype) = 0;
virtual void notifySelection(PhotoItem *item, int ptype) = 0;
};
#define PHOTO_ITEM_TYPE_ALBUM 0x0001
#define PHOTO_ITEM_TYPE_PHOTO 0x0002
#define PHOTO_ITEM_TYPE_NEW 0x0003
class PhotoItem : public QWidget, private Ui::PhotoItem
{
Q_OBJECT
public:
PhotoItem(PhotoHolder *parent, const RsPhotoAlbum &album, const RsPhotoThumbnail &thumbnail);
PhotoItem(PhotoHolder *parent, const RsPhotoPhoto &photo, const RsPhotoThumbnail &thumbnail);
PhotoItem(PhotoHolder *parent, std::string url); // for new photos.
bool getPhotoThumbnail(RsPhotoThumbnail &nail);
void removeItem();
void setSelected(bool on);
bool isSelected();
const QPixmap *getPixmap();
// details are public - so that can be easily edited.
RsPhotoPhoto mDetails;
//private slots:
protected:
void mousePressEvent(QMouseEvent *event);
private:
void updateAlbumText(const RsPhotoAlbum &album);
void updatePhotoText(const RsPhotoPhoto &photo);
void updateImage(const RsPhotoThumbnail &thumbnail);
PhotoHolder *mParent;
uint32_t mType;
bool mSelected;
};
#endif

View File

@ -0,0 +1,247 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PhotoItem</class>
<widget class="QWidget" name="PhotoItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>166</width>
<height>216</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>6</number>
</property>
<item row="1" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">QFrame#frame{border: 2px solid #CCCCCC;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #EEEEEE, stop: 1 #CCCCCC);
border-radius: 10px}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="imgLabel">
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLabel#label{border: 2px solid black;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #EEEEEE, stop: 1 #CCCCCC);
border-radius: 10px}</string>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:/images/konversation.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Album:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="_3">
<item>
<widget class="QLabel" name="fromBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>From</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="fromLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">Signed by</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="_2">
<item>
<widget class="QLabel" name="statusBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Status</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="statusLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">You eyes only</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="_4">
<item>
<widget class="QLabel" name="dateBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Date</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="dateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">You eyes only</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../retroshare-gui/src/gui/images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/" >
<file>images/dummy.png</file>
</qresource>
</RCC>