Added ChannelDetails for Channel Informations

Added Context Menu for Channelist for open ChannelDetails


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2095 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-01-20 00:29:40 +00:00
parent dd09c2a344
commit 3a1c6ed76f
10 changed files with 460 additions and 18 deletions

View File

@ -188,6 +188,7 @@ HEADERS += rshare.h \
gui/profile/ProfileWidget.h \
gui/profile/StatusMessage.h \
gui/chat/PopupChatDialog.h \
gui/channels/ChannelDetails.h \
gui/channels/CreateChannelMsg.h \
gui/connect/ConnectDialog.h \
gui/connect/ConfCertDialog.h \
@ -272,6 +273,7 @@ FORMS += gui/StartDialog.ui \
gui/profile/ProfileWidget.ui \
gui/profile/StatusMessage.ui \
gui/channels/CreateChannelMsg.ui \
gui/channels/ChannelDetails.ui \
gui/chat/PopupChatDialog.ui \
gui/connect/ConnectDialog.ui \
gui/connect/ConfCertDialog.ui \
@ -366,6 +368,7 @@ SOURCES += main.cpp \
gui/profile/ProfileWidget.cpp \
gui/profile/StatusMessage.cpp \
gui/channels/CreateChannelMsg.cpp \
gui/channels/ChannelDetails.cpp \
gui/chat/PopupChatDialog.cpp \
gui/connect/ConnectDialog.cpp \
gui/connect/ConfCertDialog.cpp \

View File

@ -19,6 +19,12 @@
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QtGui>
#include <QContextMenuEvent>
#include <QCursor>
#include <QMenu>
#include <QMouseEvent>
#include <QPixmap>
#include <QPoint>
#include <iostream>
#include <algorithm>
@ -31,6 +37,7 @@
#include "gui/feeds/ChanMsgItem.h"
#include "gui/forums/CreateForum.h"
#include "gui/channels/ChannelDetails.h"
#include "gui/ChanGroupDelegate.h"
#include "GeneralMsgDialog.h"
@ -150,6 +157,7 @@ ChannelFeed::ChannelFeed(QWidget *parent)
connect(treeView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(selectChannel(const QModelIndex &)));
connect(treeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(toggleSelection(const QModelIndex &)));
connect(treeView, SIGNAL(customContextMenuRequested( QPoint ) ), this, SLOT( channelListCustomPopupMenu( QPoint ) ) );
//added from ahead
updateChannelList();
@ -182,6 +190,21 @@ ChannelFeed::ChannelFeed(QWidget *parent)
timer->start(1000);
}
void ChannelFeed::channelListCustomPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
QAction *channeldetailsAct = new QAction(QIcon(":/images/info16.png"), tr( "Show Channel Details" ), this );
connect( channeldetailsAct , SIGNAL( triggered() ), this, SLOT( showChannelDetails() ) );
contextMnu.clear();
contextMnu.addAction( channeldetailsAct );
contextMnu.exec( mevent->globalPos() );
}
void ChannelFeed::createChannel()
{
@ -716,3 +739,19 @@ void ChannelFeed::toggleSelection(const QModelIndex &index)
selectionModel->select(index, QItemSelectionModel::Toggle);
}
void ChannelFeed::showChannelDetails()
{
if (mChannelId == "")
{
return;
}
if (!rsChannels)
return;
static ChannelDetails *channelui = new ChannelDetails();
channelui->showDetails(mChannelId);
channelui->show();
}

View File

@ -61,6 +61,8 @@ public slots:
private slots:
void channelListCustomPopupMenu( QPoint point );
void checkUpdate();
void createChannel();
@ -73,6 +75,7 @@ private slots:
void createMsg();
void showChannelDetails();
private:

View File

@ -36,13 +36,13 @@
</property>
<property name="minimumSize">
<size>
<width>221</width>
<width>222</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>221</width>
<width>222</width>
<height>16777215</height>
</size>
</property>
@ -205,7 +205,11 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="1" column="0">
<widget class="QTreeView" name="treeView"/>
<widget class="QTreeView" name="treeView">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
</layout>
</widget>
@ -318,7 +322,7 @@ p, li { white-space: pre-wrap; }
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
<height>25</height>
</size>
</property>
<property name="toolTip">
@ -554,7 +558,7 @@ border-bottom-right-radius: 1px;
<rect>
<x>0</x>
<y>0</y>
<width>430</width>
<width>429</width>
<height>331</height>
</rect>
</property>

View File

@ -0,0 +1,153 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2009 RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "ChannelDetails.h"
#include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsdisc.h"
#include "rsiface/rschannels.h"
#include <QTime>
#include <QDateTime>
#include <sstream>
#include <list>
#include <iostream>
#include <string>
/* Define the format used for displaying the date and time */
#define DATETIME_FMT "MMM dd hh:mm:ss"
/** Default constructor */
ChannelDetails::ChannelDetails(QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags)
{
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg()));
ui.applyButton->setToolTip(tr("Close"));
ui.nameline ->setReadOnly(true);
ui.popline ->setReadOnly(true);
ui.postline ->setReadOnly(true);
ui.IDline ->setReadOnly(true);
ui.DescriptiontextEdit ->setReadOnly(true);
}
/**
Overloads the default show() slot so we can set opacity*/
void
ChannelDetails::show()
{
//loadSettings();
if(!this->isVisible()) {
QDialog::show();
}
}
void ChannelDetails::closeEvent (QCloseEvent * event)
{
QWidget::closeEvent(event);
}
void ChannelDetails::closeinfodlg()
{
close();
}
void ChannelDetails::showDetails(std::string mChannelId)
{
cId = mChannelId;
loadChannel();
}
void ChannelDetails::loadChannel()
{
if (!rsChannels)
{
return;
}
std::list<ChannelInfo> channelList;
std::list<ChannelInfo>::iterator it;
ChannelInfo ci;
rsChannels->getChannelInfo(cId, ci);
rsChannels->getChannelList(channelList);
for(it = channelList.begin(); it != channelList.end(); it++)
{
// Set Channel Name
ui.nameline->setText(QString::fromStdWString(ci.channelName));
// Set Channel Popularity
{
std::ostringstream out;
out << it->pop;
ui.popline -> setText(QString::fromStdString(out.str()));
}
// Set Last Channel Post Date
{
QDateTime qtime;
qtime.setTime_t(it->lastPost);
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
ui.postline -> setText(timestamp);
}
// Set Channel ID
ui.IDline->setText(QString::fromStdString(ci.channelId));
// Set Channel Description
ui.DescriptiontextEdit->setText(QString::fromStdWString(ci.channelDesc));
}
}
void ChannelDetails::applyDialog()
{
/* reload now */
loadChannel();
/* close the Dialog after the Changes applied */
closeinfodlg();
}

View File

@ -0,0 +1,68 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2009 RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _CHANNELDETAILS_H
#define _CHANNELDETAILS_H
#include <QDialog>
#include "ui_ChannelDetails.h"
class ChannelDetails : public QDialog
{
Q_OBJECT
public:
/** Default constructor */
ChannelDetails(QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */
void showDetails(std::string mChannelId);
signals:
void configChanged() ;
public slots:
/** Overloaded QWidget.show */
void show();
protected:
void closeEvent (QCloseEvent * event);
private slots:
void closeinfodlg();
void applyDialog();
private:
void loadChannel();
std::string cId;
/** Qt Designer generated object */
Ui::ChannelDetails ui;
};
#endif

View File

@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChannelDetails</class>
<widget class="QDialog" name="ChannelDetails">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>436</width>
<height>355</height>
</rect>
</property>
<property name="windowTitle">
<string>Channel Details</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QTabWidget" name="stabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/info16.png</normaloff>:/images/info16.png</iconset>
</attribute>
<attribute name="title">
<string>Channel Details</string>
</attribute>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Channel Info</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Forum Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameline"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Popularity</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="popline">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Last Post</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="postline">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Forum ID</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="IDline"/>
</item>
<item row="4" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Channel Description</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTextEdit" name="DescriptiontextEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="_2">
<item row="0" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>311</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="applyButton">
<property name="text">
<string>OK</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -29,6 +29,8 @@
#include "rsiface/rschannels.h"
#include <iostream>
#include <sstream>
/****
* #define DEBUG_ITEM 1
@ -92,12 +94,19 @@ void ChanMsgItem::updateItemStatic()
subjectLabel->setText(QString::fromStdWString(cmi.msg));
}
msgLabel->setText(QString::fromStdWString(cmi.msg));
QDateTime qtime;
qtime.setTime_t(cmi.ts);
QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm:ss");
datetimelabel->setText(timestamp);
{
std::ostringstream out;
out << "(" << cmi.count << " Files)";
filelabel->setText(QString::fromStdString(out.str()));
}
msgLabel->setText(QString::fromStdWString(cmi.msg));
std::list<FileInfo>::iterator it;
for(it = cmi.files.begin(); it != cmi.files.end(); it++)

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>526</width>
<height>213</height>
<width>538</width>
<height>272</height>
</rect>
</property>
<property name="windowTitle">
@ -87,10 +87,13 @@ border-radius: 10px;}</string>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>138</width>
<height>18</height>
<height>1</height>
</size>
</property>
</spacer>
@ -99,7 +102,7 @@ border-radius: 10px;}</string>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="3">
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
@ -124,7 +127,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="3" colspan="4">
<item row="0" column="4" colspan="4">
<widget class="QLabel" name="datetimelabel">
<property name="font">
<font>
@ -141,7 +144,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="1" column="0" colspan="7">
<item row="1" column="0" colspan="8">
<widget class="QLabel" name="subjectLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
@ -169,7 +172,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="1">
<item row="2" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -185,7 +188,7 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="2" column="2" colspan="2">
<item row="2" column="3" colspan="2">
<widget class="QPushButton" name="unsubscribeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -205,7 +208,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="4">
<item row="2" column="5">
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -225,7 +228,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="5">
<item row="2" column="6">
<widget class="QPushButton" name="playButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -245,7 +248,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="6">
<item row="2" column="7">
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -268,6 +271,13 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="filelabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
@ -313,7 +323,7 @@ border-radius: 10px;}</string>
<property name="sizeHint" stdset="0">
<size>
<width>200</width>
<height>1</height>
<height>200</height>
</size>
</property>
</spacer>
@ -340,6 +350,8 @@ border-radius: 10px;}</string>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB