mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Changes in ForumsDialog:
- modal window for creating new forum - refill forum and thread tree - enabled next and previous button - set enable/disable state of menu items Open problem: - last post time not updated git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2822 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
401dac86e9
commit
9cf20fd9fd
@ -89,15 +89,14 @@ ForumsDialog::ForumsDialog(QWidget *parent)
|
|||||||
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( currentItemChanged ( QTreeWidgetItem *, QTreeWidgetItem *) ), this,
|
|
||||||
// SLOT( changedThread( QTreeWidgetItem *, QTreeWidgetItem * ) ) );
|
|
||||||
|
|
||||||
connect( ui.threadTreeWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( changedThread2() ) );
|
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( insertThreads() ) );
|
||||||
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(togglefileview()));
|
||||||
|
connect(ui.previousButton, SIGNAL(clicked()), this, SLOT(previousMessage()));
|
||||||
|
connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(nextMessage()));
|
||||||
|
|
||||||
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()));
|
||||||
@ -117,9 +116,9 @@ ForumsDialog::ForumsDialog(QWidget *parent)
|
|||||||
ttheader->resizeSection ( 1, 170 );
|
ttheader->resizeSection ( 1, 170 );
|
||||||
|
|
||||||
|
|
||||||
mForumNameFont = QFont("Times", 12, QFont::Bold);
|
m_ForumNameFont = QFont("Times", 12, QFont::Bold);
|
||||||
ui.forumName->setFont(mForumNameFont);
|
ui.forumName->setFont(m_ForumNameFont);
|
||||||
ui.threadTitle->setFont(mForumNameFont);
|
ui.threadTitle->setFont(m_ForumNameFont);
|
||||||
|
|
||||||
loadForumEmoticons();
|
loadForumEmoticons();
|
||||||
|
|
||||||
@ -131,6 +130,42 @@ ForumsDialog::ForumsDialog(QWidget *parent)
|
|||||||
ui.postText->setOpenExternalLinks ( false );
|
ui.postText->setOpenExternalLinks ( false );
|
||||||
ui.postText->setOpenLinks ( false );
|
ui.postText->setOpenLinks ( false );
|
||||||
|
|
||||||
|
/* create forum tree */
|
||||||
|
m_ItemFont = QFont("ARIAL", 10);
|
||||||
|
m_ItemFont.setBold(true);
|
||||||
|
|
||||||
|
QList<QTreeWidgetItem *> TopList;
|
||||||
|
|
||||||
|
YourForums = new QTreeWidgetItem();
|
||||||
|
YourForums->setText(0, tr("Your Forums"));
|
||||||
|
YourForums->setFont(0, m_ItemFont);
|
||||||
|
YourForums->setIcon(0,(QIcon(IMAGE_FOLDER)));
|
||||||
|
TopList.append(YourForums);
|
||||||
|
|
||||||
|
SubscribedForums = new QTreeWidgetItem((QTreeWidget*)0);
|
||||||
|
SubscribedForums->setText(0, tr("Subscribed Forums"));
|
||||||
|
SubscribedForums->setFont(0, m_ItemFont);
|
||||||
|
SubscribedForums->setIcon(0,(QIcon(IMAGE_FOLDERRED)));
|
||||||
|
TopList.append(SubscribedForums);
|
||||||
|
|
||||||
|
PopularForums = new QTreeWidgetItem();
|
||||||
|
PopularForums->setText(0, tr("Popular Forums"));
|
||||||
|
PopularForums->setFont(0, m_ItemFont);
|
||||||
|
PopularForums->setIcon(0,(QIcon(IMAGE_FOLDERGREEN)));
|
||||||
|
TopList.append(PopularForums);
|
||||||
|
|
||||||
|
OtherForums = new QTreeWidgetItem();
|
||||||
|
OtherForums->setText(0, tr("Other Forums"));
|
||||||
|
OtherForums->setFont(0, m_ItemFont);
|
||||||
|
OtherForums->setIcon(0,(QIcon(IMAGE_FOLDERYELLOW)));
|
||||||
|
TopList.append(OtherForums);
|
||||||
|
|
||||||
|
ui.forumTreeWidget->addTopLevelItems(TopList);
|
||||||
|
|
||||||
|
YourForums->setExpanded(true);
|
||||||
|
SubscribedForums->setExpanded(true);
|
||||||
|
|
||||||
|
m_LastViewType = -1;
|
||||||
|
|
||||||
/* Hide platform specific features */
|
/* Hide platform specific features */
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
@ -144,17 +179,37 @@ void ForumsDialog::forumListCustomPopupMenu( QPoint point )
|
|||||||
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
||||||
|
|
||||||
QAction *subForumAct = new QAction(QIcon(IMAGE_SUBSCRIBE), tr( "Subscribe to Forum" ), this );
|
QAction *subForumAct = new QAction(QIcon(IMAGE_SUBSCRIBE), tr( "Subscribe to Forum" ), this );
|
||||||
|
subForumAct->setDisabled (true);
|
||||||
connect( subForumAct , SIGNAL( triggered() ), this, SLOT( subscribeToForum() ) );
|
connect( subForumAct , SIGNAL( triggered() ), this, SLOT( subscribeToForum() ) );
|
||||||
|
|
||||||
QAction *unsubForumAct = new QAction(QIcon(IMAGE_UNSUBSCRIBE), tr( "Unsubscribe to Forum" ), this );
|
QAction *unsubForumAct = new QAction(QIcon(IMAGE_UNSUBSCRIBE), tr( "Unsubscribe to Forum" ), this );
|
||||||
|
unsubForumAct->setDisabled (true);
|
||||||
connect( unsubForumAct , SIGNAL( triggered() ), this, SLOT( unsubscribeToForum() ) );
|
connect( unsubForumAct , SIGNAL( triggered() ), this, SLOT( unsubscribeToForum() ) );
|
||||||
|
|
||||||
QAction *newForumAct = new QAction(QIcon(IMAGE_NEWFORUM), tr( "New Forum" ), this );
|
QAction *newForumAct = new QAction(QIcon(IMAGE_NEWFORUM), tr( "New Forum" ), this );
|
||||||
connect( newForumAct , SIGNAL( triggered() ), this, SLOT( newforum() ) );
|
connect( newForumAct , SIGNAL( triggered() ), this, SLOT( newforum() ) );
|
||||||
|
|
||||||
QAction *detailsForumAct = new QAction(QIcon(IMAGE_INFO), tr( "Show Forum Details" ), this );
|
QAction *detailsForumAct = new QAction(QIcon(IMAGE_INFO), tr( "Show Forum Details" ), this );
|
||||||
|
detailsForumAct->setDisabled (true);
|
||||||
connect( detailsForumAct , SIGNAL( triggered() ), this, SLOT( showForumDetails() ) );
|
connect( detailsForumAct , SIGNAL( triggered() ), this, SLOT( showForumDetails() ) );
|
||||||
|
|
||||||
|
ForumInfo fi;
|
||||||
|
if (rsForums && !mCurrForumId.empty ()) {
|
||||||
|
if (rsForums->getForumInfo (mCurrForumId, fi)) {
|
||||||
|
if ((fi.subscribeFlags & (RS_DISTRIB_ADMIN | RS_DISTRIB_SUBSCRIBED)) == 0) {
|
||||||
|
subForumAct->setEnabled (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((fi.subscribeFlags & (RS_DISTRIB_ADMIN | RS_DISTRIB_SUBSCRIBED)) != 0) {
|
||||||
|
unsubForumAct->setEnabled (true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mCurrForumId.empty ()) {
|
||||||
|
detailsForumAct->setEnabled (true);
|
||||||
|
}
|
||||||
|
|
||||||
contextMnu.clear();
|
contextMnu.clear();
|
||||||
contextMnu.addAction( subForumAct );
|
contextMnu.addAction( subForumAct );
|
||||||
contextMnu.addAction( unsubForumAct );
|
contextMnu.addAction( unsubForumAct );
|
||||||
@ -162,8 +217,6 @@ void ForumsDialog::forumListCustomPopupMenu( QPoint point )
|
|||||||
contextMnu.addAction( newForumAct );
|
contextMnu.addAction( newForumAct );
|
||||||
contextMnu.addAction( detailsForumAct );
|
contextMnu.addAction( detailsForumAct );
|
||||||
contextMnu.exec( mevent->globalPos() );
|
contextMnu.exec( mevent->globalPos() );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForumsDialog::threadListCustomPopupMenu( QPoint point )
|
void ForumsDialog::threadListCustomPopupMenu( QPoint point )
|
||||||
@ -172,12 +225,15 @@ void ForumsDialog::threadListCustomPopupMenu( QPoint point )
|
|||||||
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
||||||
|
|
||||||
QAction *replyAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply" ), this );
|
QAction *replyAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply" ), this );
|
||||||
|
replyAct->setDisabled (true);
|
||||||
connect( replyAct , SIGNAL( triggered() ), this, SLOT( createmessage() ) );
|
connect( replyAct , SIGNAL( triggered() ), this, SLOT( createmessage() ) );
|
||||||
|
|
||||||
QAction *viewAct = new QAction(QIcon(IMAGE_DOWNLOADALL), tr( "Start New Thread" ), this );
|
QAction *viewAct = new QAction(QIcon(IMAGE_DOWNLOADALL), tr( "Start New Thread" ), this );
|
||||||
|
viewAct->setDisabled (true);
|
||||||
connect( viewAct , SIGNAL( triggered() ), this, SLOT( showthread() ) );
|
connect( viewAct , SIGNAL( triggered() ), this, SLOT( showthread() ) );
|
||||||
|
|
||||||
QAction *replyauthorAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply to Author" ), this );
|
QAction *replyauthorAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply to Author" ), this );
|
||||||
|
replyauthorAct->setDisabled (true);
|
||||||
connect( replyauthorAct , SIGNAL( triggered() ), this, SLOT( replytomessage() ) );
|
connect( replyauthorAct , SIGNAL( triggered() ), this, SLOT( replytomessage() ) );
|
||||||
|
|
||||||
QAction* expandAll = new QAction(tr( "Expand all" ), this );
|
QAction* expandAll = new QAction(tr( "Expand all" ), this );
|
||||||
@ -186,6 +242,13 @@ void ForumsDialog::threadListCustomPopupMenu( QPoint point )
|
|||||||
QAction* collapseAll = new QAction(tr( "Collapse all" ), this );
|
QAction* collapseAll = new QAction(tr( "Collapse all" ), this );
|
||||||
connect( collapseAll , SIGNAL( triggered() ), ui.threadTreeWidget, SLOT(collapseAll()) );
|
connect( collapseAll , SIGNAL( triggered() ), ui.threadTreeWidget, SLOT(collapseAll()) );
|
||||||
|
|
||||||
|
if (!mCurrForumId.empty ()) {
|
||||||
|
viewAct->setEnabled (true);
|
||||||
|
if (!mCurrPostId.empty ()) {
|
||||||
|
replyAct->setEnabled (true);
|
||||||
|
replyauthorAct->setEnabled (true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
contextMnu.clear();
|
contextMnu.clear();
|
||||||
contextMnu.addAction( replyAct);
|
contextMnu.addAction( replyAct);
|
||||||
@ -195,23 +258,6 @@ void ForumsDialog::threadListCustomPopupMenu( QPoint point )
|
|||||||
contextMnu.addAction( expandAll);
|
contextMnu.addAction( expandAll);
|
||||||
contextMnu.addAction( collapseAll);
|
contextMnu.addAction( collapseAll);
|
||||||
contextMnu.exec( mevent->globalPos() );
|
contextMnu.exec( mevent->globalPos() );
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ForumsDialog::newmessage()
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
|
|
||||||
|
|
||||||
/* fill it in */
|
|
||||||
//std::cerr << "ForumsDialog::newmessage()" << std::endl;
|
|
||||||
nMsgDialog->newMsg();
|
|
||||||
nMsgDialog->show();
|
|
||||||
nMsgDialog->activateWindow();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* window will destroy itself! */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForumsDialog::togglefileview()
|
void ForumsDialog::togglefileview()
|
||||||
@ -291,19 +337,16 @@ void ForumsDialog::checkUpdate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ForumsDialog::changeBox( int newrow )
|
static void CleanupItems (QList<QTreeWidgetItem *> &Items)
|
||||||
{
|
{
|
||||||
#if 0
|
QList<QTreeWidgetItem *>::iterator Item;
|
||||||
//std::cerr << "ForumsDialog::changeBox()" << std::endl;
|
for (Item = Items.begin (); Item != Items.end (); Item++) {
|
||||||
insertMessages();
|
delete (*Item);
|
||||||
insertMsgTxtAndFiles();
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ForumsDialog::insertForums()
|
void ForumsDialog::insertForums()
|
||||||
{
|
{
|
||||||
|
|
||||||
std::list<ForumInfo> forumList;
|
std::list<ForumInfo> forumList;
|
||||||
std::list<ForumInfo>::iterator it;
|
std::list<ForumInfo>::iterator it;
|
||||||
if (!rsForums)
|
if (!rsForums)
|
||||||
@ -313,9 +356,6 @@ void ForumsDialog::insertForums()
|
|||||||
|
|
||||||
rsForums->getForumList(forumList);
|
rsForums->getForumList(forumList);
|
||||||
|
|
||||||
mCurrForumId = "";
|
|
||||||
mCurrPostId = "";
|
|
||||||
|
|
||||||
QList<QTreeWidgetItem *> AdminList;
|
QList<QTreeWidgetItem *> AdminList;
|
||||||
QList<QTreeWidgetItem *> SubList;
|
QList<QTreeWidgetItem *> SubList;
|
||||||
QList<QTreeWidgetItem *> PopList;
|
QList<QTreeWidgetItem *> PopList;
|
||||||
@ -506,44 +546,72 @@ void ForumsDialog::insertForums()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
itemFont = QFont("ARIAL", 10);
|
|
||||||
itemFont.setBold(true);
|
|
||||||
|
|
||||||
/* now we can add them in as a tree! */
|
/* now we can add them in as a tree! */
|
||||||
QList<QTreeWidgetItem *> TopList;
|
FillForums (YourForums, AdminList);
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
FillForums (SubscribedForums, SubList);
|
||||||
item -> setText(0, tr("Your Forums"));
|
FillForums (PopularForums, PopList);
|
||||||
item -> setFont(0,itemFont);
|
FillForums (OtherForums, OtherList);
|
||||||
item -> setIcon(0,(QIcon(IMAGE_FOLDER)));
|
|
||||||
item -> addChildren(AdminList);
|
|
||||||
TopList.append(item);
|
|
||||||
|
|
||||||
item = new QTreeWidgetItem((QTreeWidget*)0);
|
// cleanup
|
||||||
item -> setText(0, tr("Subscribed Forums"));
|
CleanupItems (AdminList);
|
||||||
item -> setFont(0,itemFont);
|
CleanupItems (SubList);
|
||||||
item -> setIcon(0,(QIcon(IMAGE_FOLDERRED)));
|
CleanupItems (PopList);
|
||||||
item -> addChildren(SubList);
|
CleanupItems (OtherList);
|
||||||
TopList.append(item);
|
}
|
||||||
|
|
||||||
item = new QTreeWidgetItem((QTreeWidget*)0);
|
void ForumsDialog::FillForums(QTreeWidgetItem *Forum, QList<QTreeWidgetItem *> &ChildList)
|
||||||
item -> setText(0, tr("Popular Forums"));
|
{
|
||||||
item -> setFont(0,itemFont);
|
int ChildIndex;
|
||||||
item -> setIcon(0,(QIcon(IMAGE_FOLDERGREEN)));
|
int ChildIndexCur = 0;
|
||||||
item -> addChildren(PopList);
|
|
||||||
TopList.append(item);
|
|
||||||
|
|
||||||
item = new QTreeWidgetItem((QTreeWidget*)0);
|
QTreeWidgetItem *Child;
|
||||||
item -> setText(0, tr("Other Forums"));
|
|
||||||
item -> setFont(0,itemFont);
|
|
||||||
item -> setIcon(0,(QIcon(IMAGE_FOLDERYELLOW)));
|
|
||||||
item -> addChildren(OtherList);
|
|
||||||
TopList.append(item);
|
|
||||||
|
|
||||||
/* add the items in! */
|
// iterate all new childs
|
||||||
ui.forumTreeWidget->clear();
|
QList<QTreeWidgetItem *>::iterator NewChild;
|
||||||
ui.forumTreeWidget->insertTopLevelItems(0, TopList);
|
for (NewChild = ChildList.begin (); NewChild != ChildList.end (); NewChild++) {
|
||||||
|
// search existing child
|
||||||
|
int ChildIndexFound = -1;
|
||||||
|
int ChildCount = Forum->childCount ();
|
||||||
|
for (ChildIndex = ChildIndexCur; ChildIndex < ChildCount; ChildIndex++) {
|
||||||
|
Child = Forum->child (ChildIndex);
|
||||||
|
if (Child->text (4) == (*NewChild)->text (4)) {
|
||||||
|
// found it
|
||||||
|
ChildIndexFound = ChildIndex;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ChildIndexFound >= 0) {
|
||||||
|
// delete all childs between
|
||||||
|
while (ChildIndexCur < ChildIndexFound) {
|
||||||
|
Child = Forum->takeChild (ChildIndexCur);
|
||||||
|
delete (Child);
|
||||||
|
ChildIndexFound--;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
// set child data
|
||||||
|
Child = Forum->child (ChildIndexFound);
|
||||||
|
Child->setIcon (0, (*NewChild)->icon (0));
|
||||||
|
Child->setToolTip (0, (*NewChild)->toolTip (0));
|
||||||
|
|
||||||
|
for (int i = 0; i <= 4; i++) {
|
||||||
|
Child->setText (i, (*NewChild)->text (i));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// insert new child
|
||||||
|
if (ChildIndexCur < ChildCount) {
|
||||||
|
Forum->insertChild (ChildIndexCur, (*NewChild)->clone ());
|
||||||
|
} else {
|
||||||
|
Forum->addChild ((*NewChild)->clone ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ChildIndexCur++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete rest
|
||||||
|
while (ChildIndexCur < Forum->childCount ()) {
|
||||||
|
Child = Forum->takeChild (ChildIndexCur);
|
||||||
|
delete (Child);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForumsDialog::changedForum( QTreeWidgetItem *curr, QTreeWidgetItem *prev )
|
void ForumsDialog::changedForum( QTreeWidgetItem *curr, QTreeWidgetItem *prev )
|
||||||
@ -551,36 +619,18 @@ void ForumsDialog::changedForum( QTreeWidgetItem *curr, QTreeWidgetItem *prev )
|
|||||||
insertThreads();
|
insertThreads();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForumsDialog::changedThread( QTreeWidgetItem *curr, QTreeWidgetItem *prev )
|
void ForumsDialog::changedThread ()
|
||||||
{
|
{
|
||||||
/* just grab the ids of the current item */
|
/* just grab the ids of the current item */
|
||||||
if ((!curr) || (!curr->isSelected()))
|
|
||||||
{
|
|
||||||
mCurrPostId = "";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mCurrPostId = (curr->text(5)).toStdString();
|
|
||||||
insertPost();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ForumsDialog::changedThread2()
|
|
||||||
{
|
|
||||||
QTreeWidgetItem *curr = ui.threadTreeWidget->currentItem();
|
QTreeWidgetItem *curr = ui.threadTreeWidget->currentItem();
|
||||||
|
|
||||||
/* just grab the ids of the current item */
|
if ((!curr) || (!curr->isSelected())) {
|
||||||
if ((!curr) || (!curr->isSelected()))
|
|
||||||
{
|
|
||||||
mCurrPostId = "";
|
mCurrPostId = "";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
mCurrPostId = (curr->text(5)).toStdString();
|
mCurrPostId = (curr->text(5)).toStdString();
|
||||||
|
}
|
||||||
insertPost();
|
insertPost();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ForumsDialog::insertThreads()
|
void ForumsDialog::insertThreads()
|
||||||
{
|
{
|
||||||
@ -607,7 +657,6 @@ void ForumsDialog::insertThreads()
|
|||||||
/* store forumId */
|
/* store forumId */
|
||||||
mCurrForumId = (forumItem->text(4)).toStdString();
|
mCurrForumId = (forumItem->text(4)).toStdString();
|
||||||
ui.forumName->setText(forumItem->text(0));
|
ui.forumName->setText(forumItem->text(0));
|
||||||
mCurrPostId = "";
|
|
||||||
std::string fId = mCurrForumId;
|
std::string fId = mCurrForumId;
|
||||||
|
|
||||||
#define VIEW_LAST_POST 0
|
#define VIEW_LAST_POST 0
|
||||||
@ -616,7 +665,8 @@ void ForumsDialog::insertThreads()
|
|||||||
|
|
||||||
bool flatView = false;
|
bool flatView = false;
|
||||||
bool useChildTS = false;
|
bool useChildTS = false;
|
||||||
switch(ui.viewBox->currentIndex())
|
int ViewType = ui.viewBox->currentIndex();
|
||||||
|
switch(ViewType)
|
||||||
{
|
{
|
||||||
case VIEW_LAST_POST:
|
case VIEW_LAST_POST:
|
||||||
useChildTS = true;
|
useChildTS = true;
|
||||||
@ -801,23 +851,140 @@ void ForumsDialog::insertThreads()
|
|||||||
items.append(item);
|
items.append(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add all messages in! */
|
|
||||||
ui.threadTreeWidget->clear();
|
|
||||||
ui.postText->clear();
|
ui.postText->clear();
|
||||||
ui.threadTitle->clear();
|
ui.threadTitle->clear();
|
||||||
|
/* add all messages in! */
|
||||||
|
if (m_LastViewType != ViewType || m_LastForumID != mCurrForumId) {
|
||||||
|
ui.threadTreeWidget->clear();
|
||||||
|
m_LastViewType = ViewType;
|
||||||
|
m_LastForumID = mCurrForumId;
|
||||||
ui.threadTreeWidget->insertTopLevelItems(0, items);
|
ui.threadTreeWidget->insertTopLevelItems(0, items);
|
||||||
|
} else {
|
||||||
|
FillThreads (items);
|
||||||
|
|
||||||
|
CleanupItems (items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
insertPost ();
|
||||||
|
}
|
||||||
|
|
||||||
void ForumsDialog::updateMessages( QTreeWidgetItem * item, int column )
|
void ForumsDialog::FillThreads(QList<QTreeWidgetItem *> &ThreadList)
|
||||||
{
|
{
|
||||||
#if 0
|
int Index;
|
||||||
//std::cerr << "ForumsDialog::insertMsgTxtAndFiles()" << std::endl;
|
QTreeWidgetItem *Thread;
|
||||||
insertMsgTxtAndFiles();
|
|
||||||
#endif
|
// iterate all new threads
|
||||||
|
QList<QTreeWidgetItem *>::iterator NewThread;
|
||||||
|
for (NewThread = ThreadList.begin (); NewThread != ThreadList.end (); NewThread++) {
|
||||||
|
// search existing thread
|
||||||
|
int Found = -1;
|
||||||
|
int Count = ui.threadTreeWidget->topLevelItemCount ();
|
||||||
|
for (Index = 0; Index < Count; Index++) {
|
||||||
|
Thread = ui.threadTreeWidget->topLevelItem (Index);
|
||||||
|
if (Thread->text (5) == (*NewThread)->text (5)) {
|
||||||
|
// found it
|
||||||
|
Found = Index;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Found >= 0) {
|
||||||
|
// set child data
|
||||||
|
for (int i = 0; i <= 5; i++) {
|
||||||
|
Thread->setText (i, (*NewThread)->text (i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fill recursive
|
||||||
|
FillChildren (Thread, *NewThread);
|
||||||
|
} else {
|
||||||
|
// add new thread
|
||||||
|
ui.threadTreeWidget->addTopLevelItem ((*NewThread)->clone ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete rest
|
||||||
|
while (Index < ui.threadTreeWidget->topLevelItemCount ()) {
|
||||||
|
Thread = ui.threadTreeWidget->topLevelItem (Index);
|
||||||
|
|
||||||
|
// search existing new thread
|
||||||
|
int Found = -1;
|
||||||
|
for (NewThread = ThreadList.begin (); NewThread != ThreadList.end (); NewThread++) {
|
||||||
|
if (Thread->text (5) == (*NewThread)->text (5)) {
|
||||||
|
// found it
|
||||||
|
Found = Index;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Found >= 0) {
|
||||||
|
Index++;
|
||||||
|
} else {
|
||||||
|
Thread = ui.threadTreeWidget->takeTopLevelItem (Index);
|
||||||
|
delete (Thread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ForumsDialog::FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewParent)
|
||||||
|
{
|
||||||
|
int Index;
|
||||||
|
int NewIndex;
|
||||||
|
int NewCount = NewParent->childCount();
|
||||||
|
|
||||||
|
QTreeWidgetItem *Child;
|
||||||
|
QTreeWidgetItem *NewChild;
|
||||||
|
|
||||||
|
// iterate all new children
|
||||||
|
for (NewIndex = 0; NewIndex < NewCount; NewIndex++) {
|
||||||
|
NewChild = NewParent->child (NewIndex);
|
||||||
|
|
||||||
|
// search existing child
|
||||||
|
int Found = -1;
|
||||||
|
int Count = Parent->childCount();
|
||||||
|
for (Index = 0; Index < Count; Index++) {
|
||||||
|
Child = Parent->child (Index);
|
||||||
|
if (Child->text (5) == NewChild->text (5)) {
|
||||||
|
// found it
|
||||||
|
Found = Index;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Found >= 0) {
|
||||||
|
// set child data
|
||||||
|
for (int i = 0; i <= 5; i++) {
|
||||||
|
Child->setText (i, NewChild->text (i));
|
||||||
|
}
|
||||||
|
|
||||||
|
// fill recursive
|
||||||
|
FillChildren (Child, NewChild);
|
||||||
|
} else {
|
||||||
|
// add new child
|
||||||
|
Parent->addChild (NewChild->clone ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete rest
|
||||||
|
while (Index < Parent->childCount ()) {
|
||||||
|
Child = Parent->child (Index);
|
||||||
|
|
||||||
|
// search existing new child
|
||||||
|
int Found = -1;
|
||||||
|
int Count = NewParent->childCount();
|
||||||
|
for (NewIndex = 0; NewIndex < Count; NewIndex++) {
|
||||||
|
NewChild = NewParent->child (NewIndex);
|
||||||
|
if (NewChild->text (5) == Child->text (5)) {
|
||||||
|
// found it
|
||||||
|
Found = Index;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Found >= 0) {
|
||||||
|
Index++;
|
||||||
|
} else {
|
||||||
|
Child = Parent->takeChild (Index);
|
||||||
|
delete (Child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ForumsDialog::insertPost()
|
void ForumsDialog::insertPost()
|
||||||
{
|
{
|
||||||
@ -828,9 +995,24 @@ void ForumsDialog::insertPost()
|
|||||||
|
|
||||||
ui.postText->setText("");
|
ui.postText->setText("");
|
||||||
ui.threadTitle->setText("");
|
ui.threadTitle->setText("");
|
||||||
|
ui.previousButton->setEnabled(false);
|
||||||
|
ui.nextButton->setEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTreeWidgetItem *curr = ui.threadTreeWidget->currentItem();
|
||||||
|
if (curr) {
|
||||||
|
QTreeWidgetItem *Parent = curr->parent ();
|
||||||
|
int Index = Parent ? Parent->indexOfChild (curr) : ui.threadTreeWidget->indexOfTopLevelItem (curr);
|
||||||
|
int Count = Parent ? Parent->childCount () : ui.threadTreeWidget->topLevelItemCount ();
|
||||||
|
ui.previousButton->setEnabled (Index > 0);
|
||||||
|
ui.nextButton->setEnabled (Index < Count - 1);
|
||||||
|
} else {
|
||||||
|
// there is something wrong
|
||||||
|
ui.previousButton->setEnabled(false);
|
||||||
|
ui.nextButton->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
/* get the Post */
|
/* get the Post */
|
||||||
ForumMsgInfo msg;
|
ForumMsgInfo msg;
|
||||||
if (!rsForums->getForumMessage(mCurrForumId, mCurrPostId, msg))
|
if (!rsForums->getForumMessage(mCurrForumId, mCurrPostId, msg))
|
||||||
@ -862,13 +1044,49 @@ void ForumsDialog::insertPost()
|
|||||||
ui.threadTitle->setText(QString::fromStdWString(title.title));
|
ui.threadTitle->setText(QString::fromStdWString(title.title));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ForumsDialog::previousMessage ()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *Item = ui.threadTreeWidget->currentItem ();
|
||||||
|
if (Item == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTreeWidgetItem *Parent = Item->parent ();
|
||||||
|
int Index = Parent ? Parent->indexOfChild (Item) : ui.threadTreeWidget->indexOfTopLevelItem (Item);
|
||||||
|
if (Index > 0) {
|
||||||
|
QTreeWidgetItem *Previous = Parent ? Parent->child (Index - 1) : ui.threadTreeWidget->topLevelItem (Index - 1);
|
||||||
|
if (Previous) {
|
||||||
|
ui.threadTreeWidget->setCurrentItem (Previous);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ForumsDialog::nextMessage ()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *Item = ui.threadTreeWidget->currentItem ();
|
||||||
|
if (Item == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTreeWidgetItem *Parent = Item->parent ();
|
||||||
|
int Index = Parent ? Parent->indexOfChild (Item) : ui.threadTreeWidget->indexOfTopLevelItem (Item);
|
||||||
|
int Count = Parent ? Parent->childCount () : ui.threadTreeWidget->topLevelItemCount ();
|
||||||
|
if (Index < Count - 1) {
|
||||||
|
QTreeWidgetItem *Next = Parent ? Parent->child (Index + 1) : ui.threadTreeWidget->topLevelItem (Index + 1);
|
||||||
|
if (Next) {
|
||||||
|
ui.threadTreeWidget->setCurrentItem (Next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
bool ForumsDialog::getCurrentMsg(std::string &cid, std::string &mid)
|
bool ForumsDialog::getCurrentMsg(std::string &cid, std::string &mid)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO
|
||||||
void ForumsDialog::removemessage()
|
void ForumsDialog::removemessage()
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
@ -888,6 +1106,7 @@ void ForumsDialog::removemessage()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO
|
||||||
void ForumsDialog::markMsgAsRead()
|
void ForumsDialog::markMsgAsRead()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -912,26 +1131,26 @@ void ForumsDialog::markMsgAsRead()
|
|||||||
|
|
||||||
void ForumsDialog::newforum()
|
void ForumsDialog::newforum()
|
||||||
{
|
{
|
||||||
static CreateForum *cf = new CreateForum(this);
|
CreateForum cf (this);
|
||||||
cf->show();
|
cf.exec ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ForumsDialog::createmessage()
|
void ForumsDialog::createmessage()
|
||||||
{
|
{
|
||||||
if (mCurrForumId == "")
|
if (mCurrForumId.empty ()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateForumMsg *cfm = new CreateForumMsg(mCurrForumId, mCurrPostId);
|
CreateForumMsg *cfm = new CreateForumMsg(mCurrForumId, mCurrPostId);
|
||||||
cfm->show();
|
cfm->show();
|
||||||
|
|
||||||
|
/* window will destroy itself! */
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForumsDialog::showthread()
|
void ForumsDialog::showthread()
|
||||||
{
|
{
|
||||||
if (mCurrForumId == "")
|
if (mCurrForumId.empty ()) {
|
||||||
{
|
|
||||||
QMessageBox::information(this, tr("RetroShare"),tr("No Forum Selected!"));
|
QMessageBox::information(this, tr("RetroShare"),tr("No Forum Selected!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -939,6 +1158,8 @@ void ForumsDialog::showthread()
|
|||||||
CreateForumMsg *cfm = new CreateForumMsg(mCurrForumId, "");
|
CreateForumMsg *cfm = new CreateForumMsg(mCurrForumId, "");
|
||||||
cfm->setWindowTitle(tr("Start New Thread"));
|
cfm->setWindowTitle(tr("Start New Thread"));
|
||||||
cfm->show();
|
cfm->show();
|
||||||
|
|
||||||
|
/* window will destroy itself! */
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForumsDialog::subscribeToForum()
|
void ForumsDialog::subscribeToForum()
|
||||||
@ -967,18 +1188,15 @@ void ForumsDialog::forumSubscribe(bool subscribe)
|
|||||||
|
|
||||||
void ForumsDialog::showForumDetails()
|
void ForumsDialog::showForumDetails()
|
||||||
{
|
{
|
||||||
|
|
||||||
static ForumDetails *fui = new ForumDetails();
|
|
||||||
|
|
||||||
if (mCurrForumId == "")
|
if (mCurrForumId == "")
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fui->showDetails(mCurrForumId);
|
ForumDetails fui;
|
||||||
fui->show();
|
|
||||||
|
|
||||||
|
|
||||||
|
fui.showDetails (mCurrForumId);
|
||||||
|
fui.exec ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForumsDialog::loadForumEmoticons()
|
void ForumsDialog::loadForumEmoticons()
|
||||||
@ -1056,10 +1274,8 @@ void ForumsDialog::replytomessage()
|
|||||||
ForumMsgInfo msgInfo ;
|
ForumMsgInfo msgInfo ;
|
||||||
rsForums->getForumMessage(fId,pId,msgInfo) ;
|
rsForums->getForumMessage(fId,pId,msgInfo) ;
|
||||||
|
|
||||||
|
|
||||||
if (rsPeers->getPeerName(msgInfo.srcId) !="")
|
if (rsPeers->getPeerName(msgInfo.srcId) !="")
|
||||||
{
|
{
|
||||||
|
|
||||||
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
|
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
|
||||||
nMsgDialog->newMsg();
|
nMsgDialog->newMsg();
|
||||||
nMsgDialog->insertTitleText( (QString("Re: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ;
|
nMsgDialog->insertTitleText( (QString("Re: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ;
|
||||||
@ -1073,7 +1289,6 @@ void ForumsDialog::replytomessage()
|
|||||||
nMsgDialog->addRecipient( msgInfo.srcId ) ;
|
nMsgDialog->addRecipient( msgInfo.srcId ) ;
|
||||||
nMsgDialog->show();
|
nMsgDialog->show();
|
||||||
nMsgDialog->activateWindow();
|
nMsgDialog->activateWindow();
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -51,13 +51,8 @@ private slots:
|
|||||||
void checkUpdate();
|
void checkUpdate();
|
||||||
|
|
||||||
void changedForum( QTreeWidgetItem *curr, QTreeWidgetItem *prev );
|
void changedForum( QTreeWidgetItem *curr, QTreeWidgetItem *prev );
|
||||||
void changedThread( QTreeWidgetItem *curr, QTreeWidgetItem *prev );
|
void changedThread();
|
||||||
void changedThread2();
|
|
||||||
|
|
||||||
void changeBox( int newrow );
|
|
||||||
void updateMessages ( QTreeWidgetItem * item, int column );
|
|
||||||
|
|
||||||
void newmessage();
|
|
||||||
|
|
||||||
void replytomessage();
|
void replytomessage();
|
||||||
//void print();
|
//void print();
|
||||||
@ -77,17 +72,30 @@ private slots:
|
|||||||
|
|
||||||
void showForumDetails();
|
void showForumDetails();
|
||||||
|
|
||||||
|
void previousMessage ();
|
||||||
|
void nextMessage ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void forumSubscribe(bool subscribe);
|
void forumSubscribe(bool subscribe);
|
||||||
bool getCurrentMsg(std::string &cid, std::string &mid);
|
bool getCurrentMsg(std::string &cid, std::string &mid);
|
||||||
|
void FillForums(QTreeWidgetItem *Forum, QList<QTreeWidgetItem *> &ChildList);
|
||||||
|
void FillThreads(QList<QTreeWidgetItem *> &ThreadList);
|
||||||
|
void FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewParent);
|
||||||
|
|
||||||
|
QTreeWidgetItem *YourForums;
|
||||||
|
QTreeWidgetItem *SubscribedForums;
|
||||||
|
QTreeWidgetItem *PopularForums;
|
||||||
|
QTreeWidgetItem *OtherForums;
|
||||||
|
|
||||||
std::string mCurrForumId;
|
std::string mCurrForumId;
|
||||||
std::string mCurrThreadId;
|
std::string mCurrThreadId;
|
||||||
std::string mCurrPostId;
|
std::string mCurrPostId;
|
||||||
|
|
||||||
QFont mForumNameFont;
|
QFont m_ForumNameFont;
|
||||||
QFont itemFont;
|
QFont m_ItemFont;
|
||||||
|
int m_LastViewType;
|
||||||
|
std::string m_LastForumID;
|
||||||
|
|
||||||
QHash<QString, QString> smileys;
|
QHash<QString, QString> smileys;
|
||||||
|
|
||||||
|
@ -960,7 +960,10 @@ background: white;}</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
<item row="0" column="3">
|
||||||
<widget class="QPushButton" name="pushButton_2">
|
<widget class="QPushButton" name="previousButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -989,7 +992,10 @@ background: white;}</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="4">
|
<item row="0" column="4">
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QPushButton" name="nextButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -59,6 +59,7 @@ CreateForumMsg::CreateForumMsg(std::string fId, std::string pId)
|
|||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
|
||||||
RshareSettings config;
|
RshareSettings config;
|
||||||
config.loadWidgetInformation(this);
|
config.loadWidgetInformation(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user