mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -05:00
resurrected prev/next buttons
This commit is contained in:
parent
581e892d94
commit
3a76f25152
@ -494,7 +494,7 @@ void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<F
|
|||||||
|
|
||||||
bool has_unread_below,has_read_below ;
|
bool has_unread_below,has_read_below ;
|
||||||
recursUpdateReadStatus(0,has_unread_below,has_read_below) ;
|
recursUpdateReadStatus(0,has_unread_below,has_read_below) ;
|
||||||
#ifdef DEBUG_FORUMMODEL
|
#ifndef DEBUG_FORUMMODEL
|
||||||
debug_dump();
|
debug_dump();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1009,19 +1009,6 @@ void RsGxsForumModel::recursUpdateReadStatus(ForumModelIndex i,bool& has_unread_
|
|||||||
mPosts[i].mPostFlags &= ~ForumModelPostEntry::FLAG_POST_HAS_READ_CHILDREN;
|
mPosts[i].mPostFlags &= ~ForumModelPostEntry::FLAG_POST_HAS_READ_CHILDREN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void recursPrintModel(const std::vector<ForumModelPostEntry>& entries,ForumModelIndex index,int depth)
|
|
||||||
{
|
|
||||||
const ForumModelPostEntry& e(entries[index]);
|
|
||||||
|
|
||||||
std::cerr << std::string(depth*2,' ') << e.mAuthorId.toStdString() << " "
|
|
||||||
<< QString("%1").arg((uint32_t)e.mPostFlags,8,16,QChar('0')).toStdString() << " "
|
|
||||||
<< QString("%1").arg((uint32_t)e.mMsgStatus,8,16,QChar('0')).toStdString() << " "
|
|
||||||
<< QDateTime::fromSecsSinceEpoch(e.mPublishTs).toString().toStdString() << " \"" << e.mTitle << "\"" << std::endl;
|
|
||||||
|
|
||||||
for(uint32_t i=0;i<e.mChildren.size();++i)
|
|
||||||
recursPrintModel(entries,e.mChildren[i],depth+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
QModelIndex RsGxsForumModel::getIndexOfMessage(const RsGxsMessageId& mid) const
|
QModelIndex RsGxsForumModel::getIndexOfMessage(const RsGxsMessageId& mid) const
|
||||||
{
|
{
|
||||||
// brutal search. This is not so nice, so dont call that in a loop!
|
// brutal search. This is not so nice, so dont call that in a loop!
|
||||||
@ -1038,8 +1025,21 @@ QModelIndex RsGxsForumModel::getIndexOfMessage(const RsGxsMessageId& mid) const
|
|||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RsGxsForumModel::test_iterator() const
|
||||||
|
{
|
||||||
|
const_iterator it(*this);
|
||||||
|
|
||||||
|
while(it)
|
||||||
|
{
|
||||||
|
std::cerr << "Current node: " << *it << std::endl;
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QModelIndex RsGxsForumModel::getNextIndex(const QModelIndex& i,bool unread_only) const
|
QModelIndex RsGxsForumModel::getNextIndex(const QModelIndex& i,bool unread_only) const
|
||||||
{
|
{
|
||||||
|
test_iterator();
|
||||||
|
|
||||||
ForumModelIndex fmi ;
|
ForumModelIndex fmi ;
|
||||||
convertRefPointerToTabEntry(i.internalPointer(),fmi);
|
convertRefPointerToTabEntry(i.internalPointer(),fmi);
|
||||||
|
|
||||||
@ -1130,6 +1130,20 @@ RsGxsForumModel::const_iterator::operator bool() const
|
|||||||
return kid >= 0;
|
return kid >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void recursPrintModel(const std::vector<ForumModelPostEntry>& entries,ForumModelIndex index,int depth)
|
||||||
|
{
|
||||||
|
const ForumModelPostEntry& e(entries[index]);
|
||||||
|
|
||||||
|
std::cerr << std::string(depth*2,' ') << index << " : " << e.mAuthorId.toStdString() << " "
|
||||||
|
<< QString("%1").arg((uint32_t)e.mPostFlags,8,16,QChar('0')).toStdString() << " "
|
||||||
|
<< QString("%1").arg((uint32_t)e.mMsgStatus,8,16,QChar('0')).toStdString() << " "
|
||||||
|
<< QDateTime::fromSecsSinceEpoch(e.mPublishTs).toString().toStdString() << " \"" << e.mTitle << "\"" << std::endl;
|
||||||
|
|
||||||
|
for(uint32_t i=0;i<e.mChildren.size();++i)
|
||||||
|
recursPrintModel(entries,e.mChildren[i],depth+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void RsGxsForumModel::debug_dump()
|
void RsGxsForumModel::debug_dump()
|
||||||
{
|
{
|
||||||
std::cerr << "Model data dump:" << std::endl;
|
std::cerr << "Model data dump:" << std::endl;
|
||||||
|
@ -99,6 +99,7 @@ public:
|
|||||||
ForumModelIndex current_parent;
|
ForumModelIndex current_parent;
|
||||||
const RsGxsForumModel& model;
|
const RsGxsForumModel& model;
|
||||||
};
|
};
|
||||||
|
void test_iterator() const;
|
||||||
|
|
||||||
// This method will asynchroneously update the data
|
// This method will asynchroneously update the data
|
||||||
void setForum(const RsGxsGroupId& forumGroup);
|
void setForum(const RsGxsGroupId& forumGroup);
|
||||||
|
@ -1825,24 +1825,24 @@ void GxsForumThreadWidget::insertMessage()
|
|||||||
mStateHelper->setActive(mTokenTypeMessageData, true);
|
mStateHelper->setActive(mTokenTypeMessageData, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TODO
|
QModelIndex index = getCurrentIndex();
|
||||||
QTreeWidgetItem *item = ui->threadTreeWidget->currentItem();
|
|
||||||
|
|
||||||
if (item) {
|
if (index.isValid())
|
||||||
QTreeWidgetItem *parentItem = item->parent();
|
{
|
||||||
int index = parentItem ? parentItem->indexOfChild(item) : ui->threadTreeWidget->indexOfTopLevelItem(item);
|
QModelIndex parentIndex = index.parent();
|
||||||
int count = parentItem ? parentItem->childCount() : ui->threadTreeWidget->topLevelItemCount();
|
int curr_index = index.row();
|
||||||
mStateHelper->setWidgetEnabled(ui->previousButton, (index > 0));
|
int count = mThreadModel->rowCount(parentIndex);
|
||||||
mStateHelper->setWidgetEnabled(ui->nextButton, (index < count - 1));
|
|
||||||
|
ui->previousButton->setEnabled(curr_index > 0);
|
||||||
|
ui->nextButton->setEnabled(curr_index < count - 1);
|
||||||
} else {
|
} else {
|
||||||
// there is something wrong
|
// there is something wrong
|
||||||
mStateHelper->setWidgetEnabled(ui->previousButton, false);
|
ui->previousButton->setEnabled(false);
|
||||||
mStateHelper->setWidgetEnabled(ui->nextButton, false);
|
ui->nextButton->setEnabled(false);
|
||||||
ui->versions_CB->hide();
|
ui->versions_CB->hide();
|
||||||
ui->time_label->show();
|
ui->time_label->show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
mStateHelper->setWidgetEnabled(ui->newmessageButton, (IS_GROUP_SUBSCRIBED(mSubscribeFlags) && mThreadId.isNull() == false));
|
mStateHelper->setWidgetEnabled(ui->newmessageButton, (IS_GROUP_SUBSCRIBED(mSubscribeFlags) && mThreadId.isNull() == false));
|
||||||
|
|
||||||
@ -1984,41 +1984,53 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
|
|||||||
|
|
||||||
void GxsForumThreadWidget::previousMessage()
|
void GxsForumThreadWidget::previousMessage()
|
||||||
{
|
{
|
||||||
#ifdef TODO
|
QModelIndex current_index = getCurrentIndex();
|
||||||
QTreeWidgetItem *item = ui->threadTreeWidget->currentItem();
|
|
||||||
if (item == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTreeWidgetItem *parentItem = item->parent();
|
if (!current_index.isValid())
|
||||||
int index = parentItem ? parentItem->indexOfChild(item) : ui->threadTreeWidget->indexOfTopLevelItem(item);
|
return;
|
||||||
if (index > 0) {
|
|
||||||
QTreeWidgetItem *previousItem = parentItem ? parentItem->child(index - 1) : ui->threadTreeWidget->topLevelItem(index - 1);
|
QModelIndex parentIndex = current_index.parent();
|
||||||
if (previousItem) {
|
|
||||||
ui->threadTreeWidget->setCurrentItem(previousItem);
|
int index = current_index.row();
|
||||||
|
int count = mThreadModel->rowCount(parentIndex) ;
|
||||||
|
|
||||||
|
if (index > 0)
|
||||||
|
{
|
||||||
|
QModelIndex prevItem = mThreadModel->index(index - 1,0,parentIndex) ;
|
||||||
|
|
||||||
|
if (prevItem.isValid()) {
|
||||||
|
ui->threadTreeWidget->setCurrentIndex(prevItem);
|
||||||
|
ui->threadTreeWidget->setFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
ui->previousButton->setEnabled(index-1 > 0);
|
||||||
|
ui->nextButton->setEnabled(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumThreadWidget::nextMessage()
|
void GxsForumThreadWidget::nextMessage()
|
||||||
{
|
{
|
||||||
#ifdef TODO
|
QModelIndex current_index = getCurrentIndex();
|
||||||
QTreeWidgetItem *item = ui->threadTreeWidget->currentItem();
|
|
||||||
if (item == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTreeWidgetItem *parentItem = item->parent();
|
if (!current_index.isValid())
|
||||||
int index = parentItem ? parentItem->indexOfChild(item) : ui->threadTreeWidget->indexOfTopLevelItem(item);
|
return;
|
||||||
int count = parentItem ? parentItem->childCount() : ui->threadTreeWidget->topLevelItemCount();
|
|
||||||
if (index < count - 1) {
|
QModelIndex parentIndex = current_index.parent();
|
||||||
QTreeWidgetItem *nextItem = parentItem ? parentItem->child(index + 1) : ui->threadTreeWidget->topLevelItem(index + 1);
|
|
||||||
if (nextItem) {
|
int index = current_index.row();
|
||||||
ui->threadTreeWidget->setCurrentItem(nextItem);
|
int count = mThreadModel->rowCount(parentIndex) ;
|
||||||
|
|
||||||
|
if (index < count - 1)
|
||||||
|
{
|
||||||
|
QModelIndex nextItem = mThreadModel->index(index + 1,0,parentIndex) ;
|
||||||
|
|
||||||
|
if (nextItem.isValid()) {
|
||||||
|
ui->threadTreeWidget->setCurrentIndex(nextItem);
|
||||||
|
ui->threadTreeWidget->setFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
ui->previousButton->setEnabled(true);
|
||||||
|
ui->nextButton->setEnabled(index+1 < count - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumThreadWidget::downloadAllFiles()
|
void GxsForumThreadWidget::downloadAllFiles()
|
||||||
|
Loading…
Reference in New Issue
Block a user