added key share list to channels

fixed problem with other channels not showing except top 5

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3005 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2010-05-25 22:53:35 +00:00
parent cf785bb8a3
commit 84da8eb074
5 changed files with 313 additions and 83 deletions

View File

@ -321,37 +321,14 @@ void ChannelFeed::updateChannelList()
} }
uint32_t i = 0; uint32_t i = 0;
uint32_t popLimit = 0;
std::multimap<uint32_t, std::string>::reverse_iterator rit; std::multimap<uint32_t, std::string>::reverse_iterator rit;
for(rit = popMap.rbegin(); ((rit != popMap.rend()) && (i < popCount)); rit++, i++) for(rit = popMap.rbegin(); rit != popMap.rend(); rit++)
{ {
popIds.push_back(rit->second); if(i < popCount){
} popIds.push_back(rit->second);
i++;
if (rit != popMap.rend()) }else{
{ otherIds.push_back(rit->second);
popLimit = rit->first;
}
for(it = channelList.begin(); it != channelList.end(); it++)
{
/* ignore the ones we've done already */
uint32_t flags = it->channelFlags;
if (flags & RS_DISTRIB_ADMIN)
{
continue;
}
else if (flags & RS_DISTRIB_SUBSCRIBED)
{
continue;
}
else
{
if (it->pop < popLimit)
{
otherIds.push_back(it->channelId);
}
} }
} }
@ -606,14 +583,25 @@ void ChannelFeed::updateChannelListOther(std::list<std::string> &ids)
QStandardItem *chNameItem = new QStandardItem(); QStandardItem *chNameItem = new QStandardItem();
QStandardItem *chPopItem = new QStandardItem(); QStandardItem *chPopItem = new QStandardItem();
QStandardItem *chIdItem = new QStandardItem(); QStandardItem *chIdItem = new QStandardItem();
chNameItem->setSizeHint( QSize( 22,22 ) );
ChannelInfo ci; ChannelInfo ci;
if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) { if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) {
chNameItem->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole); chNameItem->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole);
chPopItem->setData(QVariant(QString::fromStdString(ci.channelId)), Qt::DisplayRole); chIdItem->setData(QVariant(QString::fromStdString(ci.channelId)), Qt::DisplayRole);
chNameItem->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3" chNameItem->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3"
).arg(QString::number(ci.pop)).arg(9999).arg(9999)); ).arg(QString::number(ci.pop)).arg(9999).arg(9999));
if(ci.pngImageLen != 0){
QPixmap chanImage;
chanImage.loadFromData(ci.pngChanImage, ci.pngImageLen, "PNG");
chNameItem->setData(QIcon(chanImage), Qt::DecorationRole);
}else{
QPixmap defaulImage(CHAN_DEFAULT_IMAGE);
chNameItem->setData(QIcon(defaulImage), Qt::DecorationRole);
}
/* set Popularity icon */ /* set Popularity icon */
int popcount = ci.pop; int popcount = ci.pop;

View File

@ -22,9 +22,12 @@
#include <QtGui> #include <QtGui>
#include <QMessageBox> #include <QMessageBox>
#include <algorithm>
#include "CreateChannel.h" #include "CreateChannel.h"
#include "rsiface/rschannels.h" #include "rsiface/rschannels.h"
#include "rsiface/rspeers.h"
/** Constructor */ /** Constructor */
CreateChannel::CreateChannel(QWidget *parent) CreateChannel::CreateChannel(QWidget *parent)
@ -41,6 +44,16 @@ CreateChannel::CreateChannel(QWidget *parent)
connect( ui.LogoButton, SIGNAL(clicked() ), this , SLOT(addChannelLogo())); connect( ui.LogoButton, SIGNAL(clicked() ), this , SLOT(addChannelLogo()));
connect( ui.ChannelLogoButton, SIGNAL(clicked() ), this , SLOT(addChannelLogo())); connect( ui.ChannelLogoButton, SIGNAL(clicked() ), this , SLOT(addChannelLogo()));
connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) ));
connect(ui.keyShareList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ),
this, SLOT(togglePersonItem( QTreeWidgetItem *, int ) ));
if(!ui.pubKeyShare_cb->isChecked()){
ui.contactsdockWidget->hide();
this->resize(this->size().width() - ui.contactsdockWidget->size().width(),
this->size().height());
}
newChannel(); newChannel();
@ -55,13 +68,80 @@ void CreateChannel::show()
} }
} }
void CreateChannel::setShareList(){
if(ui.pubKeyShare_cb->isChecked()){
this->resize(this->size().width() + ui.contactsdockWidget->size().width(),
this->size().height());
ui.contactsdockWidget->show();
if (!rsPeers)
{
/* not ready yet! */
return;
}
std::list<std::string> peers;
std::list<std::string>::iterator it;
rsPeers->getFriendList(peers);
/* get a link to the table */
QTreeWidget *shareWidget = ui.keyShareList;
QList<QTreeWidgetItem *> items;
for(it = peers.begin(); it != peers.end(); it++)
{
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(*it, detail))
{
continue; /* BAD */
}
/* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
item -> setText(0, QString::fromStdString(detail.name) + " - " + QString::fromStdString(detail.location));
if (detail.state & RS_PEER_STATE_CONNECTED) {
item -> setTextColor(0,(Qt::darkBlue));
}
item -> setText(1, QString::fromStdString(detail.id));
item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
item -> setCheckState(0, Qt::Unchecked);
/* add to the list */
items.append(item);
}
/* remove old items */
shareWidget->clear();
shareWidget->setColumnCount(1);
/* add the items in! */
shareWidget->insertTopLevelItems(0, items);
shareWidget->update(); /* update display */
}else{
ui.contactsdockWidget->hide();
this->resize(this->size().width() - ui.contactsdockWidget->size().width(),
this->size().height());
mShareList.clear();
}
}
void CreateChannel::newChannel() void CreateChannel::newChannel()
{ {
/* enforce Private for the moment */ /* enforce Private for the moment */
ui.typePrivate->setChecked(true); ui.typePrivate->setChecked(true);
ui.typePublic->setEnabled(false);
ui.typeEncrypted->setEnabled(false); ui.typeEncrypted->setEnabled(false);
ui.msgAnon->setChecked(true); ui.msgAnon->setChecked(true);
@ -84,11 +164,7 @@ void CreateChannel::createChannel()
} }
else else
if (ui.typePublic->isChecked()) if (ui.typePrivate->isChecked())
{
flags |= RS_DISTRIB_PUBLIC;
}
else if (ui.typePrivate->isChecked())
{ {
flags |= RS_DISTRIB_PRIVATE; flags |= RS_DISTRIB_PRIVATE;
} }
@ -117,14 +193,45 @@ void CreateChannel::createChannel()
if (rsChannels) if (rsChannels)
{ {
rsChannels->createChannel(name.toStdWString(), desc.toStdWString(), flags, (unsigned char*)ba.data(), ba.size()); std::string chId = rsChannels->createChannel(name.toStdWString(), desc.toStdWString(), flags, (unsigned char*)ba.data(), ba.size());
if(ui.pubKeyShare_cb->isChecked())
rsChannels->channelShareKeys(chId, mShareList);
} }
close(); close();
return; return;
} }
void CreateChannel::togglePersonItem( QTreeWidgetItem *item, int col )
{
/* extract id */
std::string id = (item -> text(1)).toStdString();
/* get state */
bool checked = (Qt::Checked == item -> checkState(0)); /* alway column 0 */
/* call control fns */
std::list<std::string>::iterator lit = std::find(mShareList.begin(), mShareList.end(), id);
if(checked && (lit == mShareList.end())){
// make sure ids not added already
mShareList.push_back(id);
}else
if(lit != mShareList.end()){
mShareList.erase(lit);
}
return;
}
void CreateChannel::cancelChannel() void CreateChannel::cancelChannel()
{ {
close(); close();

View File

@ -52,6 +52,12 @@ void createChannel();
void cancelChannel(); void cancelChannel();
void addChannelLogo(); void addChannelLogo();
void setShareList();
void togglePersonItem(QTreeWidgetItem* item, int col);
private:
std::list<std::string> mShareList;
}; };

View File

@ -6,10 +6,16 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>534</width> <width>703</width>
<height>535</height> <height>611</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Create a new Channel</string> <string>Create a new Channel</string>
</property> </property>
@ -87,7 +93,7 @@ p, li { white-space: pre-wrap; }
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="2" column="0">
<widget class="QFrame" name="frame"> <widget class="QFrame" name="frame">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
@ -96,7 +102,7 @@ p, li { white-space: pre-wrap; }
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QGridLayout" name="gridLayout_5"> <layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0" colspan="3"> <item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
@ -110,6 +116,101 @@ p, li { white-space: pre-wrap; }
</item> </item>
</layout> </layout>
</item> </item>
<item row="0" column="3" rowspan="7">
<widget class="QDockWidget" name="contactsdockWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>524287</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>check peers you would like to share private publish key with</string>
</property>
<property name="floating">
<bool>false</bool>
</property>
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Share Key With</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="_2">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTreeWidget" name="keyShareList">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>4</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Contacts:</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0" colspan="3"> <item row="1" column="0" colspan="3">
<layout class="QVBoxLayout"> <layout class="QVBoxLayout">
<item> <item>
@ -136,13 +237,6 @@ p, li { white-space: pre-wrap; }
<property name="margin"> <property name="margin">
<number>6</number> <number>6</number>
</property> </property>
<item>
<widget class="QRadioButton" name="typePublic">
<property name="text">
<string>Public - Anyone can read and publish (Shared Publish Key)</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QRadioButton" name="typePrivate"> <widget class="QRadioButton" name="typePrivate">
<property name="text"> <property name="text">
@ -173,16 +267,16 @@ p, li { white-space: pre-wrap; }
<number>6</number> <number>6</number>
</property> </property>
<item> <item>
<widget class="QRadioButton" name="msgAuth"> <widget class="QRadioButton" name="msgAnon">
<property name="text"> <property name="text">
<string>Authemticated Messages</string> <string>Anonymous Messages</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="msgAnon"> <widget class="QRadioButton" name="msgAuth">
<property name="text"> <property name="text">
<string>Anonymous Messages</string> <string>Authemticated Messages</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -202,37 +296,42 @@ p, li { white-space: pre-wrap; }
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="5" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>238</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QPushButton" name="createButton">
<property name="text">
<string>Create</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3"> <item row="4" column="0" colspan="3">
<widget class="QGroupBox" name="msgGroupBox_2">
<property name="title">
<string>Key Sharing</string>
</property>
<layout class="QVBoxLayout" name="_5">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="pubKeyShare_cb">
<property name="text">
<string>Share Private Publish Key</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QGroupBox" name="groupBoxLogo"> <widget class="QGroupBox" name="groupBoxLogo">
<property name="title"> <property name="title">
<string>Channel Logo</string> <string>Channel Logo</string>
@ -345,6 +444,36 @@ border-radius: 10px;
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="6" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>238</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QPushButton" name="createButton">
<property name="text">
<string>Create</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -41,7 +41,6 @@
#define BLOG_DEFAULT_IMAGE ":/images/hi64-app-kblogger.png" #define BLOG_DEFAULT_IMAGE ":/images/hi64-app-kblogger.png"
/** Constructor */ /** Constructor */
BlogsDialog::BlogsDialog(QWidget *parent) BlogsDialog::BlogsDialog(QWidget *parent)
: MainPage (parent) : MainPage (parent)
@ -506,6 +505,7 @@ void BlogsDialog::updateBlogMsgs()
} }
iconLabel->setEnabled(true); iconLabel->setEnabled(true);
/* set textcolor for Blog name */ /* set textcolor for Blog name */
QString blogStr("<span style=\"font-size:22pt; font-weight:500;" QString blogStr("<span style=\"font-size:22pt; font-weight:500;"