Merge pull request #218 from csoler/v0.6-ContactList

V0.6 contact list
This commit is contained in:
Cyril Soler 2015-12-23 18:07:10 -05:00
commit f30f71db8e
32 changed files with 1011 additions and 716 deletions

View file

@ -235,7 +235,7 @@ static bool trimAnonIds(std::list<RsGxsId>& lst)
RsIdentityDetails idd ;
for(std::list<RsGxsId>::iterator it = lst.begin();it!=lst.end();)
if(!rsIdentity->getIdDetails(*it,idd) || !idd.mPgpLinked)
if(!rsIdentity->getIdDetails(*it,idd) || !(idd.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED))
{
it = lst.erase(it) ;
removed= true ;
@ -269,7 +269,7 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint)
{
QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem();
ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
//ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
ChatLobbyFlags flags(item->data(COLUMN_DATA, ROLE_FLAGS).toUInt());
bool removed = false ;
@ -725,7 +725,7 @@ void ChatLobbyWidget::subscribeChatLobbyAs()
return ;
RsGxsId gxs_id(action->data().toString().toStdString());
uint32_t error_code ;
//uint32_t error_code ;
if(rsMsgs->joinVisibleChatLobby(id,gxs_id))
ChatDialog::chatFriend(ChatId(id),true) ;
@ -795,7 +795,7 @@ void ChatLobbyWidget::subscribeChatLobbyAtItem(QTreeWidgetItem *item)
if(!rsIdentity->getIdDetails(gxs_id,idd))
return ;
if( (flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED) && !idd.mPgpLinked)
if( (flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED) && !(idd.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED))
{
QMessageBox::warning(NULL,tr("Default identity is anonymous"),tr("You cannot join this lobby with your default identity, since it is anonymous and the lobby forbids it.")) ;
return ;
@ -844,11 +844,13 @@ void ChatLobbyWidget::showBlankPage(ChatLobbyId id)
QString text = tr("You're not subscribed to this lobby; Double click-it to enter and chat.") ;
if(my_ids.empty())
if( (*it).lobby_flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED)
text += "\n\n"+tr("You will need to create a non anonymous identity in order to join this chat lobby.") ;
else
text += "\n\n"+tr("You will need to create an identity in order to join chat lobbies.") ;
if(my_ids.empty())
{
if( (*it).lobby_flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED)
text += "\n\n"+tr("You will need to create a non anonymous identity in order to join this chat lobby.") ;
else
text += "\n\n"+tr("You will need to create an identity in order to join chat lobbies.") ;
}
ui.lobbyInfoLabel->setText(text);
return ;

View file

@ -81,6 +81,13 @@ IdDialog::IdDialog(QWidget *parent) :
ui->setupUi(this);
mIdQueue = NULL;
allItem = new QTreeWidgetItem();
allItem->setText(0, tr("All"));
contactsItem = new QTreeWidgetItem();
contactsItem->setText(0, tr("Contacts"));
/* Setup UI helper */
mStateHelper = new UIStateHelper(this);
@ -123,7 +130,6 @@ IdDialog::IdDialog(QWidget *parent) :
/* Connect signals */
connect(ui->toolButton_NewId, SIGNAL(clicked()), this, SLOT(addIdentity()));
connect(ui->todoPushButton, SIGNAL(clicked()), this, SLOT(todo()));
connect(ui->removeIdentity, SIGNAL(triggered()), this, SLOT(removeIdentity()));
connect(ui->editIdentity, SIGNAL(triggered()), this, SLOT(editIdentity()));
@ -162,8 +168,7 @@ IdDialog::IdDialog(QWidget *parent) :
QTreeWidgetItem *headerItem = ui->idTreeWidget->headerItem();
QString headerText = headerItem->text(RSID_COL_NICKNAME);
ui->filterLineEdit->addFilter(QIcon(), headerText, RSID_COL_NICKNAME, QString("%1 %2").arg(tr("Search"), headerText));
headerText = headerItem->text(RSID_COL_KEYID);
ui->filterLineEdit->addFilter(QIcon(), headerItem->text(RSID_COL_KEYID), RSID_COL_KEYID, QString("%1 %2").arg(tr("Search"), headerText));
ui->filterLineEdit->addFilter(QIcon(), tr("ID"), RSID_COL_KEYID, tr("Search ID"));
/* Setup tree */
ui->idTreeWidget->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder);
@ -171,6 +176,8 @@ IdDialog::IdDialog(QWidget *parent) :
ui->idTreeWidget->enableColumnCustomize(true);
ui->idTreeWidget->setColumnCustomizable(RSID_COL_NICKNAME, false);
ui->idTreeWidget->setColumnHidden(RSID_COL_IDTYPE, true);
ui->idTreeWidget->setColumnHidden(RSID_COL_KEYID, true);
/* Set initial column width */
int fontWidth = QFontMetricsF(ui->idTreeWidget->font()).width("W");
ui->idTreeWidget->setColumnWidth(RSID_COL_NICKNAME, 14 * fontWidth);
@ -185,12 +192,6 @@ IdDialog::IdDialog(QWidget *parent) :
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
mStateHelper->setActive(IDDIALOG_REPLIST, false);
// Hiding RepList until that part is finished.
//ui->treeWidget_RepList->setVisible(false);
#ifndef UNFINISHED
ui->todoPushButton->hide() ;
#endif
QString hlp_str = tr(
" <h1><img width=\"32\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Identities</h1> \
@ -214,9 +215,6 @@ IdDialog::IdDialog(QWidget *parent) :
// load settings
processSettings(true);
// hide reputation sice it's currently unused
//ui->reputationGroupBox->hide();
//ui->tweakGroupBox->hide();
}
IdDialog::~IdDialog()
@ -228,14 +226,6 @@ IdDialog::~IdDialog()
delete(mIdQueue);
}
void IdDialog::todo()
{
QMessageBox::information(this, "Todo",
"<b>Open points:</b><ul>"
"<li>Reputation"
"</ul>");
}
void IdDialog::processSettings(bool load)
{
Settings->beginGroup("IdDialog");
@ -448,10 +438,11 @@ void IdDialog::insertIdList(uint32_t token)
mStateHelper->setLoading(IDDIALOG_IDLIST, false);
int accept = ui->filterComboBox->itemData(ui->filterComboBox->currentIndex()).toInt();
RsGxsIdGroup data;
std::vector<RsGxsIdGroup> datavector;
std::vector<RsGxsIdGroup>::iterator vit;
if (!rsIdentity->getGroupData(token, datavector))
{
#ifdef ID_DEBUG
@ -464,53 +455,69 @@ void IdDialog::insertIdList(uint32_t token)
return;
}
// turn that vector into a std::set, to avoid a linear search
std::map<RsGxsGroupId,RsGxsIdGroup> ids_set ;
for(uint32_t i=0;i<datavector.size();++i)
ids_set[datavector[i].mMeta.mGroupId] = datavector[i] ;
mStateHelper->setActive(IDDIALOG_IDLIST, true);
RsPgpId ownPgpId = rsPeers->getGPGOwnId();
/* Update existing and remove not existing items */
// Update existing and remove not existing items
// Also remove items that do not have the correct parent
QTreeWidgetItemIterator itemIterator(ui->idTreeWidget);
QTreeWidgetItem *item = NULL;
while ((item = *itemIterator) != NULL) {
while ((item = *itemIterator) != NULL)
{
++itemIterator;
std::map<RsGxsGroupId,RsGxsIdGroup>::iterator it = ids_set.find(RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString())) ;
for (vit = datavector.begin(); vit != datavector.end(); ++vit)
if(it == ids_set.end())
{
if (vit->mMeta.mGroupId == RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString()))
{
break;
}
}
if (vit == datavector.end())
{
delete(item);
} else {
if (!fillIdListItem(*vit, item, ownPgpId, accept))
{
if(item != allItem && item != contactsItem)
delete(item);
}
datavector.erase(vit);
}
continue ;
}
QTreeWidgetItem *parent_item = item->parent() ;
if( (parent_item == allItem && it->second.mIsAContact) || (parent_item == contactsItem && !it->second.mIsAContact))
{
delete item ; // do not remove from the list, so that it is added again in the correct place.
continue ;
}
if (!fillIdListItem(it->second, item, ownPgpId, accept))
delete(item);
ids_set.erase(it); // erase, so it is not considered to be a new item
}
/* Insert new items */
for (vit = datavector.begin(); vit != datavector.end(); ++vit)
for (std::map<RsGxsGroupId,RsGxsIdGroup>::const_iterator vit = ids_set.begin(); vit != ids_set.end(); ++vit)
{
data = (*vit);
data = vit->second ;
item = NULL;
if (fillIdListItem(*vit, item, ownPgpId, accept))
{
ui->idTreeWidget->addTopLevelItem(item);
}
ui->idTreeWidget->insertTopLevelItem(0, contactsItem );
ui->idTreeWidget->insertTopLevelItem(0, allItem);
if (fillIdListItem(vit->second, item, ownPgpId, accept))
if(vit->second.mIsAContact)
contactsItem->addChild(item);
else
allItem->addChild(item);
}
/* count items */
ui->label_count->setText( "(" + QString::number(ui->idTreeWidget->topLevelItemCount()) + ")" );
filterIds();
updateSelection();
}
@ -916,7 +923,8 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
rsIdentity->getOwnIds(own_identities) ;
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
if (item) {
if(item != allItem && item != contactsItem) {
uint32_t item_flags = item->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ;
if(!(item_flags & RSID_FILTER_OWNED_BY_YOU))
@ -952,7 +960,29 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
contextMnu.addAction(QIcon(":/images/mail_new.png"), tr("Send message to this person"), this, SLOT(sendMsg()));
contextMnu.addSeparator();
RsIdentityDetails details;
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
rsIdentity->getIdDetails(RsGxsId(keyId), details);
QAction *addContact = contextMnu.addAction(QIcon(), tr("Add to Contacts"), this, SLOT(addtoContacts()));
QAction *removeContact = contextMnu.addAction(QIcon(":/images/cancel.png"), tr("Remove from Contacts"), this, SLOT(removefromContacts()));
if(details.mFlags & RS_IDENTITY_FLAGS_IS_A_CONTACT)
{
addContact->setVisible(false);
removeContact->setVisible(true);
}
else
{
addContact->setVisible(true);
removeContact->setVisible(false);
}
contextMnu.addSeparator();
RsReputations::ReputationInfo info ;
std::string Id = item->text(RSID_COL_KEYID).toStdString();
rsReputations->getReputationInfo(RsGxsId(Id),info) ;
@ -974,12 +1004,13 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
}
}
contextMnu.addSeparator();
contextMnu.addAction(ui->editIdentity);
contextMnu.addAction(ui->removeIdentity);
}
contextMnu.addSeparator();
contextMnu.addAction(ui->editIdentity);
contextMnu.addAction(ui->removeIdentity);
contextMnu.addSeparator();
@ -1064,3 +1095,34 @@ void IdDialog::unbanPerson()
requestIdDetails();
requestIdList();
}
void IdDialog::addtoContacts()
{
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
if (!item)
{
return;
}
std::string Id = item->text(RSID_COL_KEYID).toStdString();
rsIdentity->setAsRegularContact(RsGxsId(Id),true);
requestIdList();
}
void IdDialog::removefromContacts()
{
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
if (!item)
{
return;
}
std::string Id = item->text(RSID_COL_KEYID).toStdString();
rsIdentity->setAsRegularContact(RsGxsId(Id),false);
requestIdList();
}

View file

@ -1,109 +1,114 @@
/*
* Retroshare Identity.
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef IDENTITYDIALOG_H
#define IDENTITYDIALOG_H
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
#include <retroshare/rsidentity.h>
#include "util/TokenQueue.h"
#define IMAGE_IDDIALOG ":/icons/friends_128.png"
namespace Ui {
class IdDialog;
}
class UIStateHelper;
class QTreeWidgetItem;
class IdDialog : public RsGxsUpdateBroadcastPage, public TokenResponse
{
Q_OBJECT
public:
IdDialog(QWidget *parent = 0);
~IdDialog();
virtual QIcon iconPixmap() const { return QIcon(IMAGE_IDDIALOG) ; } //MainPage
virtual QString pageName() const { return tr("People") ; } //MainPage
virtual QString helpText() const { return ""; } //MainPage
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
protected:
virtual void updateDisplay(bool complete);
private slots:
void filterComboBoxChanged();
void filterChanged(const QString &text);
void addIdentity();
void removeIdentity();
void editIdentity();
void chatIdentity();
void sendMsg();
void updateSelection();
void todo();
void modifyReputation();
/** Create the context popup menu and it's submenus */
void IdListCustomPopupMenu( QPoint point );
void banPerson();
void unbanPerson();
private:
void processSettings(bool load);
void requestIdDetails();
void insertIdDetails(uint32_t token);
void requestIdList();
void requestIdData(std::list<RsGxsGroupId> &ids);
bool fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept);
void insertIdList(uint32_t token);
void filterIds();
void requestRepList();
void insertRepList(uint32_t token);
void requestIdEdit(std::string &id);
void showIdEdit(uint32_t token);
private:
TokenQueue *mIdQueue;
UIStateHelper *mStateHelper;
RsGxsGroupId mId;
/* UI - Designer */
Ui::IdDialog *ui;
};
#endif
/*
* Retroshare Identity.
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef IDENTITYDIALOG_H
#define IDENTITYDIALOG_H
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
#include <retroshare/rsidentity.h>
#include "util/TokenQueue.h"
#define IMAGE_IDDIALOG ":/icons/friends_128.png"
namespace Ui {
class IdDialog;
}
class UIStateHelper;
class QTreeWidgetItem;
class IdDialog : public RsGxsUpdateBroadcastPage, public TokenResponse
{
Q_OBJECT
public:
IdDialog(QWidget *parent = 0);
~IdDialog();
virtual QIcon iconPixmap() const { return QIcon(IMAGE_IDDIALOG) ; } //MainPage
virtual QString pageName() const { return tr("People") ; } //MainPage
virtual QString helpText() const { return ""; } //MainPage
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
protected:
virtual void updateDisplay(bool complete);
private slots:
void filterComboBoxChanged();
void filterChanged(const QString &text);
void addIdentity();
void removeIdentity();
void editIdentity();
void chatIdentity();
void sendMsg();
void updateSelection();
void modifyReputation();
/** Create the context popup menu and it's submenus */
void IdListCustomPopupMenu( QPoint point );
void addtoContacts();
void removefromContacts();
void banPerson();
void unbanPerson();
private:
void processSettings(bool load);
void requestIdDetails();
void insertIdDetails(uint32_t token);
void requestIdList();
void requestIdData(std::list<RsGxsGroupId> &ids);
bool fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept);
void insertIdList(uint32_t token);
void filterIds();
void requestRepList();
void insertRepList(uint32_t token);
void requestIdEdit(std::string &id);
void showIdEdit(uint32_t token);
private:
TokenQueue *mIdQueue;
UIStateHelper *mStateHelper;
QTreeWidgetItem *contactsItem;
QTreeWidgetItem *allItem;
RsGxsGroupId mId;
/* UI - Designer */
Ui::IdDialog *ui;
};
#endif

View file

@ -111,13 +111,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="todoPushButton">
<property name="text">
<string>Todo</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="helpButton">
<property name="focusPolicy">
@ -221,6 +214,18 @@
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="indentation">
<number>24</number>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
@ -229,7 +234,7 @@
</attribute>
<column>
<property name="text">
<string>Identity name</string>
<string>Persons</string>
</property>
</column>
<column>
@ -713,7 +718,6 @@ p, li { white-space: pre-wrap; }
</customwidget>
</customwidgets>
<tabstops>
<tabstop>todoPushButton</tabstop>
<tabstop>idTreeWidget</tabstop>
<tabstop>lineEdit_Nickname</tabstop>
<tabstop>lineEdit_KeyId</tabstop>

View file

@ -1335,7 +1335,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
if(!gxs_id.isNull() && rsIdentity->getIdDetails(gxs_id,gxs_details))
{
if(gxs_details.mIsOwnId)
if(gxs_details.mFlags & RS_IDENTITY_FLAGS_IS_OWN_ID)
{
QMessageBox::warning(NULL,QString("Cannot send message to yourself"),QString("This identity is owned by you. You wouldn't want to send yourself a message right?"));
break ;

View file

@ -110,7 +110,7 @@ void CreateLobbyDialog::checkTextFields()
rsIdentity->getIdDetails(id,idd) ;
if( (!idd.mPgpKnown) && ui->pgp_signed_CB->isChecked())
if( (!(idd.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN)) && ui->pgp_signed_CB->isChecked())
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false) ;
}

View file

@ -284,6 +284,10 @@ void FriendSelectionWidget::secured_fillList()
std::set<RsGxsId> gxsIdsSelected;
if (mShowTypes & SHOW_GXS)
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected,true);
std::set<RsGxsId> gxsIdsSelected2;
if (mShowTypes & SHOW_CONTACTS)
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected2,true);
// remove old items
ui->friendList->clear();
@ -525,6 +529,7 @@ void FriendSelectionWidget::secured_fillList()
// iterate through gpg ids
for (std::vector<RsGxsGroupId>::const_iterator gxsIt = gxsIds.begin(); gxsIt != gxsIds.end(); ++gxsIt)
{
// we fill the not assigned gpg ids
if (std::find(filledIds.begin(), filledIds.end(), (*gxsIt).toStdString()) != filledIds.end())
continue;
@ -570,6 +575,61 @@ void FriendSelectionWidget::secured_fillList()
setSelected(mListModus, gxsItem, true);
}
}
if(mShowTypes & SHOW_CONTACTS)
{
// iterate through gpg ids
for (std::vector<RsGxsGroupId>::const_iterator gxsIt = gxsIds.begin(); gxsIt != gxsIds.end(); ++gxsIt)
{
// we fill the not assigned gpg ids
if (std::find(filledIds.begin(), filledIds.end(), (*gxsIt).toStdString()) != filledIds.end())
continue;
// add equal too, its no problem
filledIds.push_back((*gxsIt).toStdString());
RsIdentityDetails detail;
if (!rsIdentity->getIdDetails(RsGxsId(*gxsIt), detail))
continue; /* BAD */
QList<QIcon> icons ;
GxsIdDetails::getIcons(detail,icons,GxsIdDetails::ICON_TYPE_AVATAR) ;
QIcon identicon = icons.front() ;
if(detail.mFlags & RS_IDENTITY_FLAGS_IS_A_CONTACT)
{
// make a widget per friend
gxsItem = new RSTreeWidgetItem(mCompareRole, IDTYPE_GXS);
QString name = QString::fromUtf8(detail.mNickname.c_str());
gxsItem->setText(COLUMN_NAME, name + " ("+QString::fromStdString( (*gxsIt).toStdString() )+")");
//gxsItem->setTextColor(COLUMN_NAME, textColorOnline());
gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags());
gxsItem->setIcon(COLUMN_NAME, identicon);
gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString()));
gxsItem->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1);
gxsItem->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, 0);
//TODO: online state for gxs items
gxsItem->setData(COLUMN_NAME, ROLE_SORT_STATE, 1);
gxsItem->setData(COLUMN_NAME, ROLE_SORT_NAME, name);
if (mListModus == MODUS_CHECK)
gxsItem->setCheckState(0, Qt::Unchecked);
ui->friendList->addTopLevelItem(gxsItem);
gxsItem->setExpanded(true);
emit itemAdded(IDTYPE_GXS, QString::fromStdString(detail.mId.toStdString()), gxsItem);
if (std::find(gxsIdsSelected.begin(), gxsIdsSelected.end(), detail.mId) != gxsIdsSelected.end())
setSelected(mListModus, gxsItem, true);
}
}
}
if (groupIt != groupInfoList.end()) {
++groupIt;
} else {

View file

@ -65,7 +65,8 @@ public:
SHOW_GPG = 2,
SHOW_SSL = 4,
SHOW_NON_FRIEND_GPG = 8,
SHOW_GXS =16
SHOW_GXS =16,
SHOW_CONTACTS =32
};
Q_DECLARE_FLAGS(ShowTypes, ShowType)

View file

@ -160,9 +160,9 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail
chooser->setItemData(index, (type == GXS_ID_DETAILS_TYPE_DONE) ? TYPE_FOUND_ID : TYPE_UNKNOWN_ID, ROLE_TYPE);
chooser->setItemIcon(index, icons.empty() ? QIcon() : icons[0]);
std::cerr << "ID=" << details.mId << ", chooser->flags()=" << chooser->flags() << ", pgpLinked=" << details.mPgpLinked ;
std::cerr << "ID=" << details.mId << ", chooser->flags()=" << chooser->flags() << ", flags=" << details.mFlags ;
if((chooser->flags() & IDCHOOSER_NON_ANONYMOUS) && !(details.mPgpLinked))
if((chooser->flags() & IDCHOOSER_NON_ANONYMOUS) && !(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED))
{
std::cerr << " - disabling ID - entry = " << index << std::endl;
chooser->setEntryEnabled(index,false) ;

View file

@ -912,11 +912,11 @@ QString nickname ;
QApplication::translate("GxsIdDetails", "Identity&nbsp;Id"),
QString::fromStdString(details.mId.toStdString()));
if (details.mPgpLinked)
if (details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED)
{
comment += QString("<br/>%1:%2 ").arg(QApplication::translate("GxsIdDetails", "Authentication"), QApplication::translate("GxsIdDetails", "Signed&nbsp;by"));
if (details.mPgpKnown)
if (details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN)
{
/* look up real name */
std::string authorName = rsPeers->getGPGName(details.mPgpId);
@ -962,9 +962,9 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList<QIcon> &icon
{
// ICON Logic.
QIcon baseIcon;
if (details.mPgpLinked)
if (details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED)
{
if (details.mPgpKnown)
if (details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN)
baseIcon = QIcon(IMAGE_PGPKNOWN);
else
baseIcon = QIcon(IMAGE_PGPUNKNOWN);

View file

@ -266,10 +266,11 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
ui.respond_to_CB->setFlags(IDCHOOSER_ID_REQUIRED) ;
/* Add filter types */
ui.filterComboBox->addItem(tr("All"));
ui.filterComboBox->addItem(tr("All addresses (mixed)"));
ui.filterComboBox->addItem(tr("Friend Nodes"));
ui.filterComboBox->addItem(tr("Distant peer identities"));
ui.filterComboBox->setCurrentIndex(0);
ui.filterComboBox->addItem(tr("All people"));
ui.filterComboBox->addItem(tr("My contacts"));
ui.filterComboBox->setCurrentIndex(3);
connect(ui.comboStyle, SIGNAL(activated(int)),this, SLOT(changeFormatType(int)));
connect(ui.comboFont, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &)));
@ -2569,6 +2570,11 @@ void MessageComposer::filterComboBoxChanged(int i)
case 2: ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GXS) ;
break ;
case 3: ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_CONTACTS) ;
break ;
default: ;
}

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>925</width>
<height>747</height>
<width>1679</width>
<height>951</height>
</rect>
</property>
<property name="windowTitle">
@ -56,14 +56,14 @@
<set>QDockWidget::DockWidgetClosable</set>
</property>
<property name="windowTitle">
<string>Contacts</string>
<string>Address list:</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout_4">
<property name="margin">
<number>1</number>
</property>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QComboBox" name="filterComboBox"/>
</item>
<item>
<widget class="FriendSelectionWidget" name="friendSelectionWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
@ -100,25 +100,8 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="addToButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&gt;&gt; To</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@ -130,7 +113,20 @@
</sizepolicy>
</property>
<property name="text">
<string>&gt;&gt; Cc</string>
<string>Cc</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addToButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>To</string>
</property>
</widget>
</item>
@ -143,7 +139,7 @@
</sizepolicy>
</property>
<property name="text">
<string>&gt;&gt; Bcc</string>
<string>Bcc</string>
</property>
</widget>
</item>
@ -160,7 +156,7 @@
</sizepolicy>
</property>
<property name="text">
<string>&gt;&gt; Recommend</string>
<string>Recommend this friend</string>
</property>
</widget>
</item>
@ -168,23 +164,6 @@
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Show:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="filterComboBox"/>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
@ -1105,8 +1084,8 @@ border-image: url(:/images/closepressed.png)
<rect>
<x>0</x>
<y>0</y>
<width>925</width>
<height>21</height>
<width>1679</width>
<height>37</height>
</rect>
</property>
</widget>
@ -1238,8 +1217,6 @@ border-image: url(:/images/closepressed.png)
<tabstop>titleEdit</tabstop>
<tabstop>msgText</tabstop>
<tabstop>msgFileList</tabstop>
<tabstop>addToButton</tabstop>
<tabstop>addCcButton</tabstop>
<tabstop>addBccButton</tabstop>
<tabstop>addRecommendButton</tabstop>
<tabstop>comboSize</tabstop>

View file

@ -100,6 +100,8 @@ ChatPage::ChatPage(QWidget * parent, Qt::WindowFlags flags)
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
connect(ui.distantChatcomboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(distantChatComboBoxChanged(int)));
#if QT_VERSION < 0x040600
ui.minimumContrastLabel->hide();
ui.minimumContrast->hide();
@ -120,6 +122,8 @@ ChatPage::save(QString &/*errmsg*/)
Settings->setValue("EnableItalics", ui.checkBox_enableItalics->isChecked());
Settings->setValue("MinimumContrast", ui.minimumContrast->value());
Settings->endGroup();
// state of distant Chat combobox
Settings->setValue("DistantChat", ui.distantChatcomboBox->currentIndex());
Settings->setChatScreenFont(fontTempChat.toString());
NotifyQt::getInstance()->notifyChatFontChanged();
@ -226,6 +230,10 @@ ChatPage::load()
ui.minimumContrast->setValue(Settings->value("MinimumContrast", 4.5).toDouble());
Settings->endGroup();
// state of distant Chat combobox
int index = Settings->value("DistantChat", 0).toInt();
ui.distantChatcomboBox->setCurrentIndex(index);
fontTempChat.fromString(Settings->getChatScreenFont());
ui.sendMessageWithCtrlReturn->setChecked(Settings->getChatSendMessageWithCtrlReturn());
@ -493,3 +501,22 @@ void ChatPage::on_btSearch_FoundColor_clicked()
ui.btSearch_FoundColor->setIcon(pix);
}
}
void ChatPage::distantChatComboBoxChanged(int i)
{
switch(i)
{
case 0: ;
break ;
case 1: ;
break ;
case 2: ;
break ;
default: ;
}
}

View file

@ -1,79 +1,81 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006 - 2010 RetroShare Team
*
* 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 _CHATPAGE_H
#define _CHATPAGE_H
#include <retroshare-gui/configpage.h>
#include "ui_ChatPage.h"
class ChatPage : public ConfigPage
{
Q_OBJECT
public:
/** Default Constructor */
ChatPage(QWidget * parent = 0, Qt::WindowFlags flags = 0);
/** Default Destructor */
~ChatPage() {}
/** Saves the changes on this page */
virtual bool save(QString &errmsg);
/** Loads the settings for this page */
virtual void load();
virtual QPixmap iconPixmap() const { return QPixmap(":/images/chat_24.png") ; }
virtual QString pageName() const { return tr("Chat") ; }
virtual QString helpText() const { return ""; }
private slots:
void on_historyComboBoxVariant_currentIndexChanged(int index);
void on_privateComboBoxVariant_currentIndexChanged(int index);
void on_publicComboBoxVariant_currentIndexChanged(int index);
void on_pushButtonChangeChatFont_clicked();
void on_publicList_currentRowChanged(int currentRow);
void on_privateList_currentRowChanged(int currentRow);
void on_historyList_currentRowChanged(int currentRow);
void on_cbSearch_WithoutLimit_toggled(bool);
void on_btSearch_FoundColor_clicked();
private:
void setPreviewMessages(QString &stylePath, QString styleVariant, QTextBrowser *textBrowser);
void fillPreview(QListWidget *listWidget, QComboBox *comboBox, QTextBrowser *textBrowser);
QFont fontTempChat;
QString publicStylePath;
QString publicStyleVariant;
QString privateStylePath;
QString privateStyleVariant;
QString historyStylePath;
QString historyStyleVariant;
QRgb rgbChatSearchFoundColor;
/** Qt Designer generated object */
Ui::ChatPage ui;
};
#endif
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006 - 2010 RetroShare Team
*
* 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 _CHATPAGE_H
#define _CHATPAGE_H
#include <retroshare-gui/configpage.h>
#include "ui_ChatPage.h"
class ChatPage : public ConfigPage
{
Q_OBJECT
public:
/** Default Constructor */
ChatPage(QWidget * parent = 0, Qt::WindowFlags flags = 0);
/** Default Destructor */
~ChatPage() {}
/** Saves the changes on this page */
virtual bool save(QString &errmsg);
/** Loads the settings for this page */
virtual void load();
virtual QPixmap iconPixmap() const { return QPixmap(":/images/chat_24.png") ; }
virtual QString pageName() const { return tr("Chat") ; }
virtual QString helpText() const { return ""; }
private slots:
void on_historyComboBoxVariant_currentIndexChanged(int index);
void on_privateComboBoxVariant_currentIndexChanged(int index);
void on_publicComboBoxVariant_currentIndexChanged(int index);
void on_pushButtonChangeChatFont_clicked();
void on_publicList_currentRowChanged(int currentRow);
void on_privateList_currentRowChanged(int currentRow);
void on_historyList_currentRowChanged(int currentRow);
void on_cbSearch_WithoutLimit_toggled(bool);
void on_btSearch_FoundColor_clicked();
void distantChatComboBoxChanged(int);
private:
void setPreviewMessages(QString &stylePath, QString styleVariant, QTextBrowser *textBrowser);
void fillPreview(QListWidget *listWidget, QComboBox *comboBox, QTextBrowser *textBrowser);
QFont fontTempChat;
QString publicStylePath;
QString publicStyleVariant;
QString privateStylePath;
QString privateStyleVariant;
QString historyStylePath;
QString historyStyleVariant;
QRgb rgbChatSearchFoundColor;
/** Qt Designer generated object */
Ui::ChatPage ui;
};
#endif

View file

@ -20,8 +20,43 @@
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Distant Chat</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="2">
<widget class="QComboBox" name="distantChatcomboBox">
<item>
<property name="text">
<string>Everyone</string>
</property>
</item>
<item>
<property name="text">
<string>Contacts</string>
</property>
</item>
<item>
<property name="text">
<string>Nobody</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="distantchatlabel">
<property name="text">
<string>Accept encrypted distant chat from</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QGroupBox" name="groupBox">
@ -240,7 +275,7 @@
</item>
</layout>
</item>
<item>
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_2">

View file

@ -1,239 +1,269 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
*
* 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 "rshare.h"
#include "rsharesettings.h"
#include "retroshare/rsmsgs.h"
#include "MessagePage.h"
#include "gui/common/TagDefs.h"
#include <algorithm>
#include "NewTag.h"
MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags)
: ConfigPage(parent, flags)
{
ui.setupUi(this);
m_pTags = new MsgTagType;
connect (ui.addpushButton, SIGNAL(clicked(bool)), this, SLOT (addTag()));
connect (ui.editpushButton, SIGNAL(clicked(bool)), this, SLOT (editTag()));
connect (ui.deletepushButton, SIGNAL(clicked(bool)), this, SLOT (deleteTag()));
connect (ui.defaultTagButton, SIGNAL(clicked(bool)), this, SLOT (defaultTag()));
connect (ui.encryptedMsgs_CB, SIGNAL(toggled(bool)), this, SLOT (toggleEnableEncryptedDistantMsgs(bool)));
connect (ui.tags_listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(currentRowChangedTag(int)));
ui.editpushButton->setEnabled(false);
ui.deletepushButton->setEnabled(false);
ui.openComboBox->addItem(tr("A new tab"), RshareSettings::MSG_OPEN_TAB);
ui.openComboBox->addItem(tr("A new window"), RshareSettings::MSG_OPEN_WINDOW);
//ui.encryptedMsgs_CB->setEnabled(false) ;
}
MessagePage::~MessagePage()
{
delete(m_pTags);
}
void MessagePage::toggleEnableEncryptedDistantMsgs(bool b)
{
rsMail->enableDistantMessaging(b) ;
}
/** Saves the changes on this page */
bool
MessagePage::save(QString &/*errmsg*/)
{
Settings->setMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked());
Settings->setMsgLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked());
Settings->setMsgOpen((RshareSettings::enumMsgOpen) ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt());
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) {
// check for changed tags
std::list<uint32_t>::iterator changedTagId;
for (changedTagId = m_changedTagIds.begin(); changedTagId != m_changedTagIds.end(); ++changedTagId) {
if (*changedTagId == Tag->first) {
if (Tag->second.first.empty()) {
// delete tag
rsMail->removeMessageTagType(Tag->first);
continue;
}
rsMail->setMessageTagType(Tag->first, Tag->second.first, Tag->second.second);
break;
}
}
}
return true;
}
/** Loads the settings for this page */
void
MessagePage::load()
{
ui.setMsgToReadOnActivate->setChecked(Settings->getMsgSetToReadOnActivate());
ui.loadEmbeddedImages->setChecked(Settings->getMsgLoadEmbeddedImages());
ui.openComboBox->setCurrentIndex(ui.openComboBox->findData(Settings->getMsgOpen()));
ui.encryptedMsgs_CB->setChecked(rsMail->distantMessagingEnabled()) ;
// fill items
rsMail->getMessageTagTypes(*m_pTags);
fillTags();
}
// fill tags
void MessagePage::fillTags()
{
ui.tags_listWidget->clear();
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) {
QString text = TagDefs::name(Tag->first, Tag->second.first);
QListWidgetItem *pItemWidget = new QListWidgetItem(text, ui.tags_listWidget);
pItemWidget->setTextColor(QColor(Tag->second.second));
pItemWidget->setData(Qt::UserRole, Tag->first);
}
}
void MessagePage::addTag()
{
NewTag TagDlg(*m_pTags);
if (TagDlg.exec() == QDialog::Accepted && TagDlg.m_nId) {
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
Tag = m_pTags->types.find(TagDlg.m_nId);
if (Tag != m_pTags->types.end()) {
QString text = TagDefs::name(Tag->first, Tag->second.first);
QListWidgetItem *pItemWidget = new QListWidgetItem(text, ui.tags_listWidget);
pItemWidget->setTextColor(QColor(Tag->second.second));
pItemWidget->setData(Qt::UserRole, TagDlg.m_nId);
m_changedTagIds.push_back(TagDlg.m_nId);
}
}
}
void MessagePage::editTag()
{
QListWidgetItem *pItemWidget = ui.tags_listWidget->currentItem();
if (pItemWidget == NULL) {
return;
}
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
if (nId == 0) {
return;
}
NewTag TagDlg(*m_pTags, nId);
TagDlg.setWindowTitle(tr("Edit Tag"));
if (TagDlg.exec() == QDialog::Accepted && TagDlg.m_nId) {
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
Tag = m_pTags->types.find(TagDlg.m_nId);
if (Tag != m_pTags->types.end()) {
if (Tag->first >= RS_MSGTAGTYPE_USER) {
pItemWidget->setText(QString::fromStdString(Tag->second.first));
}
pItemWidget->setTextColor(QColor(Tag->second.second));
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), TagDlg.m_nId) == m_changedTagIds.end()) {
m_changedTagIds.push_back(TagDlg.m_nId);
}
}
}
}
void MessagePage::deleteTag()
{
QListWidgetItem *pItemWidget = ui.tags_listWidget->currentItem();
if (pItemWidget == NULL) {
return;
}
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
if (nId == 0) {
return;
}
if (nId < RS_MSGTAGTYPE_USER) {
// can't delete standard tag item
return;
}
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
Tag = m_pTags->types.find(nId);
if (Tag != m_pTags->types.end()) {
// erase the text for later delete
Tag->second.first.erase();
}
ui.tags_listWidget->removeItemWidget(pItemWidget);
delete (pItemWidget);
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), nId) == m_changedTagIds.end()) {
m_changedTagIds.push_back(nId);
}
}
void MessagePage::defaultTag()
{
rsMail->resetMessageStandardTagTypes(*m_pTags);
// add all standard items to changed list
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) {
if (Tag->first < RS_MSGTAGTYPE_USER) {
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), Tag->first) == m_changedTagIds.end()) {
m_changedTagIds.push_back(Tag->first);
}
}
}
fillTags();
}
void MessagePage::currentRowChangedTag(int row)
{
QListWidgetItem *pItemWidget = ui.tags_listWidget->item(row);
bool bEditEnable = false;
bool bDeleteEnable = false;
if (pItemWidget) {
bEditEnable = true;
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
if (nId >= RS_MSGTAGTYPE_USER) {
bDeleteEnable = true;
}
}
ui.editpushButton->setEnabled(bEditEnable);
ui.deletepushButton->setEnabled(bDeleteEnable);
}
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
*
* 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 "rshare.h"
#include "rsharesettings.h"
#include "retroshare/rsmsgs.h"
#include "MessagePage.h"
#include "gui/common/TagDefs.h"
#include <algorithm>
#include "NewTag.h"
MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags)
: ConfigPage(parent, flags)
{
ui.setupUi(this);
m_pTags = new MsgTagType;
connect (ui.addpushButton, SIGNAL(clicked(bool)), this, SLOT (addTag()));
connect (ui.editpushButton, SIGNAL(clicked(bool)), this, SLOT (editTag()));
connect (ui.deletepushButton, SIGNAL(clicked(bool)), this, SLOT (deleteTag()));
connect (ui.defaultTagButton, SIGNAL(clicked(bool)), this, SLOT (defaultTag()));
//connect (ui.encryptedMsgs_CB, SIGNAL(toggled(bool)), this, SLOT (toggleEnableEncryptedDistantMsgs(bool)));
connect (ui.tags_listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(currentRowChangedTag(int)));
ui.editpushButton->setEnabled(false);
ui.deletepushButton->setEnabled(false);
ui.openComboBox->addItem(tr("A new tab"), RshareSettings::MSG_OPEN_TAB);
ui.openComboBox->addItem(tr("A new window"), RshareSettings::MSG_OPEN_WINDOW);
connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(distantMsgsComboBoxChanged(int)));
//ui.encryptedMsgs_CB->setEnabled(false) ;
}
MessagePage::~MessagePage()
{
delete(m_pTags);
}
void MessagePage::distantMsgsComboBoxChanged(int i)
{
switch(i)
{
case 0: rsMail->setDistantMessagingPermissionFlags(RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_EVERYBODY |RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_CONTACT_LIST) ;
break ;
case 1: rsMail->setDistantMessagingPermissionFlags(RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_CONTACT_LIST) ;
break ;
case 2: rsMail->setDistantMessagingPermissionFlags(RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_NONE) ;
break ;
default: ;
}
}
/** Saves the changes on this page */
bool
MessagePage::save(QString &/*errmsg*/)
{
Settings->setMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked());
Settings->setMsgLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked());
Settings->setMsgOpen((RshareSettings::enumMsgOpen) ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt());
// state of distant Message combobox
Settings->setValue("DistantMessages", ui.comboBox->currentIndex());
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) {
// check for changed tags
std::list<uint32_t>::iterator changedTagId;
for (changedTagId = m_changedTagIds.begin(); changedTagId != m_changedTagIds.end(); ++changedTagId) {
if (*changedTagId == Tag->first) {
if (Tag->second.first.empty()) {
// delete tag
rsMail->removeMessageTagType(Tag->first);
continue;
}
rsMail->setMessageTagType(Tag->first, Tag->second.first, Tag->second.second);
break;
}
}
}
return true;
}
/** Loads the settings for this page */
void
MessagePage::load()
{
ui.setMsgToReadOnActivate->setChecked(Settings->getMsgSetToReadOnActivate());
ui.loadEmbeddedImages->setChecked(Settings->getMsgLoadEmbeddedImages());
ui.openComboBox->setCurrentIndex(ui.openComboBox->findData(Settings->getMsgOpen()));
// state of filter combobox
uint32_t flags = rsMail->getDistantMessagingPermissionFlags() ;
if(flags == (RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_CONTACT_LIST | RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_EVERYBODY))
ui.comboBox->setCurrentIndex(2);
else if(flags == RS_DISTANT_MESSAGING_CONTACT_PERMISSION_FLAG_CONTACT_LIST)
ui.comboBox->setCurrentIndex(1);
else
ui.comboBox->setCurrentIndex(0);
// fill items
rsMail->getMessageTagTypes(*m_pTags);
fillTags();
}
// fill tags
void MessagePage::fillTags()
{
ui.tags_listWidget->clear();
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) {
QString text = TagDefs::name(Tag->first, Tag->second.first);
QListWidgetItem *pItemWidget = new QListWidgetItem(text, ui.tags_listWidget);
pItemWidget->setTextColor(QColor(Tag->second.second));
pItemWidget->setData(Qt::UserRole, Tag->first);
}
}
void MessagePage::addTag()
{
NewTag TagDlg(*m_pTags);
if (TagDlg.exec() == QDialog::Accepted && TagDlg.m_nId) {
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
Tag = m_pTags->types.find(TagDlg.m_nId);
if (Tag != m_pTags->types.end()) {
QString text = TagDefs::name(Tag->first, Tag->second.first);
QListWidgetItem *pItemWidget = new QListWidgetItem(text, ui.tags_listWidget);
pItemWidget->setTextColor(QColor(Tag->second.second));
pItemWidget->setData(Qt::UserRole, TagDlg.m_nId);
m_changedTagIds.push_back(TagDlg.m_nId);
}
}
}
void MessagePage::editTag()
{
QListWidgetItem *pItemWidget = ui.tags_listWidget->currentItem();
if (pItemWidget == NULL) {
return;
}
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
if (nId == 0) {
return;
}
NewTag TagDlg(*m_pTags, nId);
TagDlg.setWindowTitle(tr("Edit Tag"));
if (TagDlg.exec() == QDialog::Accepted && TagDlg.m_nId) {
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
Tag = m_pTags->types.find(TagDlg.m_nId);
if (Tag != m_pTags->types.end()) {
if (Tag->first >= RS_MSGTAGTYPE_USER) {
pItemWidget->setText(QString::fromStdString(Tag->second.first));
}
pItemWidget->setTextColor(QColor(Tag->second.second));
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), TagDlg.m_nId) == m_changedTagIds.end()) {
m_changedTagIds.push_back(TagDlg.m_nId);
}
}
}
}
void MessagePage::deleteTag()
{
QListWidgetItem *pItemWidget = ui.tags_listWidget->currentItem();
if (pItemWidget == NULL) {
return;
}
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
if (nId == 0) {
return;
}
if (nId < RS_MSGTAGTYPE_USER) {
// can't delete standard tag item
return;
}
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
Tag = m_pTags->types.find(nId);
if (Tag != m_pTags->types.end()) {
// erase the text for later delete
Tag->second.first.erase();
}
ui.tags_listWidget->removeItemWidget(pItemWidget);
delete (pItemWidget);
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), nId) == m_changedTagIds.end()) {
m_changedTagIds.push_back(nId);
}
}
void MessagePage::defaultTag()
{
rsMail->resetMessageStandardTagTypes(*m_pTags);
// add all standard items to changed list
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
for (Tag = m_pTags->types.begin(); Tag != m_pTags->types.end(); ++Tag) {
if (Tag->first < RS_MSGTAGTYPE_USER) {
if (std::find(m_changedTagIds.begin(), m_changedTagIds.end(), Tag->first) == m_changedTagIds.end()) {
m_changedTagIds.push_back(Tag->first);
}
}
}
fillTags();
}
void MessagePage::currentRowChangedTag(int row)
{
QListWidgetItem *pItemWidget = ui.tags_listWidget->item(row);
bool bEditEnable = false;
bool bDeleteEnable = false;
if (pItemWidget) {
bEditEnable = true;
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
if (nId >= RS_MSGTAGTYPE_USER) {
bDeleteEnable = true;
}
}
ui.editpushButton->setEnabled(bEditEnable);
ui.deletepushButton->setEnabled(bDeleteEnable);
}

View file

@ -1,70 +1,71 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
*
* 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 MESSAGEPAGE_H
#define MESSAGEPAGE_H
#include <stdint.h>
#include <retroshare-gui/configpage.h>
#include "ui_MessagePage.h"
#include "gui/msgs/MessageInterface.h"
class MessagePage : public ConfigPage
{
Q_OBJECT
public:
MessagePage(QWidget * parent = 0, Qt::WindowFlags flags = 0);
~MessagePage();
/** Saves the changes on this page */
virtual bool save(QString &errmsg);
/** Loads the settings for this page */
virtual void load();
virtual QPixmap iconPixmap() const { return QPixmap(":/images/evolution.png") ; }
virtual QString pageName() const { return tr("Message") ; }
virtual QString helpText() const { return ""; }
private slots:
void addTag();
void editTag();
void deleteTag();
void defaultTag();
void currentRowChangedTag(int row);
void toggleEnableEncryptedDistantMsgs(bool) ;
private:
void fillTags();
/* Pointer for not include of rsmsgs.h */
MsgTagType *m_pTags;
std::list<uint32_t> m_changedTagIds;
Ui::MessagePage ui;
};
#endif // !MESSAGEPAGE_H
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
*
* 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 MESSAGEPAGE_H
#define MESSAGEPAGE_H
#include <stdint.h>
#include <retroshare-gui/configpage.h>
#include "ui_MessagePage.h"
#include "gui/msgs/MessageInterface.h"
class MessagePage : public ConfigPage
{
Q_OBJECT
public:
MessagePage(QWidget * parent = 0, Qt::WindowFlags flags = 0);
~MessagePage();
/** Saves the changes on this page */
virtual bool save(QString &errmsg);
/** Loads the settings for this page */
virtual void load();
virtual QPixmap iconPixmap() const { return QPixmap(":/images/evolution.png") ; }
virtual QString pageName() const { return tr("Message") ; }
virtual QString helpText() const { return ""; }
private slots:
void addTag();
void editTag();
void deleteTag();
void defaultTag();
void currentRowChangedTag(int row);
void distantMsgsComboBoxChanged(int);
private:
void fillTags();
/* Pointer for not include of rsmsgs.h */
MsgTagType *m_pTags;
std::list<uint32_t> m_changedTagIds;
Ui::MessagePage ui;
};
#endif // !MESSAGEPAGE_H

View file

@ -59,21 +59,30 @@
<property name="title">
<string>Distant messages:</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&gt;The link below allows people in the network to send encrypted messages to you, using tunnels. To do that, they need your public PGP key, which they will get using the Retroshare discovery system. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="2">
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>Everyone</string>
</property>
</item>
<item>
<property name="text">
<string>Contacts</string>
</property>
</item>
<item>
<property name="text">
<string>Nobody</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QCheckBox" name="encryptedMsgs_CB">
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Accept encrypted distant messages from everyone</string>
<string>Accept encrypted distant messages from</string>
</property>
</widget>
</item>