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,
|
||||
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.postText, SIGNAL( anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
|
||||
|
||||
|
||||
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);
|
||||
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
|
||||
@ -117,9 +116,9 @@ ForumsDialog::ForumsDialog(QWidget *parent)
|
||||
ttheader->resizeSection ( 1, 170 );
|
||||
|
||||
|
||||
mForumNameFont = QFont("Times", 12, QFont::Bold);
|
||||
ui.forumName->setFont(mForumNameFont);
|
||||
ui.threadTitle->setFont(mForumNameFont);
|
||||
m_ForumNameFont = QFont("Times", 12, QFont::Bold);
|
||||
ui.forumName->setFont(m_ForumNameFont);
|
||||
ui.threadTitle->setFont(m_ForumNameFont);
|
||||
|
||||
loadForumEmoticons();
|
||||
|
||||
@ -131,6 +130,42 @@ ForumsDialog::ForumsDialog(QWidget *parent)
|
||||
ui.postText->setOpenExternalLinks ( 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 */
|
||||
#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 );
|
||||
|
||||
QAction *subForumAct = new QAction(QIcon(IMAGE_SUBSCRIBE), tr( "Subscribe to Forum" ), this );
|
||||
subForumAct->setDisabled (true);
|
||||
connect( subForumAct , SIGNAL( triggered() ), this, SLOT( subscribeToForum() ) );
|
||||
|
||||
QAction *unsubForumAct = new QAction(QIcon(IMAGE_UNSUBSCRIBE), tr( "Unsubscribe to Forum" ), this );
|
||||
unsubForumAct->setDisabled (true);
|
||||
connect( unsubForumAct , SIGNAL( triggered() ), this, SLOT( unsubscribeToForum() ) );
|
||||
|
||||
QAction *newForumAct = new QAction(QIcon(IMAGE_NEWFORUM), tr( "New Forum" ), this );
|
||||
connect( newForumAct , SIGNAL( triggered() ), this, SLOT( newforum() ) );
|
||||
|
||||
QAction *detailsForumAct = new QAction(QIcon(IMAGE_INFO), tr( "Show Forum Details" ), this );
|
||||
detailsForumAct->setDisabled (true);
|
||||
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.addAction( subForumAct );
|
||||
contextMnu.addAction( unsubForumAct );
|
||||
@ -162,8 +217,6 @@ void ForumsDialog::forumListCustomPopupMenu( QPoint point )
|
||||
contextMnu.addAction( newForumAct );
|
||||
contextMnu.addAction( detailsForumAct );
|
||||
contextMnu.exec( mevent->globalPos() );
|
||||
|
||||
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
QAction *replyAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply" ), this );
|
||||
replyAct->setDisabled (true);
|
||||
connect( replyAct , SIGNAL( triggered() ), this, SLOT( createmessage() ) );
|
||||
|
||||
QAction *viewAct = new QAction(QIcon(IMAGE_DOWNLOADALL), tr( "Start New Thread" ), this );
|
||||
viewAct->setDisabled (true);
|
||||
connect( viewAct , SIGNAL( triggered() ), this, SLOT( showthread() ) );
|
||||
|
||||
QAction *replyauthorAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply to Author" ), this );
|
||||
replyauthorAct->setDisabled (true);
|
||||
connect( replyauthorAct , SIGNAL( triggered() ), this, SLOT( replytomessage() ) );
|
||||
|
||||
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 );
|
||||
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.addAction( replyAct);
|
||||
@ -195,23 +258,6 @@ void ForumsDialog::threadListCustomPopupMenu( QPoint point )
|
||||
contextMnu.addAction( expandAll);
|
||||
contextMnu.addAction( collapseAll);
|
||||
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()
|
||||
@ -291,19 +337,16 @@ void ForumsDialog::checkUpdate()
|
||||
}
|
||||
|
||||
|
||||
void ForumsDialog::changeBox( int newrow )
|
||||
static void CleanupItems (QList<QTreeWidgetItem *> &Items)
|
||||
{
|
||||
#if 0
|
||||
//std::cerr << "ForumsDialog::changeBox()" << std::endl;
|
||||
insertMessages();
|
||||
insertMsgTxtAndFiles();
|
||||
#endif
|
||||
QList<QTreeWidgetItem *>::iterator Item;
|
||||
for (Item = Items.begin (); Item != Items.end (); Item++) {
|
||||
delete (*Item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ForumsDialog::insertForums()
|
||||
{
|
||||
|
||||
std::list<ForumInfo> forumList;
|
||||
std::list<ForumInfo>::iterator it;
|
||||
if (!rsForums)
|
||||
@ -313,9 +356,6 @@ void ForumsDialog::insertForums()
|
||||
|
||||
rsForums->getForumList(forumList);
|
||||
|
||||
mCurrForumId = "";
|
||||
mCurrPostId = "";
|
||||
|
||||
QList<QTreeWidgetItem *> AdminList;
|
||||
QList<QTreeWidgetItem *> SubList;
|
||||
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! */
|
||||
QList<QTreeWidgetItem *> TopList;
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
item -> setText(0, tr("Your Forums"));
|
||||
item -> setFont(0,itemFont);
|
||||
item -> setIcon(0,(QIcon(IMAGE_FOLDER)));
|
||||
item -> addChildren(AdminList);
|
||||
TopList.append(item);
|
||||
FillForums (YourForums, AdminList);
|
||||
FillForums (SubscribedForums, SubList);
|
||||
FillForums (PopularForums, PopList);
|
||||
FillForums (OtherForums, OtherList);
|
||||
|
||||
item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
item -> setText(0, tr("Subscribed Forums"));
|
||||
item -> setFont(0,itemFont);
|
||||
item -> setIcon(0,(QIcon(IMAGE_FOLDERRED)));
|
||||
item -> addChildren(SubList);
|
||||
TopList.append(item);
|
||||
// cleanup
|
||||
CleanupItems (AdminList);
|
||||
CleanupItems (SubList);
|
||||
CleanupItems (PopList);
|
||||
CleanupItems (OtherList);
|
||||
}
|
||||
|
||||
item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
item -> setText(0, tr("Popular Forums"));
|
||||
item -> setFont(0,itemFont);
|
||||
item -> setIcon(0,(QIcon(IMAGE_FOLDERGREEN)));
|
||||
item -> addChildren(PopList);
|
||||
TopList.append(item);
|
||||
void ForumsDialog::FillForums(QTreeWidgetItem *Forum, QList<QTreeWidgetItem *> &ChildList)
|
||||
{
|
||||
int ChildIndex;
|
||||
int ChildIndexCur = 0;
|
||||
|
||||
item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
item -> setText(0, tr("Other Forums"));
|
||||
item -> setFont(0,itemFont);
|
||||
item -> setIcon(0,(QIcon(IMAGE_FOLDERYELLOW)));
|
||||
item -> addChildren(OtherList);
|
||||
TopList.append(item);
|
||||
QTreeWidgetItem *Child;
|
||||
|
||||
/* add the items in! */
|
||||
ui.forumTreeWidget->clear();
|
||||
ui.forumTreeWidget->insertTopLevelItems(0, TopList);
|
||||
// iterate all new childs
|
||||
QList<QTreeWidgetItem *>::iterator NewChild;
|
||||
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 )
|
||||
@ -551,36 +619,18 @@ void ForumsDialog::changedForum( QTreeWidgetItem *curr, QTreeWidgetItem *prev )
|
||||
insertThreads();
|
||||
}
|
||||
|
||||
void ForumsDialog::changedThread( QTreeWidgetItem *curr, QTreeWidgetItem *prev )
|
||||
void ForumsDialog::changedThread ()
|
||||
{
|
||||
/* 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();
|
||||
|
||||
/* just grab the ids of the current item */
|
||||
if ((!curr) || (!curr->isSelected()))
|
||||
{
|
||||
if ((!curr) || (!curr->isSelected())) {
|
||||
mCurrPostId = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
mCurrPostId = (curr->text(5)).toStdString();
|
||||
}
|
||||
insertPost();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ForumsDialog::insertThreads()
|
||||
{
|
||||
@ -607,7 +657,6 @@ void ForumsDialog::insertThreads()
|
||||
/* store forumId */
|
||||
mCurrForumId = (forumItem->text(4)).toStdString();
|
||||
ui.forumName->setText(forumItem->text(0));
|
||||
mCurrPostId = "";
|
||||
std::string fId = mCurrForumId;
|
||||
|
||||
#define VIEW_LAST_POST 0
|
||||
@ -616,7 +665,8 @@ void ForumsDialog::insertThreads()
|
||||
|
||||
bool flatView = false;
|
||||
bool useChildTS = false;
|
||||
switch(ui.viewBox->currentIndex())
|
||||
int ViewType = ui.viewBox->currentIndex();
|
||||
switch(ViewType)
|
||||
{
|
||||
case VIEW_LAST_POST:
|
||||
useChildTS = true;
|
||||
@ -801,23 +851,140 @@ void ForumsDialog::insertThreads()
|
||||
items.append(item);
|
||||
}
|
||||
|
||||
/* add all messages in! */
|
||||
ui.threadTreeWidget->clear();
|
||||
|
||||
ui.postText->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);
|
||||
} else {
|
||||
FillThreads (items);
|
||||
|
||||
CleanupItems (items);
|
||||
}
|
||||
|
||||
insertPost ();
|
||||
}
|
||||
|
||||
void ForumsDialog::updateMessages( QTreeWidgetItem * item, int column )
|
||||
void ForumsDialog::FillThreads(QList<QTreeWidgetItem *> &ThreadList)
|
||||
{
|
||||
#if 0
|
||||
//std::cerr << "ForumsDialog::insertMsgTxtAndFiles()" << std::endl;
|
||||
insertMsgTxtAndFiles();
|
||||
#endif
|
||||
int Index;
|
||||
QTreeWidgetItem *Thread;
|
||||
|
||||
// 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()
|
||||
{
|
||||
@ -828,9 +995,24 @@ void ForumsDialog::insertPost()
|
||||
|
||||
ui.postText->setText("");
|
||||
ui.threadTitle->setText("");
|
||||
ui.previousButton->setEnabled(false);
|
||||
ui.nextButton->setEnabled(false);
|
||||
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 */
|
||||
ForumMsgInfo msg;
|
||||
if (!rsForums->getForumMessage(mCurrForumId, mCurrPostId, msg))
|
||||
@ -862,13 +1044,49 @@ void ForumsDialog::insertPost()
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// TODO
|
||||
void ForumsDialog::removemessage()
|
||||
{
|
||||
#if 0
|
||||
@ -888,6 +1106,7 @@ void ForumsDialog::removemessage()
|
||||
}
|
||||
|
||||
|
||||
// TODO
|
||||
void ForumsDialog::markMsgAsRead()
|
||||
{
|
||||
|
||||
@ -912,26 +1131,26 @@ void ForumsDialog::markMsgAsRead()
|
||||
|
||||
void ForumsDialog::newforum()
|
||||
{
|
||||
static CreateForum *cf = new CreateForum(this);
|
||||
cf->show();
|
||||
CreateForum cf (this);
|
||||
cf.exec ();
|
||||
}
|
||||
|
||||
|
||||
void ForumsDialog::createmessage()
|
||||
{
|
||||
if (mCurrForumId == "")
|
||||
{
|
||||
if (mCurrForumId.empty ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CreateForumMsg *cfm = new CreateForumMsg(mCurrForumId, mCurrPostId);
|
||||
cfm->show();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void ForumsDialog::showthread()
|
||||
{
|
||||
if (mCurrForumId == "")
|
||||
{
|
||||
if (mCurrForumId.empty ()) {
|
||||
QMessageBox::information(this, tr("RetroShare"),tr("No Forum Selected!"));
|
||||
return;
|
||||
}
|
||||
@ -939,6 +1158,8 @@ void ForumsDialog::showthread()
|
||||
CreateForumMsg *cfm = new CreateForumMsg(mCurrForumId, "");
|
||||
cfm->setWindowTitle(tr("Start New Thread"));
|
||||
cfm->show();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void ForumsDialog::subscribeToForum()
|
||||
@ -967,18 +1188,15 @@ void ForumsDialog::forumSubscribe(bool subscribe)
|
||||
|
||||
void ForumsDialog::showForumDetails()
|
||||
{
|
||||
|
||||
static ForumDetails *fui = new ForumDetails();
|
||||
|
||||
if (mCurrForumId == "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fui->showDetails(mCurrForumId);
|
||||
fui->show();
|
||||
|
||||
ForumDetails fui;
|
||||
|
||||
fui.showDetails (mCurrForumId);
|
||||
fui.exec ();
|
||||
}
|
||||
|
||||
void ForumsDialog::loadForumEmoticons()
|
||||
@ -1056,10 +1274,8 @@ void ForumsDialog::replytomessage()
|
||||
ForumMsgInfo msgInfo ;
|
||||
rsForums->getForumMessage(fId,pId,msgInfo) ;
|
||||
|
||||
|
||||
if (rsPeers->getPeerName(msgInfo.srcId) !="")
|
||||
{
|
||||
|
||||
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
|
||||
nMsgDialog->newMsg();
|
||||
nMsgDialog->insertTitleText( (QString("Re: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ;
|
||||
@ -1073,7 +1289,6 @@ void ForumsDialog::replytomessage()
|
||||
nMsgDialog->addRecipient( msgInfo.srcId ) ;
|
||||
nMsgDialog->show();
|
||||
nMsgDialog->activateWindow();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -51,13 +51,8 @@ private slots:
|
||||
void checkUpdate();
|
||||
|
||||
void changedForum( QTreeWidgetItem *curr, QTreeWidgetItem *prev );
|
||||
void changedThread( QTreeWidgetItem *curr, QTreeWidgetItem *prev );
|
||||
void changedThread2();
|
||||
void changedThread();
|
||||
|
||||
void changeBox( int newrow );
|
||||
void updateMessages ( QTreeWidgetItem * item, int column );
|
||||
|
||||
void newmessage();
|
||||
|
||||
void replytomessage();
|
||||
//void print();
|
||||
@ -77,17 +72,30 @@ private slots:
|
||||
|
||||
void showForumDetails();
|
||||
|
||||
void previousMessage ();
|
||||
void nextMessage ();
|
||||
|
||||
private:
|
||||
|
||||
void forumSubscribe(bool subscribe);
|
||||
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 mCurrThreadId;
|
||||
std::string mCurrPostId;
|
||||
|
||||
QFont mForumNameFont;
|
||||
QFont itemFont;
|
||||
QFont m_ForumNameFont;
|
||||
QFont m_ItemFont;
|
||||
int m_LastViewType;
|
||||
std::string m_LastForumID;
|
||||
|
||||
QHash<QString, QString> smileys;
|
||||
|
||||
|
@ -960,7 +960,10 @@ background: white;}</string>
|
||||
</widget>
|
||||
</item>
|
||||
<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">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -989,7 +992,10 @@ background: white;}</string>
|
||||
</widget>
|
||||
</item>
|
||||
<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">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -59,6 +59,7 @@ CreateForumMsg::CreateForumMsg(std::string fId, std::string pId)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
RshareSettings config;
|
||||
config.loadWidgetInformation(this);
|
||||
|
Loading…
Reference in New Issue
Block a user