* 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:
drbob 2008-07-04 14:41:24 +00:00
parent 56639fd1ba
commit 1f01c08de4
41 changed files with 3362 additions and 521 deletions

View File

@ -72,6 +72,7 @@ HEADERS += rshare.h \
gui/NetworkView.h \
gui/MessengerWindow.h \
gui/PeersDialog.h \
gui/SearchTreeWidget.h \
gui/SearchDialog.h \
gui/SharedFilesDialog.h \
gui/StatisticDialog.h \
@ -153,14 +154,19 @@ HEADERS += rshare.h \
gui/elastic/edge.h \
gui/elastic/node.h \
gui/NewsFeed.h \
gui/PeersFeed.h \
gui/MsgFeed.h \
gui/TransferFeed.h \
gui/ChannelFeed.h \
gui/GeneralMsgDialog.h \
gui/feeds/FeedHolder.h \
gui/feeds/ForumNewItem.h \
gui/feeds/ForumMsgItem.h \
gui/feeds/PeerItem.h \
gui/feeds/MsgItem.h \
gui/feeds/ChanGroupItem.h \
gui/feeds/ChanMenuItem.h \
gui/feeds/ChanNewItem.h \
gui/feeds/ChanMsgItem.h \
gui/feeds/BlogMsgItem.h \
gui/feeds/SubFileItem.h \
@ -229,13 +235,18 @@ FORMS += gui/ChatDialog.ui \
gui/channels/MyChannelsDialog.ui \
gui/channels/MySubscriptionsDialog.ui \
gui/NewsFeed.ui \
gui/PeersFeed.ui \
gui/MsgFeed.ui \
gui/TransferFeed.ui \
gui/ChannelFeed.ui \
gui/GeneralMsgDialog.ui \
gui/feeds/ForumNewItem.ui \
gui/feeds/ForumMsgItem.ui \
gui/feeds/PeerItem.ui \
gui/feeds/MsgItem.ui \
gui/feeds/ChanGroupItem.ui \
gui/feeds/ChanMenuItem.ui \
gui/feeds/ChanNewItem.ui \
gui/feeds/ChanMsgItem.ui \
gui/feeds/BlogMsgItem.ui \
gui/feeds/SubFileItem.ui \
@ -270,6 +281,7 @@ SOURCES += main.cpp \
gui/NetworkView.cpp \
gui/MessengerWindow.cpp \
gui/PeersDialog.cpp \
gui/SearchTreeWidget.cpp \
gui/SearchDialog.cpp \
gui/SharedFilesDialog.cpp \
gui/StatisticDialog.cpp \
@ -342,13 +354,18 @@ SOURCES += main.cpp \
gui/elastic/edge.cpp \
gui/elastic/node.cpp \
gui/NewsFeed.cpp \
gui/PeersFeed.cpp \
gui/MsgFeed.cpp \
gui/TransferFeed.cpp \
gui/ChannelFeed.cpp \
gui/GeneralMsgDialog.cpp \
gui/feeds/ForumNewItem.cpp \
gui/feeds/ForumMsgItem.cpp \
gui/feeds/PeerItem.cpp \
gui/feeds/MsgItem.cpp \
gui/feeds/ChanGroupItem.cpp \
gui/feeds/ChanMenuItem.cpp \
gui/feeds/ChanNewItem.cpp \
gui/feeds/ChanMsgItem.cpp \
gui/feeds/BlogMsgItem.cpp \
gui/feeds/SubFileItem.cpp \

View File

@ -49,6 +49,9 @@
#include "BlogDialog.h"
#include "CalDialog.h"
#include "NewsFeed.h"
#include "PeersFeed.h"
#include "TransferFeed.h"
#include "MsgFeed.h"
#include "ChannelFeed.h"
/* for smplayer */
@ -112,18 +115,30 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
ui.stackPages->add(newsFeed = new NewsFeed(ui.stackPages),
createPageAction(QIcon(IMAGE_NEWSFEED), tr("News Feed"), grp));
ForumsDialog *forumsDialog = NULL;
ui.stackPages->add(forumsDialog = new ForumsDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_NETWORK), tr("Forums"), grp));
PeersFeed *peersFeed = NULL;
ui.stackPages->add(peersFeed = new PeersFeed(ui.stackPages),
createPageAction(QIcon(IMAGE_NEWSFEED), tr("Peers"), grp));
ChannelFeed *channelFeed = NULL;
ui.stackPages->add(channelFeed = new ChannelFeed(ui.stackPages),
createPageAction(QIcon(IMAGE_CHANNELS), tr("Channel Feed"), grp));
TransferFeed *transferFeed = NULL;
ui.stackPages->add(transferFeed = new TransferFeed(ui.stackPages),
createPageAction(QIcon(IMAGE_NEWSFEED), tr("Transfers"), grp));
MsgFeed *msgFeed = NULL;
ui.stackPages->add(msgFeed = new MsgFeed(ui.stackPages),
createPageAction(QIcon(IMAGE_NEWSFEED), tr("Messages"), grp));
BlogDialog *blogDialog = NULL;
ui.stackPages->add(blogDialog = new BlogDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_NETWORK), tr("Blog Feed"), grp));
ChannelFeed *channelFeed = NULL;
ui.stackPages->add(channelFeed = new ChannelFeed(ui.stackPages),
createPageAction(QIcon(IMAGE_CHANNELS), tr("Channel Feed"), grp));
ForumsDialog *forumsDialog = NULL;
ui.stackPages->add(forumsDialog = new ForumsDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_NETWORK), tr("Forums"), grp));
GamesDialog *gamesDialog = NULL;
ui.stackPages->add(gamesDialog = new GamesDialog(ui.stackPages),
createPageAction(QIcon(IMAGE_GAMES), tr("Games Launcher"), grp));

View File

@ -43,6 +43,8 @@ ChannelFeed::ChannelFeed(QWidget *parent)
connect(chanButton, SIGNAL(clicked()), this, SLOT(createChannel()));
connect(postButton, SIGNAL(clicked()), this, SLOT(sendMsg()));
connect(subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeChannel ( void ) ) );
connect(unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) );
/*************** Setup Left Hand Side (List of Channels) ****************/
@ -454,3 +456,37 @@ void ChannelFeed::updateChannelMsgs()
}
}
void ChannelFeed::unsubscribeChannel()
{
#ifdef DEBUG_ITEM
std::cerr << "ChannelFeed::unsubscribeChannel()";
std::cerr << std::endl;
#endif
if (rsChannels)
{
rsChannels->channelSubscribe(mChannelId, false);
}
updateChannelMsgs();
}
void ChannelFeed::subscribeChannel()
{
#ifdef DEBUG_ITEM
std::cerr << "ChannelFeed::subscribeChannel()";
std::cerr << std::endl;
#endif
if (rsChannels)
{
rsChannels->channelSubscribe(mChannelId, true);
}
updateChannelMsgs();
}

View File

@ -58,6 +58,9 @@ private slots:
void channelSelection();
void subscribeChannel();
void unsubscribeChannel();
private:
void updateChannelList();

View File

@ -92,6 +92,12 @@ void GeneralMsgDialog::dragEnterEvent(QDragEnterEvent *event)
std::cerr << std::endl;
event->acceptProposedAction();
}
else if (event->mimeData()->hasFormat("application/x-rsfilelist"))
{
std::cerr << "GeneralMsgDialog::dragEnterEvent() accepting Application/x-qabs...";
std::cerr << std::endl;
event->acceptProposedAction();
}
else
{
std::cerr << "GeneralMsgDialog::dragEnterEvent() No PlainText/Urls";
@ -101,6 +107,15 @@ void GeneralMsgDialog::dragEnterEvent(QDragEnterEvent *event)
void GeneralMsgDialog::dropEvent(QDropEvent *event)
{
if (!(Qt::CopyAction & event->possibleActions()))
{
std::cerr << "GeneralMsgDialog::dropEvent() Rejecting uncopyable DropAction";
std::cerr << std::endl;
/* can't do it */
return;
}
std::cerr << "GeneralMsgDialog::dropEvent() Formats";
std::cerr << std::endl;
QStringList formats = event->mimeData()->formats();
@ -140,11 +155,121 @@ void GeneralMsgDialog::dropEvent(QDropEvent *event)
}
}
}
else if (event->mimeData()->hasFormat("application/x-rsfilelist"))
{
std::cerr << "GeneralMsgDialog::dropEvent() Application/x-rsfilelist";
std::cerr << std::endl;
QByteArray data = event->mimeData()->data("application/x-rsfilelist");
std::cerr << "Data Len:" << data.length();
std::cerr << std::endl;
std::cerr << "Data is:" << data.data();
std::cerr << std::endl;
std::string newattachments(data.data());
parseRsFileListAttachments(newattachments);
}
event->acceptProposedAction();
event->setDropAction(Qt::CopyAction);
event->accept();
}
void GeneralMsgDialog::parseRsFileListAttachments(std::string attachList)
{
/* split into lines */
QString input = QString::fromStdString(attachList);
QStringList attachItems = input.split("\n");
QStringList::iterator it;
QStringList::iterator it2;
for(it = attachItems.begin(); it != attachItems.end(); it++)
{
std::cerr << "GeneralMsgDialog::parseRsFileListAttachments() Entry: ";
QStringList parts = (*it).split("/");
bool ok = false;
quint64 qsize = 0;
std::string fname;
std::string hash;
uint64_t size = 0;
std::string source;
int i = 0;
for(it2 = parts.begin(); it2 != parts.end(); it2++, i++)
{
std::cerr << "\"" << it2->toStdString() << "\" ";
switch(i)
{
case 0:
fname = it2->toStdString();
break;
case 1:
hash = it2->toStdString();
break;
case 2:
qsize = it2->toULongLong(&ok, 10);
size = qsize;
break;
case 3:
source = it2->toStdString();
break;
}
}
std::cerr << std::endl;
std::cerr << "\tfname: " << fname << std::endl;
std::cerr << "\thash: " << hash << std::endl;
std::cerr << "\tsize: " << size << std::endl;
std::cerr << "\tsource: " << source << std::endl;
/* basic error checking */
if ((ok) && (hash.size() == 40))
{
std::cerr << "Item Ok" << std::endl;
if (source == "Local")
{
addAttachment(hash, fname, size);
}
else
{
// TEMP NOT ALLOWED UNTIL FT WORKING.
//addAttachment(hash, fname, size);
}
}
else
{
std::cerr << "Error Decode: Hash size: " << hash.size() << std::endl;
}
}
}
void GeneralMsgDialog::addAttachment(std::string hash, std::string fname, uint64_t size)
{
/* add a SubFileItem to the attachment section */
std::cerr << "GeneralMsgDialog::addAttachment()";
std::cerr << std::endl;
/* add widget in for new destination */
SubFileItem *file = new SubFileItem(hash, fname, size);
mAttachments.push_back(file);
QLayout *layout = fileFrame->layout();
layout->addWidget(file);
return;
}
void GeneralMsgDialog::addAttachment(std::string path)
{
/* add a SubFileItem to the attachment section */
@ -185,6 +310,27 @@ void GeneralMsgDialog::addDestination(uint32_t type, std::string grpId, std::str
return;
}
void GeneralMsgDialog::setMsgType(uint32_t type)
{
switch(type)
{
default:
case FEEDHOLDER_MSG_MESSAGE:
typeComboBox->setCurrentIndex(GMD_TYPE_MESSAGE_IDX);
break;
case FEEDHOLDER_MSG_FORUM:
typeComboBox->setCurrentIndex(GMD_TYPE_FORUM_IDX);
break;
case FEEDHOLDER_MSG_CHANNEL:
typeComboBox->setCurrentIndex(GMD_TYPE_CHANNEL_IDX);
break;
case FEEDHOLDER_MSG_BLOG:
typeComboBox->setCurrentIndex(GMD_TYPE_BLOG_IDX);
break;
}
}
void GeneralMsgDialog::updateGroupId()
{
std::cerr << "GeneralMsgDialog::updateGroupId()";

View File

@ -43,7 +43,10 @@ public:
/** Default Destructor */
void addAttachment(std::string path);
void addAttachment(std::string hash, std::string fname, uint64_t size);
void addDestination(uint32_t type, std::string grpId, std::string inReplyTo);
void setMsgType(uint32_t type);
protected:
virtual void dragEnterEvent(QDragEnterEvent *event);
@ -57,6 +60,8 @@ private slots:
private:
void parseRsFileListAttachments(std::string attachList);
void sendMessage(uint32_t type, std::string grpId, std::string inReplyTo,
std::wstring subject, std::wstring msg, std::list<FileInfo> &files);

View File

@ -20,6 +20,9 @@
<layout class="QHBoxLayout" >
<item>
<widget class="QComboBox" name="typeComboBox" >
<property name="acceptDrops" >
<bool>true</bool>
</property>
<item>
<property name="text" >
<string>Friend</string>
@ -97,6 +100,9 @@
</item>
<item>
<widget class="QFrame" name="destFrame" >
<property name="acceptDrops" >
<bool>true</bool>
</property>
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
@ -171,6 +177,9 @@
<height>60</height>
</size>
</property>
<property name="acceptDrops" >
<bool>true</bool>
</property>
<property name="toolTip" >
<string>Drag and Drop Files from Search Results</string>
</property>

View File

@ -0,0 +1,314 @@
/****************************************************************
* 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 "feeds/MsgItem.h"
#include "GeneralMsgDialog.h"
#include "rsiface/rsmsgs.h"
#include "rsiface/rspeers.h"
/** 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);
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)
{
std::cerr << "MsgFeed::deleteFeedItem()";
std::cerr << std::endl;
}
void MsgFeed::openChat(std::string peerId)
{
std::cerr << "MsgFeed::openChat()";
std::cerr << std::endl;
}
void MsgFeed::openMsg(uint32_t type, std::string grpId, std::string inReplyTo)
{
std::cerr << "MsgFeed::openMsg()";
std::cerr << std::endl;
GeneralMsgDialog *msgDialog = new GeneralMsgDialog(NULL);
msgDialog->addDestination(type, grpId, inReplyTo);
msgDialog->show();
}
void MsgFeed::newMsg()
{
std::cerr << "MsgFeed::newMsg()";
std::cerr << std::endl;
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()
{
std::cerr << "MsgFeed::updatePeerIds()";
std::cerr << std::endl;
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

@ -0,0 +1,72 @@
/****************************************************************
* 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 "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

@ -0,0 +1,257 @@
<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" >
<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>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" >
<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" >
<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" >
<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" >
<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" >
<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" >
<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" >:/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

@ -26,11 +26,13 @@
#include "rsiface/rsnotify.h"
#include "feeds/ChanNewItem.h"
#include "feeds/ChanMsgItem.h"
#include "feeds/ForumNewItem.h"
#include "feeds/ForumMsgItem.h"
#include "feeds/PeerItem.h"
#include "feeds/BlogMsgItem.h"
#include "feeds/MsgItem.h"
#include "GeneralMsgDialog.h"
@ -42,6 +44,7 @@ const uint32_t NEWSFEED_FORUMMSGLIST = 0x0003;
const uint32_t NEWSFEED_CHANNEWLIST = 0x0004;
const uint32_t NEWSFEED_CHANMSGLIST = 0x0005;
const uint32_t NEWSFEED_BLOGMSGLIST = 0x0006;
const uint32_t NEWSFEED_MESSAGELIST = 0x0007;
/** Constructor */
NewsFeed::NewsFeed(QWidget *parent)
@ -206,6 +209,14 @@ void NewsFeed::addFeedItemPeerNew(RsFeedItem &fi)
void NewsFeed::addFeedItemChanNew(RsFeedItem &fi)
{
/* make new widget */
ChanNewItem *cni = new ChanNewItem(this, NEWSFEED_CHANNEWLIST, fi.mId1, false, true);
/* store in list */
/* add to layout */
mLayout->addWidget(cni);
std::cerr << "NewsFeed::addFeedItemChanNew()";
std::cerr << std::endl;
}
@ -213,6 +224,14 @@ void NewsFeed::addFeedItemChanNew(RsFeedItem &fi)
void NewsFeed::addFeedItemChanUpdate(RsFeedItem &fi)
{
/* make new widget */
ChanNewItem *cni = new ChanNewItem(this, NEWSFEED_CHANNEWLIST, fi.mId1, false, false);
/* store in list */
/* add to layout */
mLayout->addWidget(cni);
std::cerr << "NewsFeed::addFeedItemChanUpdate()";
std::cerr << std::endl;
}
@ -305,6 +324,14 @@ void NewsFeed::addFeedItemChatNew(RsFeedItem &fi)
void NewsFeed::addFeedItemMessage(RsFeedItem &fi)
{
/* make new widget */
MsgItem *mi = new MsgItem(this, NEWSFEED_MESSAGELIST, fi.mId1, false);
/* store in list */
/* add to layout */
mLayout->addWidget(mi);
std::cerr << "NewsFeed::addFeedItemMessage()";
std::cerr << std::endl;
}

View File

@ -12,124 +12,20 @@
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Enabled Feeds:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="noneButton" >
<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/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/deleteall.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="allButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>All Feeds</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/startall.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chanCheckBox" >
<property name="text" >
<string>Channels</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="forumCheckBox" >
<property name="text" >
<string>Forums</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="friendCheckBox" >
<property name="text" >
<string>Friends</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="blogCheckBox" >
<property name="text" >
<string>Blogs</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="msgCheckBox" >
<property name="text" >
<string>Messages</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chatCheckBox" >
<property name="text" >
<string>Chat</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Clear Feed</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/deletemail24.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item row="0" column="0" >
<widget class="QFrame" name="frame" >
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>

View File

@ -0,0 +1,449 @@
/****************************************************************
* 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 "feeds/PeerItem.h"
#include "rsiface/rspeers.h"
#include "GeneralMsgDialog.h"
const uint32_t PEERSFEED_MODE_FRIENDS = 0x0000;
const uint32_t PEERSFEED_MODE_FOF = 0x0001;
const uint32_t PEERSFEED_MODE_ALL = 0x0002;
/** 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);
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)
{
std::cerr << "PeersFeed::deleteFeedItem()";
std::cerr << std::endl;
}
void PeersFeed::openChat(std::string peerId)
{
std::cerr << "PeersFeed::openChat()";
std::cerr << std::endl;
}
void PeersFeed::openMsg(uint32_t type, std::string grpId, std::string inReplyTo)
{
std::cerr << "PeersFeed::openMsg()";
std::cerr << std::endl;
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);
}
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

@ -0,0 +1,65 @@
/****************************************************************
* 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 "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

@ -0,0 +1,115 @@
<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" >
<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" >
<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 Only</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" >
<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

@ -1075,7 +1075,7 @@ p, li { white-space: pre-wrap; }
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTreeWidget" name="searchResultWidget" >
<widget class="SearchTreeWidget" name="searchResultWidget" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>1</horstretch>
@ -1085,6 +1085,12 @@ p, li { white-space: pre-wrap; }
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="dragEnabled" >
<bool>true</bool>
</property>
<property name="dragDropMode" >
<enum>QAbstractItemView::DragOnly</enum>
</property>
<property name="sortingEnabled" >
<bool>true</bool>
</property>
@ -1159,6 +1165,13 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>SearchTreeWidget</class>
<extends>QTreeWidget</extends>
<header>gui/SearchTreeWidget.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="images.qrc" />
</resources>

View File

@ -0,0 +1,77 @@
/****************************************************************
* 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 "SearchTreeWidget.h"
#include <iostream>
SearchTreeWidget::SearchTreeWidget(QWidget *parent)
:QTreeWidget(parent)
{
return;
}
QMimeData * SearchTreeWidget::mimeData ( const QList<QTreeWidgetItem *> items ) const
{
/* extract from each QTreeWidgetItem... all the member text */
QList<QTreeWidgetItem *>::const_iterator it;
QString text;
for(it = items.begin(); it != items.end(); it++)
{
QString line;
for(int i = 0; i < (*it)->columnCount(); i++)
{
line += (*it)->text(i);
line += "/";
}
line += "\n";
text += line;
}
std::cerr << "Created MimeData:";
std::cerr << std::endl;
std::string str = text.toStdString();
std::cerr << str;
std::cerr << std::endl;
QMimeData *data = new QMimeData();
data->setData("application/x-rsfilelist", QByteArray(str.c_str()));
return data;
}
QStringList SearchTreeWidget::mimeTypes () const
{
QStringList list;
list.push_back("application/x-rsfilelist");
return list;
}
Qt::DropActions SearchTreeWidget::supportedDropActions () const
{
return Qt::CopyAction;
}

View File

@ -0,0 +1,43 @@
/****************************************************************
* 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 _SEARCH_TREE_WIDGET_H
#define _SEARCH_TREE_WIDGET_H
#include <QtGui>
class SearchTreeWidget : public QTreeWidget
{
Q_OBJECT
public:
SearchTreeWidget(QWidget *parent = 0);
protected:
virtual QMimeData * mimeData ( const QList<QTreeWidgetItem *> items ) const;
virtual QStringList mimeTypes () const;
virtual Qt::DropActions supportedDropActions () const;
};
#endif

View File

@ -599,13 +599,13 @@ p, li { white-space: pre-wrap; }
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="acceptDrops" >
<bool>true</bool>
<bool>false</bool>
</property>
<property name="dragEnabled" >
<bool>true</bool>
</property>
<property name="dragDropMode" >
<enum>QAbstractItemView::DragDrop</enum>
<enum>QAbstractItemView::DragOnly</enum>
</property>
<property name="alternatingRowColors" >
<bool>false</bool>

View 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);
}
}

View File

@ -0,0 +1,69 @@
/****************************************************************
* 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 "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

@ -0,0 +1,124 @@
<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" >
<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" >
<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" >
<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>

View File

@ -40,7 +40,7 @@ BlogMsgItem::BlogMsgItem(FeedHolder *parent, uint32_t feedId, std::string peerId
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
//connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
/* specific ones */
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( playMedia ( void ) ) );
@ -83,7 +83,9 @@ void BlogMsgItem::updateItemStatic()
{
/* disable buttons */
clearButton->setEnabled(false);
gotoButton->setEnabled(false);
//gotoButton->setEnabled(false);
clearButton->hide();
}
}
@ -108,7 +110,10 @@ void BlogMsgItem::updateItem()
return;
}
}
playButton->setEnabled(true);
if (mFileItems.size() > 0)
{
playButton->setEnabled(true);
}
}

View File

@ -43,7 +43,7 @@
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="gotoButton" >
<widget class="QPushButton" name="clearButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>0</horstretch>
@ -51,13 +51,13 @@
</sizepolicy>
</property>
<property name="toolTip" >
<string>Goto Section</string>
<string>Remove Item</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/add-friend24.png</iconset>
<iconset resource="images.qrc" >:/images/close_normal.png</iconset>
</property>
</widget>
</item>
@ -113,41 +113,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="clearButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Delete FeedItem</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/close_normal.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="expandButton" >
<property name="sizePolicy" >

View File

@ -42,7 +42,7 @@ ChanMsgItem::ChanMsgItem(FeedHolder *parent, uint32_t feedId, std::string chanId
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
//connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
/* specific ones */
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( playMedia ( void ) ) );
@ -107,9 +107,14 @@ void ChanMsgItem::updateItemStatic()
{
/* disable buttons */
clearButton->setEnabled(false);
gotoButton->setEnabled(false);
//gotoButton->setEnabled(false);
unsubscribeButton->setEnabled(false);
clearButton->hide();
}
/* don't really want this at all! */
unsubscribeButton->hide();
}
@ -133,7 +138,10 @@ void ChanMsgItem::updateItem()
return;
}
}
playButton->setEnabled(true);
if (mFileItems.size() > 0)
{
playButton->setEnabled(true);
}
}

View File

@ -43,7 +43,7 @@
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="gotoButton" >
<widget class="QPushButton" name="clearButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>0</horstretch>
@ -51,13 +51,13 @@
</sizepolicy>
</property>
<property name="toolTip" >
<string>Goto Section</string>
<string>Remove Item</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/add-friend24.png</iconset>
<iconset resource="images.qrc" >:/images/close_normal.png</iconset>
</property>
</widget>
</item>
@ -113,41 +113,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="clearButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Delete FeedItem</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/close_normal.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="expandButton" >
<property name="sizePolicy" >
@ -171,13 +136,6 @@
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Subject</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="subjectLabel" >
<property name="sizePolicy" >

View File

@ -0,0 +1,194 @@
/****************************************************************
* 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 "ChanNewItem.h"
#include "FeedHolder.h"
#include "rsiface/rschannels.h"
#include <iostream>
#define DEBUG_ITEM 1
/** Constructor */
ChanNewItem::ChanNewItem(FeedHolder *parent, uint32_t feedId, std::string chanId, bool isHome, bool isNew)
:QWidget(NULL), mParent(parent), mFeedId(feedId),
mChanId(chanId), mIsHome(isHome), mIsNew(isNew)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
//connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
/* specific ones */
connect( subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeChannel ( void ) ) );
small();
updateItemStatic();
updateItem();
}
void ChanNewItem::updateItemStatic()
{
if (!rsChannels)
return;
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "ChanNewItem::updateItemStatic()";
std::cerr << std::endl;
#endif
ChannelInfo ci;
if (rsChannels->getChannelInfo(mChanId, ci))
{
nameLabel->setText(QString::fromStdWString(ci.channelName));
descLabel->setText(QString::fromStdWString(ci.channelDesc));
if (ci.channelFlags & RS_DISTRIB_SUBSCRIBED)
{
subscribeButton->setEnabled(false);
//postButton->setEnabled(true);
}
else
{
subscribeButton->setEnabled(true);
//postButton->setEnabled(false);
}
/* should also check the other flags */
}
else
{
nameLabel->setText("Unknown Channel");
titleLabel->setText("Channel ???");
descLabel->setText("");
}
if (mIsNew)
{
titleLabel->setText("New Channel");
}
else
{
titleLabel->setText("Updated Channel");
}
if (mIsHome)
{
/* disable buttons */
clearButton->setEnabled(false);
//gotoButton->setEnabled(false);
}
}
void ChanNewItem::updateItem()
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "ChanNewItem::updateItem()";
std::cerr << std::endl;
#endif
}
void ChanNewItem::small()
{
expandFrame->hide();
}
void ChanNewItem::toggle()
{
if (expandFrame->isHidden())
{
expandFrame->show();
}
else
{
expandFrame->hide();
}
}
void ChanNewItem::removeItem()
{
#ifdef DEBUG_ITEM
std::cerr << "ChanNewItem::removeItem()";
std::cerr << std::endl;
#endif
hide();
if (mParent)
{
mParent->deleteFeedItem(this, mFeedId);
}
}
void ChanNewItem::gotoHome()
{
#ifdef DEBUG_ITEM
std::cerr << "ChanNewItem::gotoHome()";
std::cerr << std::endl;
#endif
}
/*********** SPECIFIC FUNCTIOSN ***********************/
void ChanNewItem::unsubscribeChannel()
{
#ifdef DEBUG_ITEM
std::cerr << "ChanNewItem::unsubscribeChannel()";
std::cerr << std::endl;
#endif
if (rsChannels)
{
rsChannels->channelSubscribe(mChanId, false);
}
updateItemStatic();
}
void ChanNewItem::subscribeChannel()
{
#ifdef DEBUG_ITEM
std::cerr << "ChanNewItem::subscribeChannel()";
std::cerr << std::endl;
#endif
if (rsChannels)
{
rsChannels->channelSubscribe(mChanId, true);
}
updateItemStatic();
}

View File

@ -0,0 +1,67 @@
/****************************************************************
* 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 _CHANNEL_NEW_ITEM_DIALOG_H
#define _CHANNEL_NEW_ITEM_DIALOG_H
#include "ui_ChanNewItem.h"
#include <string>
class FeedHolder;
class ChanNewItem : public QWidget, private Ui::ChanNewItem
{
Q_OBJECT
public:
/** Default Constructor */
ChanNewItem(FeedHolder *parent, uint32_t feedId, std::string chanId, bool isHome, bool isNew);
/** Default Destructor */
void updateItemStatic();
void small();
private slots:
/* default stuff */
void gotoHome();
void removeItem();
void toggle();
void unsubscribeChannel();
void subscribeChannel();
void updateItem();
private:
FeedHolder *mParent;
uint32_t mFeedId;
std::string mChanId;
bool mIsHome;
bool mIsNew;
};
#endif

View File

@ -1,18 +1,24 @@
<ui version="4.0" >
<class>MsgItem</class>
<widget class="QWidget" name="MsgItem" >
<class>ChanNewItem</class>
<widget class="QWidget" name="ChanNewItem" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>603</width>
<height>358</height>
<width>634</width>
<height>354</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<property name="topMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item row="0" column="0" >
<widget class="QFrame" name="frame" >
<property name="sizePolicy" >
@ -28,83 +34,24 @@
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" >
<property name="topMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="gotoButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Goto Section</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/add-friend24.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" >
<size>
<width>16</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="typeLabel" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font" >
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Connected</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" >
<size>
<width>500</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="clearButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Remove</string>
<string>Remove Item</string>
</property>
<property name="text" >
<string/>
@ -130,8 +77,108 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="titleLabel" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font" >
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Connected</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" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="nameLabel" >
<property name="text" >
<string>name</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>500</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="subscribeButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Subscribe to Channel</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/directoryadd_24x24_shadow.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="expandButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Expand</string>
</property>
@ -146,96 +193,7 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string/>
</property>
<property name="pixmap" >
<pixmap resource="images.qrc" >:/images/advsearch_24x24.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="catLabel" >
<property name="text" >
<string>Category</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" >
<size>
<width>200</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3" >
<property name="text" >
<string/>
</property>
<property name="pixmap" >
<pixmap/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="nameLabel" >
<property name="text" >
<string>Name</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" >
<size>
<width>200</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="subscribeButton" >
<property name="toolTip" >
<string>Subscribe To Channel</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/channelsubscribe.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="frame_2" >
<widget class="QFrame" name="expandFrame" >
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
@ -243,6 +201,21 @@
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>0</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" >
<item>
@ -251,10 +224,7 @@
<string/>
</property>
<property name="pixmap" >
<pixmap resource="images.qrc" >:/images/channels.png</pixmap>
</property>
<property name="scaledContents" >
<bool>false</bool>
<pixmap resource="images.qrc" >:/images/contacts24.png</pixmap>
</property>
</widget>
</item>
@ -268,7 +238,7 @@
</property>
<property name="text" >
<string>Description
of Channel</string>
of Forum</string>
</property>
</widget>
</item>

View File

@ -40,7 +40,7 @@ ForumMsgItem::ForumMsgItem(FeedHolder *parent, uint32_t feedId, std::string foru
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
//connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
/* specific ones */
connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeForum ( void ) ) );
@ -144,8 +144,12 @@ void ForumMsgItem::updateItemStatic()
{
/* disable buttons */
clearButton->setEnabled(false);
gotoButton->setEnabled(false);
//gotoButton->setEnabled(false);
clearButton->hide();
}
unsubscribeButton->hide();
}

View File

@ -43,7 +43,7 @@
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="gotoButton" >
<widget class="QPushButton" name="clearButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
@ -51,13 +51,13 @@
</sizepolicy>
</property>
<property name="toolTip" >
<string>Goto Section</string>
<string>Remove Item</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/add-friend24.png</iconset>
<iconset resource="images.qrc" >:/images/close_normal.png</iconset>
</property>
</widget>
</item>
@ -113,41 +113,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="clearButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Remove</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/close_normal.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="expandButton" >
<property name="sizePolicy" >

View File

@ -40,7 +40,7 @@ ForumNewItem::ForumNewItem(FeedHolder *parent, uint32_t feedId, std::string foru
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
//connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
/* specific ones */
connect( subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeForum ( void ) ) );
@ -106,7 +106,7 @@ void ForumNewItem::updateItemStatic()
{
/* disable buttons */
clearButton->setEnabled(false);
gotoButton->setEnabled(false);
//gotoButton->setEnabled(false);
}
}

View File

@ -43,7 +43,7 @@
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="gotoButton" >
<widget class="QPushButton" name="clearButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
@ -51,13 +51,13 @@
</sizepolicy>
</property>
<property name="toolTip" >
<string>Goto Section</string>
<string>Remove Item</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/add-friend24.png</iconset>
<iconset resource="images.qrc" >:/images/close_normal.png</iconset>
</property>
</widget>
</item>
@ -171,41 +171,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="clearButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Remove</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/close_normal.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="expandButton" >
<property name="sizePolicy" >

View File

@ -0,0 +1,260 @@
/****************************************************************
* 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 "MsgItem.h"
#include "FeedHolder.h"
#include "SubFileItem.h"
#include "rsiface/rsmsgs.h"
#include "rsiface/rspeers.h"
#include <iostream>
#define DEBUG_ITEM 1
/** Constructor */
MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, std::string msgId, bool isHome)
:QWidget(NULL), mParent(parent), mFeedId(feedId), mMsgId(msgId), mIsHome(isHome)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
//connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
/* specific ones */
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( playMedia ( void ) ) );
connect( deleteButton, SIGNAL( clicked( void ) ), this, SLOT( deleteMsg ( void ) ) );
connect( replyButton, SIGNAL( clicked( void ) ), this, SLOT( replyMsg ( void ) ) );
small();
updateItemStatic();
updateItem();
}
void MsgItem::updateItemStatic()
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "MsgItem::updateItemStatic()";
std::cerr << std::endl;
#endif
MessageInfo mi;
if (!rsMsgs)
return;
if (!rsMsgs->getMessage(mMsgId, mi))
return;
/* get peer Id */
mPeerId = mi.srcId;
QString title;
QString timestamp;
QString srcName = QString::fromStdString(rsPeers->getPeerName(mi.srcId));
{
QDateTime qtime;
qtime.setTime_t(mi.ts);
timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
}
if (!mIsHome)
{
title = "Message From: ";
}
else
{
/* subject */
uint32_t box = mi.msgflags & RS_MSG_BOXMASK;
switch(box)
{
case RS_MSG_SENTBOX:
title = "Sent Msg: ";
replyButton->setEnabled(false);
break;
case RS_MSG_DRAFTBOX:
title = "Draft Msg: ";
replyButton->setEnabled(false);
break;
case RS_MSG_OUTBOX:
title = "Pending Msg: ";
//deleteButton->setEnabled(false);
replyButton->setEnabled(false);
break;
default:
case RS_MSG_INBOX:
title = "";
break;
}
}
title += srcName + " @ " + timestamp;
titleLabel->setText(title);
subjectLabel->setText(QString::fromStdWString(mi.title));
msgLabel->setText(QString::fromStdWString(mi.msg));
std::list<FileInfo>::iterator it;
for(it = mi.files.begin(); it != mi.files.end(); it++)
{
/* add file */
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->size);
mFileItems.push_back(fi);
QLayout *layout = expandFrame->layout();
layout->addWidget(fi);
}
playButton->setEnabled(false);
if (mIsHome)
{
/* disable buttons */
clearButton->setEnabled(false);
//gotoButton->setEnabled(false);
/* hide buttons */
clearButton->hide();
}
else
{
//deleteButton->setEnabled(false);
}
}
void MsgItem::updateItem()
{
/* fill in */
#ifdef DEBUG_ITEM
std::cerr << "MsgItem::updateItem()";
std::cerr << std::endl;
#endif
int msec_rate = 10000;
/* Very slow Tick to check when all files are downloaded */
std::list<SubFileItem *>::iterator it;
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
{
if (!(*it)->done())
{
/* loop again */
QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) ));
return;
}
}
if (mFileItems.size() > 0)
{
playButton->setEnabled(true);
}
}
void MsgItem::small()
{
expandFrame->hide();
}
void MsgItem::toggle()
{
if (expandFrame->isHidden())
{
expandFrame->show();
}
else
{
expandFrame->hide();
}
}
void MsgItem::removeItem()
{
#ifdef DEBUG_ITEM
std::cerr << "MsgItem::removeItem()";
std::cerr << std::endl;
#endif
hide();
if (mParent)
{
mParent->deleteFeedItem(this, mFeedId);
}
}
void MsgItem::gotoHome()
{
#ifdef DEBUG_ITEM
std::cerr << "MsgItem::gotoHome()";
std::cerr << std::endl;
#endif
}
/*********** SPECIFIC FUNCTIOSN ***********************/
void MsgItem::deleteMsg()
{
#ifdef DEBUG_ITEM
std::cerr << "MsgItem::deleteMsg()";
std::cerr << std::endl;
#endif
if (rsMsgs)
{
rsMsgs->MessageDelete(mMsgId);
hide(); /* will be cleaned up next refresh */
}
}
void MsgItem::replyMsg()
{
#ifdef DEBUG_ITEM
std::cerr << "MsgItem::replyMsg()";
std::cerr << std::endl;
#endif
if (mParent)
{
mParent->openMsg(FEEDHOLDER_MSG_MESSAGE, mPeerId, mMsgId);
}
}
void MsgItem::playMedia()
{
#ifdef DEBUG_ITEM
std::cerr << "MsgItem::playMedia()";
std::cerr << std::endl;
#endif
}

View File

@ -0,0 +1,72 @@
/****************************************************************
* 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_ITEM_DIALOG_H
#define _MSG_ITEM_DIALOG_H
#include "ui_MsgItem.h"
#include <string>
class FeedHolder;
class SubFileItem;
class MsgItem : public QWidget, private Ui::MsgItem
{
Q_OBJECT
public:
/** Default Constructor */
MsgItem(FeedHolder *parent, uint32_t feedId, std::string msgId, bool isHome);
/** Default Destructor */
void updateItemStatic();
void small();
private slots:
/* default stuff */
void gotoHome();
void removeItem();
void toggle();
void playMedia();
void deleteMsg();
void replyMsg();
void updateItem();
private:
FeedHolder *mParent;
uint32_t mFeedId;
std::string mPeerId;
std::string mMsgId;
bool mIsHome;
std::list<SubFileItem *> mFileItems;
};
#endif

View File

@ -0,0 +1,288 @@
<ui version="4.0" >
<class>MsgItem</class>
<widget class="QWidget" name="MsgItem" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>917</width>
<height>238</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<property name="topMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item row="0" column="0" >
<widget class="QFrame" name="frame" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" >
<property name="topMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="clearButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Remove Item</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/close_normal.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" >
<size>
<width>16</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="titleLabel" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font" >
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Connected</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" >
<size>
<width>1000</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="expandButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Expand</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/add_24x24.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="subjectLabel" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>subjectLabel</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" >
<size>
<width>500</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="replyButton" >
<property name="toolTip" >
<string>Reply to Message</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/mail_reply.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="deleteButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Delete Message</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/mail_delete.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="playButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Play Media</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/startall.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="expandFrame" >
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="msgLabel" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Long
message here</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc" />
</resources>
<connections/>
</ui>

View File

@ -41,7 +41,7 @@ PeerItem::PeerItem(FeedHolder *parent, uint32_t feedId, std::string peerId, uint
/* general ones */
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
//connect( gotoButton, SIGNAL( clicked( void ) ), this, SLOT( gotoHome ( void ) ) );
/* specific ones */
connect( chatButton, SIGNAL( clicked( void ) ), this, SLOT( openChat ( void ) ) );
@ -125,7 +125,10 @@ void PeerItem::updateItemStatic()
{
/* disable buttons */
clearButton->setEnabled(false);
gotoButton->setEnabled(false);
//gotoButton->setEnabled(false);
/* disable buttons */
clearButton->hide();
}
}

View File

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>835</width>
<height>551</height>
<width>825</width>
<height>323</height>
</rect>
</property>
<property name="windowTitle" >
@ -43,7 +43,7 @@
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="gotoButton" >
<widget class="QPushButton" name="clearButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
@ -51,13 +51,13 @@
</sizepolicy>
</property>
<property name="toolTip" >
<string>Goto Section</string>
<string>Remove Item</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/add-friend24.png</iconset>
<iconset resource="images.qrc" >:/images/close_normal.png</iconset>
</property>
</widget>
</item>
@ -113,41 +113,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="clearButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Remove</string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/close_normal.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="expandButton" >
<property name="sizePolicy" >
@ -539,12 +504,12 @@
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Preferred</enum>
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
<height>20</height>
</size>
</property>
</spacer>

View File

@ -2,13 +2,21 @@
#include "RemoteDirModel.h"
#include "rsfiles.h"
#include <QPalette>
#include <QtGui>
#include <iostream>
#include <sstream>
#include <math.h>
RemoteDirModel::RemoteDirModel(bool mode, QObject *parent)
: QAbstractItemModel(parent),
RemoteMode(mode), nIndex(1), indexSet(1) /* ass zero index cant be used */
{
setSupportedDragActions(Qt::CopyAction);
}
bool RemoteDirModel::hasChildren(const QModelIndex &parent) const
{
@ -518,9 +526,9 @@
else // (details.type == DIR_TYPE_FILE)
{
return ( Qt::ItemIsSelectable |
Qt::ItemIsDragEnabled |
Qt::ItemIsEnabled);
// Qt::ItemIsDragEnabled |
}
}
@ -753,4 +761,100 @@ void RemoteDirModel::getFilePaths(QModelIndexList list, std::list<std::string> &
std::cerr << "::::::::::::Done getFilePaths" << std::endl;
}
/* Drag and Drop Functionality */
QMimeData * RemoteDirModel::mimeData ( const QModelIndexList & indexes ) const
{
/* extract from each the member text */
std::string text;
QModelIndexList::const_iterator it;
std::map<std::string, uint64_t> drags;
std::map<std::string, uint64_t>::iterator dit;
for(it = indexes.begin(); it != indexes.end(); it++)
{
void *ref = it -> internalPointer();
DirDetails details;
uint32_t flags = DIR_FLAGS_DETAILS;
if (RemoteMode)
{
flags |= DIR_FLAGS_REMOTE;
}
else
{
flags |= DIR_FLAGS_LOCAL;
}
if (!rsFiles->RequestDirDetails(ref, details, flags))
{
continue;
}
std::cerr << "::::::::::::FileDrag:::: " << std::endl;
std::cerr << "Name: " << details.name << std::endl;
std::cerr << "Hash: " << details.hash << std::endl;
std::cerr << "Size: " << details.count << std::endl;
std::cerr << "Path: " << details.path << std::endl;
if (details.type != DIR_TYPE_FILE)
{
std::cerr << "RemoteDirModel::mimeData() Not File" << std::endl;
continue; /* not file! */
}
if (drags.end() != (dit = drags.find(details.hash)))
{
std::cerr << "RemoteDirModel::mimeData() Duplicate" << std::endl;
continue; /* duplicate */
}
drags[details.hash] = details.count;
std::string line = details.name;
line += "/";
line += details.hash;
line += "/";
{
std::ostringstream out;
out << details.count;
line += out.str();
line += "/";
}
if (RemoteMode)
{
line += "Remote";
}
else
{
line += "Local";
}
line += "/\n";
text += line;
}
std::cerr << "Created MimeData:";
std::cerr << std::endl;
std::cerr << text;
std::cerr << std::endl;
QMimeData *data = new QMimeData();
data->setData("application/x-rsfilelist", QByteArray(text.c_str()));
return data;
}
QStringList RemoteDirModel::mimeTypes () const
{
QStringList list;
list.push_back("application/x-rsfilelist");
return list;
}

View File

@ -11,11 +11,7 @@ class RemoteDirModel : public QAbstractItemModel
Q_OBJECT
public:
RemoteDirModel(bool mode, QObject *parent = 0)
: QAbstractItemModel(parent),
RemoteMode(mode),
nIndex(1), indexSet(1) /* ass zero index cant be used */
{}
RemoteDirModel(bool mode, QObject *parent = 0);
/* These are all overloaded Virtual Functions */
int rowCount(const QModelIndex &parent = QModelIndex()) const;
@ -53,6 +49,12 @@ class RemoteDirModel : public QAbstractItemModel
void collapsed ( const QModelIndex & index ) { update(index); }
void expanded ( const QModelIndex & index ) { update(index); }
/* Drag and Drop Functionality */
public:
virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
virtual QStringList mimeTypes () const;
private:
void update (const QModelIndex &index );

View File

@ -201,7 +201,7 @@ class DirDetails
std::string name;
std::string hash;
std::string path;
uint32_t count;
uint64_t count;
uint32_t age;
uint32_t rank;
@ -215,7 +215,7 @@ class FileDetail
std::string name;
std::string hash;
std::string path;
uint32_t size;
uint64_t size;
uint32_t age;
uint32_t rank;
};