mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-23 21:25:22 -04:00
* Addition of new Feeds (PeersFeed / TransferFeed / MsgFeed)
* Addition of new FeedItems (MsgItem / ChanNewItem ) * Removed CheckBoxes at the top of NewsFeed (should be in config) * Enabled subscribe/unsubscribeButtons in ChannelFeed. * Enabled ChanNewItem and MsgItem in NewsFeeds. * Remove Goto Section Button from FeedItems. * Disabled PlayMedia button - if no attachments. * Enabled Drag from Search Window (with new class SearchTreeWidget) * Enabled Drag from SharedFiles Dialog (mods to RemoteDirModel). * Enabled Drop in GeneralMsgDialog from Search/SharedFiles. * Updated Rs Interface (64 bits for filesize) * Other bits and bobs. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@635 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
56639fd1ba
commit
1f01c08de4
41 changed files with 3362 additions and 521 deletions
294
retroshare-gui/src/gui/TransferFeed.cpp
Normal file
294
retroshare-gui/src/gui/TransferFeed.cpp
Normal file
|
@ -0,0 +1,294 @@
|
|||
/****************************************************************
|
||||
* 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 "feeds/SubFileItem.h"
|
||||
#include "GeneralMsgDialog.h"
|
||||
|
||||
#include "rsiface/rsfiles.h"
|
||||
|
||||
/** 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);
|
||||
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
std::cerr << "TransferFeed::deleteFeedItem()";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
void TransferFeed::openChat(std::string peerId)
|
||||
{
|
||||
std::cerr << "TransferFeed::openChat()";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
void TransferFeed::openMsg(uint32_t type, std::string grpId, std::string inReplyTo)
|
||||
{
|
||||
std::cerr << "TransferFeed::openMsg()";
|
||||
std::cerr << std::endl;
|
||||
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++)
|
||||
{
|
||||
SubFileItem *fi = new SubFileItem(*it, "FileName", 123498);
|
||||
mDownloads[*it] = fi;
|
||||
mDownloadsLayout->addWidget(fi);
|
||||
}
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
SubFileItem *fi = new SubFileItem(*it, "FileName", 123498);
|
||||
mUploads[*it] = fi;
|
||||
mUploadsLayout->addWidget(fi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue