mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
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:
parent
cf785bb8a3
commit
84da8eb074
@ -321,37 +321,14 @@ void ChannelFeed::updateChannelList()
|
||||
}
|
||||
|
||||
uint32_t i = 0;
|
||||
uint32_t popLimit = 0;
|
||||
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 (rit != popMap.rend())
|
||||
{
|
||||
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);
|
||||
}
|
||||
if(i < popCount){
|
||||
popIds.push_back(rit->second);
|
||||
i++;
|
||||
}else{
|
||||
otherIds.push_back(rit->second);
|
||||
}
|
||||
}
|
||||
|
||||
@ -606,14 +583,25 @@ void ChannelFeed::updateChannelListOther(std::list<std::string> &ids)
|
||||
QStandardItem *chNameItem = new QStandardItem();
|
||||
QStandardItem *chPopItem = new QStandardItem();
|
||||
QStandardItem *chIdItem = new QStandardItem();
|
||||
chNameItem->setSizeHint( QSize( 22,22 ) );
|
||||
|
||||
ChannelInfo ci;
|
||||
if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) {
|
||||
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"
|
||||
).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 */
|
||||
int popcount = ci.pop;
|
||||
|
||||
|
@ -22,9 +22,12 @@
|
||||
#include <QtGui>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "CreateChannel.h"
|
||||
|
||||
#include "rsiface/rschannels.h"
|
||||
#include "rsiface/rspeers.h"
|
||||
|
||||
/** Constructor */
|
||||
CreateChannel::CreateChannel(QWidget *parent)
|
||||
@ -41,6 +44,16 @@ CreateChannel::CreateChannel(QWidget *parent)
|
||||
|
||||
connect( ui.LogoButton, 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();
|
||||
|
||||
@ -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()
|
||||
{
|
||||
/* enforce Private for the moment */
|
||||
ui.typePrivate->setChecked(true);
|
||||
|
||||
ui.typePublic->setEnabled(false);
|
||||
ui.typeEncrypted->setEnabled(false);
|
||||
|
||||
ui.msgAnon->setChecked(true);
|
||||
@ -84,11 +164,7 @@ void CreateChannel::createChannel()
|
||||
}
|
||||
else
|
||||
|
||||
if (ui.typePublic->isChecked())
|
||||
{
|
||||
flags |= RS_DISTRIB_PUBLIC;
|
||||
}
|
||||
else if (ui.typePrivate->isChecked())
|
||||
if (ui.typePrivate->isChecked())
|
||||
{
|
||||
flags |= RS_DISTRIB_PRIVATE;
|
||||
}
|
||||
@ -117,14 +193,45 @@ void CreateChannel::createChannel()
|
||||
|
||||
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();
|
||||
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()
|
||||
{
|
||||
close();
|
||||
|
@ -52,6 +52,12 @@ void createChannel();
|
||||
void cancelChannel();
|
||||
|
||||
void addChannelLogo();
|
||||
void setShareList();
|
||||
void togglePersonItem(QTreeWidgetItem* item, int col);
|
||||
|
||||
private:
|
||||
|
||||
std::list<std::string> mShareList;
|
||||
|
||||
};
|
||||
|
||||
|
@ -6,10 +6,16 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>534</width>
|
||||
<height>535</height>
|
||||
<width>703</width>
|
||||
<height>611</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Create a new Channel</string>
|
||||
</property>
|
||||
@ -87,7 +93,7 @@ p, li { white-space: pre-wrap; }
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
@ -96,7 +102,7 @@ p, li { white-space: pre-wrap; }
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
@ -110,6 +116,101 @@ p, li { white-space: pre-wrap; }
|
||||
</item>
|
||||
</layout>
|
||||
</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">
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
@ -136,13 +237,6 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</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>
|
||||
<widget class="QRadioButton" name="typePrivate">
|
||||
<property name="text">
|
||||
@ -173,16 +267,16 @@ p, li { white-space: pre-wrap; }
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="msgAuth">
|
||||
<widget class="QRadioButton" name="msgAnon">
|
||||
<property name="text">
|
||||
<string>Authemticated Messages</string>
|
||||
<string>Anonymous Messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="msgAnon">
|
||||
<widget class="QRadioButton" name="msgAuth">
|
||||
<property name="text">
|
||||
<string>Anonymous Messages</string>
|
||||
<string>Authemticated Messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -202,37 +296,42 @@ p, li { white-space: pre-wrap; }
|
||||
</layout>
|
||||
</widget>
|
||||
</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">
|
||||
<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">
|
||||
<property name="title">
|
||||
<string>Channel Logo</string>
|
||||
@ -345,6 +444,36 @@ border-radius: 10px;
|
||||
</layout>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -41,7 +41,6 @@
|
||||
|
||||
#define BLOG_DEFAULT_IMAGE ":/images/hi64-app-kblogger.png"
|
||||
|
||||
|
||||
/** Constructor */
|
||||
BlogsDialog::BlogsDialog(QWidget *parent)
|
||||
: MainPage (parent)
|
||||
@ -506,6 +505,7 @@ void BlogsDialog::updateBlogMsgs()
|
||||
}
|
||||
|
||||
iconLabel->setEnabled(true);
|
||||
|
||||
|
||||
/* set textcolor for Blog name */
|
||||
QString blogStr("<span style=\"font-size:22pt; font-weight:500;"
|
||||
|
Loading…
Reference in New Issue
Block a user