Addition of two more Services / Applications.

(1) A PhotoService / Dialog to share slideshows.
(2) A Network View service, derived from p3disc for a graphical view of peers.
Both of these need a little help to get them fully functional.




git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@375 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-03-04 21:31:11 +00:00
parent 3ed1eef186
commit 08860b25e6
28 changed files with 3297 additions and 235 deletions

View file

@ -62,6 +62,7 @@ HEADERS += rshare.h \
gui/GamesDialog.h \
gui/PhotoDialog.h \
gui/LinksDialog.h \
gui/NetworkView.h \
gui/MessengerWindow.h \
gui/PeersDialog.h \
gui/SearchDialog.h \
@ -150,6 +151,7 @@ FORMS += gui/ChatDialog.ui \
gui/GamesDialog.ui \
gui/PhotoDialog.ui \
gui/LinksDialog.ui \
gui/NetworkView.ui \
gui/MessengerWindow.ui \
gui/PeersDialog.ui \
gui/SearchDialog.ui \
@ -212,6 +214,7 @@ SOURCES += main.cpp \
gui/GamesDialog.cpp \
gui/PhotoDialog.cpp \
gui/LinksDialog.cpp \
gui/NetworkView.cpp \
gui/MessengerWindow.cpp \
gui/PeersDialog.cpp \
gui/SearchDialog.cpp \

View file

@ -42,6 +42,7 @@
#include "LinksDialog.h"
#include "GamesDialog.h"
#include "NetworkView.h"
#include "PhotoDialog.h"
#include "channels/channelsDialog.h"
@ -103,7 +104,21 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
ui.stackPages->add(gamesDialog = new GamesDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_MESSAGES), tr("Games Launcher"), grp));
NetworkView *networkView = NULL;
ui.stackPages->add(networkView = new NetworkView(ui.stackPages),
createPageAction(QIcon(IMAGE_NETWORK), tr("Network View"), grp));
PhotoDialog *photoDialog = NULL;
ui.stackPages->add(photoDialog = new PhotoDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_CHANNELS), tr("Photo View"), grp));
//ui.stackPages->add(groupsDialog = new GroupsDialog(ui.stackPages),
// createPageAction(QIcon(), tr("Groups"), grp));
//ui.stackPages->add(new StatisticDialog(ui.stackPages),
// createPageAction(QIcon(IMAGE_STATISTIC), tr("Statistics"), grp));
/* Create the toolbar */
ui.toolBar->addActions(grp->actions());
ui.toolBar->addSeparator();

View file

@ -0,0 +1,326 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "NetworkView.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsdisc.h"
#include <QMenu>
#include <QMouseEvent>
#include <QGraphicsItem>
#include <iostream>
/** Constructor */
NetworkView::NetworkView(QWidget *parent)
: MainPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
mScene = new QGraphicsScene();
ui.graphicsView->setScene(mScene);
//connect( ui.linkTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( linkTreeWidgetCostumPopupMenu( QPoint ) ) );
/* link combos */
// connect( ui.rankComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortRank( int ) ) );
// connect( ui.periodComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortPeriod( int ) ) );
// connect( ui.fromComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortFrom( int ) ) );
// connect( ui.topComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortTop( int ) ) );
/* add button */
connect( ui.refreshButton, SIGNAL( clicked( void ) ), this, SLOT( insertPeers( void ) ) );
connect( mScene, SIGNAL( changed ( const QList<QRectF> & ) ), this, SLOT ( changedScene( void ) ) );
/* hide the Tree +/- */
// ui.linkTreeWidget -> setRootIsDecorated( false );
/* Set header resize modes and initial section sizes */
// QHeaderView * _header = ui.linkTreeWidget->header () ;
// _header->setResizeMode (0, QHeaderView::Interactive);
// _header->setResizeMode (1, QHeaderView::Interactive);
// _header->setResizeMode (2, QHeaderView::Interactive);
//
// _header->resizeSection ( 0, 400 );
// _header->resizeSection ( 1, 50 );
// _header->resizeSection ( 2, 150 );
}
void NetworkView::peerCustomPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
//QAction * voteupAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Vote Link Up" ), this );
//connect( voteupAct , SIGNAL( triggered() ), this, SLOT( voteup() ) );
contextMnu.clear();
//contextMnu.addAction(voteupAct);
contextMnu.exec( mevent->globalPos() );
}
void NetworkView::changedFoFCheckBox( )
{
insertPeers();
}
void NetworkView::changedDrawSignatures( )
{
insertPeers();
}
void NetworkView::changedDrawFriends( )
{
insertPeers();
}
void NetworkView::clearPeerItems()
{
std::map<std::string, QGraphicsItem *>::iterator pit;
for(pit = mPeerItems.begin(); pit != mPeerItems.end(); pit++)
{
//mScene->removeItem(pit->second);
mScene->destroyItemGroup((QGraphicsItemGroup *) pit->second);
//delete (pit->second);
}
mPeerItems.clear();
}
void NetworkView::clearOtherItems()
{
std::list<QGraphicsItem *>::iterator oit;
for(oit = mOtherItems.begin(); oit != mOtherItems.end(); oit++)
{
mScene->removeItem(*oit);
delete (*oit);
}
mOtherItems.clear();
}
void NetworkView::clearLineItems()
{
std::list<QGraphicsItem *>::iterator oit;
for(oit = mLineItems.begin(); oit != mLineItems.end(); oit++)
{
mScene->removeItem(*oit);
delete (*oit);
}
mLineItems.clear();
}
void NetworkView::insertPeers()
{
/* clear graphics scene */
clearPeerItems();
clearOtherItems();
/* add all friends */
std::list<std::string> ids;
std::list<std::string>::iterator it;
rsPeers->getOthersList(ids);
ids.push_back(rsPeers->getOwnId()); /* add yourself too */
std::cerr << "NetworkView::insertPeers()" << std::endl;
int i = 0;
for(it = ids.begin(); it != ids.end(); it++, i++)
{
/* *** */
QString name = QString::fromStdString(rsPeers->getPeerName(*it));
QGraphicsTextItem *gti = new QGraphicsTextItem(name);
mScene->addItem(gti);
//QPointF textPoint( i * 10, i * 20);
//gti->setPos(textPoint);
gti->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
gti->setZValue(20);
QRectF textBound = gti->boundingRect();
/* work out bounds for circle */
qreal diameter = textBound.width() + 10;
if (diameter < 40)
diameter = 40;
qreal x = textBound.left() + (textBound.width() / 2.0) - (diameter/ 2.0);
qreal y = textBound.top() + (textBound.height() / 2.0) - (diameter/ 2.0);
QGraphicsEllipseItem *gei = new QGraphicsEllipseItem(x, y, diameter, diameter);
mScene->addItem(gei);
gei->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
gei->setZValue(10);
/* colour depends on Friend... */
if (*it == rsPeers->getOwnId())
{
gei->setBrush(QBrush(Qt::green));
}
else if (rsPeers->isFriend(*it))
{
gei->setBrush(QBrush(Qt::blue));
}
else
{
gei->setBrush(QBrush(Qt::red));
}
QGraphicsItemGroup *gig = new QGraphicsItemGroup();
mScene->addItem(gig);
gig->addToGroup(gei);
gig->addToGroup(gti);
gig->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
//, const QPen & pen = QPen(), const QBrush & brush = QBrush() )
mPeerItems[*it] = gig;
mOtherItems.push_back(gti);
mOtherItems.push_back(gei);
std::cerr << "NetworkView::insertPeers() Added Friend: " << *it << std::endl;
std::cerr << "\t At: " << i*5 << "," << i*10 << std::endl;
}
insertConnections();
}
void NetworkView::insertConnections()
{
clearLineItems();
/* iterate through all peerItems .... and find any proxies */
std::map<std::string, QGraphicsItem *>::const_iterator pit, pit2;
int i = 0;
for(pit = mPeerItems.begin(); pit != mPeerItems.end(); pit++, i++)
{
std::list<std::string> friendList;
std::list<std::string>::iterator it;
rsDisc->getDiscFriends(pit->first, friendList);
int j = 0;
for(it = friendList.begin(); it != friendList.end(); it++)
{
//pit2 = std::find(pit, mPeerItems.end(), *it);
pit2 = mPeerItems.find(*it);
if (pit2 == mPeerItems.end())
{
std::cerr << " Failed to Find: " << *it;
std::cerr << std::endl;
continue; /* missing */
}
if (pit == pit2)
continue; /* skip same one */
std::cerr << " Connecting: " << pit->first << " to " << pit2->first;
std::cerr << std::endl;
QPointF pos1 = (pit->second)->pos();
QRectF bound1 = (pit->second)->boundingRect();
QPointF pos2 = (pit2->second)->pos();
QRectF bound2 = (pit2->second)->boundingRect();
pos1 += QPointF(bound1.width() / 2.0, bound1.height() / 2.0);
pos2 += QPointF(bound2.width() / 2.0, bound2.height() / 2.0);
QLineF line(pos1, pos2);
QGraphicsLineItem *gli = mScene->addLine(line);
mLineItems.push_back(gli);
}
}
/* debugging all lines */
#if 0
/* iterate through all peerItems .... and find any proxies */
std::map<std::string, QGraphicsItem *>::const_iterator pit, pit2;
int i = 0;
for(pit = mPeerItems.begin(); pit != mPeerItems.end(); pit++, i++)
{
int j = 0;
for(pit2 = mPeerItems.begin(); (pit2 != mPeerItems.end()) && (j < i); pit2++, j++)
{
if (pit == pit2)
continue; /* skip same one */
std::cerr << " Connecting: " << pit->first << " to " << pit2->first;
std::cerr << std::endl;
QPointF pos1 = (pit->second)->pos();
QPointF pos2 = (pit2->second)->pos();
QLineF line(pos1, pos2);
QGraphicsLineItem *gli = mScene->addLine(line);
mLineItems.push_back(gli);
}
}
#endif
mLineChanged = true;
}
void NetworkView::changedScene()
{
std::cerr << "NetworkView::changedScene()" << std::endl;
QList<QGraphicsItem *> items = mScene->selectedItems();
std::cerr << "NetworkView::changedScene() Items selected: " << items.size() << std::endl;
/* if an item was selected and moved - then redraw lines */
if (mLineChanged)
{
mLineChanged = false;
return;
}
if (items.size() > 0)
{
mScene->clearSelection();
insertConnections();
}
}

View file

@ -0,0 +1,73 @@
/****************************************************************
* RetroShare GUI is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _NETWORK_VIEW_H
#define _NETWORK_VIEW_H
#include <QGraphicsScene>
#include "mainpage.h"
#include "ui_NetworkView.h"
class NetworkView : public MainPage
{
Q_OBJECT
public:
NetworkView(QWidget *parent = 0);
private slots:
/** Create the context popup menu and it's submenus */
void peerCustomPopupMenu( QPoint point );
void insertPeers();
void insertConnections();
void changedScene();
void changedFoFCheckBox( );
void changedDrawSignatures( );
void changedDrawFriends( );
private:
void clearPeerItems();
void clearOtherItems();
void clearLineItems();
QGraphicsScene *mScene;
std::map<std::string, QGraphicsItem *> mPeerItems;
std::list<QGraphicsItem *> mOtherItems;
std::list<QGraphicsItem *> mLineItems;
bool mLineChanged;
/** Qt Designer generated object */
Ui::NetworkView ui;
};
#endif

View file

@ -0,0 +1,76 @@
<ui version="4.0" >
<class>NetworkView</class>
<widget class="QWidget" name="NetworkView" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>479</width>
<height>467</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="refreshButton" >
<property name="text" >
<string>Refresh</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>411</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="fofCheckBox" >
<property name="text" >
<string>Show Friends of Friends</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox" >
<property name="text" >
<string>Connect Signature</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_2" >
<property name="text" >
<string>Draw Friend Connections</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QGraphicsView" name="graphicsView" />
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -17,15 +17,15 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
****************************************************************/
#include <QFile>
#include <QFile>
#include <QFileInfo>
#include "common/vmessagebox.h"
#include "rshare.h"
#include "PhotoDialog.h"
#include "rsiface/rsiface.h"
#include "common/vmessagebox.h"
#include "PhotoDialog.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsphoto.h"
#include <iostream>
#include <sstream>
@ -40,25 +40,53 @@
#include <QHeaderView>
/* Images for context menu icons */
/* Images for context menu icons */
#define IMAGE_REMOVEFRIEND ":/images/removefriend16.png"
#define IMAGE_EXPIORTFRIEND ":/images/exportpeers_16x16.png"
#define IMAGE_CHAT ":/images/chat.png"
/* Images for Status icons */
#define IMAGE_ONLINE ":/images/donline.png"
#define IMAGE_OFFLINE ":/images/dhidden.png"
/** Constructor */
PhotoDialog::PhotoDialog(QWidget *parent)
#define IMAGE_OFFLINE ":/images/dhidden.png"
#define PHOTO_ICON_SIZE 90
#define PHOTO_PEER_COL_NAME 0
#define PHOTO_PEER_COL_SHOW 1
#define PHOTO_PEER_COL_PHOTO 2
#define PHOTO_PEER_COL_PID 3
#define PHOTO_PEER_COL_SID 4
#define PHOTO_PEER_COL_PHOTOID 5
#define PHOTO_LIST_COL_PHOTO 0
#define PHOTO_LIST_COL_COMMENT 1
#define PHOTO_LIST_COL_PHOTOID 2
/** Constructor */
PhotoDialog::PhotoDialog(QWidget *parent)
: MainPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
connect( ui.photoTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( photoTreeWidgetCostumPopupMenu( QPoint ) ) );
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
connect( ui.peerTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( peerTreeWidgetCustomPopupMenu( QPoint ) ) );
connect( ui.photoTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( photoTreeWidgetCustomPopupMenu( QPoint ) ) );
connect( ui.peerTreeWidget, SIGNAL( currentItemChanged ( QTreeWidgetItem * , QTreeWidgetItem * ) ), this, SLOT( updatePhotoList( ) ) );
//connect( ui.photoTreeWidget, SIGNAL( currentItemChanged ( QTreeWidgetItem * , QTreeWidgetItem * ) ), this, SLOT( displayPhoto( ) ) );
//connect( ui.addPhotoButton, SIGNAL( clicked( ) ), this, SLOT( addPhotos( ) ) );
/* hide the Tree +/- */
ui.photoTreeWidget -> setRootIsDecorated( false );
QSize iconSize(PHOTO_ICON_SIZE,PHOTO_ICON_SIZE);
ui.photoTreeWidget->setIconSize(iconSize);
/* Set header resize modes and initial section sizes */
// QHeaderView * _header = ui.peertreeWidget->header () ;
@ -86,31 +114,204 @@ PhotoDialog::PhotoDialog(QWidget *parent)
// _header->resizeSection ( 8, 100 );
// _header->resizeSection ( 9, 100 );
// _header->resizeSection ( 10, 100 );
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
void PhotoDialog::peertreeWidgetCostumPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
voteupAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Vote Up" ), this );
connect( voteupAct , SIGNAL( triggered() ), this, SLOT( voteup() ) );
votedownAct = new QAction(QIcon(IMAGE_REMOVEFRIEND), tr( "Vote Down" ), this );
connect( votedownAct , SIGNAL( triggered() ), this, SLOT( votedown() ) );
contextMnu.clear();
contextMnu.addAction(voteupAct);
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
void PhotoDialog::peerTreeWidgetCustomPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
QAction *ins = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Insert Show Lists" ), this );
connect( ins , SIGNAL( triggered() ), this, SLOT( insertShowLists() ) );
contextMnu.clear();
contextMnu.addAction(ins);
contextMnu.exec( mevent->globalPos() );
}
void PhotoDialog::photoTreeWidgetCustomPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
QAction *rm = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Remove" ), this );
connect( rm , SIGNAL( triggered() ), this, SLOT( removePhoto() ) );
contextMnu.clear();
contextMnu.addAction(rm);
contextMnu.addSeparator();
contextMnu.addAction(votedownAct);
contextMnu.exec( mevent->globalPos() );
contextMnu.exec( mevent->globalPos() );
}
void PhotoDialog::insertShowLists()
{
/* clear it all */
ui.peerTreeWidget->clear();
/* iterate through peers */
addShows(rsPeers->getOwnId());
std::list<std::string> ids;
std::list<std::string>::iterator it;
rsPeers->getFriendList(ids);
for(it = ids.begin(); it != ids.end(); it++)
{
addShows(*it);
}
}
void PhotoDialog::addShows(std::string id)
{
std::list<std::string> allPhotos;
std::list<std::string> showIds;
std::list<std::string>::iterator it;
QTreeWidgetItem *peerItem = new QTreeWidgetItem((QTreeWidget*)0);
peerItem->setText(PHOTO_PEER_COL_NAME, QString::fromStdString(rsPeers->getPeerName(id)));
peerItem->setText(PHOTO_PEER_COL_PID, QString::fromStdString(id));
peerItem->setText(PHOTO_PEER_COL_SID, "");
peerItem->setText(PHOTO_PEER_COL_PHOTOID, "");
ui.peerTreeWidget->insertTopLevelItem(0, peerItem);
QTreeWidgetItem *allItem = new QTreeWidgetItem((QTreeWidget*)0);
allItem->setText(PHOTO_PEER_COL_SHOW, "All Photos");
allItem->setText(PHOTO_PEER_COL_PID, QString::fromStdString(id));
allItem->setText(PHOTO_PEER_COL_SID, "");
allItem->setText(PHOTO_PEER_COL_PHOTOID, "");
peerItem->addChild(allItem);
rsPhoto->getPhotoList(id, allPhotos);
rsPhoto->getShowList(id, showIds);
for(it = allPhotos.begin(); it != allPhotos.end(); it++)
{
QTreeWidgetItem *photoItem = new QTreeWidgetItem((QTreeWidget*)0);
photoItem->setText(PHOTO_PEER_COL_PHOTO, QString::fromStdString(*it));
photoItem->setText(PHOTO_PEER_COL_PID, QString::fromStdString(id));
photoItem->setText(PHOTO_PEER_COL_SID, "");
photoItem->setText(PHOTO_PEER_COL_PHOTOID, QString::fromStdString(*it));
allItem->addChild(photoItem);
}
for(it = showIds.begin(); it != showIds.end(); it++)
{
/* get details */
RsPhotoShowDetails detail;
rsPhoto->getShowDetails(id, *it, detail);
QTreeWidgetItem *showItem = new QTreeWidgetItem((QTreeWidget*)0);
showItem->setText(PHOTO_PEER_COL_SHOW, QString::fromStdString(*it));
showItem->setText(PHOTO_PEER_COL_PID, QString::fromStdString(id));
showItem->setText(PHOTO_PEER_COL_SID, QString::fromStdString(*it));
showItem->setText(PHOTO_PEER_COL_PHOTOID, "");
peerItem->addChild(showItem);
std::list<RsPhotoShowInfo>::iterator sit;
for(sit = detail.photos.begin(); sit != detail.photos.end(); sit++)
{
QTreeWidgetItem *photoItem = new QTreeWidgetItem((QTreeWidget*)0);
photoItem->setText(PHOTO_PEER_COL_PHOTO, QString::fromStdString(sit->photoId));
photoItem->setText(PHOTO_PEER_COL_PID, QString::fromStdString(id));
photoItem->setText(PHOTO_PEER_COL_SID, QString::fromStdString(*it));
photoItem->setText(PHOTO_PEER_COL_PHOTOID, QString::fromStdString(sit->photoId));
showItem->addChild(photoItem);
}
}
}
void PhotoDialog::updatePhotoList()
{
/* get current item */
QTreeWidgetItem *item = ui.peerTreeWidget->currentItem();
if (!item)
{
/* leave current list */
return;
}
/* check if it has changed */
std::string pid = item->text(PHOTO_PEER_COL_PID).toStdString();
std::string sid = item->text(PHOTO_PEER_COL_SID).toStdString();
if ((mCurrentPID == pid) && (mCurrentSID == sid))
{
/* still good */
return;
}
/* get the list of photos */
ui.photoTreeWidget->clear();
QList<QTreeWidgetItem *> items;
if (sid != "")
{
/* load up show list */
RsPhotoShowDetails detail;
rsPhoto->getShowDetails(pid, sid, detail);
std::list<RsPhotoShowInfo>::iterator sit;
for(sit = detail.photos.begin(); sit != detail.photos.end(); sit++)
{
RsPhotoDetails photoDetail;
if (!rsPhoto->getPhotoDetails(pid, sit->photoId, photoDetail))
{
continue;
}
QTreeWidgetItem *photoItem = new QTreeWidgetItem((QTreeWidget*)0);
if (photoDetail.isAvailable)
{
QPixmap qpp(QString::fromStdString(photoDetail.path));
photoItem->setIcon(PHOTO_LIST_COL_PHOTO,
QIcon(qpp.scaledToHeight(PHOTO_ICON_SIZE)));
QSize iconSize(PHOTO_ICON_SIZE + 10,PHOTO_ICON_SIZE + 10);
photoItem->setSizeHint(PHOTO_LIST_COL_PHOTO, iconSize);
}
else
{
photoItem->setText(PHOTO_LIST_COL_PHOTO, "Photo Not Available");
}
photoItem->setText(PHOTO_LIST_COL_COMMENT,
QString::fromStdWString(photoDetail.comment));
photoItem->setText(PHOTO_LIST_COL_PHOTOID,
QString::fromStdString(photoDetail.hash));
items.append(photoItem);
}
}
else
{
}
/* add the items in! */
ui.photoTreeWidget->insertTopLevelItems(0, items);
ui.photoTreeWidget->update();
}
@ -119,114 +320,6 @@ void PhotoDialog::peertreeWidgetCostumPopupMenu( QPoint point )
void PhotoDialog::insertExample()
{
#if 0
rsiface->lockData(); /* Lock Interface */
std::map<RsCertId,NeighbourInfo>::const_iterator it;
const std::map<RsCertId,NeighbourInfo> &friends =
rsiface->getFriendMap();
/* get a link to the table */
QTreeWidget *peerWidget = ui.photoTreeWidget;
/* remove old items ??? */
peerWidget->clear();
peerWidget->setColumnCount(12);
QList<QTreeWidgetItem *> items;
for(it = friends.begin(); it != friends.end(); it++)
{
/* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
/* add all the labels */
/* First 5 (1-5) Key Items */
/* () Status Icon */
item -> setText(0, "");
/* (0) Status */
item -> setText(1, QString::fromStdString(
it->second.statusString));
/* (1) Person */
item -> setText(2, QString::fromStdString(it->second.name));
/* (2) Auto Connect */
item -> setText(3, QString::fromStdString(
it->second.connectString));
/* (3) Trust Level */
item -> setText(4, QString::fromStdString(it->second.trustString));
/* (4) Peer Address */
item -> setText(5, QString::fromStdString(it->second.peerAddress));
/* less important ones */
/* () Last Contact */
item -> setText(6, QString::fromStdString(it->second.lastConnect));
/* () Org */
item -> setText(7, QString::fromStdString(it->second.org));
/* () Location */
item -> setText(8, QString::fromStdString(it->second.loc));
/* () Country */
item -> setText(9, QString::fromStdString(it->second.country));
/* Hidden ones: */
/* () RsCertId */
{
std::ostringstream out;
out << it -> second.id;
item -> setText(10, QString::fromStdString(out.str()));
}
/* () AuthCode */
item -> setText(11, QString::fromStdString(it->second.authCode));
/* change background */
int i;
if (it->second.statusString == "Online")
{
/* bright green */
for(i = 1; i < 12; i++)
{
item -> setBackground(i,QBrush(Qt::green));
item -> setIcon(0,(QIcon(IMAGE_ONLINE)));
}
}
else
{
if (it->second.lastConnect != "Never")
{
for(i = 1; i < 12; i++)
{
item -> setBackground(i,QBrush(Qt::lightGray));
item -> setIcon(0,(QIcon(IMAGE_OFFLINE)));
}
}
else
{
for(i = 1; i < 12; i++)
{
item -> setBackground(i,QBrush(Qt::gray));
item -> setIcon(0,(QIcon(IMAGE_OFFLINE)));
}
}
}
/* add to the list */
items.append(item);
}
/* add the items in! */
peerWidget->insertTopLevelItems(0, items);
rsiface->unlockData(); /* UnLock Interface */
peerWidget->update(); /* update display */
#endif
}
QTreeWidgetItem *PhotoDialog::getCurrentLine()
@ -255,24 +348,97 @@ QTreeWidgetItem *PhotoDialog::getCurrentLine()
return item;
}
void PhotoDialog::voteup()
void PhotoDialog::removePhoto()
{
QTreeWidgetItem *c = getCurrentLine();
std::cerr << "PhotoDialog::voteup()" << std::endl;
std::cerr << "PhotoDialog::removePhoto()" << std::endl;
}
void PhotoDialog::votedown()
{
QTreeWidgetItem *c = getCurrentLine();
std::cerr << "PhotoDialog::votedown()" << std::endl;
/* need to get the input address / port */
/*
std::string addr;
unsigned short port;
rsServer->FriendSetAddress(getPeerRsCertId(c), addr, port);
*/
void PhotoDialog::addPhotos()
{
/* get file dialog */
QStringList files = QFileDialog::getOpenFileNames(this,
"Select one or more Photos to add",
"/home", "Images (*.png *.xpm *.jpg *.gif)");
/* add photo to list */
QStringList::iterator it;
for(it = files.begin(); it != files.end(); it++)
{
addPhoto(*it);
}
}
void PhotoDialog::addPhoto(QString filename)
{
/* load pixmap */
/* add QTreeWidgetItem */
QPixmap *qpp = new QPixmap(filename);
/* store in map */
photoMap[filename] = qpp;
/* add treeitem */
QTreeWidgetItem *item = new QTreeWidgetItem(NULL);
/* */
item->setText(0, "Yourself");
item->setText(2, filename);
item->setIcon(1, QIcon(qpp->scaledToHeight(PHOTO_ICON_SIZE)));
QSize iconSize(PHOTO_ICON_SIZE + 10,PHOTO_ICON_SIZE + 10);
item->setSizeHint(1, iconSize);
//item->setIcon(1, QIcon(*qpp));
ui.photoTreeWidget->insertTopLevelItem (0, item);
showPhoto(filename);
}
void PhotoDialog::updatePhoto()
{
/* load pixmap */
QTreeWidgetItem *item = ui.photoTreeWidget->currentItem();
if (!item)
{
showPhoto("");
}
showPhoto(item->text(2));
}
void PhotoDialog::showPhoto(QString filename)
{
#if 0
/* find in map */
std::map<QString, QPixmap *>::iterator it;
it = photoMap.find(filename);
if (it == photoMap.end())
{
ui.photoPixLabel->clear();
ui.photoPixLabel->setText("No Photo Selected");
ui.photoNameLabel->setText("No Photo File Selected");
return;
}
QSize diaSize = ui.photoTreeWidget->size();
int width = diaSize.width();
ui.photoPixLabel->setPixmap((it->second)->scaledToWidth(width));
ui.photoNameLabel->setText(filename);
#endif
return;
}

View file

@ -24,29 +24,42 @@
#include <QFileDialog>
#include "mainpage.h"
#include "ui_PhotoDialog.h"
#include "mainpage.h"
#include "ui_PhotoDialog.h"
class PhotoDialog : public MainPage
{
Q_OBJECT
public:
#include <map>
class PhotoDialog : public MainPage
{
Q_OBJECT
public:
/** Default Constructor */
PhotoDialog(QWidget *parent = 0);
/** Default Destructor */
void insertExample();
void insertShowLists();
private slots:
/** Create the context popup menu and it's submenus */
void peertreeWidgetCostumPopupMenu( QPoint point );
void photoTreeWidgetCustomPopupMenu( QPoint point );
void peerTreeWidgetCustomPopupMenu( QPoint point );
void voteup();
void votedown();
private:
void updatePhotoList();
void removePhoto();
void updatePhoto();
void addPhotos();
private:
void addShows(std::string peerid);
void addPhoto(QString filename);
void showPhoto(QString filename);
/* Worker Functions */
/* (1) Update Display */
@ -54,11 +67,13 @@ private:
/* (2) Utility Fns */
QTreeWidgetItem *getCurrentLine();
std::map<QString, QPixmap *> photoMap;
std::string mCurrentPID;
std::string mCurrentSID;
/** Define the popup menus for the Context menu */
QMenu* contextMnu;
/** Defines the actions for the context menu */
QAction* voteupAct;
QAction* votedownAct;
QTreeWidget *exampletreeWidget;

View file

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>598</width>
<height>510</height>
<width>561</width>
<height>489</height>
</rect>
</property>
<property name="windowTitle" >
@ -14,60 +14,178 @@
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QTreeWidget" name="photoTreeWidget" >
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
<widget class="QSplitter" name="splitter_2" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<column>
<property name="text" >
<string>Friend / Set</string>
</property>
</column>
<column>
<property name="text" >
<string>Thumb Image</string>
</property>
</column>
<column>
<property name="text" >
<string>Image Name</string>
</property>
</column>
<column>
<property name="text" >
<string>Date</string>
</property>
</column>
<column>
<property name="text" >
<string>Location</string>
</property>
</column>
<column>
<property name="text" >
<string>Comment</string>
</property>
</column>
<item>
<property name="text" >
<string>QtChess</string>
</property>
<property name="text" >
<string>DrBob</string>
</property>
<property name="text" >
<string>2</string>
</property>
<property name="text" >
<string>Invites</string>
</property>
<property name="text" >
<string/>
</property>
<property name="text" >
<string/>
</property>
</item>
<widget class="QWidget" name="" >
<layout class="QVBoxLayout" >
<item>
<widget class="QSplitter" name="splitter" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTreeWidget" name="peerTreeWidget" >
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
<column>
<property name="text" >
<string>Peer</string>
</property>
</column>
<column>
<property name="text" >
<string>Slideshow</string>
</property>
</column>
<column>
<property name="text" >
<string>Photo</string>
</property>
</column>
</widget>
<widget class="QTreeWidget" name="photoTreeWidget" >
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
<column>
<property name="text" >
<string>Friend / Set</string>
</property>
</column>
<column>
<property name="text" >
<string>Thumb Image</string>
</property>
</column>
<column>
<property name="text" >
<string>Image Name</string>
</property>
</column>
<column>
<property name="text" >
<string>Date</string>
</property>
</column>
<column>
<property name="text" >
<string>Location</string>
</property>
</column>
<column>
<property name="text" >
<string>Comment</string>
</property>
</column>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="expandButton" >
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/add_24x24.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addButton" >
<property name="text" >
<string>Add Photo(s)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addShowButton" >
<property name="text" >
<string>Add Photo SlideShow</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="updateButton" >
<property name="text" >
<string>Update Details</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="" >
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Photo </string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="photoNameEdit" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Date</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="photoDateEdit" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Location</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="photoLocEdit" />
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Description</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="photoDescEdit" />
</item>
<item row="4" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Comment</string>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QTextEdit" name="photoCommentEdit" />
</item>
</layout>
</widget>
</widget>
</item>
</layout>

View file

@ -0,0 +1,236 @@
<ui version="4.0" >
<class>PhotoShow</class>
<widget class="QWidget" name="PhotoShow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>591</width>
<height>421</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Date:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Location:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Comment:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="QLineEdit" name="lineEdit_2" />
</item>
<item>
<widget class="QLineEdit" name="lineEdit" />
</item>
<item>
<widget class="QLineEdit" name="lineEdit_3" />
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Display Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_2" >
<item>
<property name="text" >
<string>320 x 320</string>
</property>
</item>
<item>
<property name="text" >
<string>640 x 640</string>
</property>
</item>
<item>
<property name="text" >
<string>Full Size</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>Play Rate:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox" >
<item>
<property name="text" >
<string>1 Sec</string>
</property>
</item>
<item>
<property name="text" >
<string>2 Sec</string>
</property>
</item>
<item>
<property name="text" >
<string>5 Sec</string>
</property>
</item>
<item>
<property name="text" >
<string>10 Sec</string>
</property>
</item>
<item>
<property name="text" >
<string>20 Sec</string>
</property>
</item>
<item>
<property name="text" >
<string>1 Min</string>
</property>
</item>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_4" >
<property name="text" >
<string>Edit Photo Details</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_3" >
<property name="text" >
<string>Save Photo</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>No Photo Selected</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_5" >
<property name="text" >
<string>Start</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_6" >
<property name="text" >
<string>Back</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton" >
<property name="text" >
<string>Play </string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2" >
<property name="text" >
<string>Pause</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_7" >
<property name="text" >
<string>Forward</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -0,0 +1,48 @@
#ifndef RETROSHARE_DISC_GUI_INTERFACE_H
#define RETROSHARE_DISC_GUI_INTERFACE_H
/*
* libretroshare/src/rsiface: rsdisc.h
*
* RetroShare C++ Interface.
*
* Copyright 2008-2008 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 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 <inttypes.h>
#include <string>
#include <list>
/* The Main Interface Class - for information about your Peers */
class RsDisc;
extern RsDisc *rsDisc;
class RsDisc
{
public:
RsDisc() { return; }
virtual ~RsDisc() { return; }
virtual bool getDiscFriends(std::string id, std::list<std::string> &friends) = 0;
};
#endif

View file

@ -0,0 +1,122 @@
#ifndef RETROSHARE_PHOTO_GUI_INTERFACE_H
#define RETROSHARE_PHOTO_GUI_INTERFACE_H
/*
* libretroshare/src/rsiface: rsphoto.h
*
* RetroShare C++ Interface.
*
* Copyright 2008-2008 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 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 <inttypes.h>
#include <string>
#include <list>
/* The Main Interface Class - for information about your Peers */
class RsPhoto;
extern RsPhoto *rsPhoto;
class RsPhotoDetails;
class RsPhotoShowDetails;
class RsPhotoShowInfo
{
public:
std::string photoId;
std::wstring altComment;
uint32_t deltaT; /* in 100ths of sec? */
};
class RsPhotoShowDetails
{
public:
RsPhotoShowDetails();
std::string id;
std::string showid;
std::string name;
std::wstring location;
std::wstring comment;
std::string date;
std::list<RsPhotoShowInfo> photos;
};
/* Details class */
class RsPhotoDetails
{
public:
RsPhotoDetails();
std::string id;
std::string srcid;
std::string hash;
std::string name;
std::wstring location;
std::wstring comment;
std::string date;
uint32_t format;
bool isAvailable;
std::string path;
};
std::ostream &operator<<(std::ostream &out, const RsPhotoShowDetails &detail);
std::ostream &operator<<(std::ostream &out, const RsPhotoDetails &detail);
class RsPhoto
{
public:
RsPhoto() { return; }
virtual ~RsPhoto() { return; }
/* access data */
virtual bool getPhotoList(std::string id, std::list<std::string> hashs) = 0;
virtual bool getShowList(std::string id, std::list<std::string> showIds) = 0;
virtual bool getShowDetails(std::string id, std::string showId, RsPhotoShowDetails &detail) = 0;
virtual bool getPhotoDetails(std::string id, std::string photoId, RsPhotoDetails &detail) = 0;
/* add / delete */
virtual std::string createShow(std::string name) = 0;
virtual bool deleteShow(std::string showId) = 0;
virtual bool addPhotoToShow(std::string showId, std::string photoId, int16_t index) = 0;
virtual bool movePhotoInShow(std::string showId, std::string photoId, int16_t index) = 0;
virtual bool removePhotoFromShow(std::string showId, std::string photoId) = 0;
virtual std::string addPhoto(std::string path) = 0; /* add from file */
virtual bool addPhoto(std::string srcId, std::string photoId) = 0; /* add from peers photos */
virtual bool deletePhoto(std::string photoId) = 0;
/* modify properties (TODO) */
virtual bool modifyShow(std::string showId, std::wstring name, std::wstring comment) = 0;
virtual bool modifyPhoto(std::string photoId, std::wstring name, std::wstring comment) = 0;
virtual bool modifyShowComment(std::string showId, std::string photoId, std::wstring comment) = 0;
};
#endif