2008-01-21 04:26:12 -05:00
|
|
|
/****************************************************************
|
|
|
|
* 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.
|
2008-03-04 16:31:11 -05:00
|
|
|
****************************************************************/
|
2008-01-21 04:26:12 -05:00
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
#include <QFile>
|
2008-01-21 04:26:12 -05:00
|
|
|
#include <QFileInfo>
|
2008-03-04 16:31:11 -05:00
|
|
|
#include "common/vmessagebox.h"
|
|
|
|
|
|
|
|
#include "PhotoDialog.h"
|
2008-03-17 10:03:47 -04:00
|
|
|
#include "PhotoShow.h"
|
2008-03-04 16:31:11 -05:00
|
|
|
#include "rsiface/rspeers.h"
|
|
|
|
#include "rsiface/rsphoto.h"
|
2008-01-21 04:26:12 -05:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#include <QContextMenuEvent>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QCursor>
|
|
|
|
#include <QPoint>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QHeaderView>
|
2008-03-17 10:03:47 -04:00
|
|
|
#include <QTimer>
|
2008-01-21 04:26:12 -05:00
|
|
|
|
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
/* Images for context menu icons */
|
2008-01-21 04:26:12 -05:00
|
|
|
#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"
|
2008-03-04 16:31:11 -05:00
|
|
|
#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
|
2008-03-17 10:03:47 -04:00
|
|
|
#define PHOTO_LIST_COL_NAME 1
|
|
|
|
#define PHOTO_LIST_COL_COMMENT 2
|
|
|
|
#define PHOTO_LIST_COL_DATE 3
|
|
|
|
#define PHOTO_LIST_COL_LOCATION 4
|
|
|
|
#define PHOTO_LIST_COL_SIZE 5
|
|
|
|
#define PHOTO_LIST_COL_PEERID 6
|
|
|
|
#define PHOTO_LIST_COL_PHOTOID 7
|
2008-03-04 16:31:11 -05:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
/******
|
|
|
|
* #define PHOTO_DEBUG 1
|
|
|
|
*****/
|
|
|
|
|
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
PhotoDialog::PhotoDialog(QWidget *parent)
|
2008-01-21 04:26:12 -05:00
|
|
|
: MainPage(parent)
|
2008-03-04 16:31:11 -05:00
|
|
|
{
|
|
|
|
/* 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( ) ) );
|
|
|
|
|
2008-03-17 10:03:47 -04:00
|
|
|
connect( ui.photoTreeWidget, SIGNAL( itemDoubleClicked ( QTreeWidgetItem * , int ) ), this, SLOT( showPhoto( QTreeWidgetItem *, int ) ) );
|
|
|
|
connect( ui.addButton, SIGNAL( clicked( ) ), this, SLOT( addPhotos( ) ) );
|
2008-01-21 04:26:12 -05:00
|
|
|
|
|
|
|
/* hide the Tree +/- */
|
|
|
|
ui.photoTreeWidget -> setRootIsDecorated( false );
|
2008-03-04 16:31:11 -05:00
|
|
|
|
|
|
|
QSize iconSize(PHOTO_ICON_SIZE,PHOTO_ICON_SIZE);
|
|
|
|
ui.photoTreeWidget->setIconSize(iconSize);
|
2008-01-21 04:26:12 -05:00
|
|
|
|
|
|
|
/* Set header resize modes and initial section sizes */
|
|
|
|
// QHeaderView * _header = ui.peertreeWidget->header () ;
|
|
|
|
// _header->setResizeMode (0, QHeaderView::Custom);
|
|
|
|
// _header->setResizeMode (1, QHeaderView::Interactive);
|
|
|
|
// _header->setResizeMode (2, QHeaderView::Interactive);
|
|
|
|
// _header->setResizeMode (3, QHeaderView::Interactive);
|
|
|
|
// _header->setResizeMode (4, QHeaderView::Interactive);
|
|
|
|
// _header->setResizeMode (5, QHeaderView::Interactive);
|
|
|
|
// _header->setResizeMode (6, QHeaderView::Interactive);
|
|
|
|
// _header->setResizeMode (7, QHeaderView::Interactive);
|
|
|
|
// _header->setResizeMode (8, QHeaderView::Interactive);
|
|
|
|
// _header->setResizeMode (9, QHeaderView::Interactive);
|
|
|
|
// _header->setResizeMode (10, QHeaderView::Interactive);
|
|
|
|
// _header->setResizeMode (11, QHeaderView::Interactive);
|
|
|
|
//
|
|
|
|
// _header->resizeSection ( 0, 25 );
|
|
|
|
// _header->resizeSection ( 1, 100 );
|
|
|
|
// _header->resizeSection ( 2, 100 );
|
|
|
|
// _header->resizeSection ( 3, 100 );
|
|
|
|
// _header->resizeSection ( 4, 100 );
|
|
|
|
// _header->resizeSection ( 5, 200 );
|
|
|
|
// _header->resizeSection ( 6, 100 );
|
|
|
|
// _header->resizeSection ( 7, 100 );
|
|
|
|
// _header->resizeSection ( 8, 100 );
|
|
|
|
// _header->resizeSection ( 9, 100 );
|
|
|
|
// _header->resizeSection ( 10, 100 );
|
2008-03-04 16:31:11 -05:00
|
|
|
|
|
|
|
|
2008-03-17 10:03:47 -04:00
|
|
|
/* Set a GUI update timer - much cleaner than
|
|
|
|
* doing everything through the notify agent
|
|
|
|
*/
|
|
|
|
|
|
|
|
QTimer *timer = new QTimer(this);
|
|
|
|
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
|
|
|
|
timer->start(1000);
|
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
/* Hide platform specific features */
|
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
|
|
|
|
#endif
|
2008-03-17 10:03:47 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void PhotoDialog::checkUpdate()
|
|
|
|
{
|
|
|
|
/* update */
|
|
|
|
if (!rsPhoto)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (rsPhoto->updated())
|
|
|
|
{
|
|
|
|
insertShowLists();
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2008-03-04 16:31:11 -05:00
|
|
|
}
|
|
|
|
|
2008-03-17 10:03:47 -04:00
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
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);
|
2008-01-21 04:26:12 -05:00
|
|
|
contextMnu.addSeparator();
|
2008-03-04 16:31:11 -05:00
|
|
|
contextMnu.exec( mevent->globalPos() );
|
2008-01-21 04:26:12 -05:00
|
|
|
}
|
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
void PhotoDialog::insertShowLists()
|
|
|
|
{
|
|
|
|
/* clear it all */
|
|
|
|
ui.peerTreeWidget->clear();
|
2008-01-21 04:26:12 -05:00
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
/* iterate through peers */
|
|
|
|
addShows(rsPeers->getOwnId());
|
2008-01-21 04:26:12 -05:00
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
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)
|
2008-01-21 04:26:12 -05:00
|
|
|
{
|
2008-03-04 16:31:11 -05:00
|
|
|
std::list<std::string> allPhotos;
|
|
|
|
std::list<std::string> showIds;
|
|
|
|
std::list<std::string>::iterator it;
|
2008-01-25 03:49:40 -05:00
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
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, "");
|
2008-01-21 04:26:12 -05:00
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
ui.peerTreeWidget->insertTopLevelItem(0, peerItem);
|
2008-01-21 04:26:12 -05:00
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
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, "");
|
2008-01-21 04:26:12 -05:00
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
peerItem->addChild(allItem);
|
2008-01-21 04:26:12 -05:00
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
rsPhoto->getPhotoList(id, allPhotos);
|
|
|
|
rsPhoto->getShowList(id, showIds);
|
|
|
|
|
|
|
|
for(it = allPhotos.begin(); it != allPhotos.end(); it++)
|
2008-01-21 04:26:12 -05:00
|
|
|
{
|
2008-03-04 16:31:11 -05:00
|
|
|
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++)
|
2008-01-21 04:26:12 -05:00
|
|
|
{
|
2008-03-04 16:31:11 -05:00
|
|
|
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);
|
2008-01-21 04:26:12 -05:00
|
|
|
}
|
2008-03-04 16:31:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PhotoDialog::updatePhotoList()
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef PHOTO_DEBUG
|
2008-03-17 10:03:47 -04:00
|
|
|
std::cerr << "PhotoDialog::updatePhotoList()" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-17 10:03:47 -04:00
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
/* get current item */
|
|
|
|
QTreeWidgetItem *item = ui.peerTreeWidget->currentItem();
|
|
|
|
|
|
|
|
if (!item)
|
|
|
|
{
|
|
|
|
/* leave current list */
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef PHOTO_DEBUG
|
2008-03-17 10:03:47 -04:00
|
|
|
std::cerr << "PhotoDialog::updatePhotoList() No Current item -> leave" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-04 16:31:11 -05:00
|
|
|
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 */
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef PHOTO_DEBUG
|
2008-03-17 10:03:47 -04:00
|
|
|
std::cerr << "PhotoDialog::updatePhotoList() List still good!" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-04 16:31:11 -05:00
|
|
|
return;
|
|
|
|
}
|
2008-01-21 04:26:12 -05:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef PHOTO_DEBUG
|
2008-03-17 10:03:47 -04:00
|
|
|
std::cerr << "PhotoDialog::updatePhotoList() pid: " << pid << " sid: " << sid << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-04 16:31:11 -05:00
|
|
|
/* get the list of photos */
|
|
|
|
|
|
|
|
ui.photoTreeWidget->clear();
|
|
|
|
QList<QTreeWidgetItem *> items;
|
|
|
|
|
|
|
|
if (sid != "")
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef PHOTO_DEBUG
|
2008-03-17 10:03:47 -04:00
|
|
|
std::cerr << "PhotoDialog::updatePhotoList() SID -> showing show" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-04 16:31:11 -05:00
|
|
|
/* load up show list */
|
|
|
|
RsPhotoShowDetails detail;
|
|
|
|
rsPhoto->getShowDetails(pid, sid, detail);
|
2008-01-21 04:26:12 -05:00
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
|
|
|
|
std::list<RsPhotoShowInfo>::iterator sit;
|
|
|
|
for(sit = detail.photos.begin(); sit != detail.photos.end(); sit++)
|
2008-01-21 04:26:12 -05:00
|
|
|
{
|
2008-03-04 16:31:11 -05:00
|
|
|
RsPhotoDetails photoDetail;
|
|
|
|
|
|
|
|
if (!rsPhoto->getPhotoDetails(pid, sit->photoId, photoDetail))
|
2008-01-21 04:26:12 -05:00
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef PHOTO_DEBUG
|
2008-03-17 10:03:47 -04:00
|
|
|
std::cerr << "PhotoDialog::updatePhotoList() getPhotoDetails: " << sit->photoId << " FAILED" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-04 16:31:11 -05:00
|
|
|
continue;
|
2008-01-21 04:26:12 -05:00
|
|
|
}
|
2008-03-04 16:31:11 -05:00
|
|
|
|
|
|
|
QTreeWidgetItem *photoItem = new QTreeWidgetItem((QTreeWidget*)0);
|
|
|
|
if (photoDetail.isAvailable)
|
2008-01-21 04:26:12 -05:00
|
|
|
{
|
2008-03-04 16:31:11 -05:00
|
|
|
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);
|
2008-01-21 04:26:12 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-04 16:31:11 -05:00
|
|
|
photoItem->setText(PHOTO_LIST_COL_PHOTO, "Photo Not Available");
|
2008-01-21 04:26:12 -05:00
|
|
|
}
|
|
|
|
|
2008-03-17 10:03:47 -04:00
|
|
|
photoItem->setText(PHOTO_LIST_COL_NAME,
|
|
|
|
QString::fromStdString(photoDetail.name));
|
2008-03-04 16:31:11 -05:00
|
|
|
photoItem->setText(PHOTO_LIST_COL_COMMENT,
|
|
|
|
QString::fromStdWString(photoDetail.comment));
|
2008-03-17 10:03:47 -04:00
|
|
|
photoItem->setText(PHOTO_LIST_COL_DATE,
|
|
|
|
QString::fromStdString(photoDetail.date));
|
|
|
|
photoItem->setText(PHOTO_LIST_COL_LOCATION,
|
|
|
|
QString::fromStdString(photoDetail.location));
|
|
|
|
photoItem->setText(PHOTO_LIST_COL_SIZE,
|
|
|
|
QString::number(photoDetail.size));
|
|
|
|
photoItem->setText(PHOTO_LIST_COL_PEERID,
|
|
|
|
QString::fromStdString(photoDetail.id));
|
2008-03-04 16:31:11 -05:00
|
|
|
photoItem->setText(PHOTO_LIST_COL_PHOTOID,
|
|
|
|
QString::fromStdString(photoDetail.hash));
|
|
|
|
|
|
|
|
items.append(photoItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef PHOTO_DEBUG
|
2008-03-17 10:03:47 -04:00
|
|
|
std::cerr << "PhotoDialog::updatePhotoList() No SID -> show all" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-17 10:03:47 -04:00
|
|
|
|
|
|
|
std::list<std::string> photoIds;
|
|
|
|
std::list<std::string>::iterator pit;
|
|
|
|
rsPhoto->getPhotoList(pid, photoIds);
|
|
|
|
for(pit = photoIds.begin(); pit != photoIds.end(); pit++)
|
|
|
|
{
|
|
|
|
RsPhotoDetails photoDetail;
|
|
|
|
|
|
|
|
if (!rsPhoto->getPhotoDetails(pid, *pit, photoDetail))
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef PHOTO_DEBUG
|
2008-03-17 10:03:47 -04:00
|
|
|
std::cerr << "PhotoDialog::updatePhotoList() getPhotoDetails: " << *pit << " FAILED" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-17 10:03:47 -04:00
|
|
|
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_NAME,
|
|
|
|
QString::fromStdString(photoDetail.name));
|
|
|
|
photoItem->setText(PHOTO_LIST_COL_COMMENT,
|
|
|
|
QString::fromStdWString(photoDetail.comment));
|
|
|
|
photoItem->setText(PHOTO_LIST_COL_DATE,
|
|
|
|
QString::fromStdString(photoDetail.date));
|
|
|
|
photoItem->setText(PHOTO_LIST_COL_LOCATION,
|
|
|
|
QString::fromStdString(photoDetail.location));
|
|
|
|
photoItem->setText(PHOTO_LIST_COL_SIZE,
|
|
|
|
QString::number(photoDetail.size));
|
|
|
|
photoItem->setText(PHOTO_LIST_COL_PEERID,
|
|
|
|
QString::fromStdString(photoDetail.id));
|
|
|
|
photoItem->setText(PHOTO_LIST_COL_PHOTOID,
|
|
|
|
QString::fromStdString(photoDetail.hash));
|
|
|
|
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef PHOTO_DEBUG
|
2008-03-17 10:03:47 -04:00
|
|
|
std::cerr << "PhotoDialog::updatePhotoList() added Item: " << *pit << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-17 10:03:47 -04:00
|
|
|
items.append(photoItem);
|
|
|
|
}
|
2008-01-21 04:26:12 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-03-17 10:03:47 -04:00
|
|
|
/* update ids? */
|
|
|
|
mCurrentPID = pid;
|
|
|
|
mCurrentSID = sid;
|
|
|
|
|
2008-01-21 04:26:12 -05:00
|
|
|
/* add the items in! */
|
2008-03-04 16:31:11 -05:00
|
|
|
ui.photoTreeWidget->insertTopLevelItems(0, items);
|
|
|
|
ui.photoTreeWidget->update();
|
|
|
|
}
|
2008-01-21 04:26:12 -05:00
|
|
|
|
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
|
|
|
|
/* get the list of peers from the RsIface. */
|
|
|
|
void PhotoDialog::insertExample()
|
|
|
|
{
|
|
|
|
|
2008-01-21 04:26:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
QTreeWidgetItem *PhotoDialog::getCurrentLine()
|
|
|
|
{
|
|
|
|
/* get the current, and extract the Id */
|
|
|
|
|
|
|
|
/* get a link to the table */
|
|
|
|
QTreeWidget *peerWidget = ui.photoTreeWidget;
|
|
|
|
QTreeWidgetItem *item = peerWidget -> currentItem();
|
|
|
|
if (!item)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef PHOTO_DEBUG
|
2008-01-21 04:26:12 -05:00
|
|
|
std::cerr << "Invalid Current Item" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-01-21 04:26:12 -05:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Display the columns of this item. */
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef PHOTO_DEBUG
|
2008-01-21 04:26:12 -05:00
|
|
|
std::ostringstream out;
|
|
|
|
out << "CurrentPeerItem: " << std::endl;
|
|
|
|
|
|
|
|
for(int i = 1; i < 6; i++)
|
|
|
|
{
|
|
|
|
QString txt = item -> text(i);
|
|
|
|
out << "\t" << i << ":" << txt.toStdString() << std::endl;
|
|
|
|
}
|
|
|
|
std::cerr << out.str();
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-01-21 04:26:12 -05:00
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
void PhotoDialog::removePhoto()
|
2008-01-21 04:26:12 -05:00
|
|
|
{
|
|
|
|
QTreeWidgetItem *c = getCurrentLine();
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef PHOTO_DEBUG
|
2008-03-04 16:31:11 -05:00
|
|
|
std::cerr << "PhotoDialog::removePhoto()" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-01-21 04:26:12 -05:00
|
|
|
}
|
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
|
|
|
|
void PhotoDialog::addPhotos()
|
2008-01-21 04:26:12 -05:00
|
|
|
{
|
2008-03-04 16:31:11 -05:00
|
|
|
/* 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);
|
|
|
|
}
|
2008-01-21 04:26:12 -05:00
|
|
|
}
|
|
|
|
|
2008-03-04 16:31:11 -05:00
|
|
|
void PhotoDialog::addPhoto(QString filename)
|
|
|
|
{
|
2008-03-17 10:03:47 -04:00
|
|
|
/* store in rsPhoto */
|
|
|
|
std::string photoId = rsPhoto->addPhoto(filename.toStdString());
|
2008-03-04 16:31:11 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-03-17 10:03:47 -04:00
|
|
|
void PhotoDialog::showPhoto( QTreeWidgetItem *item, int column)
|
2008-03-04 16:31:11 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
if (!item)
|
2008-03-17 10:03:47 -04:00
|
|
|
return;
|
2008-03-04 16:31:11 -05:00
|
|
|
|
2008-03-17 10:03:47 -04:00
|
|
|
/* get the photoId */
|
|
|
|
std::string pid = item->text(PHOTO_LIST_COL_PEERID).toStdString();
|
|
|
|
std::string photoid = item->text(PHOTO_LIST_COL_PHOTOID).toStdString();
|
2008-03-04 16:31:11 -05:00
|
|
|
|
2008-03-17 10:03:47 -04:00
|
|
|
PhotoShow *newView = new PhotoShow();
|
|
|
|
newView->show();
|
2008-03-04 16:31:11 -05:00
|
|
|
|
2008-03-17 10:03:47 -04:00
|
|
|
newView->setPeerId(pid);
|
|
|
|
newView->setPhotoId(photoid);
|
2008-03-04 16:31:11 -05:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-21 04:26:12 -05:00
|
|
|
|
|
|
|
|