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 "common/vmessagebox.h"
#include "AddLinksDialog.h" #include "AddLinksDialog.h"
#include "RetroShareLinkAnalyzer.h"
#include "rsiface/rsrank.h" #include "rsiface/rsrank.h"
/* Images for context menu icons */ /* Images for context menu icons */
@ -33,7 +34,7 @@
#define IMAGE_BADLINK ":/images/filerating1.png" #define IMAGE_BADLINK ":/images/filerating1.png"
/** Constructor */ /** Constructor */
AddLinksDialog::AddLinksDialog(QWidget *parent) AddLinksDialog::AddLinksDialog(QString url, QWidget *parent)
: QDialog(parent) : QDialog(parent)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
@ -44,6 +45,20 @@ AddLinksDialog::AddLinksDialog(QWidget *parent)
connect(ui.closepushButton, SIGNAL(clicked()), this, SLOT(close())); connect(ui.closepushButton, SIGNAL(clicked()), this, SLOT(close()));
ui.linkLineEdit->setReadOnly(true); 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 */ /* Hide platform specific features */
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
@ -91,13 +106,3 @@ void AddLinksDialog::addLinkComment()
close(); 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: public:
/** Default Constructor */ /** Default Constructor */
AddLinksDialog(QWidget *parent = 0); AddLinksDialog(QString url, QWidget *parent = 0);
/** Default Destructor */ /** Default Destructor */
void insertTitleText(std::string title);
void insertLinkText(std::string link);
static int IndexToScore(int index); static int IndexToScore(int index);
public slots: public slots:

View File

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