mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
few changes added to channel gui - list of groups and channels was replaced with a tree view
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1636 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
656380415d
commit
e26829e76a
@ -247,6 +247,7 @@ HEADERS += rshare.h \
|
||||
gui/TransferFeed.h \
|
||||
gui/ChannelFeed.h \
|
||||
gui/GeneralMsgDialog.h \
|
||||
gui/ChanGroupDelegate.h \
|
||||
gui/feeds/FeedHolder.h \
|
||||
gui/feeds/ForumNewItem.h \
|
||||
gui/feeds/ForumMsgItem.h \
|
||||
@ -459,6 +460,7 @@ SOURCES += main.cpp \
|
||||
gui/TransferFeed.cpp \
|
||||
gui/ChannelFeed.cpp \
|
||||
gui/GeneralMsgDialog.cpp \
|
||||
gui/ChanGroupDelegate.cpp \
|
||||
gui/feeds/ForumNewItem.cpp \
|
||||
gui/feeds/ForumMsgItem.cpp \
|
||||
gui/feeds/PeerItem.cpp \
|
||||
|
23
retroshare-gui/src/gui/ChanGroupDelegate.cpp
Normal file
23
retroshare-gui/src/gui/ChanGroupDelegate.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* ChanGroupDelegate.cpp
|
||||
*
|
||||
* Created on: Sep 7, 2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#include "ChanGroupDelegate.h"
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include <QColor>
|
||||
|
||||
void ChanGroupDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
|
||||
{
|
||||
if (index.child(0, 0).isValid()) {
|
||||
painter->setPen(Qt::blue);
|
||||
QStyleOptionButton opt;
|
||||
opt.rect = option.rect;
|
||||
QApplication::style()->drawControl(QStyle::CE_PushButtonBevel, &opt, painter);
|
||||
}
|
||||
|
||||
QItemDelegate::paint(painter, option, index);
|
||||
}
|
18
retroshare-gui/src/gui/ChanGroupDelegate.h
Normal file
18
retroshare-gui/src/gui/ChanGroupDelegate.h
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* ChanGroupDelegate.h
|
||||
*
|
||||
* Created on: Sep 7, 2009
|
||||
* Author: alex
|
||||
*/
|
||||
|
||||
#ifndef CHANGROUPDELEGATE_H_
|
||||
#define CHANGROUPDELEGATE_H_
|
||||
|
||||
#include <QItemDelegate>
|
||||
|
||||
class ChanGroupDelegate : public QItemDelegate
|
||||
{
|
||||
virtual void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||
};
|
||||
|
||||
#endif /* CHANGROUPDELEGATE_H_ */
|
@ -32,6 +32,8 @@
|
||||
|
||||
#include "gui/forums/CreateForum.h"
|
||||
|
||||
#include "gui/ChanGroupDelegate.h"
|
||||
|
||||
#include "GeneralMsgDialog.h"
|
||||
|
||||
/****
|
||||
@ -52,43 +54,43 @@ ChannelFeed::ChannelFeed(QWidget *parent)
|
||||
|
||||
/*************** Setup Left Hand Side (List of Channels) ****************/
|
||||
|
||||
mGroupLayout = new QVBoxLayout;
|
||||
mGroupLayout->setSpacing(0);
|
||||
mGroupLayout->setMargin(0);
|
||||
mGroupLayout->setContentsMargins(0,0,0,0);
|
||||
|
||||
mGroupOwn = new ChanGroupItem("Own Channels");
|
||||
mGroupSub = new ChanGroupItem("Subscribed Channels");
|
||||
mGroupPop = new ChanGroupItem("Popular Channels");
|
||||
mGroupOther = new ChanGroupItem("Other Channels");
|
||||
|
||||
mGroupLayout->addWidget(mGroupOwn);
|
||||
mGroupLayout->addWidget(mGroupSub);
|
||||
mGroupLayout->addWidget(mGroupPop);
|
||||
mGroupLayout->addWidget(mGroupOther);
|
||||
|
||||
|
||||
QWidget *middleWidget = new QWidget();
|
||||
//middleWidget->setSizePolicy( QSizePolicy::Policy::Maximum, QSizePolicy::Policy::Minimum);
|
||||
middleWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
|
||||
middleWidget->setLayout(mGroupLayout);
|
||||
|
||||
QScrollArea *scrollArea = new QScrollArea;
|
||||
//scrollArea->setBackgroundRole(QPalette::Dark);
|
||||
scrollArea->setWidget(middleWidget);
|
||||
scrollArea->setWidgetResizable(true);
|
||||
scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
|
||||
QVBoxLayout *layout2 = new QVBoxLayout;
|
||||
layout2->addWidget(scrollArea);
|
||||
layout2->setSpacing(0);
|
||||
layout2->setMargin(0);
|
||||
layout2->setContentsMargins(0,0,0,0);
|
||||
|
||||
|
||||
chanFrame->setLayout(layout2);
|
||||
|
||||
/*************** Setup Left Hand Side (List of Channels) ****************/
|
||||
// mGroupLayout = new QVBoxLayout;
|
||||
// mGroupLayout->setSpacing(0);
|
||||
// mGroupLayout->setMargin(0);
|
||||
// mGroupLayout->setContentsMargins(0,0,0,0);
|
||||
//
|
||||
// mGroupOwn = new ChanGroupItem("Own Channels");
|
||||
// mGroupSub = new ChanGroupItem("Subscribed Channels");
|
||||
// mGroupPop = new ChanGroupItem("Popular Channels");
|
||||
// mGroupOther = new ChanGroupItem("Other Channels");
|
||||
//
|
||||
// mGroupLayout->addWidget(mGroupOwn);
|
||||
// mGroupLayout->addWidget(mGroupSub);
|
||||
// mGroupLayout->addWidget(mGroupPop);
|
||||
// mGroupLayout->addWidget(mGroupOther);
|
||||
//
|
||||
//
|
||||
// QWidget *middleWidget = new QWidget();
|
||||
// //middleWidget->setSizePolicy( QSizePolicy::Policy::Maximum, QSizePolicy::Policy::Minimum);
|
||||
// middleWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
|
||||
// middleWidget->setLayout(mGroupLayout);
|
||||
//
|
||||
// QScrollArea *scrollArea = new QScrollArea;
|
||||
// //scrollArea->setBackgroundRole(QPalette::Dark);
|
||||
// scrollArea->setWidget(middleWidget);
|
||||
// scrollArea->setWidgetResizable(true);
|
||||
// scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
//
|
||||
// QVBoxLayout *layout2 = new QVBoxLayout;
|
||||
// layout2->addWidget(scrollArea);
|
||||
// layout2->setSpacing(0);
|
||||
// layout2->setMargin(0);
|
||||
// layout2->setContentsMargins(0,0,0,0);
|
||||
//
|
||||
//
|
||||
// chanFrame->setLayout(layout2);
|
||||
//
|
||||
/*************** Setup Right Hand Side (List of Messages) ****************/
|
||||
|
||||
mMsgLayout = new QVBoxLayout;
|
||||
mMsgLayout->setSpacing(0);
|
||||
@ -114,8 +116,43 @@ ChannelFeed::ChannelFeed(QWidget *parent)
|
||||
|
||||
msgFrame->setLayout(layout3);
|
||||
|
||||
mChannelId = "OWNID";
|
||||
// mChannelId = "OWNID";
|
||||
|
||||
// updateChannelList();
|
||||
//
|
||||
// QTimer *timer = new QTimer(this);
|
||||
// timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
|
||||
// timer->start(1000);
|
||||
|
||||
mChannelId = "";
|
||||
model = new QStandardItemModel(0, 2, this);
|
||||
model->setHeaderData(0, Qt::Horizontal, tr("Name"), Qt::DisplayRole);
|
||||
model->setHeaderData(1, Qt::Horizontal, tr("ID"), Qt::DisplayRole);
|
||||
|
||||
treeView->setModel(model);
|
||||
treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
|
||||
treeView->setItemDelegate(new ChanGroupDelegate());
|
||||
treeView->setRootIsDecorated(false);
|
||||
|
||||
// hide header and id column
|
||||
treeView->setHeaderHidden(true);
|
||||
treeView->hideColumn(1);
|
||||
|
||||
QStandardItem *item1 = new QStandardItem("Own Channels");
|
||||
QStandardItem *item2 = new QStandardItem("Subscribed Channels");
|
||||
QStandardItem *item3 = new QStandardItem("Popular Channels");
|
||||
QStandardItem *item4 = new QStandardItem("Other Channels");
|
||||
|
||||
model->appendRow(item1);
|
||||
model->appendRow(item2);
|
||||
model->appendRow(item3);
|
||||
model->appendRow(item4);
|
||||
|
||||
connect(treeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(selectChannel(const QModelIndex &)));
|
||||
connect(treeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(toggleSelection(const QModelIndex &)));
|
||||
|
||||
//added from ahead
|
||||
updateChannelList();
|
||||
|
||||
mChannelFont = QFont("MS SANS SERIF", 24);
|
||||
@ -124,7 +161,6 @@ ChannelFeed::ChannelFeed(QWidget *parent)
|
||||
QTimer *timer = new QTimer(this);
|
||||
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
|
||||
timer->start(1000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -209,6 +245,19 @@ void ChannelFeed::selectChannel( std::string cId)
|
||||
updateChannelMsgs();
|
||||
}
|
||||
|
||||
void ChannelFeed::selectChannel(const QModelIndex &index)
|
||||
{
|
||||
int row = index.row();
|
||||
int col = index.column();
|
||||
if (col != 1) {
|
||||
QModelIndex sibling = index.sibling(row, 1);
|
||||
if (sibling.isValid())
|
||||
mChannelId = sibling.data().toString().toStdString();
|
||||
} else
|
||||
mChannelId = index.data().toString().toStdString();
|
||||
updateChannelMsgs();
|
||||
}
|
||||
|
||||
void ChannelFeed::checkUpdate()
|
||||
{
|
||||
std::list<std::string> chanIds;
|
||||
@ -230,8 +279,6 @@ void ChannelFeed::checkUpdate()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ChannelFeed::updateChannelList()
|
||||
{
|
||||
|
||||
@ -323,117 +370,232 @@ void ChannelFeed::updateChannelList()
|
||||
|
||||
void ChannelFeed::updateChannelListOwn(std::list<std::string> &ids)
|
||||
{
|
||||
std::list<ChanMenuItem *>::iterator it;
|
||||
// std::list<ChanMenuItem *>::iterator it;
|
||||
std::list<std::string>::iterator iit;
|
||||
|
||||
/* TEMP just replace all of them */
|
||||
for(it = mChannelListOwn.begin(); it != mChannelListOwn.end(); it++)
|
||||
{
|
||||
delete (*it);
|
||||
}
|
||||
mChannelListOwn.clear();
|
||||
// /* TEMP just replace all of them */
|
||||
// for(it = mChannelListOwn.begin(); it != mChannelListOwn.end(); it++)
|
||||
// {
|
||||
// delete (*it);
|
||||
// }
|
||||
// mChannelListOwn.clear();
|
||||
//
|
||||
// int topIndex = mGroupLayout->indexOf(mGroupOwn);
|
||||
// int index = topIndex + 1;
|
||||
// for (iit = ids.begin(); iit != ids.end(); iit++, index++)
|
||||
// {
|
||||
//#ifdef CHAN_DEBUG
|
||||
// std::cerr << "ChannelFeed::updateChannelListOwn(): " << *iit << " at: " << index;
|
||||
// std::cerr << std::endl;
|
||||
//#endif
|
||||
//
|
||||
// ChanMenuItem *cmi = new ChanMenuItem(*iit);
|
||||
// mChannelListOwn.push_back(cmi);
|
||||
// mGroupLayout->insertWidget(index, cmi);
|
||||
//
|
||||
// connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string )));
|
||||
// }
|
||||
|
||||
int topIndex = mGroupLayout->indexOf(mGroupOwn);
|
||||
int index = topIndex + 1;
|
||||
for (iit = ids.begin(); iit != ids.end(); iit++, index++)
|
||||
{
|
||||
|
||||
/* remove rows with groups before adding new ones */
|
||||
model->item(OWN)->removeRows(0, model->item(OWN)->rowCount());
|
||||
|
||||
for (iit = ids.begin(); iit != ids.end(); iit ++) {
|
||||
#ifdef CHAN_DEBUG
|
||||
std::cerr << "ChannelFeed::updateChannelListOwn(): " << *iit << " at: " << index;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "ChannelFeed::updateChannelListOwn(): " << *iit << std::endl;
|
||||
#endif
|
||||
QStandardItem *ownGroup = model->item(OWN);
|
||||
QList<QStandardItem *> channel;
|
||||
QStandardItem *item1 = new QStandardItem();
|
||||
QStandardItem *item2 = new QStandardItem();
|
||||
|
||||
ChanMenuItem *cmi = new ChanMenuItem(*iit);
|
||||
mChannelListOwn.push_back(cmi);
|
||||
mGroupLayout->insertWidget(index, cmi);
|
||||
ChannelInfo ci;
|
||||
if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) {
|
||||
item1->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole);
|
||||
item2->setData(QVariant(QString::fromStdString(ci.channelId)), Qt::DisplayRole);
|
||||
item1->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3"
|
||||
).arg(QString::number(ci.pop)).arg(9999).arg(9999));
|
||||
} else {
|
||||
item1->setData(QVariant(QString("Unknown Channel")), Qt::DisplayRole);
|
||||
item2->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole);
|
||||
item1->setToolTip("Unknown Channel\nNo Description");
|
||||
}
|
||||
|
||||
connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string )));
|
||||
channel.append(item1);
|
||||
channel.append(item2);
|
||||
ownGroup->appendRow(channel);
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelFeed::updateChannelListSub(std::list<std::string> &ids)
|
||||
{
|
||||
std::list<ChanMenuItem *>::iterator it;
|
||||
// std::list<ChanMenuItem *>::iterator it;
|
||||
std::list<std::string>::iterator iit;
|
||||
|
||||
/* TEMP just replace all of them */
|
||||
for(it = mChannelListSub.begin(); it != mChannelListSub.end(); it++)
|
||||
{
|
||||
delete (*it);
|
||||
}
|
||||
mChannelListSub.clear();
|
||||
// /* TEMP just replace all of them */
|
||||
// for(it = mChannelListSub.begin(); it != mChannelListSub.end(); it++)
|
||||
// {
|
||||
// delete (*it);
|
||||
// }
|
||||
// mChannelListSub.clear();
|
||||
//
|
||||
// int topIndex = mGroupLayout->indexOf(mGroupSub);
|
||||
// int index = topIndex + 1;
|
||||
// for (iit = ids.begin(); iit != ids.end(); iit++, index++)
|
||||
// {
|
||||
//#ifdef CHAN_DEBUG
|
||||
// std::cerr << "ChannelFeed::updateChannelListSub(): " << *iit << " at: " << index;
|
||||
// std::cerr << std::endl;
|
||||
//#endif
|
||||
//
|
||||
// ChanMenuItem *cmi = new ChanMenuItem(*iit);
|
||||
// mChannelListSub.push_back(cmi);
|
||||
// mGroupLayout->insertWidget(index, cmi);
|
||||
// connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string )));
|
||||
// }
|
||||
|
||||
int topIndex = mGroupLayout->indexOf(mGroupSub);
|
||||
int index = topIndex + 1;
|
||||
for (iit = ids.begin(); iit != ids.end(); iit++, index++)
|
||||
{
|
||||
/* remove rows with groups before adding new ones */
|
||||
model->item(SUBSCRIBED)->removeRows(0, model->item(SUBSCRIBED)->rowCount());
|
||||
|
||||
for (iit = ids.begin(); iit != ids.end(); iit ++) {
|
||||
#ifdef CHAN_DEBUG
|
||||
std::cerr << "ChannelFeed::updateChannelListSub(): " << *iit << " at: " << index;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "ChannelFeed::updateChannelListSub(): " << *iit << std::endl;
|
||||
#endif
|
||||
QStandardItem *ownGroup = model->item(SUBSCRIBED);
|
||||
QList<QStandardItem *> channel;
|
||||
QStandardItem *item1 = new QStandardItem();
|
||||
QStandardItem *item2 = new QStandardItem();
|
||||
|
||||
ChanMenuItem *cmi = new ChanMenuItem(*iit);
|
||||
mChannelListSub.push_back(cmi);
|
||||
mGroupLayout->insertWidget(index, cmi);
|
||||
connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string )));
|
||||
ChannelInfo ci;
|
||||
if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) {
|
||||
item1->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole);
|
||||
item2->setData(QVariant(QString::fromStdString(ci.channelId)), Qt::DisplayRole);
|
||||
item1->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3"
|
||||
).arg(QString::number(ci.pop)).arg(9999).arg(9999));
|
||||
} else {
|
||||
item1->setData(QVariant(QString("Unknown Channel")), Qt::DisplayRole);
|
||||
item2->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole);
|
||||
item1->setToolTip("Unknown Channel\nNo Description");
|
||||
}
|
||||
|
||||
channel.append(item1);
|
||||
channel.append(item2);
|
||||
ownGroup->appendRow(channel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ChannelFeed::updateChannelListPop(std::list<std::string> &ids)
|
||||
{
|
||||
std::list<ChanMenuItem *>::iterator it;
|
||||
// std::list<ChanMenuItem *>::iterator it;
|
||||
std::list<std::string>::iterator iit;
|
||||
|
||||
/* TEMP just replace all of them */
|
||||
for(it = mChannelListPop.begin(); it != mChannelListPop.end(); it++)
|
||||
{
|
||||
delete (*it);
|
||||
}
|
||||
mChannelListPop.clear();
|
||||
// /* TEMP just replace all of them */
|
||||
// for(it = mChannelListPop.begin(); it != mChannelListPop.end(); it++)
|
||||
// {
|
||||
// delete (*it);
|
||||
// }
|
||||
// mChannelListPop.clear();
|
||||
//
|
||||
// int topIndex = mGroupLayout->indexOf(mGroupPop);
|
||||
// int index = topIndex + 1;
|
||||
// for (iit = ids.begin(); iit != ids.end(); iit++, index++)
|
||||
// {
|
||||
//#ifdef CHAN_DEBUG
|
||||
// std::cerr << "ChannelFeed::updateChannelListPop(): " << *iit << " at: " << index;
|
||||
// std::cerr << std::endl;
|
||||
//#endif
|
||||
//
|
||||
// ChanMenuItem *cmi = new ChanMenuItem(*iit);
|
||||
// mChannelListPop.push_back(cmi);
|
||||
// mGroupLayout->insertWidget(index, cmi);
|
||||
// connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string )));
|
||||
// }
|
||||
|
||||
int topIndex = mGroupLayout->indexOf(mGroupPop);
|
||||
int index = topIndex + 1;
|
||||
for (iit = ids.begin(); iit != ids.end(); iit++, index++)
|
||||
{
|
||||
/* remove rows with groups before adding new ones */
|
||||
model->item(POPULAR)->removeRows(0, model->item(POPULAR)->rowCount());
|
||||
|
||||
for (iit = ids.begin(); iit != ids.end(); iit ++) {
|
||||
#ifdef CHAN_DEBUG
|
||||
std::cerr << "ChannelFeed::updateChannelListPop(): " << *iit << " at: " << index;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "ChannelFeed::updateChannelListPop(): " << *iit << std::endl;
|
||||
#endif
|
||||
QStandardItem *ownGroup = model->item(POPULAR);
|
||||
QList<QStandardItem *> channel;
|
||||
QStandardItem *item1 = new QStandardItem();
|
||||
QStandardItem *item2 = new QStandardItem();
|
||||
|
||||
ChanMenuItem *cmi = new ChanMenuItem(*iit);
|
||||
mChannelListPop.push_back(cmi);
|
||||
mGroupLayout->insertWidget(index, cmi);
|
||||
connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string )));
|
||||
ChannelInfo ci;
|
||||
if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) {
|
||||
item1->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole);
|
||||
item2->setData(QVariant(QString::fromStdString(ci.channelId)), Qt::DisplayRole);
|
||||
item1->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3"
|
||||
).arg(QString::number(ci.pop)).arg(9999).arg(9999));
|
||||
} else {
|
||||
item1->setData(QVariant(QString("Unknown Channel")), Qt::DisplayRole);
|
||||
item2->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole);
|
||||
item1->setToolTip("Unknown Channel\nNo Description");
|
||||
}
|
||||
|
||||
|
||||
channel.append(item1);
|
||||
channel.append(item2);
|
||||
ownGroup->appendRow(channel);
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelFeed::updateChannelListOther(std::list<std::string> &ids)
|
||||
{
|
||||
std::list<ChanMenuItem *>::iterator it;
|
||||
// std::list<ChanMenuItem *>::iterator it;
|
||||
std::list<std::string>::iterator iit;
|
||||
|
||||
/* TEMP just replace all of them */
|
||||
for(it = mChannelListOther.begin(); it != mChannelListOther.end(); it++)
|
||||
{
|
||||
delete (*it);
|
||||
}
|
||||
mChannelListOther.clear();
|
||||
// /* TEMP just replace all of them */
|
||||
// for(it = mChannelListOther.begin(); it != mChannelListOther.end(); it++)
|
||||
// {
|
||||
// delete (*it);
|
||||
// }
|
||||
// mChannelListOther.clear();
|
||||
//
|
||||
// int topIndex = mGroupLayout->indexOf(mGroupOther);
|
||||
// int index = topIndex + 1;
|
||||
// for (iit = ids.begin(); iit != ids.end(); iit++, index++)
|
||||
// {
|
||||
//#ifdef CHAN_DEBUG
|
||||
// std::cerr << "ChannelFeed::updateChannelListOther(): " << *iit << " at: " << index;
|
||||
// std::cerr << std::endl;
|
||||
//#endif
|
||||
//
|
||||
// ChanMenuItem *cmi = new ChanMenuItem(*iit);
|
||||
// mChannelListOther.push_back(cmi);
|
||||
// mGroupLayout->insertWidget(index, cmi);
|
||||
// connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string )));
|
||||
// }
|
||||
|
||||
int topIndex = mGroupLayout->indexOf(mGroupOther);
|
||||
int index = topIndex + 1;
|
||||
for (iit = ids.begin(); iit != ids.end(); iit++, index++)
|
||||
{
|
||||
/* remove rows with groups before adding new ones */
|
||||
model->item(OTHER)->removeRows(0, model->item(OTHER)->rowCount());
|
||||
|
||||
for (iit = ids.begin(); iit != ids.end(); iit ++) {
|
||||
#ifdef CHAN_DEBUG
|
||||
std::cerr << "ChannelFeed::updateChannelListOther(): " << *iit << " at: " << index;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "ChannelFeed::updateChannelListOther(): " << *iit << std::endl;
|
||||
#endif
|
||||
QStandardItem *ownGroup = model->item(OTHER);
|
||||
QList<QStandardItem *> channel;
|
||||
QStandardItem *item1 = new QStandardItem();
|
||||
QStandardItem *item2 = new QStandardItem();
|
||||
|
||||
ChanMenuItem *cmi = new ChanMenuItem(*iit);
|
||||
mChannelListOther.push_back(cmi);
|
||||
mGroupLayout->insertWidget(index, cmi);
|
||||
connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string )));
|
||||
ChannelInfo ci;
|
||||
if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) {
|
||||
item1->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole);
|
||||
item2->setData(QVariant(QString::fromStdString(ci.channelId)), Qt::DisplayRole);
|
||||
item1->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3"
|
||||
).arg(QString::number(ci.pop)).arg(9999).arg(9999));
|
||||
} else {
|
||||
item1->setData(QVariant(QString("Unknown Channel")), Qt::DisplayRole);
|
||||
item2->setData(QVariant(QString::fromStdString(*iit)), Qt::DisplayRole);
|
||||
item1->setToolTip("Unknown Channel\nNo Description");
|
||||
}
|
||||
|
||||
channel.append(item1);
|
||||
channel.append(item2);
|
||||
ownGroup->appendRow(channel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -498,9 +660,6 @@ void ChannelFeed::updateChannelMsgs()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ChannelFeed::unsubscribeChannel()
|
||||
{
|
||||
#ifdef CHAN_DEBUG
|
||||
@ -529,5 +688,9 @@ void ChannelFeed::subscribeChannel()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ChannelFeed::toggleSelection(const QModelIndex &index)
|
||||
{
|
||||
QItemSelectionModel *selectionModel = treeView->selectionModel();
|
||||
if (index.child(0, 0).isValid())
|
||||
selectionModel->select(index, QItemSelectionModel::Toggle);
|
||||
}
|
||||
|
@ -25,12 +25,20 @@
|
||||
#include "mainpage.h"
|
||||
#include "ui_ChannelFeed.h"
|
||||
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include "gui/feeds/FeedHolder.h"
|
||||
|
||||
#define OWN 0
|
||||
#define SUBSCRIBED 1
|
||||
#define POPULAR 2
|
||||
#define OTHER 3
|
||||
|
||||
class ChanGroupItem;
|
||||
class ChanMenuItem;
|
||||
class ChanMsgItem;
|
||||
|
||||
|
||||
class ChannelFeed : public MainPage, public FeedHolder, private Ui::ChannelFeed
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -48,6 +56,8 @@ virtual void openMsg(uint32_t type, std::string grpId, std::string inReplyTo);
|
||||
public slots:
|
||||
|
||||
void selectChannel( std::string );
|
||||
void selectChannel(const QModelIndex &);
|
||||
void toggleSelection(const QModelIndex &);
|
||||
|
||||
private slots:
|
||||
|
||||
@ -71,23 +81,25 @@ private:
|
||||
|
||||
void updateChannelMsgs();
|
||||
|
||||
QStandardItemModel *model;
|
||||
|
||||
std::string mChannelId; /* current Channel */
|
||||
|
||||
/* Layout Pointers */
|
||||
QBoxLayout *mGroupLayout;
|
||||
// QBoxLayout *mGroupLayout;
|
||||
QBoxLayout *mMsgLayout;
|
||||
|
||||
/* Group Headers */
|
||||
ChanGroupItem *mGroupOwn;
|
||||
ChanGroupItem *mGroupSub;
|
||||
ChanGroupItem *mGroupPop;
|
||||
ChanGroupItem *mGroupOther;
|
||||
// ChanGroupItem *mGroupOwn;
|
||||
// ChanGroupItem *mGroupSub;
|
||||
// ChanGroupItem *mGroupPop;
|
||||
// ChanGroupItem *mGroupOther;
|
||||
|
||||
/* lists of feedItems */
|
||||
std::list<ChanMenuItem *> mChannelListOwn;
|
||||
std::list<ChanMenuItem *> mChannelListSub;
|
||||
std::list<ChanMenuItem *> mChannelListPop;
|
||||
std::list<ChanMenuItem *> mChannelListOther;
|
||||
// std::list<ChanMenuItem *> mChannelListOwn;
|
||||
// std::list<ChanMenuItem *> mChannelListSub;
|
||||
// std::list<ChanMenuItem *> mChannelListPop;
|
||||
// std::list<ChanMenuItem *> mChannelListOther;
|
||||
|
||||
std::list<ChanMsgItem *> mChanMsgItems;
|
||||
|
||||
|
@ -64,6 +64,11 @@
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeView" name="treeView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="2">
|
||||
|
Loading…
Reference in New Issue
Block a user