fixed icons and buttons in forums

This commit is contained in:
csoler 2018-12-09 17:35:31 +01:00
parent a6ed2b26ec
commit 27264cea0a
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
3 changed files with 75 additions and 35 deletions

View File

@ -1216,10 +1216,19 @@ void RsGxsForumModel::recursUpdateReadStatusAndTimes(ForumModelIndex i,bool& has
QModelIndex RsGxsForumModel::getIndexOfMessage(const RsGxsMessageId& mid) const
{
// brutal search. This is not so nice, so dont call that in a loop!
// 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;
// First look into msg versions, in case the msg is a version of an existing message
for(auto it(mPostVersions.begin());it!=mPostVersions.end();++it)
for(uint32_t i=0;i<it->second.size();++i)
if(it->second[i].second == mid)
postId = it->first;
for(uint32_t i=0;i<mPosts.size();++i)
if(mPosts[i].mMsgId == mid)
if(mPosts[i].mMsgId == postId)
{
void *ref ;
convertTabEntryToRefPointer(i,ref);

View File

@ -95,6 +95,13 @@
#define ROLE_THREAD_COUNT 4
#ifdef DEBUG_FORUMS
static std::ostream& operator<<(std::ostream& o,const QModelIndex& q)
{
return o << "(" << q.row() << "," << q.column() << "," << (void*)q.internalPointer() << ")" ;
}
#endif
class DistributionItemDelegate: public QStyledItemDelegate
{
public:
@ -990,15 +997,26 @@ void GxsForumThreadWidget::changedThread(QModelIndex index)
void GxsForumThreadWidget::clickedThread(QModelIndex index)
{
#ifdef DEBUG_FORUMS
std::cerr << "Clicked on message ID " << mThreadId << ", index=" << index << std::endl;
#endif
if(mUpdating)
{
#ifdef DEBUG_FORUMS
std::cerr << " early return because mUpdating=true" << std::endl;
#endif
return;
}
if(!index.isValid())
return;
{
#ifdef DEBUG_FORUMS
std::cerr << "Clicked on message ID " << mThreadId << std::endl;
std::cerr << " early return because index is invalid" << std::endl;
#endif
return;
}
if (index.column() == RsGxsForumModel::COLUMN_THREAD_READ)
{
@ -1313,8 +1331,8 @@ void GxsForumThreadWidget::nextUnreadMessage()
while(index.isValid() && !IS_MSG_UNREAD(index.sibling(index.row(),RsGxsForumModel::COLUMN_THREAD_DATA).data(RsGxsForumModel::StatusRole).toUInt()));
ui->threadTreeWidget->setCurrentIndex(index);
ui->threadTreeWidget->scrollTo(index);
ui->threadTreeWidget->setFocus();
ui->threadTreeWidget->scrollTo(index,QAbstractItemView::PositionAtCenter);
//ui->threadTreeWidget->setFocus();
changedThread(index);
}
@ -1366,15 +1384,17 @@ void GxsForumThreadWidget::setAllMessagesReadDo(bool read, uint32_t &/*token*/)
bool GxsForumThreadWidget::navigate(const RsGxsMessageId &msgId)
{
QModelIndex index = mThreadModel->getIndexOfMessage(msgId);
QModelIndex source_index = mThreadModel->getIndexOfMessage(msgId);
if(!index.isValid())
if(!source_index.isValid())
return false;
ui->threadTreeWidget->setCurrentIndex(index);
ui->threadTreeWidget->scrollTo(index);
QModelIndex indx = mThreadProxyModel->mapFromSource(source_index);
ui->threadTreeWidget->setCurrentIndex(indx);
ui->threadTreeWidget->scrollTo(indx,QAbstractItemView::PositionAtCenter);
ui->threadTreeWidget->setFocus();
changedThread(index);
changedThread(indx);
return true;
}
@ -1720,15 +1740,15 @@ void GxsForumThreadWidget::postForumLoading()
#ifdef DEBUG_FORUMS
std::cerr << "Post forum loading..." << std::endl;
#endif
QModelIndex indx = mThreadModel->getIndexOfMessage(mThreadId);
QModelIndex source_index = mThreadModel->getIndexOfMessage(mThreadId);
if(!mThreadId.isNull() && indx.isValid())
if(!mThreadId.isNull() && source_index.isValid())
{
QModelIndex index = mThreadProxyModel->mapFromSource(indx);
QModelIndex index = mThreadProxyModel->mapFromSource(source_index);
ui->threadTreeWidget->selectionModel()->setCurrentIndex(index,QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
ui->threadTreeWidget->scrollTo(index);
ui->threadTreeWidget->scrollTo(index,QAbstractItemView::PositionAtCenter);
#ifdef DEBUG_FORUMS
std::cerr << " re-selecting index of message " << mThreadId << " to " << indx.row() << "," << indx.column() << " " << (void*)indx.internalPointer() << std::endl;
std::cerr << " re-selecting index of message " << mThreadId << " to " << source_index.row() << "," << source_index.column() << " " << (void*)source_index.internalPointer() << std::endl;
#endif
}
else

View File

@ -253,28 +253,18 @@
<property name="toolTip">
<string>Download all files</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/down.png</normaloff>:/images/down.png</iconset>
<iconset resource="../icons.qrc">
<normaloff>:/icons/global_switch_on_128.png</normaloff>:/icons/global_switch_on_128.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="13">
<widget class="QPushButton" name="nextUnreadButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Next unread</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="newmessageButton">
<property name="maximumSize">
@ -290,14 +280,14 @@
<string>Reply Message</string>
</property>
<property name="text">
<string>Reply</string>
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/mail_reply.png</normaloff>:/images/mail_reply.png</iconset>
<normaloff>:/images/replymailall24-hover.png</normaloff>:/images/replymailall24-hover.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
<enum>Qt::ToolButtonIconOnly</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
@ -460,6 +450,26 @@
</property>
</widget>
</item>
<item row="0" column="13">
<widget class="QToolButton" name="nextUnreadButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Next unread message</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="../WikiPoos/Wiki_images.qrc">
<normaloff>:/images/arrow-right.png</normaloff>:/images/arrow-right.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -540,6 +550,7 @@
</customwidgets>
<resources>
<include location="../icons.qrc"/>
<include location="../WikiPoos/Wiki_images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>