mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
Addition of new LinksDialog to Retroshare GUI.
Addition of rsRank Interface to control information. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@326 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
06aae24efd
commit
7d6fcba5c9
@ -60,6 +60,7 @@ HEADERS += rshare.h \
|
|||||||
gui/ExampleDialog.h \
|
gui/ExampleDialog.h \
|
||||||
gui/GamesDialog.h \
|
gui/GamesDialog.h \
|
||||||
gui/PhotoDialog.h \
|
gui/PhotoDialog.h \
|
||||||
|
gui/LinksDialog.h \
|
||||||
gui/MessengerWindow.h \
|
gui/MessengerWindow.h \
|
||||||
gui/PeersDialog.h \
|
gui/PeersDialog.h \
|
||||||
gui/SearchDialog.h \
|
gui/SearchDialog.h \
|
||||||
@ -146,6 +147,7 @@ FORMS += gui/ChatDialog.ui \
|
|||||||
gui/ExampleDialog.ui \
|
gui/ExampleDialog.ui \
|
||||||
gui/GamesDialog.ui \
|
gui/GamesDialog.ui \
|
||||||
gui/PhotoDialog.ui \
|
gui/PhotoDialog.ui \
|
||||||
|
gui/LinksDialog.ui \
|
||||||
gui/MessengerWindow.ui \
|
gui/MessengerWindow.ui \
|
||||||
gui/PeersDialog.ui \
|
gui/PeersDialog.ui \
|
||||||
gui/SearchDialog.ui \
|
gui/SearchDialog.ui \
|
||||||
@ -207,6 +209,7 @@ SOURCES += main.cpp \
|
|||||||
gui/ExampleDialog.cpp \
|
gui/ExampleDialog.cpp \
|
||||||
gui/GamesDialog.cpp \
|
gui/GamesDialog.cpp \
|
||||||
gui/PhotoDialog.cpp \
|
gui/PhotoDialog.cpp \
|
||||||
|
gui/LinksDialog.cpp \
|
||||||
gui/MessengerWindow.cpp \
|
gui/MessengerWindow.cpp \
|
||||||
gui/PeersDialog.cpp \
|
gui/PeersDialog.cpp \
|
||||||
gui/SearchDialog.cpp \
|
gui/SearchDialog.cpp \
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "gui/connect/InviteDialog.h"
|
#include "gui/connect/InviteDialog.h"
|
||||||
#include "gui/connect/AddFriendDialog.h"
|
#include "gui/connect/AddFriendDialog.h"
|
||||||
|
|
||||||
|
#include "LinksDialog.h"
|
||||||
#include "GamesDialog.h"
|
#include "GamesDialog.h"
|
||||||
#include "PhotoDialog.h"
|
#include "PhotoDialog.h"
|
||||||
|
|
||||||
@ -85,17 +86,20 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
|
|||||||
/* Create the config pages and actions */
|
/* Create the config pages and actions */
|
||||||
QActionGroup *grp = new QActionGroup(this);
|
QActionGroup *grp = new QActionGroup(this);
|
||||||
|
|
||||||
|
LinksDialog *linksDialog = NULL;
|
||||||
|
ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages),
|
||||||
|
createPageAction(QIcon(IMAGE_TRANSFERS), tr("Links Cloud"), grp));
|
||||||
|
|
||||||
ui.stackPages->add(exampleDialog = new ExampleDialog(ui.stackPages),
|
// ui.stackPages->add(exampleDialog = new ExampleDialog(ui.stackPages),
|
||||||
createPageAction(QIcon(IMAGE_MESSAGES), tr("Example Application"), grp));
|
// createPageAction(QIcon(IMAGE_MESSAGES), tr("Example Application"), grp));
|
||||||
|
|
||||||
GamesDialog *gamesDialog = NULL;
|
GamesDialog *gamesDialog = NULL;
|
||||||
ui.stackPages->add(gamesDialog = new GamesDialog(ui.stackPages),
|
ui.stackPages->add(gamesDialog = new GamesDialog(ui.stackPages),
|
||||||
createPageAction(QIcon(IMAGE_MESSAGES), tr("Games Launcher"), grp));
|
createPageAction(QIcon(IMAGE_MESSAGES), tr("Games Launcher"), grp));
|
||||||
|
|
||||||
PhotoDialog *photoDialog = NULL;
|
// PhotoDialog *photoDialog = NULL;
|
||||||
ui.stackPages->add(photoDialog = new PhotoDialog(ui.stackPages),
|
// ui.stackPages->add(photoDialog = new PhotoDialog(ui.stackPages),
|
||||||
createPageAction(QIcon(IMAGE_MESSAGES), tr("Photo View"), grp));
|
// createPageAction(QIcon(IMAGE_MESSAGES), tr("Photo View"), grp));
|
||||||
|
|
||||||
|
|
||||||
//ui.stackPages->add(groupsDialog = new GroupsDialog(ui.stackPages),
|
//ui.stackPages->add(groupsDialog = new GroupsDialog(ui.stackPages),
|
||||||
@ -104,9 +108,9 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
|
|||||||
//ui.stackPages->add(new StatisticDialog(ui.stackPages),
|
//ui.stackPages->add(new StatisticDialog(ui.stackPages),
|
||||||
// createPageAction(QIcon(IMAGE_STATISTIC), tr("Statistics"), grp));
|
// createPageAction(QIcon(IMAGE_STATISTIC), tr("Statistics"), grp));
|
||||||
|
|
||||||
statusBar()->addWidget(new QLabel(tr("Application Users: 0 Files: 0 ")));
|
// statusBar()->addWidget(new QLabel(tr("Application Users: 0 Files: 0 ")));
|
||||||
statusBar()->addPermanentWidget(new QLabel(tr("Down: 0.0 Up: 0.0 ")));
|
// statusBar()->addPermanentWidget(new QLabel(tr("Down: 0.0 Up: 0.0 ")));
|
||||||
statusBar()->addPermanentWidget(new QLabel(tr("Connections: 0/45 ")));
|
// statusBar()->addPermanentWidget(new QLabel(tr("Connections: 0/45 ")));
|
||||||
|
|
||||||
/* Create the toolbar */
|
/* Create the toolbar */
|
||||||
ui.toolBar->addActions(grp->actions());
|
ui.toolBar->addActions(grp->actions());
|
||||||
|
File diff suppressed because it is too large
Load Diff
745
retroshare-gui/src/gui/LinksDialog.cpp
Normal file
745
retroshare-gui/src/gui/LinksDialog.cpp
Normal file
@ -0,0 +1,745 @@
|
|||||||
|
/****************************************************************
|
||||||
|
* RetroShare is distributed under the following license:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Robert Fernie
|
||||||
|
*
|
||||||
|
* 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 <QFile>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include "common/vmessagebox.h"
|
||||||
|
|
||||||
|
//#include "rshare.h"
|
||||||
|
#include "LinksDialog.h"
|
||||||
|
#include "rsiface/rspeers.h"
|
||||||
|
#include "rsiface/rsrank.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include <QContextMenuEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QCursor>
|
||||||
|
#include <QPoint>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
|
|
||||||
|
/* Images for context menu icons */
|
||||||
|
#define IMAGE_REMOVEFRIEND ":/images/removefriend16.png"
|
||||||
|
#define IMAGE_EXPIORTFRIEND ":/images/exportpeers_16x16.png"
|
||||||
|
#define IMAGE_CHAT ":/images/chat.png"
|
||||||
|
/* Images for Status icons */
|
||||||
|
#define IMAGE_ONLINE ":/images/donline.png"
|
||||||
|
#define IMAGE_OFFLINE ":/images/dhidden.png"
|
||||||
|
|
||||||
|
/** Constructor */
|
||||||
|
LinksDialog::LinksDialog(QWidget *parent)
|
||||||
|
: MainPage(parent)
|
||||||
|
{
|
||||||
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
connect( ui.linkTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( linkTreeWidgetCostumPopupMenu( QPoint ) ) );
|
||||||
|
|
||||||
|
|
||||||
|
/* link combos */
|
||||||
|
connect( ui.rankComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortRank( int ) ) );
|
||||||
|
connect( ui.periodComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortPeriod( int ) ) );
|
||||||
|
connect( ui.fromComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortFrom( int ) ) );
|
||||||
|
connect( ui.topComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortTop( int ) ) );
|
||||||
|
|
||||||
|
/* add button */
|
||||||
|
connect( ui.addButton, SIGNAL( clicked( void ) ), this, SLOT( addLinkComment( void ) ) );
|
||||||
|
connect( ui.expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggleWindows( void ) ) );
|
||||||
|
|
||||||
|
connect( ui.linkTreeWidget, SIGNAL( currentItemChanged ( QTreeWidgetItem *, QTreeWidgetItem * ) ),
|
||||||
|
this, SLOT( changedItem ( QTreeWidgetItem *, QTreeWidgetItem * ) ) );
|
||||||
|
|
||||||
|
connect( ui.linkTreeWidget, SIGNAL( itemDoubleClicked ( QTreeWidgetItem *, int ) ),
|
||||||
|
this, SLOT( openLink ( QTreeWidgetItem *, int ) ) );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mStart = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* hide the Tree +/- */
|
||||||
|
// ui.linkTreeWidget -> setRootIsDecorated( false );
|
||||||
|
|
||||||
|
/* Set header resize modes and initial section sizes */
|
||||||
|
QHeaderView * _header = ui.linkTreeWidget->header () ;
|
||||||
|
// _header->setResizeMode (0, QHeaderView::Custom);
|
||||||
|
_header->setResizeMode (0, QHeaderView::Interactive);
|
||||||
|
_header->setResizeMode (1, QHeaderView::Interactive);
|
||||||
|
_header->setResizeMode (2, QHeaderView::Interactive);
|
||||||
|
|
||||||
|
_header->resizeSection ( 0, 400 );
|
||||||
|
_header->resizeSection ( 1, 50 );
|
||||||
|
_header->resizeSection ( 2, 150 );
|
||||||
|
|
||||||
|
/* Hide platform specific features */
|
||||||
|
#ifdef Q_WS_WIN
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinksDialog::linkTreeWidgetCostumPopupMenu( QPoint point )
|
||||||
|
{
|
||||||
|
|
||||||
|
QMenu contextMnu( this );
|
||||||
|
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
||||||
|
|
||||||
|
voteupAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Vote Link Up" ), this );
|
||||||
|
connect( voteupAct , SIGNAL( triggered() ), this, SLOT( voteup() ) );
|
||||||
|
|
||||||
|
//votedownAct = new QAction(QIcon(IMAGE_REMOVEFRIEND), tr( "Vote Down" ), this );
|
||||||
|
//connect( votedownAct , SIGNAL( triggered() ), this, SLOT( votedown() ) );
|
||||||
|
|
||||||
|
contextMnu.clear();
|
||||||
|
contextMnu.addAction(voteupAct);
|
||||||
|
//contextMnu.addSeparator();
|
||||||
|
//contextMnu.addAction(votedownAct);
|
||||||
|
contextMnu.exec( mevent->globalPos() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinksDialog::changedSortRank( int index )
|
||||||
|
{
|
||||||
|
/* update */
|
||||||
|
if (!rsRanks)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* translate */
|
||||||
|
uint32_t type = 0;
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
type = RS_RANK_TIME;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
type = RS_RANK_SCORE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case 0:
|
||||||
|
type = RS_RANK_ALG;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type)
|
||||||
|
{
|
||||||
|
rsRanks->setSortMethod(type);
|
||||||
|
}
|
||||||
|
updateLinks();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinksDialog::changedSortPeriod( int index )
|
||||||
|
{
|
||||||
|
/* update */
|
||||||
|
if (!rsRanks)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* translate */
|
||||||
|
uint32_t period = 0;
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
period = 60 * 60 * 24 * 7; /* WEEK */
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
period = 60 * 60 * 24; /* DAY */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case 0:
|
||||||
|
period = 60 * 60 * 24 * 30; /* MONTH */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (period)
|
||||||
|
{
|
||||||
|
rsRanks->setSortPeriod(period);
|
||||||
|
}
|
||||||
|
updateLinks();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinksDialog::changedSortFrom( int index )
|
||||||
|
{
|
||||||
|
/* update */
|
||||||
|
if (!rsRanks)
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::list<std::string> peers;
|
||||||
|
|
||||||
|
/* translate */
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
peers.push_back(rsPeers->getOwnId());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (peers.size() < 1)
|
||||||
|
{
|
||||||
|
rsRanks->clearPeerFilter();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rsRanks->setPeerFilter(peers);
|
||||||
|
}
|
||||||
|
updateLinks();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LinksDialog::changedSortTop( int index )
|
||||||
|
{
|
||||||
|
/* update */
|
||||||
|
if (!rsRanks)
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::list<std::string> peers;
|
||||||
|
|
||||||
|
/* translate */
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case 0:
|
||||||
|
mStart = 0;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
mStart = 100;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
mStart = 200;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
mStart = 300;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
mStart = 400;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
mStart = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
updateLinks();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* get the list of Links from the RsRanks. */
|
||||||
|
void LinksDialog::updateLinks()
|
||||||
|
{
|
||||||
|
|
||||||
|
std::list<std::string> rids;
|
||||||
|
std::list<std::string>::iterator rit;
|
||||||
|
std::list<RsRankComment>::iterator cit;
|
||||||
|
|
||||||
|
/* Work out the number/entries to show */
|
||||||
|
uint32_t count = rsRanks->getRankingsCount();
|
||||||
|
uint32_t start;
|
||||||
|
|
||||||
|
uint32_t entries = 100;
|
||||||
|
if (count < entries)
|
||||||
|
{
|
||||||
|
entries = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mStart == -1)
|
||||||
|
{
|
||||||
|
/* backwards */
|
||||||
|
start = count-entries;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
start = mStart;
|
||||||
|
if (start + entries > count)
|
||||||
|
{
|
||||||
|
start = count - entries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get a link to the table */
|
||||||
|
QTreeWidget *linkWidget = ui.linkTreeWidget;
|
||||||
|
QList<QTreeWidgetItem *> items;
|
||||||
|
|
||||||
|
rsRanks->getRankings(start, entries, rids);
|
||||||
|
float maxRank = rsRanks->getMaxRank();
|
||||||
|
|
||||||
|
for(rit = rids.begin(); rit != rids.end(); rit++)
|
||||||
|
{
|
||||||
|
RsRankDetails detail;
|
||||||
|
if (!rsRanks->getRankDetails(*rit, detail))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create items */
|
||||||
|
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||||
|
|
||||||
|
/* (0) Title */
|
||||||
|
{
|
||||||
|
item -> setText(0, QString::fromStdWString(detail.title));
|
||||||
|
/* Bold and bigger */
|
||||||
|
QFont font = item->font(0);
|
||||||
|
font.setBold(true);
|
||||||
|
font.setPointSize(font.pointSize() + 2);
|
||||||
|
item->setFont(0, font);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (1) Rank */
|
||||||
|
{
|
||||||
|
std::ostringstream out;
|
||||||
|
out << 100 * (detail.rank / (maxRank + 0.01));
|
||||||
|
item -> setText(1, QString::fromStdString(out.str()));
|
||||||
|
/* Bold and bigger */
|
||||||
|
QFont font = item->font(1);
|
||||||
|
//font.setBold(true);
|
||||||
|
font.setPointSize(font.pointSize() + 2);
|
||||||
|
item->setFont(1, font);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (2) Link */
|
||||||
|
{
|
||||||
|
item -> setText(2, QString::fromStdWString(detail.link));
|
||||||
|
/* Bold and bigger */
|
||||||
|
QFont font = item->font(2);
|
||||||
|
font.setBold(true);
|
||||||
|
font.setPointSize(font.pointSize() + 2);
|
||||||
|
item->setFont(2, font);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (4) rid */
|
||||||
|
item -> setText(4, QString::fromStdString(detail.rid));
|
||||||
|
|
||||||
|
|
||||||
|
/* add children */
|
||||||
|
int i = 0;
|
||||||
|
for(cit = detail.comments.begin();
|
||||||
|
cit != detail.comments.end(); cit++, i++)
|
||||||
|
{
|
||||||
|
/* create items */
|
||||||
|
QTreeWidgetItem *child = new QTreeWidgetItem((QTreeWidget*)0);
|
||||||
|
|
||||||
|
/* (0) Comment */
|
||||||
|
child -> setText(0, QString::fromStdWString(cit->comment));
|
||||||
|
|
||||||
|
/* (2) Peer / Date */
|
||||||
|
{
|
||||||
|
QDateTime qtime;
|
||||||
|
qtime.setTime_t(cit->timestamp);
|
||||||
|
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
||||||
|
|
||||||
|
QString peerLabel = QString::fromStdString(rsPeers->getPeerName(cit->id));
|
||||||
|
peerLabel += " ";
|
||||||
|
peerLabel += timestamp;
|
||||||
|
child -> setText(2, peerLabel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (4) Id */
|
||||||
|
child -> setText(4, QString::fromStdString(cit->id));
|
||||||
|
|
||||||
|
if (i % 2 == 1)
|
||||||
|
{
|
||||||
|
/* set to light gray background */
|
||||||
|
child->setBackground(0,QBrush(Qt::lightGray));
|
||||||
|
child->setBackground(1,QBrush(Qt::lightGray));
|
||||||
|
child->setBackground(2,QBrush(Qt::lightGray));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* push to items */
|
||||||
|
item->addChild(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* add to the list */
|
||||||
|
items.append(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remove old items */
|
||||||
|
linkWidget->clear();
|
||||||
|
linkWidget->setColumnCount(3);
|
||||||
|
|
||||||
|
/* add the items in! */
|
||||||
|
linkWidget->insertTopLevelItems(0, items);
|
||||||
|
|
||||||
|
linkWidget->update(); /* update display */
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinksDialog::openLink ( QTreeWidgetItem * item, int column )
|
||||||
|
{
|
||||||
|
std::cerr << "LinksDialog::openLink()" << std::endl;
|
||||||
|
|
||||||
|
/* work out the ids */
|
||||||
|
if (!item)
|
||||||
|
{
|
||||||
|
std::cerr << "LinksDialog::openLink() Failed Item" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string rid;
|
||||||
|
std::string pid;
|
||||||
|
|
||||||
|
QTreeWidgetItem *parent = item->parent();
|
||||||
|
if (parent)
|
||||||
|
{
|
||||||
|
/* a child comment -> ignore double click */
|
||||||
|
std::cerr << "LinksDialog::openLink() Failed Child" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << "LinksDialog::openLink() " << (item->text(0)).toStdString() << std::endl;
|
||||||
|
/* open a browser */
|
||||||
|
QUrl url(item->text(0));
|
||||||
|
QDesktopServices::openUrl ( url );
|
||||||
|
|
||||||
|
/* close expansion */
|
||||||
|
//ui.linkTreeWidget->collapseItem(item);
|
||||||
|
|
||||||
|
bool state = item->isExpanded();
|
||||||
|
item->setExpanded(!state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinksDialog::changedItem(QTreeWidgetItem *curr, QTreeWidgetItem *prev)
|
||||||
|
{
|
||||||
|
/* work out the ids */
|
||||||
|
if (!curr)
|
||||||
|
{
|
||||||
|
updateComments("", "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string rid;
|
||||||
|
std::string pid;
|
||||||
|
|
||||||
|
QTreeWidgetItem *parent = curr->parent();
|
||||||
|
if (parent)
|
||||||
|
{
|
||||||
|
rid = (parent->text(4)).toStdString();
|
||||||
|
pid = (curr->text(4)).toStdString();
|
||||||
|
|
||||||
|
std::cerr << "LinksDialog::changedItem() Rid: " << rid << " Pid: " << pid;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
updateComments(rid, pid);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rid = (curr->text(4)).toStdString();
|
||||||
|
|
||||||
|
std::cerr << "LinksDialog::changedItem() Rid: " << rid << " Pid: NULL";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
updateComments(rid, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* get the list of Links from the RsRanks. */
|
||||||
|
void LinksDialog::updateComments(std::string rid, std::string pid)
|
||||||
|
{
|
||||||
|
std::list<RsRankComment>::iterator cit;
|
||||||
|
|
||||||
|
if (rid == "")
|
||||||
|
{
|
||||||
|
/* clear it up */
|
||||||
|
ui.titleLineEdit->setText("");
|
||||||
|
ui.linkLineEdit->setText("");
|
||||||
|
ui.linkTextEdit->setText("");
|
||||||
|
mLinkId = rid;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsRankDetails detail;
|
||||||
|
if (!rsRanks->getRankDetails(rid, detail))
|
||||||
|
{
|
||||||
|
/* clear it up */
|
||||||
|
ui.titleLineEdit->setText("");
|
||||||
|
ui.linkLineEdit->setText("");
|
||||||
|
ui.linkTextEdit->setText("");
|
||||||
|
mLinkId = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set Link details */
|
||||||
|
ui.titleLineEdit->setText(QString::fromStdWString(detail.title));
|
||||||
|
ui.linkLineEdit->setText(QString::fromStdWString(detail.link));
|
||||||
|
|
||||||
|
if (mLinkId != rid)
|
||||||
|
{
|
||||||
|
/* clean comments */
|
||||||
|
ui.linkTextEdit->setText("");
|
||||||
|
}
|
||||||
|
mLinkId = rid;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
for(cit = detail.comments.begin(); cit != detail.comments.end(); cit++)
|
||||||
|
{
|
||||||
|
if (cit->id == pid)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cit != detail.comments.end())
|
||||||
|
{
|
||||||
|
/* one comment selected */
|
||||||
|
QString comment;
|
||||||
|
|
||||||
|
QDateTime qtime;
|
||||||
|
qtime.setTime_t(cit->timestamp);
|
||||||
|
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
||||||
|
|
||||||
|
comment += "Submitter: ";
|
||||||
|
comment += QString::fromStdString(rsPeers->getPeerName(cit->id));
|
||||||
|
comment += " Date: ";
|
||||||
|
comment += timestamp;
|
||||||
|
comment += "\n";
|
||||||
|
comment += QString::fromStdWString(cit->comment);
|
||||||
|
|
||||||
|
ui.linkTextEdit->setText(comment);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString comment;
|
||||||
|
for(cit = detail.comments.begin(); cit != detail.comments.end(); cit++)
|
||||||
|
{
|
||||||
|
/* add all comments */
|
||||||
|
QDateTime qtime;
|
||||||
|
qtime.setTime_t(cit->timestamp);
|
||||||
|
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
||||||
|
|
||||||
|
comment += "Submitter: ";
|
||||||
|
comment += QString::fromStdString(rsPeers->getPeerName(cit->id));
|
||||||
|
comment += " Date: ";
|
||||||
|
comment += timestamp;
|
||||||
|
comment += "\n";
|
||||||
|
comment += QString::fromStdWString(cit->comment);
|
||||||
|
comment += "\n====================================================";
|
||||||
|
comment += "====================================================\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.linkTextEdit->setText(comment);
|
||||||
|
|
||||||
|
/* ....
|
||||||
|
* */
|
||||||
|
/**
|
||||||
|
mLinkId = rid;
|
||||||
|
mPeerId = pid;
|
||||||
|
mCommentFilled = true;
|
||||||
|
**/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinksDialog::addLinkComment( void )
|
||||||
|
{
|
||||||
|
/* get the title / link / comment */
|
||||||
|
QString title = ui.titleLineEdit->text();
|
||||||
|
QString link = ui.linkLineEdit->text();
|
||||||
|
QString comment = ui.linkTextEdit->toPlainText();
|
||||||
|
|
||||||
|
if (mLinkId == "")
|
||||||
|
{
|
||||||
|
if ((link == "") || (title == ""))
|
||||||
|
{
|
||||||
|
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
|
||||||
|
"Add Link Failure",
|
||||||
|
"Missing Link and/or Title",
|
||||||
|
QMessageBox::Ok);
|
||||||
|
/* can't do anything */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rsRanks->newRankMsg(
|
||||||
|
link.toStdWString(),
|
||||||
|
title.toStdWString(),
|
||||||
|
comment.toStdWString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get existing details */
|
||||||
|
|
||||||
|
RsRankDetails detail;
|
||||||
|
if (!rsRanks->getRankDetails(mLinkId, detail))
|
||||||
|
{
|
||||||
|
/* strange error! */
|
||||||
|
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
|
||||||
|
"Add Link Failure",
|
||||||
|
"Missing Link Data",
|
||||||
|
QMessageBox::Ok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (link.toStdWString() == detail.link) /* same link! - we can add a comment */
|
||||||
|
{
|
||||||
|
if (comment == "") /* no comment! */
|
||||||
|
{
|
||||||
|
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
|
||||||
|
"Add Link Failure",
|
||||||
|
"Missing Comment",
|
||||||
|
QMessageBox::Ok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rsRanks->updateComment(mLinkId,
|
||||||
|
comment.toStdWString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::StandardButton sb = QMessageBox::Yes;
|
||||||
|
|
||||||
|
if ((title.toStdWString() == detail.title) /* same title! - wrong */
|
||||||
|
|| (title == ""))
|
||||||
|
{
|
||||||
|
sb = QMessageBox::question ( NULL, "Link Title Not Changed",
|
||||||
|
"Do you want to continue?",
|
||||||
|
(QMessageBox::Yes | QMessageBox::No));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* add Link! */
|
||||||
|
if (sb == QMessageBox::Yes)
|
||||||
|
{
|
||||||
|
rsRanks->newRankMsg(
|
||||||
|
link.toStdWString(),
|
||||||
|
title.toStdWString(),
|
||||||
|
comment.toStdWString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateLinks();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinksDialog::toggleWindows( void )
|
||||||
|
{
|
||||||
|
/* if msg header visible -> hide by changing splitter
|
||||||
|
*/
|
||||||
|
|
||||||
|
QList<int> sizeList = ui.msgSplitter->sizes();
|
||||||
|
QList<int>::iterator it;
|
||||||
|
|
||||||
|
int listSize = 0;
|
||||||
|
int msgSize = 0;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for(it = sizeList.begin(); it != sizeList.end(); it++, i++)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
listSize = (*it);
|
||||||
|
}
|
||||||
|
else if (i == 1)
|
||||||
|
{
|
||||||
|
msgSize = (*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int totalSize = listSize + msgSize;
|
||||||
|
|
||||||
|
bool toShrink = true;
|
||||||
|
if (msgSize < (int) totalSize / 10)
|
||||||
|
{
|
||||||
|
toShrink = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<int> newSizeList;
|
||||||
|
if (toShrink)
|
||||||
|
{
|
||||||
|
newSizeList.push_back(totalSize);
|
||||||
|
newSizeList.push_back(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newSizeList.push_back(totalSize * 3/4);
|
||||||
|
newSizeList.push_back(totalSize * 1/4);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.msgSplitter->setSizes(newSizeList);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QTreeWidgetItem *LinksDialog::getCurrentLine()
|
||||||
|
{
|
||||||
|
/* get the current, and extract the Id */
|
||||||
|
|
||||||
|
/* get a link to the table */
|
||||||
|
QTreeWidget *peerWidget = ui.linkTreeWidget;
|
||||||
|
QTreeWidgetItem *item = peerWidget -> currentItem();
|
||||||
|
if (!item)
|
||||||
|
{
|
||||||
|
std::cerr << "Invalid Current Item" << std::endl;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Display the columns of this item. */
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "CurrentPeerItem: " << std::endl;
|
||||||
|
|
||||||
|
for(int i = 1; i < 6; i++)
|
||||||
|
{
|
||||||
|
QString txt = item -> text(i);
|
||||||
|
out << "\t" << i << ":" << txt.toStdString() << std::endl;
|
||||||
|
}
|
||||||
|
std::cerr << out.str();
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinksDialog::voteup()
|
||||||
|
{
|
||||||
|
//QTreeWidgetItem *c = getCurrentLine();
|
||||||
|
|
||||||
|
if (mLinkId == "")
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsRankDetails detail;
|
||||||
|
if (!rsRanks->getRankDetails(mLinkId, detail))
|
||||||
|
{
|
||||||
|
/* not there! */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString link = QString::fromStdWString(detail.link);
|
||||||
|
std::cerr << "LinksDialog::voteup() : " << link.toStdString() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinksDialog::votedown()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *c = getCurrentLine();
|
||||||
|
std::cerr << "LinksDialog::votedown()" << std::endl;
|
||||||
|
|
||||||
|
/* need to get the input address / port */
|
||||||
|
/*
|
||||||
|
std::string addr;
|
||||||
|
unsigned short port;
|
||||||
|
rsServer->FriendSetAddress(getPeerRsCertId(c), addr, port);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
87
retroshare-gui/src/gui/LinksDialog.h
Normal file
87
retroshare-gui/src/gui/LinksDialog.h
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/****************************************************************
|
||||||
|
* RetroShare GUI is distributed under the following license:
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Robert Fernie
|
||||||
|
*
|
||||||
|
* 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 _LINKS_DIALOG_H
|
||||||
|
#define _LINKS_DIALOG_H
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
#include "mainpage.h"
|
||||||
|
#include "ui_LinksDialog.h"
|
||||||
|
|
||||||
|
|
||||||
|
class LinksDialog : public MainPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
/** Default Constructor */
|
||||||
|
LinksDialog(QWidget *parent = 0);
|
||||||
|
/** Default Destructor */
|
||||||
|
|
||||||
|
void insertExample();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
/** Create the context popup menu and it's submenus */
|
||||||
|
void linkTreeWidgetCostumPopupMenu( QPoint point );
|
||||||
|
|
||||||
|
void voteup();
|
||||||
|
void votedown();
|
||||||
|
|
||||||
|
void changedSortRank( int index );
|
||||||
|
void changedSortPeriod( int index );
|
||||||
|
void changedSortFrom( int index );
|
||||||
|
void changedSortTop( int index );
|
||||||
|
|
||||||
|
void updateLinks();
|
||||||
|
void addLinkComment( void );
|
||||||
|
void toggleWindows( void );
|
||||||
|
|
||||||
|
void openLink ( QTreeWidgetItem * item, int column );
|
||||||
|
void changedItem(QTreeWidgetItem *curr, QTreeWidgetItem *prev);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void updateComments(std::string rid, std::string pid);
|
||||||
|
|
||||||
|
int mStart; /* start of rank list */
|
||||||
|
std::string mLinkId;
|
||||||
|
|
||||||
|
/* Worker Functions */
|
||||||
|
/* (1) Update Display */
|
||||||
|
|
||||||
|
/* (2) Utility Fns */
|
||||||
|
QTreeWidgetItem *getCurrentLine();
|
||||||
|
|
||||||
|
/** Define the popup menus for the Context menu */
|
||||||
|
QMenu* contextMnu;
|
||||||
|
/** Defines the actions for the context menu */
|
||||||
|
QAction* voteupAct;
|
||||||
|
QAction* votedownAct;
|
||||||
|
|
||||||
|
QTreeWidget *exampletreeWidget;
|
||||||
|
|
||||||
|
/** Qt Designer generated object */
|
||||||
|
Ui::LinksDialog ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
388
retroshare-gui/src/gui/LinksDialog.ui
Normal file
388
retroshare-gui/src/gui/LinksDialog.ui
Normal file
@ -0,0 +1,388 @@
|
|||||||
|
<ui version="4.0" >
|
||||||
|
<class>LinksDialog</class>
|
||||||
|
<widget class="QWidget" name="LinksDialog" >
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>633</width>
|
||||||
|
<height>552</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle" >
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" >
|
||||||
|
<item row="0" column="0" >
|
||||||
|
<widget class="QSplitter" name="msgSplitter" >
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="" >
|
||||||
|
<layout class="QGridLayout" >
|
||||||
|
<item row="0" column="0" colspan="13" >
|
||||||
|
<widget class="QTreeWidget" name="linkTreeWidget" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="contextMenuPolicy" >
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
|
<column>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Title / Comment</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Score</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Peer / Link</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" >
|
||||||
|
<widget class="QPushButton" name="expandButton" >
|
||||||
|
<property name="text" >
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon" >
|
||||||
|
<iconset resource="images.qrc" >:/images/add_24x24.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" >
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2" >
|
||||||
|
<widget class="QLabel" name="label" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Sort by</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3" >
|
||||||
|
<widget class="QComboBox" name="rankComboBox" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Combo</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Time</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Ranking</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="4" >
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="5" >
|
||||||
|
<widget class="QLabel" name="label_2" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>In last</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="6" >
|
||||||
|
<widget class="QComboBox" name="periodComboBox" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Month</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Week</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Day</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="7" >
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="8" >
|
||||||
|
<widget class="QLabel" name="label_3" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>From</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="9" >
|
||||||
|
<widget class="QComboBox" name="fromComboBox" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>All Peers</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Own Links</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="10" >
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="11" >
|
||||||
|
<widget class="QLabel" name="label_5" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Show</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="12" >
|
||||||
|
<widget class="QComboBox" name="topComboBox" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Top 100</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>101-200</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>201-300</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>301-400</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>401-500</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Bottom 100</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="" >
|
||||||
|
<layout class="QVBoxLayout" >
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" >
|
||||||
|
<item>
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>441</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="addButton" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Add Link/Comment</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" >
|
||||||
|
<item row="0" column="0" >
|
||||||
|
<widget class="QLabel" name="label_6" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Title:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" >
|
||||||
|
<widget class="QLineEdit" name="titleLineEdit" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" >
|
||||||
|
<widget class="QLabel" name="label_7" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Url:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" >
|
||||||
|
<widget class="QLineEdit" name="linkLineEdit" >
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTextEdit" name="linkTextEdit" >
|
||||||
|
<property name="sizePolicy" >
|
||||||
|
<sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize" >
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font" >
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="images.qrc" />
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
90
retroshare-gui/src/rsiface/rsrank.h
Normal file
90
retroshare-gui/src/rsiface/rsrank.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#ifndef RETROSHARE_RANKING_GUI_INTERFACE_H
|
||||||
|
#define RETROSHARE_RANKING_GUI_INTERFACE_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* libretroshare/src/rsiface: rsrank.h
|
||||||
|
*
|
||||||
|
* RetroShare C++ Interface.
|
||||||
|
*
|
||||||
|
* Copyright 2007-2008 by Robert Fernie.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License Version 2 as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <string>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
/* The Main Interface Class - for information about your Peers */
|
||||||
|
class RsRanks;
|
||||||
|
extern RsRanks *rsRanks;
|
||||||
|
|
||||||
|
class RsRankComment
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
std::string id;
|
||||||
|
std::wstring comment;
|
||||||
|
time_t timestamp;
|
||||||
|
};
|
||||||
|
|
||||||
|
class RsRankDetails
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
std::string rid;
|
||||||
|
std::wstring link;
|
||||||
|
std::wstring title;
|
||||||
|
float rank;
|
||||||
|
bool ownTag;
|
||||||
|
|
||||||
|
std::list<RsRankComment> comments;
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint32_t RS_RANK_SCORE = 0x0001;
|
||||||
|
const uint32_t RS_RANK_TIME = 0x0002;
|
||||||
|
const uint32_t RS_RANK_ALG = 0x0003;
|
||||||
|
|
||||||
|
std::ostream &operator<<(std::ostream &out, const RsRankDetails &detail);
|
||||||
|
|
||||||
|
class RsRanks
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
RsRanks() { return; }
|
||||||
|
virtual ~RsRanks() { return; }
|
||||||
|
|
||||||
|
/* Set Sort Methods */
|
||||||
|
virtual bool setSortPeriod(uint32_t period) = 0;
|
||||||
|
virtual bool setSortMethod(uint32_t type) = 0;
|
||||||
|
virtual bool clearPeerFilter() = 0;
|
||||||
|
virtual bool setPeerFilter(std::list<std::string> peers) = 0;
|
||||||
|
|
||||||
|
/* get Ids */
|
||||||
|
virtual uint32_t getRankingsCount() = 0;
|
||||||
|
virtual float getMaxRank() = 0;
|
||||||
|
virtual bool getRankings(uint32_t first, uint32_t count, std::list<std::string> &rids) = 0;
|
||||||
|
virtual bool getRankDetails(std::string rid, RsRankDetails &details) = 0;
|
||||||
|
|
||||||
|
/* Add New Comment / Msg */
|
||||||
|
virtual std::string newRankMsg(std::wstring link, std::wstring title, std::wstring comment) = 0;
|
||||||
|
virtual bool updateComment(std::string rid, std::wstring comment) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user