Addition of new GamesDialog and PhotoDialog.

The GamesDialog is semi-functional, but doesn't launch games yet, while the PhotoDialog is a place holder.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@302 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-01-21 09:26:12 +00:00
parent 0712590a99
commit b05d5d3297
9 changed files with 1420 additions and 1 deletions

View File

@ -58,6 +58,8 @@ HEADERS += rshare.h \
gui/MainWindow.h \
gui/ApplicationWindow.h \
gui/ExampleDialog.h \
gui/GamesDialog.h \
gui/PhotoDialog.h \
gui/MessengerWindow.h \
gui/PeersDialog.h \
gui/SearchDialog.h \
@ -142,6 +144,8 @@ FORMS += gui/ChatDialog.ui \
gui/MainWindow.ui \
gui/ApplicationWindow.ui \
gui/ExampleDialog.ui \
gui/GamesDialog.ui \
gui/PhotoDialog.ui \
gui/MessengerWindow.ui \
gui/PeersDialog.ui \
gui/SearchDialog.ui \
@ -201,6 +205,8 @@ SOURCES += main.cpp \
gui/MainWindow.cpp \
gui/ApplicationWindow.cpp \
gui/ExampleDialog.cpp \
gui/GamesDialog.cpp \
gui/PhotoDialog.cpp \
gui/MessengerWindow.cpp \
gui/PeersDialog.cpp \
gui/SearchDialog.cpp \

View File

@ -30,6 +30,7 @@
#include <rshare.h>
#include "ApplicationWindow.h"
#include "Preferences/PreferencesWindow.h"
#include "Settings/gsettingswin.h"
#include "util/rsversion.h"
@ -39,6 +40,8 @@
#include "gui/connect/InviteDialog.h"
#include "gui/connect/AddFriendDialog.h"
#include "GamesDialog.h"
#include "PhotoDialog.h"
#define FONT QFont(tr("Arial"), 8)
@ -85,6 +88,15 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
ui.stackPages->add(exampleDialog = new ExampleDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_MESSAGES), tr("Example Application"), grp));
GamesDialog *gamesDialog = NULL;
ui.stackPages->add(gamesDialog = new GamesDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_MESSAGES), tr("Games Launcher"), grp));
PhotoDialog *photoDialog = NULL;
ui.stackPages->add(photoDialog = new PhotoDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_MESSAGES), tr("Photo View"), grp));
//ui.stackPages->add(groupsDialog = new GroupsDialog(ui.stackPages),
// createPageAction(QIcon(), tr("Groups"), grp));

View File

@ -0,0 +1,548 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006,2007 crypton
*
* 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 <QFile>
#include <QFileInfo>
//#include "common/vmessagebox.h"
//#include "rshare.h"
#include "GamesDialog.h"
#include "rsiface/rsiface.h"
#include "rsiface/rsgame.h"
#include <iostream>
#include <sstream>
#include <QContextMenuEvent>
#include <QMenu>
#include <QCursor>
#include <QPoint>
#include <QMouseEvent>
#include <QPixmap>
#include <QMessageBox>
#include <QHeaderView>
const uint32_t GAME_LIST_TYPE = 0;
const uint32_t GAME_LIST_SERVER = 1;
const uint32_t GAME_LIST_STATUS = 2;
const uint32_t GAME_LIST_NAME = 3;
const uint32_t GAME_LIST_ID = 4;
const uint32_t GAME_PEER_PLAYER = 0;
const uint32_t GAME_PEER_INVITE = 1;
const uint32_t GAME_PEER_INTEREST = 2;
const uint32_t GAME_PEER_PLAY = 3;
const uint32_t GAME_PEER_ID = 4;
/* 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 */
GamesDialog::GamesDialog(QWidget *parent)
: MainPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
connect( ui.gameTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( gameListPopupMenu( QPoint ) ) );
connect( ui.peertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( gamePeersPopupMenu( QPoint ) ) );
connect( ui.createButton, SIGNAL( pressed( void ) ), this, SLOT( createGame( void ) ) );
connect( ui.deleteButton, SIGNAL( pressed( void ) ), this, SLOT( deleteGame( void ) ) );
connect( ui.inviteButton, SIGNAL( pressed( void ) ), this, SLOT( inviteGame( void ) ) );
connect( ui.playButton, SIGNAL( pressed( void ) ), this, SLOT( playGame ( void ) ) );
connect( ui.gameTreeWidget, SIGNAL( itemSelectionChanged( void ) ), this, SLOT( updateGameDetails( void ) ) );
/* hide the Tree +/- */
ui.peertreeWidget -> setRootIsDecorated( false );
/* 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 );
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
void GamesDialog::updateGameList()
{
/* get the list of games from the server */
std::list<RsGameInfo> gameList;
std::list<RsGameInfo>::iterator it;
rsGameLauncher->getGameList(gameList);
/* get a link to the table */
QTreeWidget *gameWidget = ui.gameTreeWidget;
QTreeWidgetItem *oldSelect = getCurrentGame();
QTreeWidgetItem *newSelect = NULL;
std::string oldId;
if (oldSelect)
{
oldId = (oldSelect->text(GAME_LIST_ID)).toStdString();
}
QList<QTreeWidgetItem *> items;
for(it = gameList.begin(); it != gameList.end(); it++)
{
/* make a widget per game */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
item -> setText(GAME_LIST_TYPE, QString::fromStdString(it->gameType));
item -> setText(GAME_LIST_SERVER, QString::fromStdString(it->serverName));
item -> setText(GAME_LIST_NAME, QString::fromStdString(it->gameName));
item -> setText(GAME_LIST_STATUS, QString::fromStdString(it->status));
item -> setText(GAME_LIST_ID, QString::fromStdString(it->gameId));
if ((oldSelect) && (oldId == it->gameId))
{
newSelect = item;
}
/* add to the list */
items.append(item);
}
gameWidget->clear();
gameWidget->setColumnCount(5);
/* add the items in! */
gameWidget->insertTopLevelItems(0, items);
if (newSelect)
{
gameWidget->setCurrentItem(newSelect);
}
gameWidget->update(); /* update display */
updateGameDetails();
}
QTreeWidgetItem *GamesDialog::getCurrentGame()
{
return ui.gameTreeWidget->currentItem();
}
QTreeWidgetItem *GamesDialog::getCurrentPeer()
{
return ui.peertreeWidget->currentItem();
}
void GamesDialog::updateGameDetails()
{
/* get the list of games from the server */
RsGameDetail detail;
/* get a link to the table */
QTreeWidget *detailWidget = ui.peertreeWidget;
QTreeWidgetItem *gameSelect = getCurrentGame();
if (!gameSelect)
{
/* clear and finished */
detailWidget->clear();
//detailWidget->update();
mCurrentGame = "";
mCurrentGameStatus = "";
return;
}
std::string gameId = (gameSelect->text(GAME_LIST_ID)).toStdString();
rsGameLauncher->getGameDetail(gameId, detail);
QTreeWidgetItem *oldSelect = getCurrentPeer();
QTreeWidgetItem *newSelect = NULL;
std::string oldId;
if (mCurrentGame != gameId)
oldSelect = NULL; /* if we've changed game -> clear select */
if (oldSelect)
{
oldId = (oldSelect->text(GAME_PEER_ID)).toStdString();
}
QList<QTreeWidgetItem *> items;
/* layout depends on the game status */
std::map<std::string, RsGamePeer>::iterator it;
for(it = detail.gamers.begin(); it != detail.gamers.end(); it++)
{
bool showPeer = false;
if (detail.status == "Invite")
{
showPeer = true;
}
else if (detail.status == "Confirm")
{
if ((it->second).invite == true)
showPeer = true;
}
else if (detail.status == "Playing")
{
if ((it->second).play == true)
showPeer = true;
}
/* display */
if (showPeer)
{
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
item -> setText(GAME_PEER_PLAYER, QString::fromStdString(it->second.name));
if (it->second.invite)
item -> setText(GAME_PEER_INVITE, "Yes");
else
item -> setText(GAME_PEER_INVITE, "No");
if (it->second.interested)
item -> setText(GAME_PEER_INTEREST, "Yes");
else
item -> setText(GAME_PEER_INTEREST, "No");
if (it->second.play)
item -> setText(GAME_PEER_PLAY, "Yes");
else
item -> setText(GAME_PEER_PLAY, "No");
/* add a checkItem here */
//item -> setText(GAME_PEER_PLAY, "Maybe");
item -> setText(GAME_PEER_ID, QString::fromStdString(it->first));
if ((oldSelect) && (oldId == it->first))
{
newSelect = item;
}
/* add to the list */
items.append(item);
}
}
if (detail.status == "Invite")
{
/* add all the online peers not listed above */
rsiface->lockData(); /* Lock Interface */
std::map<RsCertId,NeighbourInfo>::const_iterator fit;
const std::map<RsCertId,NeighbourInfo> &friends =
rsiface->getFriendMap();
for(fit = friends.begin(); fit != friends.end(); fit++)
{
if (detail.gamers.end() != detail.gamers.find(fit->first))
{
/* already present */
continue;
}
if (1)
{
/* not online */
}
/* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
item -> setText(GAME_PEER_PLAYER, QString::fromStdString(fit->second.name));
item -> setText(GAME_PEER_INVITE, "No");
item -> setText(GAME_PEER_INTEREST, "?");
item -> setText(GAME_PEER_PLAY, "?");
item -> setText(GAME_PEER_ID, QString::fromStdString(fit->first));
if ((oldSelect) && (oldId == fit->first))
{
newSelect = item;
}
/* add to the list */
items.append(item);
}
rsiface->unlockData(); /* UnLock Interface */
}
detailWidget->clear();
detailWidget->setColumnCount(5);
/* add the items in! */
detailWidget->insertTopLevelItems(0, items);
if (newSelect)
{
detailWidget->setCurrentItem(newSelect);
}
detailWidget->update(); /* update display */
/* store the game Id */
mCurrentGame = gameId;
mCurrentGameStatus = detail.status;
}
void GamesDialog::gameListPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
QAction *deleteAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Cancel Game" ), this );
connect( deleteAct , SIGNAL( triggered() ), this, SLOT( deleteGame() ) );
contextMnu.clear();
contextMnu.addSeparator();
contextMnu.addAction(deleteAct);
contextMnu.addSeparator();
contextMnu.exec( mevent->globalPos() );
}
void GamesDialog::gamePeersPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
if (mCurrentGame == "")
{
return;
}
if (mCurrentGameStatus == "Invite")
{
/* invite */
/* uninvite */
QAction *inviteAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Add to Invite List" ), this );
connect( inviteAct , SIGNAL( triggered() ), this, SLOT( invitePeer() ) );
QAction *uninviteAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Remove from Invite List" ), this );
connect( uninviteAct , SIGNAL( triggered() ), this, SLOT( uninvitePeer() ) );
contextMnu.clear();
contextMnu.addAction(inviteAct);
contextMnu.addAction(uninviteAct);
contextMnu.exec( mevent->globalPos() );
}
else if (mCurrentGameStatus == "Confirm")
{
/* invite */
/* uninvite */
QAction *inviteAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Add to Play List" ), this );
connect( inviteAct , SIGNAL( triggered() ), this, SLOT( confirmPeer() ) );
QAction *uninviteAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Remove from Play List" ), this );
connect( uninviteAct , SIGNAL( triggered() ), this, SLOT( unconfirmPeer() ) );
QAction *interestedAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Interested in Game" ), this );
connect( interestedAct , SIGNAL( triggered() ), this, SLOT( interested() ) );
QAction *uninterestedAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Not Interested" ), this );
connect( uninterestedAct , SIGNAL( triggered() ), this, SLOT( uninterested() ) );
contextMnu.clear();
contextMnu.addAction(inviteAct);
contextMnu.addAction(uninviteAct);
contextMnu.addSeparator();
contextMnu.addAction(interestedAct);
contextMnu.addAction(uninterestedAct);
contextMnu.exec( mevent->globalPos() );
}
else
{
/* no menu for playing */
}
return;
}
void GamesDialog::createGame()
{
/* extract the Game Type and number of players from GUI */
std::string gameName = ui.gameNameEdit->text().toStdString();
uint32_t gameType = ui.gameComboBox->currentIndex();
bool addAll = ui.checkInviteAll->isChecked();
std::list<std::string> playerList;
std::string gameId = rsGameLauncher->createGame(gameType, gameName);
if (addAll)
{
/* add all the online peers not listed above */
rsiface->lockData(); /* Lock Interface */
std::map<RsCertId,NeighbourInfo>::const_iterator fit;
const std::map<RsCertId,NeighbourInfo> &friends =
rsiface->getFriendMap();
for(fit = friends.begin(); fit != friends.end(); fit++)
{
rsGameLauncher -> invitePeer(gameId, fit->first);
}
rsiface->unlockData(); /* UnLock Interface */
}
/* call to the GameControl */
std::cerr << "GamesDialog::createGame() Game: " << gameType << " name: " << gameName;
std::cerr << std::endl;
updateGameList();
}
void GamesDialog::deleteGame()
{
QTreeWidgetItem *gameSelect = getCurrentGame();
if (!gameSelect)
return;
std::string gameId = (gameSelect->text(GAME_LIST_ID)).toStdString();
rsGameLauncher->deleteGame(gameId);
updateGameList();
}
void GamesDialog::inviteGame()
{
QTreeWidgetItem *gameSelect = getCurrentGame();
if (!gameSelect)
return;
std::string gameId = (gameSelect->text(GAME_LIST_ID)).toStdString();
rsGameLauncher->inviteGame(gameId);
updateGameList();
}
void GamesDialog::playGame()
{
QTreeWidgetItem *gameSelect = getCurrentGame();
if (!gameSelect)
return;
std::string gameId = (gameSelect->text(GAME_LIST_ID)).toStdString();
rsGameLauncher->playGame(gameId);
updateGameList();
}
void GamesDialog::invitePeer()
{
QTreeWidgetItem *peerSelect = getCurrentPeer();
if (!peerSelect)
return;
std::string peerId = (peerSelect->text(GAME_PEER_ID)).toStdString();
rsGameLauncher->invitePeer(mCurrentGame, peerId);
updateGameDetails();
}
void GamesDialog::uninvitePeer()
{
QTreeWidgetItem *peerSelect = getCurrentPeer();
if (!peerSelect)
return;
std::string peerId = (peerSelect->text(GAME_PEER_ID)).toStdString();
rsGameLauncher->uninvitePeer(mCurrentGame, peerId);
updateGameDetails();
}
void GamesDialog::confirmPeer()
{
QTreeWidgetItem *peerSelect = getCurrentPeer();
if (!peerSelect)
return;
std::string peerId = (peerSelect->text(GAME_PEER_ID)).toStdString();
rsGameLauncher->confirmPeer(mCurrentGame, peerId);
updateGameDetails();
}
void GamesDialog::unconfirmPeer()
{
QTreeWidgetItem *peerSelect = getCurrentPeer();
if (!peerSelect)
return;
std::string peerId = (peerSelect->text(GAME_PEER_ID)).toStdString();
rsGameLauncher->unconfirmPeer(mCurrentGame, peerId);
updateGameDetails();
}
void GamesDialog::interested()
{
QTreeWidgetItem *gameSelect = getCurrentGame();
if (!gameSelect)
return;
std::string gameId = (gameSelect->text(GAME_LIST_ID)).toStdString();
rsGameLauncher->interestedPeer(gameId);
updateGameDetails();
}
void GamesDialog::uninterested()
{
QTreeWidgetItem *gameSelect = getCurrentGame();
if (!gameSelect)
return;
std::string gameId = (gameSelect->text(GAME_LIST_ID)).toStdString();
rsGameLauncher->uninterestedPeer(gameId);
updateGameDetails();
}

View File

@ -0,0 +1,80 @@
/****************************************************************
* RetroShareGui is distributed under the following license:
*
* Copyright (C) 2007-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 _GAMESDIALOG_H
#define _GAMESDIALOG_H
#include "mainpage.h"
#include "ui_GamesDialog.h"
class GamesDialog : public MainPage
{
Q_OBJECT
public:
/** Default Constructor */
GamesDialog(QWidget *parent = 0);
/** Default Destructor */
void insertExample();
private slots:
/** Create the context popup menu and it's submenus */
void gameListPopupMenu( QPoint point );
void gamePeersPopupMenu( QPoint point );
void createGame();
void deleteGame();
void inviteGame();
void playGame();
void invitePeer();
void uninvitePeer();
void confirmPeer();
void unconfirmPeer();
void interested();
void uninterested();
void updateGameList();
void updateGameDetails();
/***
*
*/
private:
/***** UTILS *******/
QTreeWidgetItem *getCurrentGame();
QTreeWidgetItem *getCurrentPeer();
/* Data */
std::string mCurrentGame;
std::string mCurrentGameStatus;
private:
/** Qt Designer generated object */
Ui::GamesDialog ui;
};
#endif

View File

@ -0,0 +1,347 @@
<ui version="4.0" >
<class>GamesDialog</class>
<widget class="QWidget" name="GamesDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>578</width>
<height>519</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<layout class="QGridLayout" >
<item row="0" column="0" >
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="font" >
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text" >
<string>Game:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="gameComboBox" >
<item>
<property name="text" >
<string>QtChess</string>
</property>
</item>
<item>
<property name="text" >
<string>Backgammon</string>
</property>
</item>
<item>
<property name="text" >
<string>QGo</string>
</property>
</item>
<item>
<property name="text" >
<string>Snakes</string>
</property>
</item>
<item>
<property name="text" >
<string>BigTwo</string>
</property>
</item>
<item>
<property name="text" >
<string>Poker</string>
</property>
</item>
<item>
<property name="text" >
<string>Checkers</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label_4" >
<property name="font" >
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text" >
<string>Title / Comment</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="gameNameEdit" />
</item>
</layout>
</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="createButton" >
<property name="font" >
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text" >
<string>Create New Game</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/kbackgammon.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkInviteAll" >
<property name="font" >
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text" >
<string>Invite All Friends</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>
<item row="1" column="0" >
<widget class="QSplitter" name="splitter" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<widget class="QTreeWidget" name="gameTreeWidget" >
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
<column>
<property name="text" >
<string>Game Type</string>
</property>
</column>
<column>
<property name="text" >
<string>Server</string>
</property>
</column>
<column>
<property name="text" >
<string>Status</string>
</property>
</column>
<column>
<property name="text" >
<string>Comment</string>
</property>
</column>
<column>
<property name="text" >
<string>GameID</string>
</property>
</column>
<item>
<property name="text" >
<string>QtChess</string>
</property>
<property name="text" >
<string>DrBob</string>
</property>
<property name="text" >
<string>Invites</string>
</property>
<property name="text" >
<string>2</string>
</property>
<property name="text" >
<string/>
</property>
</item>
</widget>
<widget class="QTreeWidget" name="peertreeWidget" >
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
<column>
<property name="text" >
<string>Player</string>
</property>
</column>
<column>
<property name="text" >
<string>Invite</string>
</property>
</column>
<column>
<property name="text" >
<string>Interested</string>
</property>
</column>
<column>
<property name="text" >
<string>Accept</string>
</property>
</column>
<item>
<property name="text" >
<string>Pauly</string>
</property>
<property name="text" >
<string>Yes</string>
</property>
<property name="text" >
<string>Yes</string>
</property>
<property name="text" >
<string>Yes</string>
</property>
</item>
<item>
<property name="text" >
<string>New Item</string>
</property>
<property name="text" >
<string/>
</property>
<property name="text" >
<string/>
</property>
<property name="text" >
<string>Np</string>
</property>
</item>
</widget>
</widget>
</item>
<item row="2" column="0" >
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="deleteButton" >
<property name="font" >
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text" >
<string>Delete</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/reset.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="inviteButton" >
<property name="font" >
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text" >
<string>Invite</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/dadd.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="moveUpButton" >
<property name="font" >
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text" >
<string>Move Player</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/up.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="moveDownButton" >
<property name="font" >
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text" >
<string>Move Player</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/down_24x24.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="playButton" >
<property name="font" >
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text" >
<string>Play Game</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/startall.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc" />
</resources>
<connections/>
</ui>

View File

@ -73,7 +73,9 @@
#define UI_PREF_PROMPT_ON_QUIT "UIOptions/ConfirmOnQuit"
/* uncomment this for release version */
#define RS_RELEASE_VERSION 1
/*****
* #define RS_RELEASE_VERSION 1
****/
/* TEST (1) * friends/neighbours: okay for 16 hours! */
/* TEST (2) * all but transfer/sharedfiles: crashed in under 8 hours! */

View File

@ -0,0 +1,275 @@
/****************************************************************
* 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 <QFile>
#include <QFileInfo>
#include "common/vmessagebox.h"
#include "rshare.h"
#include "PhotoDialog.h"
#include "rsiface/rsiface.h"
#include <iostream>
#include <sstream>
#include <QContextMenuEvent>
#include <QMenu>
#include <QCursor>
#include <QPoint>
#include <QMouseEvent>
#include <QPixmap>
#include <QMessageBox>
#include <QHeaderView>
/* 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)
: MainPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
connect( ui.photoTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( photoTreeWidgetCostumPopupMenu( QPoint ) ) );
/* hide the Tree +/- */
ui.photoTreeWidget -> setRootIsDecorated( false );
/* 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 );
/* 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);
contextMnu.addSeparator();
contextMnu.addAction(votedownAct);
contextMnu.exec( mevent->globalPos() );
}
/* get the list of peers from the RsIface. */
void PhotoDialog::insertExample()
{
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 */
}
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)
{
std::cerr << "Invalid Current Item" << std::endl;
return NULL;
}
/* Display the columns of this item. */
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();
return item;
}
void PhotoDialog::voteup()
{
QTreeWidgetItem *c = getCurrentLine();
std::cerr << "PhotoDialog::voteup()" << 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);
*/
}

View File

@ -0,0 +1,70 @@
/****************************************************************
* RShare 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 _PHOTODIALOG_H
#define _PHOTODIALOG_H
#include <QFileDialog>
#include "mainpage.h"
#include "ui_PhotoDialog.h"
class PhotoDialog : public MainPage
{
Q_OBJECT
public:
/** Default Constructor */
PhotoDialog(QWidget *parent = 0);
/** Default Destructor */
void insertExample();
private slots:
/** Create the context popup menu and it's submenus */
void peertreeWidgetCostumPopupMenu( QPoint point );
void voteup();
void votedown();
private:
/* Worker Functions */
/* (1) Update Display */
/* (2) Utility Fns */
QTreeWidgetItem *getCurrentLine();
/** Define the popup menus for the Context menu */
QMenu* contextMnu;
/** Defines the actions for the context menu */
QAction* voteupAct;
QAction* votedownAct;
QTreeWidget *exampletreeWidget;
/** Qt Designer generated object */
Ui::PhotoDialog ui;
};
#endif

View File

@ -0,0 +1,79 @@
<ui version="4.0" >
<class>PhotoDialog</class>
<widget class="QWidget" name="PhotoDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>598</width>
<height>510</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<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>
<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>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc" />
</resources>
<connections/>
</ui>