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:
alexandrut 2009-09-12 10:55:40 +00:00
parent 656380415d
commit e26829e76a
6 changed files with 361 additions and 138 deletions

View File

@ -246,7 +246,8 @@ HEADERS += rshare.h \
gui/MsgFeed.h \ gui/MsgFeed.h \
gui/TransferFeed.h \ gui/TransferFeed.h \
gui/ChannelFeed.h \ gui/ChannelFeed.h \
gui/GeneralMsgDialog.h \ gui/GeneralMsgDialog.h \
gui/ChanGroupDelegate.h \
gui/feeds/FeedHolder.h \ gui/feeds/FeedHolder.h \
gui/feeds/ForumNewItem.h \ gui/feeds/ForumNewItem.h \
gui/feeds/ForumMsgItem.h \ gui/feeds/ForumMsgItem.h \
@ -458,7 +459,8 @@ SOURCES += main.cpp \
gui/MsgFeed.cpp \ gui/MsgFeed.cpp \
gui/TransferFeed.cpp \ gui/TransferFeed.cpp \
gui/ChannelFeed.cpp \ gui/ChannelFeed.cpp \
gui/GeneralMsgDialog.cpp \ gui/GeneralMsgDialog.cpp \
gui/ChanGroupDelegate.cpp \
gui/feeds/ForumNewItem.cpp \ gui/feeds/ForumNewItem.cpp \
gui/feeds/ForumMsgItem.cpp \ gui/feeds/ForumMsgItem.cpp \
gui/feeds/PeerItem.cpp \ gui/feeds/PeerItem.cpp \

View 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);
}

View 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_ */

View File

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#include <QtGui> #include <QtGui>
@ -32,6 +32,8 @@
#include "gui/forums/CreateForum.h" #include "gui/forums/CreateForum.h"
#include "gui/ChanGroupDelegate.h"
#include "GeneralMsgDialog.h" #include "GeneralMsgDialog.h"
/**** /****
@ -52,43 +54,43 @@ ChannelFeed::ChannelFeed(QWidget *parent)
/*************** Setup Left Hand Side (List of Channels) ****************/ /*************** Setup Left Hand Side (List of Channels) ****************/
mGroupLayout = new QVBoxLayout; // mGroupLayout = new QVBoxLayout;
mGroupLayout->setSpacing(0); // mGroupLayout->setSpacing(0);
mGroupLayout->setMargin(0); // mGroupLayout->setMargin(0);
mGroupLayout->setContentsMargins(0,0,0,0); // mGroupLayout->setContentsMargins(0,0,0,0);
//
mGroupOwn = new ChanGroupItem("Own Channels"); // mGroupOwn = new ChanGroupItem("Own Channels");
mGroupSub = new ChanGroupItem("Subscribed Channels"); // mGroupSub = new ChanGroupItem("Subscribed Channels");
mGroupPop = new ChanGroupItem("Popular Channels"); // mGroupPop = new ChanGroupItem("Popular Channels");
mGroupOther = new ChanGroupItem("Other Channels"); // mGroupOther = new ChanGroupItem("Other Channels");
//
mGroupLayout->addWidget(mGroupOwn); // mGroupLayout->addWidget(mGroupOwn);
mGroupLayout->addWidget(mGroupSub); // mGroupLayout->addWidget(mGroupSub);
mGroupLayout->addWidget(mGroupPop); // mGroupLayout->addWidget(mGroupPop);
mGroupLayout->addWidget(mGroupOther); // mGroupLayout->addWidget(mGroupOther);
//
//
QWidget *middleWidget = new QWidget(); // QWidget *middleWidget = new QWidget();
//middleWidget->setSizePolicy( QSizePolicy::Policy::Maximum, QSizePolicy::Policy::Minimum); // //middleWidget->setSizePolicy( QSizePolicy::Policy::Maximum, QSizePolicy::Policy::Minimum);
middleWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); // middleWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
middleWidget->setLayout(mGroupLayout); // middleWidget->setLayout(mGroupLayout);
//
QScrollArea *scrollArea = new QScrollArea; // QScrollArea *scrollArea = new QScrollArea;
//scrollArea->setBackgroundRole(QPalette::Dark); // //scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(middleWidget); // scrollArea->setWidget(middleWidget);
scrollArea->setWidgetResizable(true); // scrollArea->setWidgetResizable(true);
scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); // scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
//
QVBoxLayout *layout2 = new QVBoxLayout; // QVBoxLayout *layout2 = new QVBoxLayout;
layout2->addWidget(scrollArea); // layout2->addWidget(scrollArea);
layout2->setSpacing(0); // layout2->setSpacing(0);
layout2->setMargin(0); // layout2->setMargin(0);
layout2->setContentsMargins(0,0,0,0); // layout2->setContentsMargins(0,0,0,0);
//
//
chanFrame->setLayout(layout2); // chanFrame->setLayout(layout2);
//
/*************** Setup Left Hand Side (List of Channels) ****************/ /*************** Setup Right Hand Side (List of Messages) ****************/
mMsgLayout = new QVBoxLayout; mMsgLayout = new QVBoxLayout;
mMsgLayout->setSpacing(0); mMsgLayout->setSpacing(0);
@ -99,8 +101,8 @@ ChannelFeed::ChannelFeed(QWidget *parent)
middleWidget2->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); middleWidget2->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
middleWidget2->setLayout(mMsgLayout); middleWidget2->setLayout(mMsgLayout);
QScrollArea *scrollArea2 = new QScrollArea; QScrollArea *scrollArea2 = new QScrollArea;
//scrollArea2->setBackgroundRole(QPalette::Dark); //scrollArea2->setBackgroundRole(QPalette::Dark);
scrollArea2->setWidget(middleWidget2); scrollArea2->setWidget(middleWidget2);
scrollArea2->setWidgetResizable(true); scrollArea2->setWidgetResizable(true);
scrollArea2->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); scrollArea2->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
@ -112,19 +114,53 @@ ChannelFeed::ChannelFeed(QWidget *parent)
layout3->setContentsMargins(0,0,0,0); layout3->setContentsMargins(0,0,0,0);
msgFrame->setLayout(layout3); 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(); updateChannelList();
mChannelFont = QFont("MS SANS SERIF", 24); mChannelFont = QFont("MS SANS SERIF", 24);
nameLabel->setFont(mChannelFont); nameLabel->setFont(mChannelFont);
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate())); timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
timer->start(1000); timer->start(1000);
} }
@ -135,7 +171,7 @@ void ChannelFeed::createChannel()
cf->setWindowTitle(tr("Create a new Channel")); cf->setWindowTitle(tr("Create a new Channel"));
cf->ui.labelicon->setPixmap(QPixmap(":/images/add_channel64.png")); cf->ui.labelicon->setPixmap(QPixmap(":/images/add_channel64.png"));
QString titleStr("<span style=\"font-size:16pt; font-weight:500;" QString titleStr("<span style=\"font-size:16pt; font-weight:500;"
"color:#32cd32;\">%1</span>"); "color:#32cd32;\">%1</span>");
cf->ui.textlabelcreatforums->setText( titleStr.arg( tr("Create a new Channel") ) ) ; cf->ui.textlabelcreatforums->setText( titleStr.arg( tr("Create a new Channel") ) ) ;
cf->show(); cf->show();
} }
@ -209,6 +245,19 @@ void ChannelFeed::selectChannel( std::string cId)
updateChannelMsgs(); 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() void ChannelFeed::checkUpdate()
{ {
std::list<std::string> chanIds; std::list<std::string> chanIds;
@ -230,8 +279,6 @@ void ChannelFeed::checkUpdate()
} }
void ChannelFeed::updateChannelList() void ChannelFeed::updateChannelList()
{ {
@ -323,117 +370,232 @@ void ChannelFeed::updateChannelList()
void ChannelFeed::updateChannelListOwn(std::list<std::string> &ids) void ChannelFeed::updateChannelListOwn(std::list<std::string> &ids)
{ {
std::list<ChanMenuItem *>::iterator it; // std::list<ChanMenuItem *>::iterator it;
std::list<std::string>::iterator iit; std::list<std::string>::iterator iit;
/* TEMP just replace all of them */ // /* TEMP just replace all of them */
for(it = mChannelListOwn.begin(); it != mChannelListOwn.end(); it++) // for(it = mChannelListOwn.begin(); it != mChannelListOwn.end(); it++)
{ // {
delete (*it); // delete (*it);
} // }
mChannelListOwn.clear(); // 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; /* remove rows with groups before adding new ones */
for (iit = ids.begin(); iit != ids.end(); iit++, index++) model->item(OWN)->removeRows(0, model->item(OWN)->rowCount());
{
for (iit = ids.begin(); iit != ids.end(); iit ++) {
#ifdef CHAN_DEBUG #ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::updateChannelListOwn(): " << *iit << " at: " << index; std::cerr << "ChannelFeed::updateChannelListOwn(): " << *iit << std::endl;
std::cerr << std::endl;
#endif #endif
QStandardItem *ownGroup = model->item(OWN);
QList<QStandardItem *> channel;
QStandardItem *item1 = new QStandardItem();
QStandardItem *item2 = new QStandardItem();
ChanMenuItem *cmi = new ChanMenuItem(*iit); ChannelInfo ci;
mChannelListOwn.push_back(cmi); if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) {
mGroupLayout->insertWidget(index, cmi); item1->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole);
item2->setData(QVariant(QString::fromStdString(ci.channelId)), Qt::DisplayRole);
connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string ))); 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::updateChannelListSub(std::list<std::string> &ids) void ChannelFeed::updateChannelListSub(std::list<std::string> &ids)
{ {
std::list<ChanMenuItem *>::iterator it; // std::list<ChanMenuItem *>::iterator it;
std::list<std::string>::iterator iit; std::list<std::string>::iterator iit;
/* TEMP just replace all of them */ // /* TEMP just replace all of them */
for(it = mChannelListSub.begin(); it != mChannelListSub.end(); it++) // for(it = mChannelListSub.begin(); it != mChannelListSub.end(); it++)
{ // {
delete (*it); // delete (*it);
} // }
mChannelListSub.clear(); // 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); /* remove rows with groups before adding new ones */
int index = topIndex + 1; model->item(SUBSCRIBED)->removeRows(0, model->item(SUBSCRIBED)->rowCount());
for (iit = ids.begin(); iit != ids.end(); iit++, index++)
{ for (iit = ids.begin(); iit != ids.end(); iit ++) {
#ifdef CHAN_DEBUG #ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::updateChannelListSub(): " << *iit << " at: " << index; std::cerr << "ChannelFeed::updateChannelListSub(): " << *iit << std::endl;
std::cerr << std::endl;
#endif #endif
QStandardItem *ownGroup = model->item(SUBSCRIBED);
QList<QStandardItem *> channel;
QStandardItem *item1 = new QStandardItem();
QStandardItem *item2 = new QStandardItem();
ChanMenuItem *cmi = new ChanMenuItem(*iit); ChannelInfo ci;
mChannelListSub.push_back(cmi); if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) {
mGroupLayout->insertWidget(index, cmi); item1->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole);
connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string ))); 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) void ChannelFeed::updateChannelListPop(std::list<std::string> &ids)
{ {
std::list<ChanMenuItem *>::iterator it; // std::list<ChanMenuItem *>::iterator it;
std::list<std::string>::iterator iit; std::list<std::string>::iterator iit;
/* TEMP just replace all of them */ // /* TEMP just replace all of them */
for(it = mChannelListPop.begin(); it != mChannelListPop.end(); it++) // for(it = mChannelListPop.begin(); it != mChannelListPop.end(); it++)
{ // {
delete (*it); // delete (*it);
} // }
mChannelListPop.clear(); // 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); /* remove rows with groups before adding new ones */
int index = topIndex + 1; model->item(POPULAR)->removeRows(0, model->item(POPULAR)->rowCount());
for (iit = ids.begin(); iit != ids.end(); iit++, index++)
{ for (iit = ids.begin(); iit != ids.end(); iit ++) {
#ifdef CHAN_DEBUG #ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::updateChannelListPop(): " << *iit << " at: " << index; std::cerr << "ChannelFeed::updateChannelListPop(): " << *iit << std::endl;
std::cerr << std::endl;
#endif #endif
QStandardItem *ownGroup = model->item(POPULAR);
QList<QStandardItem *> channel;
QStandardItem *item1 = new QStandardItem();
QStandardItem *item2 = new QStandardItem();
ChanMenuItem *cmi = new ChanMenuItem(*iit); ChannelInfo ci;
mChannelListPop.push_back(cmi); if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) {
mGroupLayout->insertWidget(index, cmi); item1->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole);
connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string ))); 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) void ChannelFeed::updateChannelListOther(std::list<std::string> &ids)
{ {
std::list<ChanMenuItem *>::iterator it; // std::list<ChanMenuItem *>::iterator it;
std::list<std::string>::iterator iit; std::list<std::string>::iterator iit;
/* TEMP just replace all of them */ // /* TEMP just replace all of them */
for(it = mChannelListOther.begin(); it != mChannelListOther.end(); it++) // for(it = mChannelListOther.begin(); it != mChannelListOther.end(); it++)
{ // {
delete (*it); // delete (*it);
} // }
mChannelListOther.clear(); // 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); /* remove rows with groups before adding new ones */
int index = topIndex + 1; model->item(OTHER)->removeRows(0, model->item(OTHER)->rowCount());
for (iit = ids.begin(); iit != ids.end(); iit++, index++)
{ for (iit = ids.begin(); iit != ids.end(); iit ++) {
#ifdef CHAN_DEBUG #ifdef CHAN_DEBUG
std::cerr << "ChannelFeed::updateChannelListOther(): " << *iit << " at: " << index; std::cerr << "ChannelFeed::updateChannelListOther(): " << *iit << std::endl;
std::cerr << std::endl;
#endif #endif
QStandardItem *ownGroup = model->item(OTHER);
QList<QStandardItem *> channel;
QStandardItem *item1 = new QStandardItem();
QStandardItem *item2 = new QStandardItem();
ChanMenuItem *cmi = new ChanMenuItem(*iit); ChannelInfo ci;
mChannelListOther.push_back(cmi); if (rsChannels && rsChannels->getChannelInfo(*iit, ci)) {
mGroupLayout->insertWidget(index, cmi); item1->setData(QVariant(QString::fromStdWString(ci.channelName)), Qt::DisplayRole);
connect(cmi, SIGNAL( selectMe( std::string )), this, SLOT( selectChannel( std::string ))); 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() void ChannelFeed::unsubscribeChannel()
{ {
#ifdef CHAN_DEBUG #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);
}

View File

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -25,12 +25,20 @@
#include "mainpage.h" #include "mainpage.h"
#include "ui_ChannelFeed.h" #include "ui_ChannelFeed.h"
#include <QStandardItemModel>
#include "gui/feeds/FeedHolder.h" #include "gui/feeds/FeedHolder.h"
#define OWN 0
#define SUBSCRIBED 1
#define POPULAR 2
#define OTHER 3
class ChanGroupItem; class ChanGroupItem;
class ChanMenuItem; class ChanMenuItem;
class ChanMsgItem; class ChanMsgItem;
class ChannelFeed : public MainPage, public FeedHolder, private Ui::ChannelFeed class ChannelFeed : public MainPage, public FeedHolder, private Ui::ChannelFeed
{ {
Q_OBJECT Q_OBJECT
@ -48,6 +56,8 @@ virtual void openMsg(uint32_t type, std::string grpId, std::string inReplyTo);
public slots: public slots:
void selectChannel( std::string ); void selectChannel( std::string );
void selectChannel(const QModelIndex &);
void toggleSelection(const QModelIndex &);
private slots: private slots:
@ -71,26 +81,28 @@ private:
void updateChannelMsgs(); void updateChannelMsgs();
QStandardItemModel *model;
std::string mChannelId; /* current Channel */ std::string mChannelId; /* current Channel */
/* Layout Pointers */ /* Layout Pointers */
QBoxLayout *mGroupLayout; // QBoxLayout *mGroupLayout;
QBoxLayout *mMsgLayout; QBoxLayout *mMsgLayout;
/* Group Headers */ /* Group Headers */
ChanGroupItem *mGroupOwn; // ChanGroupItem *mGroupOwn;
ChanGroupItem *mGroupSub; // ChanGroupItem *mGroupSub;
ChanGroupItem *mGroupPop; // ChanGroupItem *mGroupPop;
ChanGroupItem *mGroupOther; // ChanGroupItem *mGroupOther;
/* lists of feedItems */ /* lists of feedItems */
std::list<ChanMenuItem *> mChannelListOwn; // std::list<ChanMenuItem *> mChannelListOwn;
std::list<ChanMenuItem *> mChannelListSub; // std::list<ChanMenuItem *> mChannelListSub;
std::list<ChanMenuItem *> mChannelListPop; // std::list<ChanMenuItem *> mChannelListPop;
std::list<ChanMenuItem *> mChannelListOther; // std::list<ChanMenuItem *> mChannelListOther;
std::list<ChanMsgItem *> mChanMsgItems; std::list<ChanMsgItem *> mChanMsgItems;
QFont mChannelFont; QFont mChannelFont;
}; };

View File

@ -64,6 +64,11 @@
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QTreeView" name="treeView"/>
</item>
</layout>
</widget> </widget>
</item> </item>
<item row="0" column="1" rowspan="2"> <item row="0" column="1" rowspan="2">