mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 15:39:27 -05:00
Removed the dummy buttons & added sorting the comments treewidget via combobox
This commit is contained in:
parent
1f6589e68e
commit
b658839214
@ -49,6 +49,15 @@ GxsCommentDialog::GxsCommentDialog(QWidget *parent, RsTokenService *token_servic
|
||||
connect(ui->refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));
|
||||
connect(ui->idChooser, SIGNAL(currentIndexChanged( int )), this, SLOT(voterSelectionChanged( int )));
|
||||
connect(ui->idChooser, SIGNAL(idsLoaded()), this, SLOT(idChooserReady()));
|
||||
|
||||
connect(ui->sortBox, SIGNAL(currentIndexChanged(int)), this, SLOT(sortComments(int)));
|
||||
|
||||
// default sort method "HOT".
|
||||
ui->treeWidget->sortByColumn(4, Qt::DescendingOrder);
|
||||
|
||||
int S = QFontMetricsF(font()).height() ;
|
||||
|
||||
ui->sortBox->setIconSize(QSize(S*1.5,S*1.5));
|
||||
}
|
||||
|
||||
GxsCommentDialog::~GxsCommentDialog()
|
||||
@ -141,3 +150,22 @@ void GxsCommentDialog::setCommentHeader(QWidget *header)
|
||||
ui->notesBrowser->setPlainText(QString::fromStdString(mCurrentPost.mNotes));
|
||||
#endif
|
||||
}
|
||||
|
||||
void GxsCommentDialog::sortComments(int i)
|
||||
{
|
||||
|
||||
switch(i)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
ui->treeWidget->sortByColumn(4, Qt::DescendingOrder);
|
||||
break;
|
||||
case 1:
|
||||
ui->treeWidget->sortByColumn(2, Qt::DescendingOrder);
|
||||
break;
|
||||
case 2:
|
||||
ui->treeWidget->sortByColumn(3, Qt::DescendingOrder);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ private slots:
|
||||
void refresh();
|
||||
void idChooserReady();
|
||||
void voterSelectionChanged( int index );
|
||||
void sortComments(int);
|
||||
|
||||
private:
|
||||
RsGxsGroupId mGrpId;
|
||||
|
@ -13,8 +13,8 @@
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="GxsCommentDialogVLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="GxsCommentDialogGLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="postFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
@ -24,59 +24,63 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="postFrameVLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="toolBarHLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="hotSortButton">
|
||||
<property name="text">
|
||||
<string>Hot</string>
|
||||
<widget class="QComboBox" name="sortBox">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p><span style=" font-family:'-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol'; font-size:14px; color:#24292e; background-color:#ffffff;">sort by</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="newSortButton">
|
||||
<property name="text">
|
||||
<string>New</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="topSortButton">
|
||||
<property name="text">
|
||||
<string>Top</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Hot</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/flame.png</normaloff>:/icons/png/flame.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>New</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/new.png</normaloff>:/icons/png/new.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/top.png</normaloff>:/icons/png/top.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -111,8 +115,11 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<item row="2" column="0">
|
||||
<widget class="GxsCommentTreeWidget" name="treeWidget">
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Comment</string>
|
||||
@ -164,6 +171,8 @@
|
||||
<header>gui/gxs/GxsCommentTreeWidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../icons.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "gui/gxs/GxsCommentTreeWidget.h"
|
||||
#include "gui/gxs/GxsCreateCommentDialog.h"
|
||||
#include "gui/gxs/GxsIdTreeWidgetItem.h"
|
||||
#include "gui/common/RSTreeWidgetItem.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -45,6 +46,7 @@
|
||||
#define PCITEM_COLUMN_PARENTID 8
|
||||
#define PCITEM_COLUMN_AUTHORID 9
|
||||
|
||||
#define ROLE_SORT Qt::UserRole + 1
|
||||
|
||||
#define GXSCOMMENTS_LOADTHREAD 1
|
||||
|
||||
@ -139,6 +141,9 @@ GxsCommentTreeWidget::GxsCommentTreeWidget(QWidget *parent)
|
||||
setWordWrap(true);
|
||||
|
||||
setItemDelegateForColumn(PCITEM_COLUMN_COMMENT,new MultiLinesCommentDelegate(QFontMetricsF(font()))) ;
|
||||
|
||||
commentsRole = new RSTreeWidgetItemCompareRole;
|
||||
commentsRole->setRole(PCITEM_COLUMN_DATE, ROLE_SORT);
|
||||
|
||||
// QFont font = QFont("ARIAL", 10);
|
||||
// font.setBold(true);
|
||||
@ -537,6 +542,8 @@ void GxsCommentTreeWidget::service_loadThread(const uint32_t &token)
|
||||
text = qtime.toString("yyyy-MM-dd hh:mm:ss") ;
|
||||
item->setText(PCITEM_COLUMN_DATE, text) ;
|
||||
item->setToolTip(PCITEM_COLUMN_DATE, text) ;
|
||||
item->setData(PCITEM_COLUMN_DATE, ROLE_SORT, comment.mMeta.mPublishTs);
|
||||
|
||||
}
|
||||
|
||||
text = QString::fromUtf8(comment.mComment.c_str());
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <retroshare/rsgxscommon.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
|
||||
class RSTreeWidgetItemCompareRole;
|
||||
|
||||
class GxsCommentTreeWidget : public QTreeWidget, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -96,6 +98,8 @@ protected:
|
||||
|
||||
std::map<RsGxsMessageId, QTreeWidgetItem *> mLoadingMap;
|
||||
std::multimap<RsGxsMessageId, QTreeWidgetItem *> mPendingInsertMap;
|
||||
|
||||
RSTreeWidgetItemCompareRole *commentsRole;
|
||||
|
||||
TokenQueue *mTokenQueue;
|
||||
RsTokenService *mRsTokenService;
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>736</height>
|
||||
<height>633</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -914,4 +914,10 @@ PostedItem QToolButton#commentButton, QPushButton#shareButton, QToolButton#notes
|
||||
font-size: 12px;
|
||||
color: #878a8c;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
GxsCommentDialog QComboBox#sortBox {
|
||||
font: bold;
|
||||
font-size: 12px;
|
||||
color: #0099cc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user