clean up unfinished, removed not useful sources

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2572 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-03-17 12:52:42 +00:00
parent 9634f5e6fc
commit 26afeccacb
17 changed files with 838 additions and 3335 deletions

View File

@ -526,40 +526,28 @@ unfinished {
DEPENDPATH += gui/unfinished \
HEADERS += gui/unfinished/ApplicationWindow.h \
gui/unfinished/BlogDialog.h \
gui/unfinished/CalDialog.h \
gui/unfinished/ExampleDialog.h \
gui/unfinished/GamesDialog.h \
gui/unfinished/MsgFeed.h \
gui/unfinished/PeersFeed.h \
gui/unfinished/PhotoDialog.h \
gui/unfinished/PhotoShow.h \
gui/unfinished/StatisticDialog.h \
gui/unfinished/TransferFeed.h
gui/unfinished/StatisticDialog.h
FORMS += gui/unfinished/ApplicationWindow.ui \
gui/unfinished/BlogDialog.ui \
gui/unfinished/CalDialog.ui \
gui/unfinished/ExampleDialog.ui \
gui/unfinished/GamesDialog.ui \
gui/unfinished/MsgFeed.ui \
gui/unfinished/PeersFeed.ui \
gui/unfinished/PhotoDialog.ui \
gui/unfinished/PhotoShow.ui \
gui/unfinished/StatisticDialog.ui \
gui/unfinished/TransferFeed.ui
gui/unfinished/StatisticDialog.ui
SOURCES += gui/unfinished/ApplicationWindow.cpp \
gui/unfinished/BlogDialog.cpp \
gui/unfinished/CalDialog.cpp \
gui/unfinished/ExampleDialog.cpp \
gui/unfinished/GamesDialog.cpp \
gui/unfinished/MsgFeed.cpp \
gui/unfinished/PeersFeed.cpp \
gui/unfinished/PhotoDialog.cpp \
gui/unfinished/PhotoShow.cpp \
gui/unfinished/StatisticDialog.cpp \
gui/unfinished/TransferFeed.cpp
gui/unfinished/StatisticDialog.cpp
DEFINES *= UNFINISHED
}

View File

@ -37,7 +37,6 @@
#include "CalDialog.h"
#include "StatisticDialog.h"
#define FONT QFont("Arial", 9)
/* Images for toolbar icons */
@ -47,20 +46,12 @@
#define IMAGE_GAMES ":/images/kgames.png"
#define IMAGE_PHOTO ":/images/lphoto.png"
#define IMAGE_BWGRAPH ":/images/ksysguard.png"
#define IMAGE_RSM32 ":/images/rsmessenger32.png"
#define IMAGE_RSM16 ":/images/rsmessenger16.png"
#define IMAGE_CLOSE ":/images/close_normal.png"
#define IMAGE_CALENDAR ":/images/calendar.png"
#define IMAGE_LIBRARY ":/images/library.png"
#define IMAGE_PLUGINS ":/images/extension_32.png"
/* Keys for UI Preferences */
#define UI_PREF_PROMPT_ON_QUIT "UIOptions/ConfirmOnQuit"
/* uncomment this for release version */
#define RS_RELEASE_VERSION 1
/** Constructor */
ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
@ -103,8 +94,6 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
ui.toolBar->addSeparator();
connect(grp, SIGNAL(triggered(QAction *)), ui.stackPages, SLOT(showPage(QAction *)));
/* Create and bind the messenger button */
//addAction(new QAction(QIcon(IMAGE_SMPLAYER), tr("SMPlayer"), ui.toolBar), SLOT(showsmplayer()));
}

View File

@ -1,210 +0,0 @@
/****************************************************************
* 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 <QtGui>
#include "BlogDialog.h"
#include "gui/GeneralMsgDialog.h"
#include "rsiface/rsQblog.h"
#include "rsiface/rspeers.h" //to retrieve peer/usrId info
#include "gui/feeds/BlogMsgItem.h"
/** Constructor */
BlogDialog::BlogDialog(QWidget *parent)
: MainPage (parent)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
connect(postButton, SIGNAL(clicked()), this, SLOT(postBlog()));
/* mLayout -> to add widgets to */
mLayout = new QVBoxLayout;
//mLayout->setSpacing(0);
//mLayout->setMargin(0);
QWidget *middleWidget = new QWidget();
middleWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
middleWidget->setLayout(mLayout);
QScrollArea *scrollArea = new QScrollArea;
//scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(middleWidget);
scrollArea->setWidgetResizable(true);
scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
QVBoxLayout *layout2 = new QVBoxLayout;
layout2->addWidget(scrollArea);
layout2->setSpacing(0);
layout2->setMargin(0);
frame->setLayout(layout2);
addDummyData();
updateBlogsStatic();
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateBlogs()));
timer->start(15631);
}
void BlogDialog::updateBlogs(void)
{
}
void BlogDialog::updateBlogsStatic(void)
{
#if 0
rsQblog->getFilterSwitch();
std::map<std::string, std::string> UsrStatus;
if(!rsQblog->getStatus(UsrStatus))
std::cerr << "failed to get usr status" << std::endl;
clear(); //create a clear screen
/* retrieve usr names and populate usr list bar */
std::list<std::string> usrList;
QString TempVar; // to convert numerics to string note: tbd find way to avoid temporary
if (!rsPeers)
{
/* not ready yet! */
return;
}
if(!rsPeers->getFriendList(usrList))
std::cerr << "failed to get friend list";
usrList.push_back(rsPeers->getOwnId()); // add your id
/* populate the blog msgs screen */
std::map< std::string, std::multimap<long int, std::string> > blogs; // to store blogs
if(!rsQblog->getBlogs(blogs))
std::cerr << "failed to get blogs" << std::endl;
/* print usr name and their blogs to screen */
for(std::list<std::string>::iterator it = usrList.begin(); it !=usrList.end(); it++)
{
TempVar = rsPeers->getPeerName(*it).c_str(); // store usr name in temporary
blogText->setTextColor(QColor(255, 0, 0, 255));
blogText->setCurrentFont(mUsrFont); // make bold for username
blogText->append("\n" + TempVar); // write usr name to screen
std::cerr << "creating usr tree" << std::endl;
/*print blog time-posted/msgs to screen*/
std::multimap<long int, std::string>::reverse_iterator blogIt = blogs[*it].rbegin();
if(blogs[*it].empty())
{
std::cerr << "usr blog empty!" << std::endl;
continue;
}
for( ; blogIt != blogs[*it].rend(); blogIt++)
{
std::cerr << "now printing blogs" << std::endl;
time_t postedTime = blogIt->first;
time(&postedTime); //convert to human readable time
blogText->setTextColor(QColor(255, 0, 0, 255)); //
blogText->setCurrentFont(mUsrFont); // make bold for posted date
blogText->append("\nPosted: " + QString (ctime(&postedTime))); // print time of blog to screen
blogText->setCurrentFont(mCurrentFont); // reset the font for blog messages
blogText->setTextColor(QColor(0, 0, 0, 255)); // set back color to black
blogText->append(blogIt->second.c_str()); // print blog msg to screen
}
}
#endif
}
void BlogDialog::addDummyData()
{
BlogMsgItem *bm1 = new BlogMsgItem(this, 0, "peerId", "msgId", true);
BlogMsgItem *bm2 = new BlogMsgItem(this, 0, "peerId", "msgId", true);
BlogMsgItem *bm3 = new BlogMsgItem(this, 0, "peerId", "msgId", true);
BlogMsgItem *bm4 = new BlogMsgItem(this, 0, "peerId", "msgId", true);
BlogMsgItem *bm5 = new BlogMsgItem(this, 0, "peerId", "msgId", true);
mLayout->addWidget(bm1);
mLayout->addWidget(bm2);
mLayout->addWidget(bm3);
mLayout->addWidget(bm4);
mLayout->addWidget(bm5);
}
/* FeedHolder Functions (for FeedItem functionality) */
void BlogDialog::deleteFeedItem(QWidget *item, uint32_t type)
{
std::cerr << "BlogDialog::deleteFeedItem()";
std::cerr << std::endl;
}
void BlogDialog::openChat(std::string peerId)
{
std::cerr << "BlogDialog::openChat()";
std::cerr << std::endl;
}
void BlogDialog::postBlog()
{
openMsg(FEEDHOLDER_MSG_BLOG, "", "");
}
void BlogDialog::openMsg(uint32_t type, std::string grpId, std::string inReplyTo)
{
std::cerr << "BlogDialog::openMsg()";
std::cerr << std::endl;
GeneralMsgDialog *msgDialog = new GeneralMsgDialog(NULL);
msgDialog->addDestination(type, grpId, inReplyTo);
msgDialog->show();
return;
}

View File

@ -1,63 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _BLOG_DIALOG_H
#define _BLOG_DIALOG_H
#include "gui/mainpage.h"
#include "ui_BlogDialog.h"
#include "gui/feeds/FeedHolder.h"
class BlogMsgItem;
class BlogDialog : public MainPage, public FeedHolder, private Ui::BlogDialog
{
Q_OBJECT
public:
/** Default Constructor */
BlogDialog(QWidget *parent = 0);
/* FeedHolder Functions (for FeedItem functionality) */
virtual void deleteFeedItem(QWidget *item, uint32_t type);
virtual void openChat(std::string peerId);
virtual void openMsg(uint32_t type, std::string grpId, std::string inReplyTo);
void updateBlogsStatic();
private slots:
void updateBlogs();
void postBlog();
private:
void addDummyData();
QLayout *mLayout;
std::map<std::string, BlogMsgItem *> mBlogMsgItems;
};
#endif

View File

@ -1,219 +0,0 @@
<ui version="4.0" >
<class>BlogDialog</class>
<widget class="QWidget" name="BlogDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>569</width>
<height>294</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<property name="toolTip" >
<string/>
</property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>0</number>
</property>
<property name="margin" >
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>6</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label" >
<property name="maximumSize" >
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string/>
</property>
<property name="pixmap" >
<pixmap resource="images.qrc" >:/images/kblogger.png</pixmap>
</property>
<property name="scaledContents" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Blogs</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="periodComboBox" >
<item>
<property name="text" >
<string>Last Month</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >
<normaloff>:/images/view_calendar_month.png</normaloff>:/images/view_calendar_month.png</iconset>
</property>
</item>
<item>
<property name="text" >
<string>Last Week</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >
<normaloff>:/images/view_calendar_week.png</normaloff>:/images/view_calendar_week.png</iconset>
</property>
</item>
<item>
<property name="text" >
<string>Last Day</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >
<normaloff>:/images/view_calendar_day.png</normaloff>:/images/view_calendar_day.png</iconset>
</property>
</item>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="usersComboBox" >
<item>
<property name="text" >
<string>All Users</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >
<normaloff>:/images/user/identity16.png</normaloff>:/images/user/identity16.png</iconset>
</property>
</item>
<item>
<property name="text" >
<string>Jimmy</string>
</property>
</item>
<item>
<property name="text" >
<string>John</string>
</property>
</item>
<item>
<property name="text" >
<string>Jacki</string>
</property>
</item>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="postButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>No Feeds</string>
</property>
<property name="text" >
<string>Post Blog</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >
<normaloff>:/images/mail_send.png</normaloff>:/images/mail_send.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="frame" >
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc" />
</resources>
<connections/>
</ui>

View File

@ -23,15 +23,9 @@
#include "rshare.h"
#include "LibraryDialog.h"
#include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsfiles.h"
#include "ShareManager.h"
#include "util/RsAction.h"
#include "msgs/ChanMsgDialog.h"
#include "FindWindow.h"
#include <iostream>
#include <sstream>
@ -59,8 +53,6 @@
#define IMAGE_PROGRESS ":/images/browse-looking.gif"
#define IMAGE_LIBRARY ":/images/library.png"
QString fileToFind;
/** Constructor */
LibraryDialog::LibraryDialog(QWidget *parent)
@ -69,27 +61,23 @@ LibraryDialog::LibraryDialog(QWidget *parent)
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
PopulateList();
connect(ui.organizerListView, SIGNAL(rightButtonClicked(QModelIndex,QPoint)), this, SLOT(ListLibrarymenu(QModelIndex,QPoint)));
connect(ui.shareFiles_btn,SIGNAL(clicked()),this, SLOT(CallShareFilesBtn_library()));
connect(ui.tileView_btn_library,SIGNAL(clicked()),this, SLOT(CallTileViewBtn_library()));
connect(ui.showDetails_btn_library,SIGNAL(clicked()),this, SLOT(CallShowDetailsBtn_library()));
connect(ui.createAlbum_btn_library,SIGNAL(clicked()),this, SLOT(CallCreateAlbumBtn_library()));
connect(ui.deleteAlbum_btn_library,SIGNAL(clicked()),this, SLOT(CallDeleteAlbumBtn_library()));
connect(ui.find_btn_library,SIGNAL(clicked()),this, SLOT(CallFindBtn_library()));
//connect(ui.tileView_btn_library,SIGNAL(clicked()),this, SLOT(CallTileViewBtn_library()));
//connect(ui.showDetails_btn_library,SIGNAL(clicked()),this, SLOT(CallShowDetailsBtn_library()));
//connect(ui.createAlbum_btn_library,SIGNAL(clicked()),this, SLOT(CallCreateAlbumBtn_library()));
//connect(ui.deleteAlbum_btn_library,SIGNAL(clicked()),this, SLOT(CallDeleteAlbumBtn_library()));
//connect(ui.find_btn_library,SIGNAL(clicked()),this, SLOT(CallFindBtn_library()));
/* Set header resize modes and initial section sizes */
QHeaderView * organizerheader = ui.organizertreeView->header();
//Load the library
fileSystemModelLibraryFolders.setFilter(QDir::AllDirs|QDir::NoDotAndDotDot);
fileSystemModelLibraryFolders.setRootPath(Settings.Library.Shares.join(" "));
organizerheader->resizeSection ( 0, 250 );
ui.treeViewLibraryNavigatorFolders->setModel(&fileSystemModelLibraryFolders);
QTimer *timer = new QTimer(this);
/*QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
timer->start(1000);
timer->start(1000);*/
/* Hide platform specific features */
#ifdef Q_WS_WIN
@ -98,70 +86,6 @@ LibraryDialog::LibraryDialog(QWidget *parent)
}
void LibraryDialog::PopulateList()
{
QDir DwnlFolder,ShrFolder,retroshareLib,treePath;
#if 0
retroshareLib.mkdir("RetroShare Library");
DwnlFolder.mkdir("RetroShare Library/Download");
ShrFolder.mkdir("RetroShare Library/SharedFolder");
LibShared=treePath.currentPath();
LibShared.append("/RetroShare Library");
#else
LibShared=Rshare::dataDirectory();
#endif
QDirModel * dmodel=new QDirModel;
ui.organizertreeView->setModel(dmodel);
ui.organizertreeView->setRootIndex(dmodel->index(LibShared));
ui.organizerListView->setModel(dmodel);
ui.organizerListView->setViewMode(QListView::ListMode);
ui.organizerListView->setWordWrap (true);
}
void LibraryDialog::ListLibrarymenu(QModelIndex index,QPoint pos)
{
ind=index;
if(index.isValid())
{
bool indexselected=true;
QMenu rmenu(this);
rmenu.move(pos);
if(indexselected)
rmenu.addAction(QIcon(""),tr("Play"), this, SLOT(PlayFrmList()));
if(indexselected)
rmenu.addAction(QIcon(""),tr("Copy"), this, SLOT(copyFile()));
if(indexselected)
rmenu.addAction(QIcon(""),tr("Delete"), this, SLOT(DeleteFile()));
if(indexselected)
rmenu.addAction(QIcon(""),tr("Rename"), this, SLOT(RenameFile()));
rmenu.exec();
}
else
return;
}
void LibraryDialog::PlayFrmList()
{
QDirModel *dmodel=new QDirModel;
QModelIndex parentIndex = dmodel->index(LibShared+"/Download");
QModelIndex index = dmodel->index(ind.row(), 0, parentIndex);
QString text = dmodel->data(index, Qt::DisplayRole).toString();
filechose.clear();
QDir dir;
filechose.append(LibShared+"/Download/");
filechose.append(text);
if(filechose.contains("avi")|| filechose.contains("MP3")||filechose.contains("mp3")|| filechose.contains("wmv")||filechose.contains("wav")|| filechose.contains("dat")|| filechose.contains("mov")|| filechose.contains("mpeg")|| filechose.contains("mpg"))
{
player();
}
else
QMessageBox::information(this,"Information", "Not Supported By the Player");
}
void LibraryDialog::copyFile()
{
@ -175,17 +99,12 @@ void LibraryDialog::DeleteFile()
void LibraryDialog::RenameFile()
{
ui.organizerListView->openPersistentEditor (ind);
progtime=new QTimer(this);
progtime->start(100000);
connect(progtime, SIGNAL(timeout()), this, SLOT(StopRename()));
}
void LibraryDialog::StopRename()
{
ui.organizerListView->closePersistentEditor(ind);
progtime->stop();
}
@ -214,37 +133,18 @@ void LibraryDialog::CallDeleteAlbumBtn_library()
//QMessageBox::information(this, tr("RetroShare"),tr("Will be Introducing this .. soon- Delete Album in Library"));
}
QString LibraryDialog::filePass()
{
fileToFind=ui.findEditmain->text();
return fileToFind;
}
void LibraryDialog::CallFindBtn_library()
{
filePass();
FindWindow *files = new FindWindow(this);
files->show();
}
void LibraryDialog:: player()
{
QString avi;
avi.append(filechose);
QStringList argu;
QString smlayer="./smplayer";
argu<<avi;
QProcess *retroshareplayer=new QProcess(this);
retroshareplayer->start(smlayer,argu);
}
void LibraryDialog::browseFile()
{
QDir dir;
QString pathseted =dir.currentPath();
pathseted.append("/RetroShare Library/Download");
filechose = QFileDialog::getOpenFileName(this, tr("Open File..."),
pathseted, tr("Media-Files (*.avi *.mp3 *.wmv *.wav *.dat *.mov *.mpeg);;All Files (*)"));
//movieEdit->setText(filechose);
}

View File

@ -39,10 +39,6 @@ public:
LibraryDialog(QWidget *parent = 0);
/** Default Destructor */
QString filePass();
QString LibShared;
QString filechose;
QModelIndex ind;
private slots:
@ -57,7 +53,6 @@ private slots:
void browseFile();
void player();
void ListLibrarymenu(QModelIndex,QPoint);
void PlayFrmList();
void copyFile();
void DeleteFile();
@ -66,11 +61,9 @@ private slots:
signals:
void rightButtonClicked(const QModelIndex , const QPoint);
private:
QTimer *progtime;
/** Qt Designer generated object */

File diff suppressed because it is too large Load Diff

View File

@ -1,332 +0,0 @@
/****************************************************************
* 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 <QtGui>
#include <iostream>
#include "MsgFeed.h"
#include "gui/feeds/MsgItem.h"
#include "gui/GeneralMsgDialog.h"
#include "rsiface/rsmsgs.h"
#include "rsiface/rspeers.h"
/*****
* #define MSG_DEBUG 1
****/
/** Constructor */
MsgFeed::MsgFeed(QWidget *parent)
: MainPage (parent)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
connect(boxComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateBox() ) );
connect(peerComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateMode() ) );
connect(sortComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateSort() ) );
connect(msgButton, SIGNAL( clicked( ) ), this, SLOT( newMsg() ) );
/* mLayout -> to add widgets to */
mLayout = new QVBoxLayout;
QWidget *middleWidget = new QWidget();
//middleWidget->setSizePolicy( QSizePolicy::Policy::Maximum, QSizePolicy::Policy::Minimum);
middleWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
middleWidget->setLayout(mLayout);
QScrollArea *scrollArea = new QScrollArea;
//scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(middleWidget);
scrollArea->setWidgetResizable(true);
scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
QVBoxLayout *layout2 = new QVBoxLayout;
layout2->addWidget(scrollArea);
layout2->setSpacing(0);
layout2->setMargin(0);
frame->setLayout(layout2);
/* default Inbox + All */
mMsgbox = RS_MSG_INBOX;
mPeerId = "";
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updatePeerIds()));
timer->start(10000);
}
/* FeedHolder Functions (for FeedItem functionality) */
void MsgFeed::deleteFeedItem(QWidget *item, uint32_t type)
{
#ifdef MSG_DEBUG
std::cerr << "MsgFeed::deleteFeedItem()";
std::cerr << std::endl;
#endif
}
void MsgFeed::openChat(std::string peerId)
{
#ifdef MSG_DEBUG
std::cerr << "MsgFeed::openChat()";
std::cerr << std::endl;
#endif
}
void MsgFeed::openMsg(uint32_t type, std::string grpId, std::string inReplyTo)
{
#ifdef MSG_DEBUG
std::cerr << "MsgFeed::openMsg()";
std::cerr << std::endl;
#endif
GeneralMsgDialog *msgDialog = new GeneralMsgDialog(NULL);
msgDialog->addDestination(type, grpId, inReplyTo);
msgDialog->show();
}
void MsgFeed::newMsg()
{
#ifdef MSG_DEBUG
std::cerr << "MsgFeed::newMsg()";
std::cerr << std::endl;
#endif
GeneralMsgDialog *msgDialog = new GeneralMsgDialog(NULL);
msgDialog->setMsgType(FEEDHOLDER_MSG_MESSAGE);
msgDialog->show();
}
void MsgFeed::updateBox()
{
int idx = boxComboBox->currentIndex();
switch(idx)
{
case 3:
mMsgbox = RS_MSG_SENTBOX;
break;
case 2:
mMsgbox = RS_MSG_DRAFTBOX;
break;
case 1:
mMsgbox = RS_MSG_OUTBOX;
break;
case 0:
default:
mMsgbox = RS_MSG_INBOX;
break;
}
updateMsgs();
}
void MsgFeed::updateMode()
{
/* NB #defines must match GUI design for correct selection */
if (peerComboBox->currentIndex() >= 0)
{
QVariant qv = peerComboBox->itemData(peerComboBox->currentIndex());
mPeerId = qv.toString().toStdString();
}
updateMsgs();
}
void MsgFeed::updateSort()
{
}
void MsgFeed::updatePeerIds()
{
#ifdef MSG_DEBUG
std::cerr << "MsgFeed::updatePeerIds()";
std::cerr << std::endl;
#endif
int selectIdx = 0; /* ALL */
std::string peerId;
if (peerComboBox->currentIndex() >= 0)
{
QVariant qv = peerComboBox->itemData(peerComboBox->currentIndex());
peerId = qv.toString().toStdString();
}
peerComboBox->clear();
peerComboBox->addItem("All Msgs", "");
/* add a list of friends */
if (rsPeers)
{
std::list<std::string> friends;
std::list<std::string>::iterator it;
rsPeers->getFriendList(friends);
for(it = friends.begin(); it != friends.end(); it++)
{
QString id = QString::fromStdString(*it);
QString name = QString::fromStdString(rsPeers->getPeerName(*it));
peerComboBox->addItem(name, id);
if (peerId == *it)
{
selectIdx = peerComboBox->count() - 1;
}
}
}
peerComboBox->setCurrentIndex(selectIdx);
/* this will trigger updateMsgs?? */
}
void MsgFeed::updateMsgs()
{
std::list<MsgInfoSummary> msgs;
std::list<MsgInfoSummary>::iterator mit;
std::list<std::string> toAdd, toRemove;
std::list<std::string>::iterator it;
std::map<std::string, uint32_t> newmsgs;
std::map<std::string, uint32_t>::iterator nit;
std::map<std::string, MsgItem *>::iterator iit;
if (!rsMsgs)
{
/* not ready yet! */
return;
}
rsMsgs->getMessageSummaries(msgs);
for(mit = msgs.begin(); mit != msgs.end(); )
{
/* filter on box type */
if (mMsgbox != (mit->msgflags & RS_MSG_BOXMASK))
{
mit = msgs.erase(mit);
}
else
{
mit++;
}
}
if (mPeerId != "")
{
for(mit = msgs.begin(); mit != msgs.end(); )
{
/* filter on source */
if (mPeerId != mit->srcId)
{
mit = msgs.erase(mit);
}
else
{
mit++;
}
}
}
for(mit = msgs.begin(); mit != msgs.end(); mit++)
{
newmsgs[mit->msgId] = 1;
}
nit = newmsgs.begin();
iit = mMsgs.begin();
while(nit != newmsgs.end())
{
if (iit == mMsgs.end())
{
toAdd.push_back(nit->first);
nit++;
continue;
}
if (nit->first == iit->first)
{
/* same - good! */
nit++;
iit++;
continue;
}
if (nit->first < iit->first)
{
/* must add in new item */
toAdd.push_back(nit->first);
nit++;
}
else
{
toRemove.push_back(iit->first);
iit++;
}
}
/* remove remaining items */
while (iit != mMsgs.end())
{
toRemove.push_back(iit->first);
iit++;
}
/* remove first */
for(it = toRemove.begin(); it != toRemove.end(); it++)
{
iit = mMsgs.find(*it);
if (iit != mMsgs.end())
{
delete (iit->second);
mMsgs.erase(iit);
}
}
/* add in new ones */
for(it = toAdd.begin(); it != toAdd.end(); it++)
{
MsgItem *mi = new MsgItem(this, 0, *it, true);
mMsgs[*it] = mi;
mLayout->addWidget(mi);
}
}

View File

@ -1,72 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _MSG_FEED_DIALOG_H
#define _MSG_FEED_DIALOG_H
#include "gui/mainpage.h"
#include "ui_MsgFeed.h"
#include "gui/feeds/FeedHolder.h"
class MsgItem;
class MsgFeed : public MainPage, public FeedHolder, private Ui::MsgFeed
{
Q_OBJECT
public:
/** Default Constructor */
MsgFeed(QWidget *parent = 0);
/** Default Destructor */
/* FeedHolder Functions (for FeedItem functionality) */
virtual void deleteFeedItem(QWidget *item, uint32_t type);
virtual void openChat(std::string peerId);
virtual void openMsg(uint32_t type, std::string grpId, std::string inReplyTo);
private slots:
void newMsg();
void updateBox();
void updateMode();
void updateSort();
void updatePeerIds();
void updateMsgs();
private:
QLayout *mLayout;
uint32_t mMsgbox;
std::string mPeerId;
uint32_t mSortMode;
std::map<std::string, MsgItem *> mMsgs;
};
#endif

View File

@ -1,276 +0,0 @@
<ui version="4.0" >
<class>MsgFeed</class>
<widget class="QWidget" name="MsgFeed" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>764</width>
<height>435</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>0</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>6</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Msgs In:</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="boxComboBox" >
<item>
<property name="text" >
<string>Inbox</string>
</property>
</item>
<item>
<property name="text" >
<string>Outbox</string>
</property>
</item>
<item>
<property name="text" >
<string>Drafts</string>
</property>
</item>
<item>
<property name="text" >
<string>Sent</string>
</property>
</item>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string> From:</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="peerComboBox" >
<property name="minimumSize" >
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<item>
<property name="text" >
<string>All</string>
</property>
</item>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Sort By:</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="sortComboBox" >
<item>
<property name="text" >
<string>Date</string>
</property>
</item>
<item>
<property name="text" >
<string>Subject</string>
</property>
</item>
<item>
<property name="text" >
<string>Received</string>
</property>
</item>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>81</width>
<height>28</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="msgButton" >
<property name="text" >
<string>New Msg</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >
<normaloff>:/images/mail_send.png</normaloff>:/images/mail_send.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="frame" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc" />
</resources>
<connections/>
</ui>

View File

@ -1,468 +0,0 @@
/****************************************************************
* 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 <QtGui>
#include <iostream>
#include "PeersFeed.h"
#include "gui/feeds/PeerItem.h"
#include "rsiface/rspeers.h"
#include "gui/GeneralMsgDialog.h"
const uint32_t PEERSFEED_MODE_FRIENDS = 0x0000;
const uint32_t PEERSFEED_MODE_ONLINE = 0x0001;
const uint32_t PEERSFEED_MODE_FOF = 0x0002;
const uint32_t PEERSFEED_MODE_ALL = 0x0003;
/*****
* #define PEERS_DEBUG 1
****/
/** Constructor */
PeersFeed::PeersFeed(QWidget *parent)
: MainPage (parent)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
connect( modeComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateMode() ) );
/* mLayout -> to add widgets to */
mLayout = new QVBoxLayout;
QWidget *middleWidget = new QWidget();
//middleWidget->setSizePolicy( QSizePolicy::Policy::Maximum, QSizePolicy::Policy::Minimum);
middleWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
middleWidget->setLayout(mLayout);
QScrollArea *scrollArea = new QScrollArea;
//scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(middleWidget);
scrollArea->setWidgetResizable(true);
scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
QVBoxLayout *layout2 = new QVBoxLayout;
layout2->addWidget(scrollArea);
layout2->setSpacing(0);
layout2->setMargin(0);
frame->setLayout(layout2);
mMode = PEERSFEED_MODE_FRIENDS;
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updatePeers()));
timer->start(1000);
}
/* FeedHolder Functions (for FeedItem functionality) */
void PeersFeed::deleteFeedItem(QWidget *item, uint32_t type)
{
#ifdef PEERS_DEBUG
std::cerr << "PeersFeed::deleteFeedItem()";
std::cerr << std::endl;
#endif
}
void PeersFeed::openChat(std::string peerId)
{
#ifdef PEERS_DEBUG
std::cerr << "PeersFeed::openChat()";
std::cerr << std::endl;
#endif
}
void PeersFeed::openMsg(uint32_t type, std::string grpId, std::string inReplyTo)
{
#ifdef PEERS_DEBUG
std::cerr << "PeersFeed::openMsg()";
std::cerr << std::endl;
#endif
GeneralMsgDialog *msgDialog = new GeneralMsgDialog(NULL);
msgDialog->addDestination(type, grpId, inReplyTo);
msgDialog->show();
}
void PeersFeed::updateMode()
{
/* NB #defines must match GUI design for correct selection */
mMode = modeComboBox->currentIndex();
updatePeers();
}
/* get the list of peers from the RsIface. */
void PeersFeed::updatePeers()
{
std::list<std::string> peers, toAdd, toRemove;
std::list<std::string>::iterator it;
std::map<std::string, uint32_t> newpeers;
std::map<std::string, uint32_t>::iterator nit;
std::map<std::string, PeerItem *>::iterator pit;
if (!rsPeers)
{
/* not ready yet! */
return;
}
if (mMode == PEERSFEED_MODE_FRIENDS)
{
rsPeers->getFriendList(peers);
}
if(mMode == PEERSFEED_MODE_ONLINE)
{
rsPeers->getOnlineList(peers);
}
/*else if (mMode == PEERSFEED_MODE_ALL)
{
rsPeers->getOthersList(peers);
}
else
{
rsPeers->getOthersList(peers);*/
/* now remove friends */
/*for(it = peers.begin(); it != peers.end(); )
{
if (rsPeers->isFriend(*it))
{
it = peers.erase(it);
}
else
{
it++;
}
}
}*/
for(it = peers.begin(); it != peers.end(); it++)
{
newpeers[*it] = 1;
}
nit = newpeers.begin();
pit = mPeers.begin();
while(nit != newpeers.end())
{
if (pit == mPeers.end())
{
toAdd.push_back(nit->first);
nit++;
continue;
}
if (nit->first == pit->first)
{
/* same - good! */
nit++;
pit++;
continue;
}
if (nit->first < pit->first)
{
/* must add in new item */
toAdd.push_back(nit->first);
nit++;
}
else
{
toRemove.push_back(pit->first);
pit++;
}
}
/* remove remaining items */
while (pit != mPeers.end())
{
toRemove.push_back(pit->first);
pit++;
}
/* remove first */
for(it = toRemove.begin(); it != toRemove.end(); it++)
{
pit = mPeers.find(*it);
if (pit != mPeers.end())
{
delete (pit->second);
mPeers.erase(pit);
}
}
/* add in new ones */
for(it = toAdd.begin(); it != toAdd.end(); it++)
{
PeerItem *pi = new PeerItem(this, 0, *it, PEER_TYPE_STD, true);
mPeers[*it] = pi;
mLayout->addWidget(pi);
}
}
// PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, fi.mId1, PEER_TYPE_STD, false);
// PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, fi.mId1, PEER_TYPE_HELLO, false);
// PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, fi.mId1, PEER_TYPE_NEW_FOF, false);
#if 0
void PeersFeed::setChatDialog(ChatDialog *cd)
{
chatDialog = cd;
}
/** Open a QFileDialog to browse for export a file. */
void PeersFeed::exportfriend()
{
QTreeWidgetItem *c = getCurrentPeer();
std::cerr << "PeersFeed::exportfriend()" << std::endl;
if (!c)
{
std::cerr << "PeersFeed::exportfriend() Noone Selected -- sorry" << std::endl;
return;
}
std::string id = getPeerRsCertId(c);
QString fileName = QFileDialog::getSaveFileName(this, tr("Save Certificate"), "",
tr("Certificates (*.pqi)"));
std::string file = fileName.toStdString();
if (file != "")
{
std::cerr << "PeersFeed::exportfriend() Saving to: " << file << std::endl;
std::cerr << std::endl;
if (rsPeers)
{
rsPeers->SaveCertificateToFile(id, file);
}
}
}
void PeersFeed::chatfriend()
{
QTreeWidgetItem *i = getCurrentPeer();
if (!i)
return;
std::string name = (i -> text(2)).toStdString();
std::string id = (i -> text(7)).toStdString();
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(id, detail))
{
return;
}
if (detail.state & RS_PEER_STATE_CONNECTED)
{
/* must reference ChatDialog */
if (chatDialog)
{
chatDialog->getPrivateChat(id, name, true);
}
}
else
{
/* info dialog */
QMessageBox::StandardButton sb = QMessageBox::question ( NULL,
"Friend Not Online",
"Your Friend is offline \nDo you want to send them a Message instead",
(QMessageBox::Yes | QMessageBox::No));
if (sb == QMessageBox::Yes)
{
msgfriend();
}
}
return;
}
void PeersFeed::msgfriend()
{
std::cerr << "SharedFilesDialog::msgfriend()" << std::endl;
QTreeWidgetItem *i = getCurrentPeer();
if (!i)
return;
std::string status = (i -> text(1)).toStdString();
std::string name = (i -> text(2)).toStdString();
std::string id = (i -> text(7)).toStdString();
rsicontrol -> ClearInMsg();
rsicontrol -> SetInMsg(id, true);
/* create a message */
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
nMsgDialog->newMsg();
nMsgDialog->show();
}
QTreeWidgetItem *PeersFeed::getCurrentPeer()
{
/* get the current, and extract the Id */
/* get a link to the table */
QTreeWidget *peerWidget = ui.peertreeWidget;
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;
}
/* So from the Peers Dialog we can call the following control Functions:
* (1) Remove Current. FriendRemove(id)
* (2) Allow/DisAllow. FriendStatus(id, accept)
* (2) Connect. FriendConnectAttempt(id, accept)
* (3) Set Address. FriendSetAddress(id, str, port)
* (4) Set Trust. FriendTrustSignature(id, bool)
* (5) Configure (GUI Only) -> 3/4
*
* All of these rely on the finding of the current Id.
*/
void PeersFeed::removefriend()
{
QTreeWidgetItem *c = getCurrentPeer();
std::cerr << "PeersFeed::removefriend()" << std::endl;
if (!c)
{
std::cerr << "PeersFeed::removefriend() Noone Selected -- sorry" << std::endl;
return;
}
if (rsPeers)
{
rsPeers->removeFriend(getPeerRsCertId(c));
}
}
void PeersFeed::allowfriend()
{
QTreeWidgetItem *c = getCurrentPeer();
std::cerr << "PeersFeed::allowfriend()" << std::endl;
/*
bool accept = true;
rsServer->FriendStatus(getPeerRsCertId(c), accept);
*/
}
void PeersFeed::connectfriend()
{
QTreeWidgetItem *c = getCurrentPeer();
std::cerr << "PeersFeed::connectfriend()" << std::endl;
if (!c)
{
std::cerr << "PeersFeed::connectfriend() Noone Selected -- sorry" << std::endl;
return;
}
if (rsPeers)
{
rsPeers->connectAttempt(getPeerRsCertId(c));
}
}
void PeersFeed::setaddressfriend()
{
QTreeWidgetItem *c = getCurrentPeer();
std::cerr << "PeersFeed::setaddressfriend()" << std::endl;
/* need to get the input address / port */
/*
std::string addr;
unsigned short port;
rsServer->FriendSetAddress(getPeerRsCertId(c), addr, port);
*/
}
void PeersFeed::trustfriend()
{
QTreeWidgetItem *c = getCurrentPeer();
std::cerr << "PeersFeed::trustfriend()" << std::endl;
/*
bool trust = true;
rsServer->FriendTrust(getPeerRsCertId(c), trust);
*/
}
/* GUI stuff -> don't do anything directly with Control */
void PeersFeed::configurefriend()
{
/* display Dialog */
std::cerr << "PeersFeed::configurefriend()" << std::endl;
QTreeWidgetItem *c = getCurrentPeer();
static ConfCertDialog *confdialog = new ConfCertDialog();
if (!c)
return;
/* set the Id */
std::string id = getPeerRsCertId(c);
confdialog -> loadId(id);
confdialog -> show();
}
#endif

View File

@ -1,65 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _PEERS_FEED_DIALOG_H
#define _PEERS_FEED_DIALOG_H
#include "gui/mainpage.h"
#include "ui_PeersFeed.h"
#include "gui/feeds/FeedHolder.h"
class PeerItem;
class PeersFeed : public MainPage, public FeedHolder, private Ui::PeersFeed
{
Q_OBJECT
public:
/** Default Constructor */
PeersFeed(QWidget *parent = 0);
/** Default Destructor */
/* FeedHolder Functions (for FeedItem functionality) */
virtual void deleteFeedItem(QWidget *item, uint32_t type);
virtual void openChat(std::string peerId);
virtual void openMsg(uint32_t type, std::string grpId, std::string inReplyTo);
private slots:
void updatePeers();
void updateMode();
private:
QLayout *mLayout;
/* lists of feedItems */
uint32_t mMode;
std::map<std::string, PeerItem *> mPeers;
};
#endif

View File

@ -1,135 +0,0 @@
<ui version="4.0" >
<class>PeersFeed</class>
<widget class="QWidget" name="PeersFeed" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>689</width>
<height>386</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>0</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>6</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Show:</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="modeComboBox" >
<property name="minimumSize" >
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<item>
<property name="text" >
<string>Friends</string>
</property>
</item>
<item>
<property name="text" >
<string>Online Friends</string>
</property>
</item>
<item>
<property name="text" >
<string>Friends of Friends.</string>
</property>
</item>
<item>
<property name="text" >
<string>All Peers</string>
</property>
</item>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>50</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="frame" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc" />
</resources>
<connections/>
</ui>

View File

@ -1,336 +0,0 @@
/****************************************************************
* 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 <QtGui>
#include <iostream>
#include "TransferFeed.h"
#include "gui/feeds/SubFileItem.h"
#include "gui/GeneralMsgDialog.h"
#include "rsiface/rsfiles.h"
/*****
* #define TRANSFER_DEBUG 1
****/
/** Constructor */
TransferFeed::TransferFeed(QWidget *parent)
: MainPage (parent)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
connect( modeComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateMode() ) );
{
/* mLayout -> to add widgets to */
mDownloadsLayout = new QVBoxLayout;
QWidget *middleWidget = new QWidget();
//middleWidget->setSizePolicy( QSizePolicy::Policy::Maximum, QSizePolicy::Policy::Minimum);
middleWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
middleWidget->setLayout(mDownloadsLayout);
QScrollArea *scrollArea = new QScrollArea;
//scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(middleWidget);
scrollArea->setWidgetResizable(true);
scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
QVBoxLayout *layout2 = new QVBoxLayout;
layout2->addWidget(scrollArea);
layout2->setSpacing(0);
layout2->setMargin(0);
frameDown->setLayout(layout2);
}
{
/* mLayout -> to add widgets to */
mUploadsLayout = new QVBoxLayout;
QWidget *middleWidget = new QWidget();
//middleWidget->setSizePolicy( QSizePolicy::Policy::Maximum, QSizePolicy::Policy::Minimum);
middleWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
middleWidget->setLayout(mUploadsLayout);
QScrollArea *scrollArea = new QScrollArea;
//scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(middleWidget);
scrollArea->setWidgetResizable(true);
scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
QVBoxLayout *layout2 = new QVBoxLayout;
layout2->addWidget(scrollArea);
layout2->setSpacing(0);
layout2->setMargin(0);
frameUp->setLayout(layout2);
}
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateAll()));
timer->start(1000);
}
/* FeedHolder Functions (for FeedItem functionality) */
void TransferFeed::deleteFeedItem(QWidget *item, uint32_t type)
{
#ifdef TRANSFER_DEBUG
std::cerr << "TransferFeed::deleteFeedItem()";
std::cerr << std::endl;
#endif
}
void TransferFeed::openChat(std::string peerId)
{
#ifdef TRANSFER_DEBUG
std::cerr << "TransferFeed::openChat()";
std::cerr << std::endl;
#endif
}
void TransferFeed::openMsg(uint32_t type, std::string grpId, std::string inReplyTo)
{
#ifdef TRANSFER_DEBUG
std::cerr << "TransferFeed::openMsg()";
std::cerr << std::endl;
#endif
GeneralMsgDialog *msgDialog = new GeneralMsgDialog(NULL);
msgDialog->addDestination(type, grpId, inReplyTo);
msgDialog->show();
}
void TransferFeed::updateMode()
{
updateAll();
}
void TransferFeed::updateAll()
{
updateDownloads();
updateUploads();
}
void TransferFeed::updateDownloads()
{
std::list<std::string> hashes, toAdd, toRemove;
std::list<std::string>::iterator it;
std::map<std::string, uint32_t> newhashes;
std::map<std::string, uint32_t>::iterator nit;
std::map<std::string, SubFileItem *>::iterator fit;
if (!rsFiles)
{
/* not ready yet! */
return;
}
rsFiles->FileDownloads(hashes);
for(it = hashes.begin(); it != hashes.end(); it++)
{
newhashes[*it] = 1;
}
nit = newhashes.begin();
fit = mDownloads.begin();
while(nit != newhashes.end())
{
if (fit == mDownloads.end())
{
toAdd.push_back(nit->first);
nit++;
continue;
}
if (nit->first == fit->first)
{
/* same - good! */
nit++;
fit++;
continue;
}
if (nit->first < fit->first)
{
/* must add in new item */
toAdd.push_back(nit->first);
nit++;
}
else
{
toRemove.push_back(fit->first);
fit++;
}
}
/* remove remaining items */
while (fit != mDownloads.end())
{
toRemove.push_back(fit->first);
fit++;
}
/* remove first */
for(it = toRemove.begin(); it != toRemove.end(); it++)
{
fit = mDownloads.find(*it);
if (fit != mDownloads.end())
{
delete (fit->second);
mDownloads.erase(fit);
}
}
/* add in new ones */
for(it = toAdd.begin(); it != toAdd.end(); it++)
{
FileInfo fi;
uint32_t hintflags = RS_FILE_HINTS_DOWNLOAD
| RS_FILE_HINTS_SPEC_ONLY;
if (rsFiles->FileDetails(*it, hintflags, fi))
{
// XXX HACK _ TOFIX >>>> fi.source);
SubFileItem *sfi = new SubFileItem(*it, fi.fname,
fi.size, SFI_STATE_DOWNLOAD, "");
// XXX HACK _ TOFIX >>>> fi.source);
mDownloads[*it] = sfi;
mDownloadsLayout->addWidget(sfi);
}
}
}
void TransferFeed::updateUploads()
{
std::list<std::string> hashes, toAdd, toRemove;
std::list<std::string>::iterator it;
std::map<std::string, uint32_t> newhashes;
std::map<std::string, uint32_t>::iterator nit;
std::map<std::string, SubFileItem *>::iterator fit;
if (!rsFiles)
{
/* not ready yet! */
return;
}
rsFiles->FileUploads(hashes);
for(it = hashes.begin(); it != hashes.end(); it++)
{
newhashes[*it] = 1;
}
nit = newhashes.begin();
fit = mUploads.begin();
while(nit != newhashes.end())
{
if (fit == mUploads.end())
{
toAdd.push_back(nit->first);
nit++;
continue;
}
if (nit->first == fit->first)
{
/* same - good! */
nit++;
fit++;
continue;
}
if (nit->first < fit->first)
{
/* must add in new item */
toAdd.push_back(nit->first);
nit++;
}
else
{
toRemove.push_back(fit->first);
fit++;
}
}
/* remove remaining items */
while (fit != mUploads.end())
{
toRemove.push_back(fit->first);
fit++;
}
/* remove first */
for(it = toRemove.begin(); it != toRemove.end(); it++)
{
fit = mUploads.find(*it);
if (fit != mUploads.end())
{
delete (fit->second);
mUploads.erase(fit);
}
}
/* add in new ones */
for(it = toAdd.begin(); it != toAdd.end(); it++)
{
FileInfo fi;
uint32_t hintflags = RS_FILE_HINTS_UPLOAD
| RS_FILE_HINTS_SPEC_ONLY;
if (rsFiles->FileDetails(*it, hintflags, fi))
{
// XXX HACK _ TOFIX >>>> fi.source);
SubFileItem *sfi = new SubFileItem(*it, fi.fname,
fi.size, SFI_STATE_UPLOAD, "");
// XXX HACK _ TOFIX >>>> fi.source);
mUploads[*it] = sfi;
mUploadsLayout->addWidget(sfi);
}
}
}

View File

@ -1,69 +0,0 @@
/****************************************************************
* 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.
****************************************************************/
#ifndef _TRANSFER_FEED_DIALOG_H
#define _TRANSFER_FEED_DIALOG_H
#include "gui/mainpage.h"
#include "ui_TransferFeed.h"
#include "gui/feeds/FeedHolder.h"
class SubFileItem;
class TransferFeed : public MainPage, public FeedHolder, private Ui::TransferFeed
{
Q_OBJECT
public:
/** Default Constructor */
TransferFeed(QWidget *parent = 0);
/** Default Destructor */
/* FeedHolder Functions (for FeedItem functionality) */
virtual void deleteFeedItem(QWidget *item, uint32_t type);
virtual void openChat(std::string peerId);
virtual void openMsg(uint32_t type, std::string grpId, std::string inReplyTo);
private slots:
void updateMode();
void updateAll();
void updateDownloads();
void updateUploads();
private:
QLayout *mDownloadsLayout;
QLayout *mUploadsLayout;
/* lists of feedItems */
uint32_t mMode;
std::map<std::string, SubFileItem *> mDownloads;
std::map<std::string, SubFileItem *> mUploads;
};
#endif

View File

@ -1,139 +0,0 @@
<ui version="4.0" >
<class>TransferFeed</class>
<widget class="QWidget" name="TransferFeed" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>689</width>
<height>386</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>0</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>6</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Sort:</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="modeComboBox" >
<property name="minimumSize" >
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<item>
<property name="text" >
<string>None</string>
</property>
</item>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>50</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QSplitter" name="splitter" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<widget class="QFrame" name="frameDown" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
</widget>
<widget class="QFrame" name="frameUp" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc" />
</resources>
<connections/>
</ui>