set default title as file name for a link

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1548 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
alexandrut 2009-08-17 22:06:48 +00:00
parent 6145efd378
commit c5e66682c8
3 changed files with 19 additions and 23 deletions

View File

@ -22,6 +22,7 @@
#include "common/vmessagebox.h"
#include "AddLinksDialog.h"
#include "RetroShareLinkAnalyzer.h"
#include "rsiface/rsrank.h"
/* Images for context menu icons */
@ -33,7 +34,7 @@
#define IMAGE_BADLINK ":/images/filerating1.png"
/** Constructor */
AddLinksDialog::AddLinksDialog(QWidget *parent)
AddLinksDialog::AddLinksDialog(QString url, QWidget *parent)
: QDialog(parent)
{
/* Invoke the Qt Designer generated object setup routine */
@ -44,6 +45,20 @@ AddLinksDialog::AddLinksDialog(QWidget *parent)
connect(ui.closepushButton, SIGNAL(clicked()), this, SLOT(close()));
ui.linkLineEdit->setReadOnly(true);
ui.linkLineEdit->setText(url);
RetroShareLinkAnalyzer analyzer(url);
QVector<RetroShareLinkData> linkList;
analyzer.getFileInformation(linkList);
if (!linkList.isEmpty())
{ /* set title as first name from list */
RetroShareLinkData item = linkList.first();
ui.titleLineEdit->setText(item.getName());
}
else
{
ui.titleLineEdit->setText("New File");
}
/* Hide platform specific features */
#ifdef Q_WS_WIN
@ -91,13 +106,3 @@ void AddLinksDialog::addLinkComment()
close();
}
void AddLinksDialog::insertTitleText(std::string title)
{
ui.titleLineEdit->setText(QString::fromStdString(title));
}
void AddLinksDialog::insertLinkText(std::string link)
{
ui.linkLineEdit->setText(QString::fromStdString(link));
}

View File

@ -30,12 +30,9 @@ class AddLinksDialog : public QDialog
public:
/** Default Constructor */
AddLinksDialog(QWidget *parent = 0);
AddLinksDialog(QString url, QWidget *parent = 0);
/** Default Destructor */
void insertTitleText(std::string title);
void insertLinkText(std::string link);
static int IndexToScore(int index);
public slots:

View File

@ -341,10 +341,7 @@ void SharedFilesDialog::sendLinkToCloud()
{
copyLinkLocal ();
AddLinksDialog *nAddLinksDialog = new AddLinksDialog();
nAddLinksDialog->insertTitleText("New File");
nAddLinksDialog->insertLinkText(QApplication::clipboard()->text().toStdString());
AddLinksDialog *nAddLinksDialog = new AddLinksDialog(QApplication::clipboard()->text());
nAddLinksDialog->addLinkComment();
nAddLinksDialog->close();
@ -354,10 +351,7 @@ void SharedFilesDialog::addLinkToCloud()
{
copyLinkLocal ();
AddLinksDialog *nAddLinksDialog = new AddLinksDialog(this);
nAddLinksDialog->insertTitleText("New File");
nAddLinksDialog->insertLinkText(QApplication::clipboard()->text().toStdString());
AddLinksDialog *nAddLinksDialog = new AddLinksDialog(QApplication::clipboard()->text());
nAddLinksDialog->show();
}