Merge remote-tracking branch 'upstream/master' into v0.6-BugFixing_2

This commit is contained in:
csoler 2020-11-12 23:17:55 +01:00
commit f8721ad60f
53 changed files with 832 additions and 659 deletions

View file

@ -414,8 +414,8 @@
<string>Directory</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/images/folder16.png</normaloff>:/images/folder16.png</iconset>
<iconset resource="../images.qrc">
<normaloff>:/images/foldermail.png</normaloff>:/images/foldermail.png</iconset>
</property>
</item>
</widget>
@ -441,8 +441,8 @@
<string>Download selected</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/download16.png</normaloff>:/images/download16.png</iconset>
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/download.png</normaloff>:/icons/png/download.png</iconset>
</property>
</widget>
</item>

View file

@ -162,8 +162,8 @@ bool PostedDialog::getGroupData(std::list<RsGxsGenericGroupData*>& groupInfo)
// request all group infos at once
if(! rsPosted->getBoardsInfo(std::list<RsGxsGroupId>(),groups))
return false;
if(! rsPosted->getBoardsInfo(std::list<RsGxsGroupId>(),groups))
return false;
/* Save groups to fill icons and description */

View file

@ -62,6 +62,8 @@
* #define DEBUG_POSTED
***/
static const int POSTED_TABS_POSTS = 1;
/* View mode */
#define VIEW_MODE_FEEDS 1
#define VIEW_MODE_FILES 2
@ -507,7 +509,7 @@ void PostedListWidgetWithModel::showPostDetails()
{
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
QTextDocument doc;
doc.setHtml(post.mMsg.c_str());
@ -529,8 +531,8 @@ void PostedListWidgetWithModel::showPostDetails()
if(index.row()==0 && index.column()==0)
std::cerr << "here" << std::endl;
std::cerr << "showPostDetails: setting mSelectedPost to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mSelectedPost << std::endl;
mSelectedPost = post.mMeta.mMsgId;
std::cerr << "showPostDetails: setting mLastSelectedPosts[groupId()] to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mLastSelectedPosts[groupId()] << std::endl;
mLastSelectedPosts[groupId()] = post.mMeta.mMsgId;
std::list<ChannelPostFileInfo> files;
for(auto& file:post.mFiles)
@ -625,24 +627,30 @@ void PostedListWidgetWithModel::updateGroupData()
void PostedListWidgetWithModel::postPostLoad()
{
std::cerr << "Post channel load..." << std::endl;
std::cerr << "Post channel load..." << std::endl;
whileBlocking(ui->filter_LE)->setText(QString()); //Clear it before navigate, as it will update it.
if(!mSelectedPost.isNull())
{
QModelIndex index = mPostedPostsModel->getIndexOfMessage(mSelectedPost);
if (!mNavigatePendingMsgId.isNull())
navigate(mNavigatePendingMsgId);
std::cerr << "Setting current index to " << index.row() << ","<< index.column() << " for current post "
<< mSelectedPost.toStdString() << std::endl;
#ifdef TO_REMOVE
else if( (mLastSelectedPosts.count(groupId()) > 0)
&& !mLastSelectedPosts[groupId()].isNull())
{
QModelIndex index = mPostedPostsModel->getIndexOfMessage(mLastSelectedPosts[groupId()]);
std::cerr << "Setting current index to " << index.row() << ","<< index.column() << " for current post "
<< mLastSelectedPosts[groupId()].toStdString() << std::endl;
ui->postsTree->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect);
ui->postsTree->scrollTo(index);//May change if model reloaded
ui->postsTree->setFocus();
}
else
std::cerr << "No pre-selected channel post." << std::endl;
}
#endif
else
std::cerr << "No pre-selected channel post." << std::endl;
whileBlocking(ui->showLabel)->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+POSTS_CHUNK_SIZE+1)));
whileBlocking(ui->filter_LE)->setText(QString());
whileBlocking(ui->showLabel)->setText(QString::number(mPostedPostsModel->displayedStartPostIndex()+1)+" - "+QString::number(std::min(mPostedPostsModel->filteredPostsCount(),mPostedPostsModel->displayedStartPostIndex()+POSTS_CHUNK_SIZE+1)));
}
void PostedListWidgetWithModel::forceRedraw()
@ -721,7 +729,7 @@ QString PostedListWidgetWithModel::groupName(bool)
return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str());
}
void PostedListWidgetWithModel::groupNameChanged(const QString &name)
void PostedListWidgetWithModel::groupNameChanged(const QString &/*name*/)
{
}
@ -737,12 +745,12 @@ QIcon PostedListWidgetWithModel::groupIcon()
return QIcon(postedImage);
}
void PostedListWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &token)
void PostedListWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &/*token*/)
{
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags))
return;
QModelIndex src_index;
//QModelIndex src_index;
mPostedPostsModel->setAllMsgReadStatus(read);
@ -1126,20 +1134,24 @@ void PostedListWidgetWithModel::blank()
bool PostedListWidgetWithModel::navigate(const RsGxsMessageId& msgId)
{
ui->filter_LE->setText("ID:" + QString::fromStdString(msgId.toStdString()));
QModelIndex index = mPostedPostsModel->getIndexOfMessage(msgId);
if(!index.isValid())
{
std::cerr << "(EE) Cannot navigate to msg " << msgId << " in board " << mGroup.mMeta.mGroupId << ": index unknown. Setting mNavigatePendingMsgId." << std::endl;
if(!index.isValid())
{
std::cerr << "(EE) Cannot navigate to msg " << msgId << " in board " << mGroup.mMeta.mGroupId << ": index unknown. Setting mNavigatePendingMsgId." << std::endl;
mSelectedPost = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading.
return true; // we have to return true here, otherwise the caller will intepret the async loading as an error.
}
mNavigatePendingMsgId = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading.
return true; // we have to return true here, otherwise the caller will intepret the async loading as an error.
}
ui->postsTree->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect);
ui->postsTree->scrollTo(index);//May change if model reloaded
ui->postsTree->setFocus();
ui->tabWidget->setCurrentIndex(POSTED_TABS_POSTS);
mNavigatePendingMsgId.clear();
return true;
}

View file

@ -132,6 +132,9 @@ protected:
virtual void setAllMessagesReadDo(bool read, uint32_t &token) override;
private slots:
#ifdef TO_REMOVE
void showPostDetails();
#endif
void showAuthorInPeople();
void tabCloseRequested(int index);
void updateSorting(int);
@ -166,7 +169,10 @@ private:
RsPostedPostsModel *mPostedPostsModel;
PostedPostDelegate *mPostedPostsDelegate;
RsGxsMessageId mSelectedPost;
#ifdef TO_REMOVE
std::map<RsGxsGroupId,RsGxsMessageId> mLastSelectedPosts;
#endif
RsGxsMessageId mNavigatePendingMsgId;
/* UI - from Designer */
Ui::PostedListWidgetWithModel *ui;

View file

@ -260,13 +260,6 @@
</property>
</widget>
</item>
<item row="5" column="1" colspan="5">
<widget class="QLabel" name="createdinfolabel">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
@ -299,16 +292,6 @@
</property>
</widget>
</item>
<item row="6" column="1" colspan="5">
<widget class="GxsIdLabel" name="infoAdministrator">
<property name="text">
<string>unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="syncPeriodTitleLabel">
<property name="font">
@ -322,7 +305,24 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="6" column="1" colspan="2">
<widget class="QLabel" name="createdinfolabel">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="GxsIdLabel" name="infoAdministrator">
<property name="text">
<string>unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLabel" name="syncPeriodLabel">
<property name="text">
<string>unknown</string>
@ -340,7 +340,7 @@
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">

View file

@ -158,42 +158,47 @@ void RsPostedPostsModel::triggerRedraw()
void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
{
preMods();
preMods();
beginRemoveRows(QModelIndex(),0,rowCount()-1);
endRemoveRows();
endRemoveRows();
if(strings.empty())
{
mFilteredPosts.clear();
for(int i=0;i<mPosts.size();++i)
mFilteredPosts.push_back(i);
}
{
mFilteredPosts.clear();
for(int i=0;i<(int)(mPosts.size());++i)
mFilteredPosts.push_back(i);
}
else
{
mFilteredPosts.clear();
//mFilteredPosts.push_back(0);
{
mFilteredPosts.clear();
//mFilteredPosts.push_back(0);
for(int i=0;i<mPosts.size();++i)
{
bool passes_strings = true;
for(int i=0;i<static_cast<int>(mPosts.size());++i)
{
bool passes_strings = true;
for(auto& s:strings)
passes_strings = passes_strings && QString::fromStdString(mPosts[i].mMeta.mMsgName).contains(s,Qt::CaseInsensitive);
{
if (s.startsWith("ID:",Qt::CaseInsensitive))
passes_strings = passes_strings && mPosts[i].mMeta.mMsgId == RsGxsMessageId(s.right(s.length() - 3).toStdString());
else
passes_strings = passes_strings && QString::fromStdString(mPosts[i].mMeta.mMsgName).contains(s,Qt::CaseInsensitive);
}
if(passes_strings)
mFilteredPosts.push_back(i);
}
}
count = mFilteredPosts.size();
if(passes_strings)
mFilteredPosts.push_back(i);
}
}
count = mFilteredPosts.size();
mDisplayedStartIndex = 0;
mDisplayedStartIndex = 0;
mDisplayedNbPosts = std::min(count,DEFAULT_DISPLAYED_NB_POSTS) ;
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
beginInsertRows(QModelIndex(),0,rowCount()-1);
endInsertRows();
endInsertRows();
postMods();
}
@ -237,8 +242,8 @@ bool RsPostedPostsModel::getPostData(const QModelIndex& i,RsPostedPost& fmpe) co
bool RsPostedPostsModel::hasChildren(const QModelIndex &parent) const
{
if(!parent.isValid())
return true;
if(!parent.isValid())
return true;
return false; // by default, no post has children
}
@ -292,8 +297,8 @@ QModelIndex RsPostedPostsModel::index(int row, int column, const QModelIndex & p
QModelIndex RsPostedPostsModel::parent(const QModelIndex& index) const
{
if(!index.isValid())
return QModelIndex();
if(!index.isValid())
return QModelIndex();
return QModelIndex(); // there's no hierarchy here. So nothing to do!
}
@ -333,10 +338,10 @@ quintptr RsPostedPostsModel::getParentRow(quintptr ref,int& row) const
int RsPostedPostsModel::getChildrenCount(quintptr ref) const
{
uint32_t entry = 0 ;
//uint32_t entry = 0 ;
if(ref == quintptr(0))
return rowCount()-1;
if(ref == quintptr(0))
return rowCount()-1;
return 0;
}
@ -391,7 +396,7 @@ QVariant RsPostedPostsModel::data(const QModelIndex& index, int role) const
}
}
QVariant RsPostedPostsModel::sizeHintRole(int col) const
QVariant RsPostedPostsModel::sizeHintRole(int /*col*/) const
{
float factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
@ -483,8 +488,8 @@ void RsPostedPostsModel::setSortingStrategy(RsPostedPostsModel::SortingStrategy
void RsPostedPostsModel::setPostsInterval(int start,int nb_posts)
{
if(start >= mFilteredPosts.size())
return;
if(start >= (int)mFilteredPosts.size())
return;
preMods();
@ -538,8 +543,8 @@ void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector<RsPost
void RsPostedPostsModel::update_posts(const RsGxsGroupId& group_id)
{
if(group_id.isNull())
return;
if(group_id.isNull())
return;
RsThread::async([this, group_id]()
{
@ -592,7 +597,7 @@ void RsPostedPostsModel::update_posts(const RsGxsGroupId& group_id)
});
}
static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
//static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
void RsPostedPostsModel::createPostsArray(std::vector<RsPostedPost>& posts)
{
@ -761,34 +766,35 @@ void RsPostedPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status)
QModelIndex RsPostedPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) const
{
// Brutal search. This is not so nice, so dont call that in a loop! If too costly, we'll use a map.
// Brutal search. This is not so nice, so dont call that in a loop! If too costly, we'll use a map.
RsGxsMessageId postId = mid;
RsGxsMessageId postId = mid;
for(uint32_t i=mDisplayedStartIndex;i<mDisplayedStartIndex+mDisplayedNbPosts;++i)
{
for(uint32_t i=mDisplayedStartIndex;i<mDisplayedStartIndex+mDisplayedNbPosts;++i)
{
// First look into msg versions, in case the msg is a version of an existing message
#ifdef TODO
for(auto& msg_id:mPosts[mFilteredPosts[i]].mOlderVersions)
if(msg_id == postId)
{
for(auto& msg_id:mPosts[mFilteredPosts[i]].mOlderVersions)
if(msg_id == postId)
{
quintptr ref ;
convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab
return createIndex(i,0, ref);
}
}
#endif
if(mPosts[mFilteredPosts[i]].mMeta.mMsgId == postId)
{
quintptr ref ;
convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab
if( mFilteredPosts.size() > (size_t)(i)
&& mPosts[mFilteredPosts[i]].mMeta.mMsgId == postId )
{
quintptr ref ;
convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab
return createIndex(i,0, ref);
}
}
}
}
return QModelIndex();
return QModelIndex();
}

View file

@ -52,6 +52,7 @@
#include "gui/chat/ChatUserNotify.h"//For BradCast
#include "util/DateTime.h"
#include "util/imageutil.h"
#include "gui/im_history/ImHistoryBrowser.h"
#include <retroshare/rsstatus.h>
#include <retroshare/rsidentity.h>

View file

@ -27,7 +27,6 @@
#include "ChatStyle.h"
#include "gui/common/HashBox.h"
#include "gui/common/RsButtonOnText.h"
#include "gui/im_history/ImHistoryBrowser.h"
#include "gui/style/RSStyle.h"
#include <retroshare/rsmsgs.h>
@ -47,6 +46,7 @@ class QTextEdit;
class QPushButton;
class ChatWidget;
class QMenu;
class ImHistoryBrowser;
namespace Ui {
class ChatWidget;

View file

@ -171,7 +171,7 @@ private:
bool m_showOfflineNodes;
};
NewFriendList::NewFriendList(QWidget *parent) : /* RsAutoUpdatePage(5000,parent),*/ ui(new Ui::NewFriendList())
NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,parent),*/ ui(new Ui::NewFriendList())
{
ui->setupUi(this);
@ -259,7 +259,7 @@ NewFriendList::NewFriendList(QWidget *parent) : /* RsAutoUpdatePage(5000,parent)
}
void NewFriendList::handleEvent(std::shared_ptr<const RsEvent> e)
void NewFriendList::handleEvent(std::shared_ptr<const RsEvent> /*e*/)
{
// /!\ The function we're in is called from a different thread. It's very important
// to use this trick in order to avoid data races.
@ -294,7 +294,7 @@ void NewFriendList::sortColumn(int col,Qt::SortOrder so)
restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes);
}
void NewFriendList::headerContextMenuRequested(QPoint p)
void NewFriendList::headerContextMenuRequested(QPoint /*p*/)
{
QMenu displayMenu(tr("Show Items"), this);
@ -463,6 +463,7 @@ void NewFriendList::processSettings(bool load)
setColumnVisible(RsFriendListModel::COLUMN_THREAD_IP,Settings->value("showIP", isColumnVisible(RsFriendListModel::COLUMN_THREAD_IP)).toBool());
setColumnVisible(RsFriendListModel::COLUMN_THREAD_ID,Settings->value("showID", isColumnVisible(RsFriendListModel::COLUMN_THREAD_ID)).toBool());
setColumnVisible(RsFriendListModel::COLUMN_THREAD_LAST_CONTACT,Settings->value("showLastContact", isColumnVisible(RsFriendListModel::COLUMN_THREAD_LAST_CONTACT)).toBool());
ui->peerTreeWidget->header()->restoreState(Settings->value("headers").toByteArray());
// sort
toggleSortByState(Settings->value("sortByState", mProxyModel->sortByState()).toBool());
@ -488,6 +489,7 @@ void NewFriendList::processSettings(bool load)
Settings->setValue("showIP",isColumnVisible(RsFriendListModel::COLUMN_THREAD_IP));
Settings->setValue("showID",isColumnVisible(RsFriendListModel::COLUMN_THREAD_ID));
Settings->setValue("showLastContact",isColumnVisible(RsFriendListModel::COLUMN_THREAD_LAST_CONTACT));
Settings->setValue("headers",ui->peerTreeWidget->header()->saveState());
// sort
Settings->setValue("sortByState", mProxyModel->sortByState());
@ -568,133 +570,141 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu()
//this is a SSL key
textLabel->setText("<strong>" + tr("Node") + "</strong>");
break;
default:
textLabel->setText("<strong>" + tr("UNKNOWN TYPE") + "</strong>");
}
switch (type)
{
case RsFriendListModel::ENTRY_TYPE_GROUP:
{
RsGroupInfo group_info ;
mModel->getGroupData(index,group_info);
case RsFriendListModel::ENTRY_TYPE_GROUP:
{
RsGroupInfo group_info ;
mModel->getGroupData(index,group_info);
bool standard = group_info.flag & RS_GROUP_FLAG_STANDARD;
bool standard = group_info.flag & RS_GROUP_FLAG_STANDARD;
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup()));
QAction *action = contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup()));
action->setDisabled(standard);
}
QAction *action = contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup()));
action->setDisabled(standard);
}
break;
case RsFriendListModel::ENTRY_TYPE_PROFILE:
{
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configureProfile()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removeProfile()));
RsFriendListModel::RsProfileDetails details;
mModel->getProfileData(index,details);
if(mModel->getDisplayGroups())
case RsFriendListModel::ENTRY_TYPE_PROFILE:
{
QMenu* addToGroupMenu = NULL;
QMenu* moveToGroupMenu = NULL;
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configureProfile()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removeProfile()));
std::list<RsGroupInfo> groupInfoList;
rsPeers->getGroupInfoList(groupInfoList);
RsFriendListModel::RsProfileDetails details;
mModel->getProfileData(index,details);
GroupDefs::sortByName(groupInfoList);
if(mModel->getDisplayGroups())
{
QMenu* addToGroupMenu = NULL;
QMenu* moveToGroupMenu = NULL;
RsPgpId gpgId ( details.gpg_id );
std::list<RsGroupInfo> groupInfoList;
rsPeers->getGroupInfoList(groupInfoList);
QModelIndex parent = mModel->parent(index);
GroupDefs::sortByName(groupInfoList);
bool foundGroup = false;
// add action for all groups, except the own group
for (std::list<RsGroupInfo>::iterator groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) {
if (std::find(groupIt->peerIds.begin(), groupIt->peerIds.end(), gpgId) == groupIt->peerIds.end()) {
if (parent.isValid())
{
if (addToGroupMenu == NULL)
addToGroupMenu = new QMenu(tr("Add to group"), &contextMenu);
RsPgpId gpgId ( details.gpg_id );
QAction* addToGroupAction = new QAction(GroupDefs::name(*groupIt), addToGroupMenu);
addToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
connect(addToGroupAction, SIGNAL(triggered()), this, SLOT(addToGroup()));
addToGroupMenu->addAction(addToGroupAction);
QModelIndex parent = mModel->parent(index);
bool foundGroup = false;
// add action for all groups, except the own group
for (std::list<RsGroupInfo>::iterator groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) {
if (std::find(groupIt->peerIds.begin(), groupIt->peerIds.end(), gpgId) == groupIt->peerIds.end()) {
if (parent.isValid())
{
if (addToGroupMenu == NULL)
addToGroupMenu = new QMenu(tr("Add to group"), &contextMenu);
QAction* addToGroupAction = new QAction(GroupDefs::name(*groupIt), addToGroupMenu);
addToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
connect(addToGroupAction, SIGNAL(triggered()), this, SLOT(addToGroup()));
addToGroupMenu->addAction(addToGroupAction);
}
if (moveToGroupMenu == NULL) {
moveToGroupMenu = new QMenu(tr("Move to group"), &contextMenu);
}
QAction* moveToGroupAction = new QAction(GroupDefs::name(*groupIt), moveToGroupMenu);
moveToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
connect(moveToGroupAction, SIGNAL(triggered()), this, SLOT(moveToGroup()));
moveToGroupMenu->addAction(moveToGroupAction);
} else {
foundGroup = true;
}
}
QMenu *groupsMenu = contextMenu.addMenu(FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP16), tr("Groups"));
groupsMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPAND), tr("Create new group"), this, SLOT(createNewGroup()));
if (addToGroupMenu || moveToGroupMenu || foundGroup) {
if (addToGroupMenu) {
groupsMenu->addMenu(addToGroupMenu);
}
if (moveToGroupMenu == NULL) {
moveToGroupMenu = new QMenu(tr("Move to group"), &contextMenu);
if (moveToGroupMenu) {
groupsMenu->addMenu(moveToGroupMenu);
}
if (foundGroup)
{
// add remove from group
if (parent.isValid() && mModel->getType(parent) == RsFriendListModel::ENTRY_TYPE_GROUP)
{
RsGroupInfo info ;
mModel->getGroupData(parent,info);
QAction *removeFromGroup = groupsMenu->addAction(tr("Remove from group ")+QString::fromUtf8(info.name.c_str()));
removeFromGroup->setData(parent.sibling(parent.row(),RsFriendListModel::COLUMN_THREAD_ID).data(Qt::DisplayRole));
connect(removeFromGroup, SIGNAL(triggered()), this, SLOT(removeFromGroup()));
}
QAction *removeFromAllGroups = groupsMenu->addAction(tr("Remove from all groups"));
removeFromAllGroups->setData("");
connect(removeFromAllGroups, SIGNAL(triggered()), this, SLOT(removeFromGroup()));
}
QAction* moveToGroupAction = new QAction(GroupDefs::name(*groupIt), moveToGroupMenu);
moveToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
connect(moveToGroupAction, SIGNAL(triggered()), this, SLOT(moveToGroup()));
moveToGroupMenu->addAction(moveToGroupAction);
} else {
foundGroup = true;
}
}
QMenu *groupsMenu = contextMenu.addMenu(FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP16), tr("Groups"));
groupsMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPAND), tr("Create new group"), this, SLOT(createNewGroup()));
if (addToGroupMenu || moveToGroupMenu || foundGroup) {
if (addToGroupMenu) {
groupsMenu->addMenu(addToGroupMenu);
}
if (moveToGroupMenu) {
groupsMenu->addMenu(moveToGroupMenu);
}
if (foundGroup)
{
// add remove from group
if (parent.isValid() && mModel->getType(parent) == RsFriendListModel::ENTRY_TYPE_GROUP)
{
RsGroupInfo info ;
mModel->getGroupData(parent,info);
QAction *removeFromGroup = groupsMenu->addAction(tr("Remove from group ")+QString::fromUtf8(info.name.c_str()));
removeFromGroup->setData(parent.sibling(parent.row(),RsFriendListModel::COLUMN_THREAD_ID).data(Qt::DisplayRole));
connect(removeFromGroup, SIGNAL(triggered()), this, SLOT(removeFromGroup()));
}
QAction *removeFromAllGroups = groupsMenu->addAction(tr("Remove from all groups"));
removeFromAllGroups->setData("");
connect(removeFromAllGroups, SIGNAL(triggered()), this, SLOT(removeFromGroup()));
}
}
}
}
break ;
case RsFriendListModel::ENTRY_TYPE_NODE:
{
case RsFriendListModel::ENTRY_TYPE_NODE:
{
#ifdef RS_DIRECT_CHAT
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT), tr("Chat"), this, SLOT(chatNode()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgNode()));
contextMenu.addSeparator();
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT), tr("Chat"), this, SLOT(chatNode()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgNode()));
contextMenu.addSeparator();
#endif // RS_DIRECT_CHAT
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configureNode()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configureNode()));
if (type == RsFriendListModel::ENTRY_TYPE_PROFILE || type == RsFriendListModel::ENTRY_TYPE_NODE)
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPORTFRIEND), tr("Recommend this node to..."), this, SLOT(recommendNode()));
if (type == RsFriendListModel::ENTRY_TYPE_PROFILE || type == RsFriendListModel::ENTRY_TYPE_NODE)
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPORTFRIEND), tr("Recommend this node to..."), this, SLOT(recommendNode()));
RsFriendListModel::RsNodeDetails details;
mModel->getNodeData(index,details);
RsFriendListModel::RsNodeDetails details;
mModel->getNodeData(index,details);
if(!rsPeers->isHiddenNode(rsPeers->getOwnId()) || rsPeers->isHiddenNode( details.id ))
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CONNECT), tr("Attempt to connect"), this, SLOT(connectNode()));
if(!rsPeers->isHiddenNode(rsPeers->getOwnId()) || rsPeers->isHiddenNode( details.id ))
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CONNECT), tr("Attempt to connect"), this, SLOT(connectNode()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate()));
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate()));
//this is a SSL key
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removeNode()));
//this is a SSL key
contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removeNode()));
}
}
break;
default:
{
contextMenu.addSection("Report it to Devs!");
}
}
}
@ -722,6 +732,7 @@ void NewFriendList::createNewGroup()
createGrpDialog.exec();
}
#ifdef NOT_USED
static QIcon createAvatar(const QPixmap &avatar, const QPixmap &overlay)
{
int avatarWidth = avatar.width();
@ -740,6 +751,7 @@ static QIcon createAvatar(const QPixmap &avatar, const QPixmap &overlay)
icon.addPixmap(pixmap);
return icon;
}
#endif
void NewFriendList::addFriend()
{
@ -755,37 +767,37 @@ void NewFriendList::addFriend()
}
void NewFriendList::msgProfile()
{
RsFriendListModel::RsNodeDetails det;
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
if(!getCurrentNode(det))
return;
MessageComposer::msgFriend(det.id);
}
void NewFriendList::msgGroup()
{
RsFriendListModel::RsNodeDetails det;
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
if(!getCurrentNode(det))
return;
MessageComposer::msgFriend(det.id);
}
void NewFriendList::msgNode()
{
RsFriendListModel::RsNodeDetails det;
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
if(!getCurrentNode(det))
return;
MessageComposer::msgFriend(det.id);
}
void NewFriendList::chatNode()
{
RsFriendListModel::RsNodeDetails det;
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
if(!getCurrentNode(det))
return;
ChatDialog::chatFriend(ChatId(det.id));
}
@ -794,10 +806,10 @@ void NewFriendList::recommendNode()
{
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
if(!getCurrentNode(det))
return;
MessageComposer::recommendFriend(std::set<RsPeerId>({ det.id }));
MessageComposer::recommendFriend(std::set<RsPeerId>({ det.id }));
}
void NewFriendList::pastePerson()
@ -808,10 +820,10 @@ void NewFriendList::pastePerson()
void NewFriendList::copyFullCertificate()
{
RsFriendListModel::RsNodeDetails det;
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
if(!getCurrentNode(det))
return;
QList<RetroShareLink> urls;
RetroShareLink link = RetroShareLink::createCertificate(det.id);
@ -935,33 +947,33 @@ void NewFriendList::removeItem()
void NewFriendList::removeNode()
{
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det) || !rsPeers)
return;
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det) || !rsPeers)
return;
if ((QMessageBox::question(this, "RetroShare", tr("Do you want to remove this node?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes)
rsPeers->removeFriendLocation(det.id);
checkInternalData(true);
checkInternalData(true);
}
void NewFriendList::removeProfile()
{
RsFriendListModel::RsProfileDetails det;
if(!getCurrentProfile(det) || !rsPeers)
return;
RsFriendListModel::RsProfileDetails det;
if(!getCurrentProfile(det) || !rsPeers)
return;
if ((QMessageBox::question(this, "RetroShare", tr("Do you want to remove this Friend?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes)
rsPeers->removeFriend(det.gpg_id);
checkInternalData(true);
checkInternalData(true);
}
void NewFriendList::connectNode()
{
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det) || !rsPeers)
return;
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det) || !rsPeers)
return;
rsPeers->connectAttempt(det.id);
ConnectProgressDialog::showProgress(det.id);
@ -972,17 +984,17 @@ void NewFriendList::configureNode()
{
RsFriendListModel::RsNodeDetails det;
if(!getCurrentNode(det))
return;
if(!getCurrentNode(det))
return;
ConfCertDialog::showIt(det.id, ConfCertDialog::PageDetails);
}
void NewFriendList::configureProfile()
{
RsFriendListModel::RsProfileDetails det;
RsFriendListModel::RsProfileDetails det;
if(!getCurrentProfile(det))
return;
if(!getCurrentProfile(det))
return;
PGPKeyDialog::showIt(det.gpg_id, PGPKeyDialog::PageDetails);
}
@ -1079,11 +1091,11 @@ void NewFriendList::removeGroup()
{
RsGroupInfo pinfo;
if(!getCurrentGroup(pinfo))
return;
if(!getCurrentGroup(pinfo))
return;
rsPeers->removeGroup(pinfo.id);
checkInternalData(true);
checkInternalData(true);
}
void NewFriendList::applyWhileKeepingTree(std::function<void()> predicate)
@ -1199,7 +1211,7 @@ bool NewFriendList::importExportFriendlistFileDialog(QString &fileName, bool imp
, tr("Select a file for exporting your friendlist to")
, tr("XML File (*.xml);;All Files (*)")
, fileName, NULL
, (QFileDialog::Options)0
, QFileDialog::Options()
);
}
if ( res && !fileName.endsWith(".xml",Qt::CaseInsensitive) )

View file

@ -18,19 +18,24 @@
* *
*******************************************************************************/
#include <iostream>
#include <QDesktopServices>
#include <QDir>
#include <QPainter>
#include <QTextDocumentFragment>
#include "RSTextBrowser.h"
#include "RSImageBlockWidget.h"
#include "gui/common/FilesDefs.h"
#include <retroshare/rsinit.h> //To get RsAccounts
#include <QDesktopServices>
#include <QDialog>
#include <QDir>
#include <QGridLayout>
#include <QMenu>
#include <QPainter>
#include <QPlainTextEdit>
#include <QTextDocumentFragment>
#include <iostream>
RSTextBrowser::RSTextBrowser(QWidget *parent) :
QTextBrowser(parent)
{
@ -291,3 +296,37 @@ QString RSTextBrowser::anchorForPosition(const QPoint &pos) const
}
return anchor;
}
QMenu *RSTextBrowser::createStandardContextMenu()
{
return createStandardContextMenu(QPoint());
}
QMenu *RSTextBrowser::createStandardContextMenu(const QPoint &position)
{
QMenu *menu = QTextBrowser::createStandardContextMenu(position);
menu->addSeparator();
QAction *a = menu->addAction(FilesDefs::getIconFromQtResourcePath("://icons/textedit/code.png"), tr("View &Source"), this, SLOT(viewSource()));
a->setEnabled(!this->document()->isEmpty());
return menu;
}
void RSTextBrowser::viewSource()
{
QString text = this->textCursor().selection().toHtml();
if (text.isEmpty())
text = this->document()->toHtml();
QDialog *dialog = new QDialog(this);
QPlainTextEdit *pte = new QPlainTextEdit(dialog);
pte->setPlainText(text);
QGridLayout *gl = new QGridLayout(dialog);
gl->addWidget(pte,0,0,1,1);
dialog->setWindowTitle(tr("Document source"));
dialog->resize(500, 400);
dialog->exec();
delete dialog;
}

View file

@ -56,6 +56,9 @@ public:
QVariant textColorQuotes() const { return highlighter->textColorQuotes();}
bool getShowImages() const { return mShowImages; }
QMenu *createStandardContextMenu();
QMenu *createStandardContextMenu(const QPoint &position);
public slots:
void showImages();
void setTextColorQuote(QColor textColorQuote) { highlighter->setTextColorQuote(textColorQuote);}
@ -64,6 +67,7 @@ public slots:
private slots:
void linkClicked(const QUrl &url);
void destroyImageBlockWidget();
void viewSource();
protected:
void paintEvent(QPaintEvent *event);

View file

@ -99,7 +99,11 @@ void GxsForumMsgItem::setup()
/* clear ui */
ui->titleLabel->setText(tr("Loading..."));
ui->titleLabel->setOpenExternalLinks(false); //To get linkActivated working
connect(ui->titleLabel, SIGNAL(linkActivated(QString)), this, SLOT(on_linkActivated(QString)));
ui->subjectLabel->clear();
ui->subjectLabel->setOpenExternalLinks(false); //To get linkActivated working
connect(ui->subjectLabel, SIGNAL(linkActivated(QString)), this, SLOT(on_linkActivated(QString)));
ui->timestamplabel->clear();
ui->parentNameLabel->clear();
ui->nameLabel->clear();
@ -506,3 +510,16 @@ void GxsForumMsgItem::setAsRead()
setReadStatus(false, false);
}
void GxsForumMsgItem::on_linkActivated(QString link)
{
RetroShareLink rsLink(link);
if (rsLink.valid() ) {
QList<RetroShareLink> rsLinks;
rsLinks.append(rsLink);
RetroShareLink::process(rsLinks);
removeItem();
return;
}
}

View file

@ -46,20 +46,20 @@ public:
uint64_t uniqueIdentifier() const override { return hash_64bits("GxsForumMsgItem " + messageId().toStdString()) ; }
protected:
/* FeedItem */
virtual void doExpand(bool open);
virtual void expandFill(bool first);
virtual void doExpand(bool open) override;
virtual void expandFill(bool first) override;
/* load message data */
virtual void loadParentMessage(const RsGxsMessageId &parent_msg);
/* GxsGroupFeedItem */
virtual QString groupName();
virtual QString groupName() override;
virtual void loadGroup() override;
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; }
virtual RetroShareLink::enumType getLinkType() override { return RetroShareLink::TYPE_FORUM; }
//virtual bool isLoading();
/* GxsFeedItem */
virtual QString messageName();
virtual QString messageName() override;
virtual void loadMessage() override;
virtual void loadComment() override { return; }
@ -70,6 +70,8 @@ private slots:
void unsubscribeForum();
void on_linkActivated(QString link);
signals:
void vote(const RsGxsGrpMsgIdPair& msgId, bool up);

View file

@ -555,6 +555,9 @@
<property name="text">
<string notr="true">Current Message..</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
@ -577,17 +580,17 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GxsIdLabel</class>
<extends>QLabel</extends>
<header>gui/gxs/GxsIdLabel.h</header>
</customwidget>
<customwidget>
<class>AvatarWidget</class>
<extends>QLabel</extends>
<header>gui/common/AvatarWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GxsIdLabel</class>
<extends>QLabel</extends>
<header>gui/gxs/GxsIdLabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>

View file

@ -98,6 +98,7 @@ GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *p
mStateHelper = new UIStateHelper(this);
mStateHelper->addWidget(TOKEN_TYPE_GROUP_SUMMARY, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
mStateHelper->setLoading(TOKEN_TYPE_GROUP_SUMMARY, true);
connect(ui->groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupTreeCustomPopupMenu(QPoint)));
connect(ui->groupTreeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(changedCurrentGroup(QString)));

View file

@ -166,7 +166,7 @@ private:
virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &/*grpId*/, const RsGxsMessageId &/*msgId*/) { return NULL; }
virtual bool getDistantSearchResults(TurtleRequestId /* id */, std::map<RsGxsGroupId,RsGxsGroupSearchResults>& /* group_infos */){ return false ;}
virtual void clearDistantSearchResults(TurtleRequestId /* id */) {}
virtual RsGxsGenericGroupData *getDistantSearchResultGroupData(const RsGxsGroupId& group_id){ return nullptr ;}
virtual RsGxsGenericGroupData *getDistantSearchResultGroupData(const RsGxsGroupId& /*group_id*/){ return nullptr ;}
void initUi();

View file

@ -774,31 +774,31 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
std::cerr << "showPostDetails: current index is " << index.row() << "," << index.column() << std::endl;
#endif
QTextDocument doc;
doc.setHtml(post.mMsg.c_str());
//QTextDocument doc;
//doc.setHtml(post.mMsg.c_str());
if(post.mMeta.mPublishTs == 0)
{
ui->postDetails_TE->clear();
ui->postLogo_LB->hide();
if(post.mMeta.mPublishTs == 0)
{
ui->postDetails_TE->clear();
ui->postLogo_LB->hide();
ui->postName_LB->hide();
ui->postTime_LB->hide();
mChannelPostFilesModel->clear();
ui->details_TW->setEnabled(false);
mSelectedPost.clear();
mChannelPostFilesModel->clear();
ui->details_TW->setEnabled(false);
//mLastSelectedPosts[groupId()].clear();
return;
}
ui->details_TW->setEnabled(true);
return;
}
ui->details_TW->setEnabled(true);
ui->postLogo_LB->show();
ui->postName_LB->show();
ui->postTime_LB->show();
#ifdef DEBUG_CHANNEL_POSTS_WIDGET
std::cerr << "showPostDetails: setting mSelectedPost to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mSelectedPost << std::endl;
std::cerr << "showPostDetails: setting mLastSelectedPosts[groupId()] to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mLastSelectedPosts[groupId()] << std::endl;
#endif
mSelectedPost = post.mMeta.mMsgId;
mLastSelectedPosts[groupId()] = post.mMeta.mMsgId;
std::list<ChannelPostFileInfo> files;
for(auto& file:post.mFiles)
@ -886,7 +886,7 @@ void GxsChannelPostsWidgetWithModel::updateGroupData()
RsQThreadUtils::postToObject( [this,group]()
{
if(mGroup.mMeta.mGroupId != group.mMeta.mGroupId) // this prevents any attempt to display the wrong index. Navigate() if needed will use mSelectedPost
if(mGroup.mMeta.mGroupId != group.mMeta.mGroupId) // this prevents any attempt to display the wrong index. Navigate() if needed will use mNavigatePendingMsgId
{
#ifdef DEBUG_CHANNEL_POSTS_WIDGET
std::cerr << "Old group: " << mGroup.mMeta.mGroupId << ", new group: " << group.mMeta.mGroupId << ". Celaring selection" << std::endl;
@ -913,12 +913,16 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad()
{
std::cerr << "Post channel load..." << std::endl;
if(!mSelectedPost.isNull())
if (!mNavigatePendingMsgId.isNull())
navigate(mNavigatePendingMsgId);
else if( (mLastSelectedPosts.count(groupId()) > 0)
&& !mLastSelectedPosts[groupId()].isNull())
{
QModelIndex index = mChannelPostsModel->getIndexOfMessage(mSelectedPost);
QModelIndex index = mChannelPostsModel->getIndexOfMessage(mLastSelectedPosts[groupId()]);
std::cerr << "Setting current index to " << index.row() << ","<< index.column() << " for current post "
<< mSelectedPost.toStdString() << std::endl;
<< mLastSelectedPosts[groupId()].toStdString() << std::endl;
ui->postsTree->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect);
ui->postsTree->scrollTo(index);//May change if model reloaded
@ -1315,20 +1319,22 @@ bool GxsChannelPostsWidgetWithModel::navigate(const RsGxsMessageId& msgId)
{
QModelIndex index = mChannelPostsModel->getIndexOfMessage(msgId);
if(!index.isValid())
{
std::cerr << "(EE) Cannot navigate to msg " << msgId << " in channel " << mGroup.mMeta.mGroupId << ": index unknown. Setting mNavigatePendingMsgId." << std::endl;
if(!index.isValid())
{
std::cerr << "(EE) Cannot navigate to msg " << msgId << " in channel " << mGroup.mMeta.mGroupId << ": index unknown. Setting mNavigatePendingMsgId." << std::endl;
mSelectedPost = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading.
return true; // we have to return true here, otherwise the caller will intepret the async loading as an error.
}
mNavigatePendingMsgId = msgId; // not found. That means the forum may not be loaded yet. So we keep that post in mind, for after loading.
return true; // we have to return true here, otherwise the caller will intepret the async loading as an error.
}
ui->postsTree->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect);
ui->postsTree->scrollTo(index);//May change if model reloaded
ui->postsTree->setFocus();
ui->channel_TW->setCurrentIndex(CHANNEL_TABS_POSTS);
ui->details_TW->setCurrentIndex(CHANNEL_TABS_DETAILS);
ui->channel_TW->setCurrentIndex(CHANNEL_TABS_POSTS);
ui->details_TW->setCurrentIndex(CHANNEL_TABS_DETAILS);
mNavigatePendingMsgId.clear();
return true;
}

View file

@ -190,7 +190,8 @@ private:
ChannelPostDelegate *mChannelPostsDelegate;
ChannelPostFilesDelegate *mFilesDelegate;
RsGxsMessageId mSelectedPost;
std::map<RsGxsGroupId,RsGxsMessageId> mLastSelectedPosts;
RsGxsMessageId mNavigatePendingMsgId;
/* UI - from Designer */
Ui::GxsChannelPostsWidgetWithModel *ui;

View file

@ -97,7 +97,7 @@ class DistributionItemDelegate: public QStyledItemDelegate
public:
DistributionItemDelegate() {}
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
{
if(!index.isValid())
{
@ -105,7 +105,7 @@ public:
return ;
}
QStyleOptionViewItemV4 opt = option;
QStyleOptionViewItem opt = option;
initStyleOption(&opt, index);
// disable default icon
opt.icon = QIcon();
@ -135,7 +135,7 @@ public:
painter->drawPixmap(r.topLeft() + p, pix);
}
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& /*index*/) const override
{
static auto img(FilesDefs::getPixmapFromQtResourcePath(IMAGE_WARNING_YELLOW));
@ -148,7 +148,7 @@ class ReadStatusItemDelegate: public QStyledItemDelegate
public:
ReadStatusItemDelegate() {}
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
{
if(!index.isValid())
{
@ -156,7 +156,7 @@ public:
return ;
}
QStyleOptionViewItemV4 opt = option;
QStyleOptionViewItem opt = option;
initStyleOption(&opt, index);
// disable default icon
opt.icon = QIcon();
@ -194,7 +194,7 @@ public:
painter->drawPixmap(r.topLeft() + p, pix);
}
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& /*index*/) const override
{
static auto img(FilesDefs::getPixmapFromQtResourcePath(":/images/message-state-unread.png"));
@ -1204,7 +1204,7 @@ void GxsForumThreadWidget::insertMessage()
int current_index = 0 ;
for(int i=0;i<post_versions.size();++i)
for(int i=0;i<static_cast<int>(post_versions.size());++i)
{
ui->versions_CB->insertItem(i, ((i==0)?tr("(Latest) "):tr("(Old) "))+" "+DateTime::formatLongDateTime( post_versions[i].first));
ui->versions_CB->setItemData(i,QString::fromStdString(post_versions[i].second.toStdString()));
@ -1227,8 +1227,17 @@ void GxsForumThreadWidget::insertMessage()
ui->versions_CB->blockSignals(false) ;
/* request Post */
updateMessageData(mThreadId);
/* request Post */
bool missing = index.sibling(index.row(),RsGxsForumModel::COLUMN_THREAD_DATA).data(RsGxsForumModel::MissingRole).toBool();
if (missing)
{
// Don't update data for missing message else get multiple entry.
setMessageLoadingError(tr("Missing Message:\nThis message is missing. You should receive it later."));
}
else
{
updateMessageData(mThreadId);
}
// markMsgAsRead();
}
@ -1335,7 +1344,7 @@ void GxsForumThreadWidget::previousMessage()
QModelIndex parentIndex = current_index.parent();
int index = current_index.row();
int count = mThreadModel->rowCount(parentIndex) ;
//int count = mThreadModel->rowCount(parentIndex) ;
if (index > 0)
{

View file

@ -232,7 +232,7 @@ win32-g++|win32-clang-g++ {
# Fix linking error (ld.exe: Error: export ordinal too large) due to too
# many exported symbols.
QMAKE_LFLAGS+=-Wl,--exclude-libs,ALL
!libretroshare_shared:QMAKE_LFLAGS+=-Wl,--exclude-libs,ALL
# Switch off optimization for release version
QMAKE_CXXFLAGS_RELEASE -= -O2

View file

@ -1034,9 +1034,10 @@ static void styleCreate(QDomDocument& doc
it.next();
const QStringList& classUsingIt ( it.value()) ;
bool first = true;
QString classNames = "";
foreach(QString className, classUsingIt) {
if (!className.trimmed().isEmpty()) {
style += QString(first?".":",.") + className;// + " ";
classNames += QString(first?".":",.") + className;// + " ";
first = false;
}
}
@ -1083,9 +1084,9 @@ static void styleCreate(QDomDocument& doc
}
//.S1 .S2 .S4 {font-family:'Sans';}
style += "{" + key + ":" + val + ";}";
style += classNames + "{" + key + ":" + val + ";}";
} else {
style += "{" + it.key() + ";}\n";
style += classNames + "{" + it.key() + ";}\n";
}
}