changes for LinksDialog: disabled bold text, added a Label to display each Link in html format

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2197 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-02-05 13:44:33 +00:00
parent d490f6b0fe
commit 7941ef591e
3 changed files with 229 additions and 79 deletions

View File

@ -90,27 +90,26 @@ LinksDialog::LinksDialog(QWidget *parent)
connect( ui.anonBox, SIGNAL( stateChanged ( int ) ), this, SLOT( checkAnon ( void ) ) ); connect( ui.anonBox, SIGNAL( stateChanged ( int ) ), this, SLOT( checkAnon ( void ) ) );
connect( ui.linklabel, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
mStart = 0; mStart = 0;
/* hide the Tree +/- */
// ui.linkTreeWidget -> setRootIsDecorated( false );
/* Set header resize modes and initial section sizes */ /* Set header resize modes and initial section sizes */
QHeaderView * _header = ui.linkTreeWidget->header () ; QHeaderView * _header = ui.linkTreeWidget->header () ;
// _header->setResizeMode (0, QHeaderView::Custom);
_header->setResizeMode (0, QHeaderView::Interactive); _header->setResizeMode (0, QHeaderView::Interactive);
_header->setResizeMode (1, QHeaderView::Interactive); _header->setResizeMode (1, QHeaderView::Interactive);
_header->setResizeMode (2, QHeaderView::Interactive); _header->setResizeMode (2, QHeaderView::Interactive);
_header->resizeSection ( 0, 400 ); _header->resizeSection ( 0, 400 );
_header->resizeSection ( 1, 50 ); _header->resizeSection ( 1, 60 );
_header->resizeSection ( 2, 150 ); _header->resizeSection ( 2, 150 );
ui.linkTreeWidget->setSortingEnabled(true); ui.linkTreeWidget->setSortingEnabled(true);
ui.linklabel->setMinimumWidth(20);
/* Set a GUI update timer - much cleaner than /* Set a GUI update timer - much cleaner than
* doing everything through the notify agent * doing everything through the notify agent
@ -366,10 +365,10 @@ void LinksDialog::updateLinks()
{ {
item -> setText(0, QString::fromStdWString(detail.title)); item -> setText(0, QString::fromStdWString(detail.title));
/* Bold and bigger */ /* Bold and bigger */
QFont font = item->font(0); /*QFont font = item->font(0);
font.setBold(true); font.setBold(true);
font.setPointSize(font.pointSize() + 2); font.setPointSize(font.pointSize() + 2);
item->setFont(0, font); item->setFont(0, font);*/
} }
/* (1) Rank */ /* (1) Rank */
@ -378,22 +377,31 @@ void LinksDialog::updateLinks()
out << 100 * (detail.rank / (maxRank + 0.01)); out << 100 * (detail.rank / (maxRank + 0.01));
item -> setText(1, QString::fromStdString(out.str())); item -> setText(1, QString::fromStdString(out.str()));
/* Bold and bigger */ /* Bold and bigger */
QFont font = item->font(1); /*QFont font = item->font(1);
//font.setBold(true); font.setBold(true);
font.setPointSize(font.pointSize() + 2); font.setPointSize(font.pointSize() + 2);
item->setFont(1, font); item->setFont(1, font);*/
} }
/* (2) Link */ /* (2) Link */
{ {
item -> setText(2, QString::fromStdWString(detail.link)); item -> setText(2, QString::fromStdWString(detail.link));
/* Bold and bigger */ /* Bold and bigger */
QFont font = item->font(2); /*QFont font = item->font(2);
font.setBold(true); font.setBold(true);
font.setPointSize(font.pointSize() + 2); font.setPointSize(font.pointSize() + 2);
item->setFont(2, font); item->setFont(2, font);*/
} }
/* (3) Date */
/*{
QDateTime qtime;
qtime.setTime_t(it->lastPost);
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
item -> setText(3, timestamp);
}*/
/* (4) rid */ /* (4) rid */
item -> setText(4, QString::fromStdString(detail.rid)); item -> setText(4, QString::fromStdString(detail.rid));
@ -654,6 +662,8 @@ void LinksDialog::updateComments(std::string rid, std::string pid)
/* set Link details */ /* set Link details */
ui.titleLineEdit->setText(QString::fromStdWString(detail.title)); ui.titleLineEdit->setText(QString::fromStdWString(detail.title));
ui.linkLineEdit->setText(QString::fromStdWString(detail.link)); ui.linkLineEdit->setText(QString::fromStdWString(detail.link));
ui.linklabel->setHtml("<a href='" + QString::fromStdWString(detail.link) + "'> " + QString::fromStdWString(detail.link) +"</a>");
if (mLinkId == rid) if (mLinkId == rid)
{ {
@ -998,3 +1008,60 @@ void LinksDialog::downloadSelected()
rsFiles->FileRequest(item.getName().toStdString(), item.getHash().toStdString(), item.getSize().toULong(), "", 0, srcIds); rsFiles->FileRequest(item.getName().toStdString(), item.getHash().toStdString(), item.getSize().toULong(), "", 0, srcIds);
} }
} }
void LinksDialog::anchorClicked (const QUrl& link )
{
#ifdef LINK_DEBUG
std::cerr << "LinksDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl;
#endif
if (link.scheme() == "retroshare")
{
QStringList L = link.toString().split("|") ;
std::string fileName = L.at(1).toStdString() ;
uint64_t fileSize = L.at(2).toULongLong();
std::string fileHash = L.at(3).toStdString() ;
#ifdef LINK_DEBUG
std::cerr << "LinksDialog::anchorClicked FileRequest : fileName : " << fileName << ". fileHash : " << fileHash << ". fileSize : " << fileSize << std::endl;
#endif
if (fileName != "" && fileHash != "")
{
std::list<std::string> srcIds;
if(rsFiles->FileRequest(fileName, fileHash, fileSize, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds))
{
QMessageBox mb(tr("File Request Confirmation"), tr("The file has been added to your download list."),QMessageBox::Information,QMessageBox::Ok,0,0);
mb.setButtonText( QMessageBox::Ok, "OK" );
mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
mb.exec();
}
else
{
QMessageBox mb(tr("File Request canceled"), tr("The file has not been added to your download list, because you already have it."),QMessageBox::Information,QMessageBox::Ok,0,0);
mb.setButtonText( QMessageBox::Ok, "OK" );
mb.exec();
}
}
else
{
QMessageBox mb(tr("File Request Error"), tr("The file link is malformed."),QMessageBox::Information,QMessageBox::Ok,0,0);
mb.setButtonText( QMessageBox::Ok, "OK" );
mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
mb.exec();
}
}
else if (link.scheme() == "http")
{
QDesktopServices::openUrl(link);
}
else if (link.scheme() == "")
{
//it's probably a web adress, let's add http:// at the beginning of the link
QString newAddress = link.toString();
newAddress.prepend("http://");
QDesktopServices::openUrl(QUrl(newAddress));
}
}

View File

@ -67,6 +67,8 @@ void checkAnon();
void checkUpdate(); void checkUpdate();
void anchorClicked (const QUrl &);
private: private:
void updateComments(std::string rid, std::string pid); void updateComments(std::string rid, std::string pid);

View File

@ -60,7 +60,7 @@
</column> </column>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="3" column="0">
<widget class="QPushButton" name="expandButton"> <widget class="QPushButton" name="expandButton">
<property name="text"> <property name="text">
<string/> <string/>
@ -71,7 +71,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="3" column="1">
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -84,7 +84,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="2"> <item row="3" column="2">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="font"> <property name="font">
<font> <font>
@ -98,11 +98,11 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="3"> <item row="3" column="3">
<widget class="QComboBox" name="rankComboBox"> <widget class="QComboBox" name="rankComboBox">
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>11</pointsize>
</font> </font>
</property> </property>
<item> <item>
@ -114,15 +114,23 @@
<property name="text"> <property name="text">
<string>Time</string> <string>Time</string>
</property> </property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/kalarm.png</normaloff>:/images/kalarm.png</iconset>
</property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Ranking</string> <string>Ranking</string>
</property> </property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/records.png</normaloff>:/images/records.png</iconset>
</property>
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="4"> <item row="3" column="4">
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -135,7 +143,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="5"> <item row="3" column="5">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="font"> <property name="font">
<font> <font>
@ -149,31 +157,43 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="6"> <item row="3" column="6">
<widget class="QComboBox" name="periodComboBox"> <widget class="QComboBox" name="periodComboBox">
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>11</pointsize>
</font> </font>
</property> </property>
<item> <item>
<property name="text"> <property name="text">
<string>Month</string> <string>Month</string>
</property> </property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/view_calendar_month.png</normaloff>:/images/view_calendar_month.png</iconset>
</property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Week</string> <string>Week</string>
</property> </property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/view_calendar_week.png</normaloff>:/images/view_calendar_week.png</iconset>
</property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Day</string> <string>Day</string>
</property> </property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/view_calendar_day.png</normaloff>:/images/view_calendar_day.png</iconset>
</property>
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="7"> <item row="3" column="7">
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -186,7 +206,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="8"> <item row="3" column="8">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="font"> <property name="font">
<font> <font>
@ -200,26 +220,34 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="9"> <item row="3" column="9">
<widget class="QComboBox" name="fromComboBox"> <widget class="QComboBox" name="fromComboBox">
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>11</pointsize>
</font> </font>
</property> </property>
<item> <item>
<property name="text"> <property name="text">
<string>All Peers</string> <string>All Peers</string>
</property> </property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/user/friends24.png</normaloff>:/images/user/friends24.png</iconset>
</property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Own Links</string> <string>Own Links</string>
</property> </property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/user/identity16.png</normaloff>:/images/user/identity16.png</iconset>
</property>
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="10"> <item row="3" column="10">
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -232,7 +260,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="11"> <item row="3" column="11">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="font"> <property name="font">
<font> <font>
@ -246,17 +274,21 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="12"> <item row="3" column="12">
<widget class="QComboBox" name="topComboBox"> <widget class="QComboBox" name="topComboBox">
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>11</pointsize>
</font> </font>
</property> </property>
<item> <item>
<property name="text"> <property name="text">
<string>Top 100</string> <string>Top 100</string>
</property> </property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/records.png</normaloff>:/images/records.png</iconset>
</property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
@ -285,6 +317,40 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="1" colspan="12">
<widget class="QTextBrowser" name="linklabel">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QTextBrowser{border: 2px solid #CCCCCC;
border-radius: 10px;
background: white;}</string>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="openLinks">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Link:</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="layoutWidget">
@ -308,7 +374,7 @@
<widget class="QCheckBox" name="anonBox"> <widget class="QCheckBox" name="anonBox">
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>11</pointsize>
<weight>50</weight> <weight>50</weight>
<bold>false</bold> <bold>false</bold>
</font> </font>
@ -322,7 +388,7 @@
<widget class="QPushButton" name="addButton"> <widget class="QPushButton" name="addButton">
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>11</pointsize>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
@ -338,9 +404,9 @@
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>10</pointsize>
<weight>75</weight> <weight>50</weight>
<bold>true</bold> <bold>false</bold>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
@ -352,18 +418,23 @@
<widget class="QLineEdit" name="titleLineEdit"> <widget class="QLineEdit" name="titleLineEdit">
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>11</pointsize>
</font> </font>
</property> </property>
<property name="styleSheet">
<string notr="true">QLineEdit{border: 2px solid #CCCCCC;
border-radius: 10px;
background: white;}</string>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="label_8">
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>10</pointsize>
<weight>75</weight> <weight>50</weight>
<bold>true</bold> <bold>false</bold>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
@ -428,9 +499,9 @@
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>10</pointsize>
<weight>75</weight> <weight>50</weight>
<bold>true</bold> <bold>false</bold>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
@ -442,9 +513,14 @@
<widget class="QLineEdit" name="linkLineEdit"> <widget class="QLineEdit" name="linkLineEdit">
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>11</pointsize>
</font> </font>
</property> </property>
<property name="styleSheet">
<string notr="true">QLineEdit{border: 2px solid #CCCCCC;
border-radius: 10px;
background: white;}</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -468,6 +544,11 @@
<pointsize>12</pointsize> <pointsize>12</pointsize>
</font> </font>
</property> </property>
<property name="styleSheet">
<string notr="true">QTextEdit{border: 2px solid #CCCCCC;
border-radius: 10px;
background: white;}</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>