From 4afa46cb82758e643bebd1a0cfd61e171c2b5bab Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 5 Mar 2010 11:58:35 +0000 Subject: [PATCH] Added Popularity view as icons to display for each channel git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2487 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/ChannelFeed.cpp | 61 +++++++++++++++++++----- retroshare-gui/src/gui/ChannelFeed.h | 5 ++ retroshare-gui/src/gui/ChannelFeed.ui | 6 +++ retroshare-gui/src/gui/images.qrc | 6 +++ retroshare-gui/src/gui/images/hot_0.png | Bin 0 -> 291 bytes retroshare-gui/src/gui/images/hot_1.png | Bin 0 -> 312 bytes retroshare-gui/src/gui/images/hot_2.png | Bin 0 -> 333 bytes retroshare-gui/src/gui/images/hot_3.png | Bin 0 -> 318 bytes retroshare-gui/src/gui/images/hot_4.png | Bin 0 -> 318 bytes retroshare-gui/src/gui/images/hot_5.png | Bin 0 -> 318 bytes 10 files changed, 67 insertions(+), 11 deletions(-) create mode 100644 retroshare-gui/src/gui/images/hot_0.png create mode 100644 retroshare-gui/src/gui/images/hot_1.png create mode 100644 retroshare-gui/src/gui/images/hot_2.png create mode 100644 retroshare-gui/src/gui/images/hot_3.png create mode 100644 retroshare-gui/src/gui/images/hot_4.png create mode 100644 retroshare-gui/src/gui/images/hot_5.png diff --git a/retroshare-gui/src/gui/ChannelFeed.cpp b/retroshare-gui/src/gui/ChannelFeed.cpp index ef1dc96ff..b5f324c94 100644 --- a/retroshare-gui/src/gui/ChannelFeed.cpp +++ b/retroshare-gui/src/gui/ChannelFeed.cpp @@ -62,9 +62,10 @@ ChannelFeed::ChannelFeed(QWidget *parent) /*************** Setup Left Hand Side (List of Channels) ****************/ mChannelId = ""; - model = new QStandardItemModel(0, 2, this); + model = new QStandardItemModel(0, 3, this); model->setHeaderData(0, Qt::Horizontal, tr("Name"), Qt::DisplayRole); - model->setHeaderData(1, Qt::Horizontal, tr("ID"), Qt::DisplayRole); + model->setHeaderData(1, Qt::Horizontal, tr("Popularity"), Qt::DisplayRole); + model->setHeaderData(2, Qt::Horizontal, tr("ID"), Qt::DisplayRole); treeView->setModel(model); treeView->setEditTriggers(QAbstractItemView::NoEditTriggers); @@ -74,7 +75,14 @@ ChannelFeed::ChannelFeed(QWidget *parent) // hide header and id column treeView->setHeaderHidden(true); - treeView->hideColumn(1); + treeView->hideColumn(2); + + /* Set header resize modes and initial section sizes TreeView*/ + QHeaderView * _header = treeView->header () ; + _header->setResizeMode ( 1, QHeaderView::Custom); + _header->resizeSection ( 0, 190 ); + _header->resizeSection ( 1, 22 ); + _header->resizeSection ( 2, 22 ); QStandardItem *item1 = new QStandardItem(tr("Own Channels")); QStandardItem *item2 = new QStandardItem(tr("Subscribed Channels")); @@ -129,16 +137,16 @@ void ChannelFeed::channelListCustomPopupMenu( QPoint point ) QMenu contextMnu( this ); QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier ); - QAction *postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), this ); + postchannelAct = new QAction(QIcon(":/images/mail_reply.png"), tr( "Post to Channel" ), this ); connect( postchannelAct , SIGNAL( triggered() ), this, SLOT( createMsg() ) ); - QAction *subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), this ); + subscribechannelAct = new QAction(QIcon(":/images/edit_add24.png"), tr( "Subscribe to Channel" ), this ); connect( subscribechannelAct , SIGNAL( triggered() ), this, SLOT( subscribeChannel() ) ); - QAction *unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), this ); + unsubscribechannelAct = new QAction(QIcon(":/images/cancel.png"), tr( "Unsubscribe to Channel" ), this ); connect( unsubscribechannelAct , SIGNAL( triggered() ), this, SLOT( unsubscribeChannel() ) ); - QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), this ); + channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), this ); connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) ); contextMnu.clear(); @@ -250,8 +258,8 @@ void ChannelFeed::selectChannel(const QModelIndex &index) { int row = index.row(); int col = index.column(); - if (col != 1) { - QModelIndex sibling = index.sibling(row, 1); + if (col != 2) { + QModelIndex sibling = index.sibling(row, 2); if (sibling.isValid()) mChannelId = sibling.data().toString().toStdString(); } else @@ -383,21 +391,52 @@ void ChannelFeed::updateChannelListOwn(std::list &ids) QList channel; QStandardItem *item1 = new QStandardItem(); QStandardItem *item2 = new QStandardItem(); + QStandardItem *item3 = new QStandardItem(); 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); + //item2->setData(QVariant(QString::number(ci.pop)), Qt::DisplayRole); + item3->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)); + + int popcount = ci.pop; + /* set Popularity icon */ + if (popcount == 0) + { + item2->setData(QIcon(QString::fromUtf8(":/images/hot_0.png")), Qt::DecorationRole); + } + else if (popcount < 2) + { + item2->setData(QIcon(QString::fromUtf8(":/images/hot_1.png")), Qt::DecorationRole); + } + else if (popcount < 4) + { + item2->setData(QIcon(QString::fromUtf8(":/images/hot_2.png")), Qt::DecorationRole); + } + else if (popcount < 8) + { + item2->setData(QIcon(QString::fromUtf8(":/images/hot_3.png")), Qt::DecorationRole); + } + else if (popcount < 16) { + item2->setData(QIcon(QString::fromUtf8(":/images/hot_4.png")), Qt::DecorationRole); + } + else + { + item2->setData(QIcon(QString::fromUtf8(":/images/hot_5.png")), Qt::DecorationRole); + } + + } 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); + channel.append(item3); ownGroup->appendRow(channel); } } diff --git a/retroshare-gui/src/gui/ChannelFeed.h b/retroshare-gui/src/gui/ChannelFeed.h index 7407edf0d..19d1dab97 100644 --- a/retroshare-gui/src/gui/ChannelFeed.h +++ b/retroshare-gui/src/gui/ChannelFeed.h @@ -94,6 +94,11 @@ private: QFont mChannelFont; QFont itemFont; + + QAction* postchannelAct; + QAction* subscribechannelAct; + QAction* unsubscribechannelAct; + QAction* channeldetailsAct; }; diff --git a/retroshare-gui/src/gui/ChannelFeed.ui b/retroshare-gui/src/gui/ChannelFeed.ui index 6219acd27..752790347 100644 --- a/retroshare-gui/src/gui/ChannelFeed.ui +++ b/retroshare-gui/src/gui/ChannelFeed.ui @@ -209,6 +209,12 @@ p, li { white-space: pre-wrap; } Qt::CustomContextMenu + + + 19 + 19 + + diff --git a/retroshare-gui/src/gui/images.qrc b/retroshare-gui/src/gui/images.qrc index 814b77634..a0aa9b855 100644 --- a/retroshare-gui/src/gui/images.qrc +++ b/retroshare-gui/src/gui/images.qrc @@ -200,6 +200,12 @@ images/hide_frame.png images/highlight.png images/hi16-app-ktorrent.png + images/hot_0.png + images/hot_1.png + images/hot_2.png + images/hot_3.png + images/hot_4.png + images/hot_5.png images/image16.png images/info16.png images/im-user.png diff --git a/retroshare-gui/src/gui/images/hot_0.png b/retroshare-gui/src/gui/images/hot_0.png new file mode 100644 index 0000000000000000000000000000000000000000..a1f7a8114feabe454e7f9cd625079c5ecbbeb72e GIT binary patch literal 291 zcmeAS@N?(olHy`uVBq!ia0vp^!a&T$!3HG5I#cHZDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(ehe3dtTpz6=aiY77hwEes65fI-L15RjOeSEA?V8lq5UtY@lcyx?WzRiL68PZ!4!3;*PlYyCgYGqBd{ zuS;-w_J8MwIWvzceA4&%cmC4TLpm2H=0B`4sbrgwCh_n52l*Tco@SGYO8&EwOb%bv zbvAutUpGB*$Cv;0Y9jL=d==|#TfBp(`|OXy0(XtPV!r+VUoW_5Z>Qja7aP63W(X!q jWEnj8tfqMQ!c)e-rx|ZvQ+Q-L15RjOeSEA?V8lq5UtY@lcyx?WzRiL7Yo-U3d7XHb9>f0Xv-@l)S z=l_2LgAEbJ21c*l|D-oG**`mdGs4g9U(;uO9q|Oijz0}Y(%C*W?pnx@a^wDFhs}LP z4ZMt!Y={3#{%huKPb{hAv9mkOk>$2|4&%)Y|Nnaya|YN7cb)!NHQD8GU`(4}8Vk?i z51guc%u;GjTg*9K89Wo+G*(V{;;YlP@R(fGB?g9_$JO+%E^B%YbR2`HtDnm{r-UW| D=$C6t literal 0 HcmV?d00001 diff --git a/retroshare-gui/src/gui/images/hot_2.png b/retroshare-gui/src/gui/images/hot_2.png new file mode 100644 index 0000000000000000000000000000000000000000..9f29930f437d652eb59cc174a57ee4b681d51ed7 GIT binary patch literal 333 zcmeAS@N?(olHy`uVBq!ia0vp^!a&T$!3HG5I#cHZDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(ehe3dtTpz6=aiY77hwEes65fI-L15RjOeSEA?V8lq5UtY@lcyx?WzRiL6}o-U3d7XHb9>f0Xv-@l)S z=l_2LgAEbJ2LEoI{vdzkANvuR*#DN1b}n`44NdlMPaloYQjS0Plj(He6G?}*zqXtv zuQd+WPf(hWXkTvh=l?#@3?Mfx?Qh3_1D}rm>jo1Zo@f(%qP+Xf|Ns9J@(;zhc^C)S z3U{Se?Bz6>lQTWBMUwHbgWbYeryJTj1#%@y5BEH@w~o5xz*%r<&&dz*3}+3*Y6O`W YgspFVdQ&MBb@0GM=npa1{> literal 0 HcmV?d00001 diff --git a/retroshare-gui/src/gui/images/hot_3.png b/retroshare-gui/src/gui/images/hot_3.png new file mode 100644 index 0000000000000000000000000000000000000000..d3c92ba5a52ca4435d4f3c912dcab2f996ace261 GIT binary patch literal 318 zcmeAS@N?(olHy`uVBq!ia0vp^!a&T$!3HG5I#cHZDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(ehe3dtTpz6=aiY77hwEes65fI-L15RjOeSEA?V8lq5UtY@lcyx?WzRiL8jo-U3d7XHb9>f0Xv-@l)S z=l_2L1B2-Q>A&_)|0v(_m%qbu&wu0ESoVj_2Js@ykAGJ>d=1!FaIL;f?C**BJO&I# zZ{B+@xV4z)zhlz=Z$^Lq@0|Sb|M#^5|E8Dn{I_49^y7b~WDCF1o3}b`|MQm_{`r6Y z!~B_%_K)m&j02J+PJ9SF?9tuO$Zec(W%C1XDV3c(84~Q8ZHx@}Lh|G^+Yf`B$l&Sf K=d#Wzp$PyNk9a5m literal 0 HcmV?d00001 diff --git a/retroshare-gui/src/gui/images/hot_4.png b/retroshare-gui/src/gui/images/hot_4.png new file mode 100644 index 0000000000000000000000000000000000000000..e759f7da312fd0b033a612994900c81a7673b1a1 GIT binary patch literal 318 zcmeAS@N?(olHy`uVBq!ia0vp^!a&TiI+J7DaPU;cPEB*=VV?2IV|apzCgi^ z{oH>NS%G|oWRD45bD@?FkGFRx=nF#0%!^3bX-Aa29w( z7Bet#3xY6XeM}+eVN$b6Z3ft7>wS$_grvmG0%U;r2XHF{`}uL`QiWXYX$yIFXj1fzdq^5|4hji zexo;Ub=v;tFLV5H=9l3A#2JZK3|_U}tZ(}-v&4mg;jH1G$BTuhNdle2;OXk;vd$@? F2>>GLbr1jm literal 0 HcmV?d00001 diff --git a/retroshare-gui/src/gui/images/hot_5.png b/retroshare-gui/src/gui/images/hot_5.png new file mode 100644 index 0000000000000000000000000000000000000000..d3c92ba5a52ca4435d4f3c912dcab2f996ace261 GIT binary patch literal 318 zcmeAS@N?(olHy`uVBq!ia0vp^!a&T$!3HG5I#cHZDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(ehe3dtTpz6=aiY77hwEes65fI-L15RjOeSEA?V8lq5UtY@lcyx?WzRiL8jo-U3d7XHb9>f0Xv-@l)S z=l_2L1B2-Q>A&_)|0v(_m%qbu&wu0ESoVj_2Js@ykAGJ>d=1!FaIL;f?C**BJO&I# zZ{B+@xV4z)zhlz=Z$^Lq@0|Sb|M#^5|E8Dn{I_49^y7b~WDCF1o3}b`|MQm_{`r6Y z!~B_%_K)m&j02J+PJ9SF?9tuO$Zec(W%C1XDV3c(84~Q8ZHx@}Lh|G^+Yf`B$l&Sf K=d#Wzp$PyNk9a5m literal 0 HcmV?d00001