mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-15 10:54:22 -05:00
improved ForumsDialog:
- new filter for threads tree - saved layout of dialog git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2954 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4b9b15be27
commit
c2f7f7935e
@ -31,6 +31,8 @@
|
|||||||
#include "rsiface/rsmsgs.h"
|
#include "rsiface/rsmsgs.h"
|
||||||
#include "rsiface/rsforums.h"
|
#include "rsiface/rsforums.h"
|
||||||
|
|
||||||
|
#include "settings/rsettings.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -55,8 +57,50 @@
|
|||||||
#define IMAGE_NEWFORUM ":/images/new_forum16.png"
|
#define IMAGE_NEWFORUM ":/images/new_forum16.png"
|
||||||
#define IMAGE_FORUMAUTHD ":/images/konv_message2.png"
|
#define IMAGE_FORUMAUTHD ":/images/konv_message2.png"
|
||||||
|
|
||||||
|
#define VIEW_LAST_POST 0
|
||||||
|
#define VIEW_THREADED 1
|
||||||
|
#define VIEW_FLAT 2
|
||||||
|
|
||||||
|
#define COLUMN_COUNT 7
|
||||||
|
#define COLUMN_DATE 0
|
||||||
|
#define COLUMN_TITLE 1
|
||||||
|
#define COLUMN_AUTHOR 2
|
||||||
|
#define COLUMN_SIGNED 3
|
||||||
|
#define COLUMN_PARENTID 4
|
||||||
|
#define COLUMN_MSGID 5
|
||||||
|
#define COLUMN_CONTENT 6
|
||||||
|
|
||||||
|
static int FilterColumnFromComboBox(int nIndex)
|
||||||
|
{
|
||||||
|
switch (nIndex) {
|
||||||
|
case 0:
|
||||||
|
return COLUMN_DATE;
|
||||||
|
case 1:
|
||||||
|
return COLUMN_TITLE;
|
||||||
|
case 2:
|
||||||
|
return COLUMN_AUTHOR;
|
||||||
|
case 3:
|
||||||
|
return COLUMN_CONTENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return COLUMN_TITLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int FilterColumnToComboBox(int nIndex)
|
||||||
|
{
|
||||||
|
switch (nIndex) {
|
||||||
|
case COLUMN_DATE:
|
||||||
|
return 0;
|
||||||
|
case COLUMN_TITLE:
|
||||||
|
return 1;
|
||||||
|
case COLUMN_AUTHOR:
|
||||||
|
return 2;
|
||||||
|
case COLUMN_CONTENT:
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FilterColumnToComboBox(COLUMN_TITLE);
|
||||||
|
}
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
ForumsDialog::ForumsDialog(QWidget *parent)
|
ForumsDialog::ForumsDialog(QWidget *parent)
|
||||||
@ -72,18 +116,20 @@ ForumsDialog::ForumsDialog(QWidget *parent)
|
|||||||
connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(createmessage()));
|
connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(createmessage()));
|
||||||
connect(ui.newthreadButton, SIGNAL(clicked()), this, SLOT(showthread()));
|
connect(ui.newthreadButton, SIGNAL(clicked()), this, SLOT(showthread()));
|
||||||
|
|
||||||
connect( ui.forumTreeWidget, SIGNAL( currentItemChanged ( QTreeWidgetItem *, QTreeWidgetItem *) ), this,
|
connect( ui.forumTreeWidget, SIGNAL( currentItemChanged ( QTreeWidgetItem *, QTreeWidgetItem *) ), this, SLOT( changedForum( QTreeWidgetItem *, QTreeWidgetItem * ) ) );
|
||||||
SLOT( changedForum( QTreeWidgetItem *, QTreeWidgetItem * ) ) );
|
|
||||||
|
|
||||||
|
|
||||||
connect( ui.threadTreeWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( changedThread () ) );
|
connect( ui.threadTreeWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( changedThread () ) );
|
||||||
connect( ui.viewBox, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( insertThreads() ) );
|
connect( ui.viewBox, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( changedViewBox () ) );
|
||||||
connect( ui.postText, SIGNAL( anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
|
connect( ui.postText, SIGNAL( anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
|
||||||
|
|
||||||
connect(ui.expandButton, SIGNAL(clicked()), this, SLOT(togglefileview()));
|
connect(ui.expandButton, SIGNAL(clicked()), this, SLOT(togglethreadview()));
|
||||||
connect(ui.previousButton, SIGNAL(clicked()), this, SLOT(previousMessage()));
|
connect(ui.previousButton, SIGNAL(clicked()), this, SLOT(previousMessage()));
|
||||||
connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(nextMessage()));
|
connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(nextMessage()));
|
||||||
|
|
||||||
|
connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||||
|
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
||||||
|
connect(ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterColumnChanged()));
|
||||||
|
|
||||||
QTimer *timer = new QTimer(this);
|
QTimer *timer = new QTimer(this);
|
||||||
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
|
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
|
||||||
timer->start(1000);
|
timer->start(1000);
|
||||||
@ -98,8 +144,9 @@ ForumsDialog::ForumsDialog(QWidget *parent)
|
|||||||
QHeaderView * ttheader = ui.threadTreeWidget->header () ;
|
QHeaderView * ttheader = ui.threadTreeWidget->header () ;
|
||||||
ttheader->setResizeMode (0, QHeaderView::Interactive);
|
ttheader->setResizeMode (0, QHeaderView::Interactive);
|
||||||
|
|
||||||
ttheader->resizeSection ( 0, 170 );
|
ttheader->resizeSection ( COLUMN_DATE, 170 );
|
||||||
ttheader->resizeSection ( 1, 170 );
|
ttheader->resizeSection ( COLUMN_TITLE, 170 );
|
||||||
|
ttheader->hideSection (COLUMN_CONTENT);
|
||||||
|
|
||||||
|
|
||||||
m_ForumNameFont = QFont("Times", 12, QFont::Bold);
|
m_ForumNameFont = QFont("Times", 12, QFont::Bold);
|
||||||
@ -153,12 +200,62 @@ ForumsDialog::ForumsDialog(QWidget *parent)
|
|||||||
|
|
||||||
m_LastViewType = -1;
|
m_LastViewType = -1;
|
||||||
|
|
||||||
|
ui.clearButton->hide();
|
||||||
|
|
||||||
|
// load settings
|
||||||
|
processSettings(true);
|
||||||
|
|
||||||
/* Hide platform specific features */
|
/* Hide platform specific features */
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ForumsDialog::~ForumsDialog()
|
||||||
|
{
|
||||||
|
// save settings
|
||||||
|
processSettings(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ForumsDialog::processSettings(bool bLoad)
|
||||||
|
{
|
||||||
|
QHeaderView *pHeader = ui.threadTreeWidget->header () ;
|
||||||
|
|
||||||
|
RSettings settings(QString("ForumsDialog"));
|
||||||
|
|
||||||
|
if (bLoad) {
|
||||||
|
// load settings
|
||||||
|
|
||||||
|
// expandFiles
|
||||||
|
bool bValue = settings.value("expandButton", true).toBool();
|
||||||
|
ui.expandButton->setChecked(bValue);
|
||||||
|
togglethreadview_internal();
|
||||||
|
|
||||||
|
// filterColumn
|
||||||
|
int nValue = FilterColumnToComboBox(settings.value("filterColumn", true).toInt());
|
||||||
|
ui.filterColumnComboBox->setCurrentIndex(nValue);
|
||||||
|
|
||||||
|
// index of viewBox
|
||||||
|
ui.viewBox->setCurrentIndex(settings.value("viewBox", VIEW_THREADED).toInt());
|
||||||
|
|
||||||
|
// state of thread tree
|
||||||
|
pHeader->restoreState(settings.value("ThreadTree").toByteArray());
|
||||||
|
|
||||||
|
// state of splitter
|
||||||
|
ui.splitter->restoreState(settings.value("Splitter").toByteArray());
|
||||||
|
ui.threadSplitter->restoreState(settings.value("threadSplitter").toByteArray());
|
||||||
|
} else {
|
||||||
|
// save settings
|
||||||
|
|
||||||
|
// state of thread tree
|
||||||
|
settings.setValue("ThreadTree", pHeader->saveState());
|
||||||
|
|
||||||
|
// state of splitter
|
||||||
|
settings.setValue("Splitter", ui.splitter->saveState());
|
||||||
|
settings.setValue("threadSplitter", ui.threadSplitter->saveState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ForumsDialog::forumListCustomPopupMenu( QPoint point )
|
void ForumsDialog::forumListCustomPopupMenu( QPoint point )
|
||||||
{
|
{
|
||||||
QMenu contextMnu( this );
|
QMenu contextMnu( this );
|
||||||
@ -244,59 +341,26 @@ void ForumsDialog::threadListCustomPopupMenu( QPoint point )
|
|||||||
contextMnu.exec(QCursor::pos());
|
contextMnu.exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForumsDialog::togglefileview()
|
void ForumsDialog::togglethreadview()
|
||||||
{
|
{
|
||||||
/* if msg header visible -> hide by changing splitter
|
// save state of button
|
||||||
* three widgets...
|
RSettings settings(QString("ForumsDialog"));
|
||||||
*/
|
settings.setValue("expandButton", ui.expandButton->isChecked());
|
||||||
|
|
||||||
QList<int> sizeList = ui.msgSplitter->sizes();
|
togglethreadview_internal();
|
||||||
QList<int>::iterator it;
|
|
||||||
|
|
||||||
int listSize = 0;
|
|
||||||
int msgSize = 0;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for(it = sizeList.begin(); it != sizeList.end(); it++, i++)
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
listSize = (*it);
|
|
||||||
}
|
|
||||||
else if (i == 1)
|
|
||||||
{
|
|
||||||
msgSize = (*it);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int totalSize = listSize + msgSize;
|
void ForumsDialog::togglethreadview_internal()
|
||||||
|
|
||||||
bool toShrink = true;
|
|
||||||
if (msgSize < (int) totalSize / 10)
|
|
||||||
{
|
{
|
||||||
toShrink = false;
|
if (ui.expandButton->isChecked()) {
|
||||||
}
|
ui.postText->setVisible(true);
|
||||||
|
ui.expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
|
||||||
QList<int> newSizeList;
|
ui.expandButton->setToolTip("Hide");
|
||||||
if (toShrink)
|
} else {
|
||||||
{
|
ui.postText->setVisible(false);
|
||||||
newSizeList.push_back(totalSize);
|
|
||||||
newSizeList.push_back(0);
|
|
||||||
ui.expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
|
ui.expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
|
||||||
ui.expandButton->setToolTip("Expand");
|
ui.expandButton->setToolTip("Expand");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/* no change */
|
|
||||||
int nlistSize = (totalSize / 2);
|
|
||||||
int nMsgSize = (totalSize / 2);
|
|
||||||
newSizeList.push_back(nlistSize);
|
|
||||||
newSizeList.push_back(nMsgSize);
|
|
||||||
ui.expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
|
|
||||||
ui.expandButton->setToolTip("Hide");
|
|
||||||
}
|
|
||||||
|
|
||||||
ui.msgSplitter->setSizes(newSizeList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForumsDialog::checkUpdate()
|
void ForumsDialog::checkUpdate()
|
||||||
@ -614,7 +678,7 @@ void ForumsDialog::changedThread ()
|
|||||||
if ((!curr) || (!curr->isSelected())) {
|
if ((!curr) || (!curr->isSelected())) {
|
||||||
mCurrPostId = "";
|
mCurrPostId = "";
|
||||||
} else {
|
} else {
|
||||||
mCurrPostId = (curr->text(5)).toStdString();
|
mCurrPostId = (curr->text(COLUMN_MSGID)).toStdString();
|
||||||
}
|
}
|
||||||
insertPost();
|
insertPost();
|
||||||
}
|
}
|
||||||
@ -646,10 +710,6 @@ void ForumsDialog::insertThreads()
|
|||||||
ui.forumName->setText(forumItem->text(0));
|
ui.forumName->setText(forumItem->text(0));
|
||||||
std::string fId = mCurrForumId;
|
std::string fId = mCurrForumId;
|
||||||
|
|
||||||
#define VIEW_LAST_POST 0
|
|
||||||
#define VIEW_THREADED 1
|
|
||||||
#define VIEW_FLAT 2
|
|
||||||
|
|
||||||
bool flatView = false;
|
bool flatView = false;
|
||||||
bool useChildTS = false;
|
bool useChildTS = false;
|
||||||
int ViewType = ui.viewBox->currentIndex();
|
int ViewType = ui.viewBox->currentIndex();
|
||||||
@ -666,6 +726,8 @@ void ForumsDialog::insertThreads()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
|
||||||
|
|
||||||
std::list<ThreadInfoSummary> threads;
|
std::list<ThreadInfoSummary> threads;
|
||||||
std::list<ThreadInfoSummary>::iterator tit;
|
std::list<ThreadInfoSummary>::iterator tit;
|
||||||
rsForums->getForumThreadList(mCurrForumId, threads);
|
rsForums->getForumThreadList(mCurrForumId, threads);
|
||||||
@ -710,33 +772,40 @@ void ForumsDialog::insertThreads()
|
|||||||
txt += " / ";
|
txt += " / ";
|
||||||
txt += timestamp2;
|
txt += timestamp2;
|
||||||
}
|
}
|
||||||
item -> setText(0, txt);
|
item -> setText(COLUMN_DATE, txt);
|
||||||
}
|
}
|
||||||
ForumMsgInfo msginfo ;
|
ForumMsgInfo msginfo ;
|
||||||
rsForums->getForumMessage(fId,tit->msgId,msginfo) ;
|
rsForums->getForumMessage(fId,tit->msgId,msginfo) ;
|
||||||
|
|
||||||
item->setText(1, QString::fromStdWString(tit->title));
|
item->setText(COLUMN_TITLE, QString::fromStdWString(tit->title));
|
||||||
|
|
||||||
if (rsPeers->getPeerName(msginfo.srcId) !="")
|
if (rsPeers->getPeerName(msginfo.srcId) !="")
|
||||||
{
|
{
|
||||||
item->setText(2, QString::fromStdString(rsPeers->getPeerName(msginfo.srcId)));
|
item->setText(COLUMN_AUTHOR, QString::fromStdString(rsPeers->getPeerName(msginfo.srcId)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item->setText(2, tr("Anonymous"));
|
item->setText(COLUMN_AUTHOR, tr("Anonymous"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msginfo.msgflags & RS_DISTRIB_AUTHEN_REQ)
|
if (msginfo.msgflags & RS_DISTRIB_AUTHEN_REQ)
|
||||||
{
|
{
|
||||||
item->setText(3, tr("signed"));
|
item->setText(COLUMN_SIGNED, tr("signed"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item->setText(3, tr("none"));
|
item->setText(COLUMN_SIGNED, tr("none"));
|
||||||
}
|
}
|
||||||
|
|
||||||
item->setText(4, QString::fromStdString(tit->parentId));
|
if (nFilterColumn == COLUMN_CONTENT) {
|
||||||
item->setText(5, QString::fromStdString(tit->msgId));
|
// need content for filter
|
||||||
|
QTextDocument doc;
|
||||||
|
doc.setHtml(QString::fromStdWString(msginfo.msg));
|
||||||
|
item->setText(COLUMN_CONTENT, doc.toPlainText().replace(QString("\n"), QString(" ")));
|
||||||
|
}
|
||||||
|
|
||||||
|
item->setText(COLUMN_PARENTID, QString::fromStdString(tit->parentId));
|
||||||
|
item->setText(COLUMN_MSGID, QString::fromStdString(tit->msgId));
|
||||||
|
|
||||||
std::list<QTreeWidgetItem *> threadlist;
|
std::list<QTreeWidgetItem *> threadlist;
|
||||||
threadlist.push_back(item);
|
threadlist.push_back(item);
|
||||||
@ -746,7 +815,7 @@ void ForumsDialog::insertThreads()
|
|||||||
/* get children */
|
/* get children */
|
||||||
QTreeWidgetItem *parent = threadlist.front();
|
QTreeWidgetItem *parent = threadlist.front();
|
||||||
threadlist.pop_front();
|
threadlist.pop_front();
|
||||||
std::string pId = (parent->text(5)).toStdString();
|
std::string pId = (parent->text(COLUMN_MSGID)).toStdString();
|
||||||
|
|
||||||
std::list<ThreadInfoSummary> msgs;
|
std::list<ThreadInfoSummary> msgs;
|
||||||
std::list<ThreadInfoSummary>::iterator mit;
|
std::list<ThreadInfoSummary>::iterator mit;
|
||||||
@ -795,33 +864,40 @@ void ForumsDialog::insertThreads()
|
|||||||
txt += " / ";
|
txt += " / ";
|
||||||
txt += timestamp2;
|
txt += timestamp2;
|
||||||
}
|
}
|
||||||
child -> setText(0, txt);
|
child -> setText(COLUMN_DATE, txt);
|
||||||
}
|
}
|
||||||
ForumMsgInfo msginfo ;
|
ForumMsgInfo msginfo ;
|
||||||
rsForums->getForumMessage(fId,mit->msgId,msginfo) ;
|
rsForums->getForumMessage(fId,mit->msgId,msginfo) ;
|
||||||
|
|
||||||
child->setText(1, QString::fromStdWString(mit->title));
|
child->setText(COLUMN_TITLE, QString::fromStdWString(mit->title));
|
||||||
|
|
||||||
if (rsPeers->getPeerName(msginfo.srcId) !="")
|
if (rsPeers->getPeerName(msginfo.srcId) !="")
|
||||||
{
|
{
|
||||||
child->setText(2, QString::fromStdString(rsPeers->getPeerName(msginfo.srcId)));
|
child->setText(COLUMN_AUTHOR, QString::fromStdString(rsPeers->getPeerName(msginfo.srcId)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
child->setText(2, tr("Anonymous"));
|
child->setText(COLUMN_AUTHOR, tr("Anonymous"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msginfo.msgflags & RS_DISTRIB_AUTHEN_REQ)
|
if (msginfo.msgflags & RS_DISTRIB_AUTHEN_REQ)
|
||||||
{
|
{
|
||||||
child->setText(3, tr("signed"));
|
child->setText(COLUMN_SIGNED, tr("signed"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
child->setText(3, tr("none"));
|
child->setText(COLUMN_SIGNED, tr("none"));
|
||||||
}
|
}
|
||||||
|
|
||||||
child->setText(4, QString::fromStdString(mit->parentId));
|
if (nFilterColumn == COLUMN_CONTENT) {
|
||||||
child->setText(5, QString::fromStdString(mit->msgId));
|
// need content for filter
|
||||||
|
QTextDocument doc;
|
||||||
|
doc.setHtml(QString::fromStdWString(msginfo.msg));
|
||||||
|
child->setText(COLUMN_CONTENT, doc.toPlainText().replace(QString("\n"), QString(" ")));
|
||||||
|
}
|
||||||
|
|
||||||
|
child->setText(COLUMN_PARENTID, QString::fromStdString(mit->parentId));
|
||||||
|
child->setText(COLUMN_MSGID, QString::fromStdString(mit->msgId));
|
||||||
|
|
||||||
/* setup child */
|
/* setup child */
|
||||||
threadlist.push_back(child);
|
threadlist.push_back(child);
|
||||||
@ -838,7 +914,6 @@ void ForumsDialog::insertThreads()
|
|||||||
items.append(item);
|
items.append(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ui.postText->clear();
|
ui.postText->clear();
|
||||||
ui.threadTitle->clear();
|
ui.threadTitle->clear();
|
||||||
/* add all messages in! */
|
/* add all messages in! */
|
||||||
@ -853,6 +928,10 @@ void ForumsDialog::insertThreads()
|
|||||||
CleanupItems (items);
|
CleanupItems (items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ui.filterPatternLineEdit->text().isEmpty() == false) {
|
||||||
|
FilterItems();
|
||||||
|
}
|
||||||
|
|
||||||
insertPost ();
|
insertPost ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -869,7 +948,7 @@ void ForumsDialog::FillThreads(QList<QTreeWidgetItem *> &ThreadList)
|
|||||||
// search existing new thread
|
// search existing new thread
|
||||||
int Found = -1;
|
int Found = -1;
|
||||||
for (NewThread = ThreadList.begin (); NewThread != ThreadList.end (); NewThread++) {
|
for (NewThread = ThreadList.begin (); NewThread != ThreadList.end (); NewThread++) {
|
||||||
if (Thread->text (5) == (*NewThread)->text (5)) {
|
if (Thread->text (COLUMN_MSGID) == (*NewThread)->text (COLUMN_MSGID)) {
|
||||||
// found it
|
// found it
|
||||||
Found = Index;
|
Found = Index;
|
||||||
break;
|
break;
|
||||||
@ -889,7 +968,7 @@ void ForumsDialog::FillThreads(QList<QTreeWidgetItem *> &ThreadList)
|
|||||||
int Count = ui.threadTreeWidget->topLevelItemCount ();
|
int Count = ui.threadTreeWidget->topLevelItemCount ();
|
||||||
for (Index = 0; Index < Count; Index++) {
|
for (Index = 0; Index < Count; Index++) {
|
||||||
Thread = ui.threadTreeWidget->topLevelItem (Index);
|
Thread = ui.threadTreeWidget->topLevelItem (Index);
|
||||||
if (Thread->text (5) == (*NewThread)->text (5)) {
|
if (Thread->text (COLUMN_MSGID) == (*NewThread)->text (COLUMN_MSGID)) {
|
||||||
// found it
|
// found it
|
||||||
Found = Index;
|
Found = Index;
|
||||||
break;
|
break;
|
||||||
@ -897,7 +976,7 @@ void ForumsDialog::FillThreads(QList<QTreeWidgetItem *> &ThreadList)
|
|||||||
}
|
}
|
||||||
if (Found >= 0) {
|
if (Found >= 0) {
|
||||||
// set child data
|
// set child data
|
||||||
for (int i = 0; i <= 5; i++) {
|
for (int i = 0; i <= COLUMN_COUNT; i++) {
|
||||||
Thread->setText (i, (*NewThread)->text (i));
|
Thread->setText (i, (*NewThread)->text (i));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -929,7 +1008,7 @@ void ForumsDialog::FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewPar
|
|||||||
int Count = NewParent->childCount();
|
int Count = NewParent->childCount();
|
||||||
for (NewIndex = 0; NewIndex < Count; NewIndex++) {
|
for (NewIndex = 0; NewIndex < Count; NewIndex++) {
|
||||||
NewChild = NewParent->child (NewIndex);
|
NewChild = NewParent->child (NewIndex);
|
||||||
if (NewChild->text (5) == Child->text (5)) {
|
if (NewChild->text (COLUMN_MSGID) == Child->text (COLUMN_MSGID)) {
|
||||||
// found it
|
// found it
|
||||||
Found = Index;
|
Found = Index;
|
||||||
break;
|
break;
|
||||||
@ -951,7 +1030,7 @@ void ForumsDialog::FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewPar
|
|||||||
int Count = Parent->childCount();
|
int Count = Parent->childCount();
|
||||||
for (Index = 0; Index < Count; Index++) {
|
for (Index = 0; Index < Count; Index++) {
|
||||||
Child = Parent->child (Index);
|
Child = Parent->child (Index);
|
||||||
if (Child->text (5) == NewChild->text (5)) {
|
if (Child->text (COLUMN_MSGID) == NewChild->text (COLUMN_MSGID)) {
|
||||||
// found it
|
// found it
|
||||||
Found = Index;
|
Found = Index;
|
||||||
break;
|
break;
|
||||||
@ -959,7 +1038,7 @@ void ForumsDialog::FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewPar
|
|||||||
}
|
}
|
||||||
if (Found >= 0) {
|
if (Found >= 0) {
|
||||||
// set child data
|
// set child data
|
||||||
for (int i = 0; i <= 5; i++) {
|
for (int i = 0; i <= COLUMN_COUNT; i++) {
|
||||||
Child->setText (i, NewChild->text (i));
|
Child->setText (i, NewChild->text (i));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -978,9 +1057,6 @@ void ForumsDialog::insertPost()
|
|||||||
{
|
{
|
||||||
if ((mCurrForumId == "") || (mCurrPostId == ""))
|
if ((mCurrForumId == "") || (mCurrPostId == ""))
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
*/
|
|
||||||
|
|
||||||
ui.postText->setText("");
|
ui.postText->setText("");
|
||||||
ui.threadTitle->setText("");
|
ui.threadTitle->setText("");
|
||||||
ui.previousButton->setEnabled(false);
|
ui.previousButton->setEnabled(false);
|
||||||
@ -1334,3 +1410,88 @@ void ForumsDialog::anchorClicked (const QUrl& link )
|
|||||||
QDesktopServices::openUrl(QUrl(newAddress));
|
QDesktopServices::openUrl(QUrl(newAddress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ForumsDialog::filterRegExpChanged()
|
||||||
|
{
|
||||||
|
// QRegExp regExp(ui.filterPatternLineEdit->text(), Qt::CaseInsensitive , QRegExp::FixedString);
|
||||||
|
// proxyModel->setFilterRegExp(regExp);
|
||||||
|
|
||||||
|
QString text = ui.filterPatternLineEdit->text();
|
||||||
|
|
||||||
|
if (text.isEmpty()) {
|
||||||
|
ui.clearButton->hide();
|
||||||
|
} else {
|
||||||
|
ui.clearButton->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
FilterItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* clear Filter */
|
||||||
|
void ForumsDialog::clearFilter()
|
||||||
|
{
|
||||||
|
ui.filterPatternLineEdit->clear();
|
||||||
|
ui.filterPatternLineEdit->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ForumsDialog::changedViewBox()
|
||||||
|
{
|
||||||
|
// save index
|
||||||
|
RSettings settings(QString("ForumsDialog"));
|
||||||
|
settings.setValue("viewBox", ui.viewBox->currentIndex());
|
||||||
|
|
||||||
|
insertThreads();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ForumsDialog::filterColumnChanged()
|
||||||
|
{
|
||||||
|
int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
|
||||||
|
if (nFilterColumn == COLUMN_CONTENT) {
|
||||||
|
// need content ... refill
|
||||||
|
insertThreads();
|
||||||
|
} else {
|
||||||
|
FilterItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
// save index
|
||||||
|
RSettings settings(QString("ForumsDialog"));
|
||||||
|
settings.setValue("filterColumn", nFilterColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ForumsDialog::FilterItems()
|
||||||
|
{
|
||||||
|
QString sPattern = ui.filterPatternLineEdit->text();
|
||||||
|
int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
|
||||||
|
|
||||||
|
int nCount = ui.threadTreeWidget->topLevelItemCount ();
|
||||||
|
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
||||||
|
FilterItem(ui.threadTreeWidget->topLevelItem(nIndex), sPattern, nFilterColumn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ForumsDialog::FilterItem(QTreeWidgetItem *pItem, QString &sPattern, int nFilterColumn)
|
||||||
|
{
|
||||||
|
bool bVisible = true;
|
||||||
|
|
||||||
|
if (sPattern.isEmpty() == false) {
|
||||||
|
if (pItem->text(nFilterColumn).contains(sPattern, Qt::CaseInsensitive) == false) {
|
||||||
|
bVisible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int nVisibleChildCount = 0;
|
||||||
|
int nCount = pItem->childCount();
|
||||||
|
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
||||||
|
if (FilterItem(pItem->child(nIndex), sPattern, nFilterColumn)) {
|
||||||
|
nVisibleChildCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bVisible || nVisibleChildCount) {
|
||||||
|
pItem->setHidden(false);
|
||||||
|
} else {
|
||||||
|
pItem->setHidden(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (bVisible || nVisibleChildCount);
|
||||||
|
}
|
||||||
|
@ -31,6 +31,7 @@ class ForumsDialog : public MainPage
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ForumsDialog(QWidget *parent = 0);
|
ForumsDialog(QWidget *parent = 0);
|
||||||
|
~ForumsDialog();
|
||||||
|
|
||||||
void insertForums();
|
void insertForums();
|
||||||
void insertPost();
|
void insertPost();
|
||||||
@ -53,7 +54,6 @@ private slots:
|
|||||||
void changedForum( QTreeWidgetItem *curr, QTreeWidgetItem *prev );
|
void changedForum( QTreeWidgetItem *curr, QTreeWidgetItem *prev );
|
||||||
void changedThread();
|
void changedThread();
|
||||||
|
|
||||||
|
|
||||||
void replytomessage();
|
void replytomessage();
|
||||||
//void print();
|
//void print();
|
||||||
//void printpreview();
|
//void printpreview();
|
||||||
@ -62,7 +62,7 @@ private slots:
|
|||||||
void markMsgAsRead();
|
void markMsgAsRead();
|
||||||
|
|
||||||
/* handle splitter */
|
/* handle splitter */
|
||||||
void togglefileview();
|
void togglethreadview();
|
||||||
|
|
||||||
void showthread();
|
void showthread();
|
||||||
void createmessage();
|
void createmessage();
|
||||||
@ -75,6 +75,12 @@ private slots:
|
|||||||
void previousMessage ();
|
void previousMessage ();
|
||||||
void nextMessage ();
|
void nextMessage ();
|
||||||
|
|
||||||
|
void changedViewBox();
|
||||||
|
|
||||||
|
void filterColumnChanged();
|
||||||
|
void filterRegExpChanged();
|
||||||
|
void clearFilter();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void forumSubscribe(bool subscribe);
|
void forumSubscribe(bool subscribe);
|
||||||
@ -83,6 +89,12 @@ private:
|
|||||||
void FillThreads(QList<QTreeWidgetItem *> &ThreadList);
|
void FillThreads(QList<QTreeWidgetItem *> &ThreadList);
|
||||||
void FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewParent);
|
void FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewParent);
|
||||||
|
|
||||||
|
void processSettings(bool bLoad);
|
||||||
|
void togglethreadview_internal();
|
||||||
|
|
||||||
|
void FilterItems();
|
||||||
|
bool FilterItem(QTreeWidgetItem *pItem, QString &sPattern, int nFilterColumn);
|
||||||
|
|
||||||
QTreeWidgetItem *YourForums;
|
QTreeWidgetItem *YourForums;
|
||||||
QTreeWidgetItem *SubscribedForums;
|
QTreeWidgetItem *SubscribedForums;
|
||||||
QTreeWidgetItem *PopularForums;
|
QTreeWidgetItem *PopularForums;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>600</width>
|
<width>732</width>
|
||||||
<height>420</height>
|
<height>420</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -792,7 +792,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QSplitter" name="msgSplitter">
|
<widget class="QSplitter" name="threadSplitter">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -866,6 +866,90 @@ background: white;}</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="filterPatternLineEdit"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="clearButton">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>MS Shell Dlg 2</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Reset</string>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QPushButton
|
||||||
|
{
|
||||||
|
border-image: url(:/images/closenormal.png)
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton:hover
|
||||||
|
{
|
||||||
|
border-image: url(:/images/closehover.png)
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton:pressed {
|
||||||
|
border-image: url(:/images/closepressed.png)
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="filterColumnComboBox">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>MS Shell Dlg 2</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Date</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Title</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Author</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Content</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="viewBox">
|
<widget class="QComboBox" name="viewBox">
|
||||||
<item>
|
<item>
|
||||||
@ -1044,6 +1128,12 @@ background: white;}</string>
|
|||||||
<iconset resource="images.qrc">
|
<iconset resource="images.qrc">
|
||||||
<normaloff>:/images/edit_remove24.png</normaloff>:/images/edit_remove24.png</iconset>
|
<normaloff>:/images/edit_remove24.png</normaloff>:/images/edit_remove24.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
Reference in New Issue
Block a user