diff --git a/retroshare-gui/src/gui/SearchDialog.cpp b/retroshare-gui/src/gui/SearchDialog.cpp index 2c9cd12c2..ebdaada01 100644 --- a/retroshare-gui/src/gui/SearchDialog.cpp +++ b/retroshare-gui/src/gui/SearchDialog.cpp @@ -91,23 +91,26 @@ SearchDialog::SearchDialog(QWidget *parent) /* initialise the filetypes mapping */ if (!SearchDialog::initialised) { - initialiseFileTypeMappings(); + initialiseFileTypeMappings(); } /* Advanced search panel specifica */ RshareSettings rsharesettings; QString key (UI_PREF_ADVANCED_SEARCH); bool useAdvanced = rsharesettings.value(key, QVariant(false)).toBool(); - if (useAdvanced) + /*if (useAdvanced) { ui.toggleAdvancedSearchBtn->setChecked(true); ui.SimpleSearchPanel->hide(); } else { ui.AdvancedSearchPanel->hide(); - } + }*/ - connect(ui.toggleAdvancedSearchBtn, SIGNAL(toggled(bool)), this, SLOT(toggleAdvancedSearchDialog(bool))); - connect(ui.focusAdvSearchDialogBtn, SIGNAL(clicked()), this, SLOT(showAdvSearchDialog())); + //connect(ui.toggleAdvancedSearchBtn, SIGNAL(toggled(bool)), this, SLOT(toggleAdvancedSearchDialog(bool))); + //connect(ui.focusAdvSearchDialogBtn, SIGNAL(clicked()), this, SLOT(showAdvSearchDialog())); + connect(ui.toggleAdvancedSearchBtn, SIGNAL(clicked()), this, SLOT(showAdvSearchDialog())); + connect(ui.cloaseallsearchresultsButton, SIGNAL(clicked()), this, SLOT(searchRemoveAll())); + connect(ui.resetButton, SIGNAL(clicked()), this, SLOT(clearKeyword())); /* End Advanced Search Panel specifics */ @@ -128,6 +131,8 @@ SearchDialog::SearchDialog(QWidget *parent) connect ( ui.searchSummaryWidget, SIGNAL( currentItemChanged ( QTreeWidgetItem *, QTreeWidgetItem * ) ), this, SLOT( selectSearchResults( void ) ) ); + + connect( ui.searchResultWidget, SIGNAL( itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(download())); /* hide the Tree +/- */ @@ -149,8 +154,8 @@ SearchDialog::SearchDialog(QWidget *parent) _smheader->setResizeMode (2, QHeaderView::Interactive); _smheader->resizeSection ( 0, 80 ); - _smheader->resizeSection ( 1, 75 ); - _smheader->resizeSection ( 2, 75 ); + _smheader->resizeSection ( 1, 60 ); + _smheader->resizeSection ( 2, 30 ); ui.searchResultWidget->setColumnCount(6); _smheader = ui.searchResultWidget->header () ; @@ -168,11 +173,11 @@ SearchDialog::SearchDialog(QWidget *parent) // set header text aligment - QTreeWidgetItem * headerItem = ui.searchResultWidget->headerItem(); - headerItem->setTextAlignment(2, Qt::AlignRight | Qt::AlignRight); - headerItem->setTextAlignment(3, Qt::AlignRight | Qt::AlignRight); + QTreeWidgetItem * headerItem = ui.searchResultWidget->headerItem(); + headerItem->setTextAlignment(2, Qt::AlignRight | Qt::AlignRight); + headerItem->setTextAlignment(3, Qt::AlignRight | Qt::AlignRight); - ui.searchResultWidget->sortItems(SR_NAME_COL, Qt::AscendingOrder); + ui.searchResultWidget->sortItems(SR_NAME_COL, Qt::AscendingOrder); @@ -367,6 +372,7 @@ void SearchDialog::searchRemoveAll() nextSearchId = 1; } +<<<<<<< HEAD:retroshare-gui/src/gui/SearchDialog.cpp /** clear keywords and ComboBox **/ void SearchDialog::clearKeyword() { @@ -375,6 +381,16 @@ void SearchDialog::clearKeyword() } +======= +/** clear keywords **/ +void SearchDialog::clearKeyword() +{ + ui.lineEdit->clear(); + ui.FileTypeComboBox->setCurrentIndex(0); +} + +>>>>>>> c9de750... + * Rolled back Modifications to SearchDialog and PopupChatDialog.:retroshare-gui/src/gui/SearchDialog.cpp /* ***************************************************************** Advanced search implementation *******************************************************************/ diff --git a/retroshare-gui/src/gui/SearchDialog.ui b/retroshare-gui/src/gui/SearchDialog.ui index a6ab4ab6c..339ea5d64 100644 --- a/retroshare-gui/src/gui/SearchDialog.ui +++ b/retroshare-gui/src/gui/SearchDialog.ui @@ -5,16 +5,34 @@ 0 0 +<<<<<<< HEAD:retroshare-gui/src/gui/SearchDialog.ui 654 374 +======= + 685 + 474 +>>>>>>> c9de750... + * Rolled back Modifications to SearchDialog and PopupChatDialog.:retroshare-gui/src/gui/SearchDialog.ui - 1 - 1 + 0 + 0 + + + 0 + 0 + + + + + 0 + 0 + + @@ -499,6 +517,7 @@ Qt::NoContextMenu +<<<<<<< HEAD:retroshare-gui/src/gui/SearchDialog.ui 6 @@ -538,389 +557,159 @@ 6 +======= + + 4 + + + + + + + + 24 + 24 + - - 0 + + + 24 + 24 + - - 0 + + +>>>>>>> c9de750... + * Rolled back Modifications to SearchDialog and PopupChatDialog.:retroshare-gui/src/gui/SearchDialog.ui - - 0 + + :/images/find.png - - 0 + + true - - - + + Qt::AlignCenter + + + + + + + + 16777215 + 32 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Search</span></p></body></html> + + + + + + + + + + 0 + 0 + + + + + 220 + 0 + + + + + 220 + 152 + + + + 0 + + + + + 0 + 0 + 235 + 131 + + + + Keyword Search + + + + + 6 - - 5 + + 6 - - 5 - - - 5 - - - 5 - - - - - - 0 - 0 - - - - - 34 - 34 - - - - - 34 - 34 - - - - Toggle advanced searching on and off. - + + - - - - :/images/advsearch_24x24.png - - - - 24 - 24 - - - - true + Type your Search here - - - - Qt::Vertical + + + + + 3 + 0 + - + - 20 - 0 + 558 + 16777215 - + - - - - - - - 255 - 0 - - - - - 390 - 24 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - + + + + + Any - - QFrame::NoFrame + + :/images/FileTypeAny.png - - QFrame::Raised + + + + Archive - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 6 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::NoFrame - - - QFrame::Plain - - - <h3>Simple Search:</h3> - - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - - - - 0 - 0 - - - - Keywords - - - - - - - - 3 - 0 - - - - - 558 - 16777215 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 16 - 32 - - - - - - - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Format</p></body></html> - - - - - - - - Any - - - :/images/FileTypeAny.png - - - - - Archive - - - :/images/FileTypeArchive.png - - - - - Audio - - - :/images/FileTypeAudio.png - - - - - CD-Image - - - :/images/FileTypeCDImage.png - - - - - Document - - - :/images/FileTypeDocument.png - - - - - Picture - - - :/images/FileTypePicture.png - - - - - Program - - - :/images/FileTypeProgram.png - - - - - Video - - - :/images/FileTypeVideo.png - - - - - - - - Qt::Horizontal - - - - 16 - 20 - - - - - - - - - 34 - 34 - - - - - 34 - 34 - - - - Perform simple search - - - - - - :/images/find.png - - - - 24 - 24 - - - - - - - - - - - - - true + + :/images/FileTypeArchive.png - - - 0 - 0 - + + + + Audio - - QFrame::NoFrame + + :/images/FileTypeAudio.png - - QFrame::Raised + + + + CD-Image +<<<<<<< HEAD:retroshare-gui/src/gui/SearchDialog.ui 0 @@ -1026,28 +815,77 @@ p, li { white-space: pre-wrap; } 0 +======= + + :/images/FileTypeCDImage.png + + + + + Document + + + :/images/FileTypeDocument.png + + + + + Picture + + + :/images/FileTypePicture.png + + + + + Program + + + :/images/FileTypeProgram.png + + + + + Video + + + :/images/FileTypeVideo.png + + + + + + +>>>>>>> c9de750... + * Rolled back Modifications to SearchDialog and PopupChatDialog.:retroshare-gui/src/gui/SearchDialog.ui - 34 - 34 + 0 + 0 - 34 - 34 + 200 + 200 +<<<<<<< HEAD:retroshare-gui/src/gui/SearchDialog.ui <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Reset Search Keyword and File Type</p></body></html> +======= + Perform simple search +>>>>>>> c9de750... + * Rolled back Modifications to SearchDialog and PopupChatDialog.:retroshare-gui/src/gui/SearchDialog.ui - + Search +<<<<<<< HEAD:retroshare-gui/src/gui/SearchDialog.ui :/images/reset.png @@ -1055,135 +893,297 @@ p, li { white-space: pre-wrap; } 24 24 +======= + :/images/find.png +>>>>>>> c9de750... + * Rolled back Modifications to SearchDialog and PopupChatDialog.:retroshare-gui/src/gui/SearchDialog.ui - + - Qt::Vertical + Qt::Horizontal - 20 - 0 + 88 + 20 + + + + Reset + + + - - - + + + + + + + - - 0 - 1 + + 1 + 0 + + Qt::CustomContextMenu + + + true + + + QAbstractItemView::DragOnly + + + true + + + + + + + + + Filename + + + + + Size + + + + + Sources + + + + + Type + + + + + Hash + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 120 + 25 + + + + Download + + + Download + + + :/images/down_24x24.png + + + + 16 + 16 + + + + + + Qt::Horizontal - - - - 1 - 0 - - - - Qt::CustomContextMenu - - - true - - - QAbstractItemView::DragOnly - - - true - - - - - - - - - Filename - - - - - Size - - - - - Sources - - - - - Type - - - - - Hash - - - - - - - 0 - 1 - - - - - 0 - 0 - - - - - 0 - 0 - - - - true - - - Qt::CustomContextMenu - - - true - - - - KeyWords - - - - - Results - - - - - Search Id - - - + + + 158 + 31 + + + + + + + + + 0 + 25 + + + + Close All Search Results + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 34 + 24 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">advanced searching</p></body></html> + + + + + + :/images/advsearch_24x24.png + + + + 16 + 16 + + + + false + + + + + + 0 + 0 + + + + + 220 + 0 + + + + + 220 + 16777215 + + + + 0 + + + 6 + + + + + 0 + 0 + 224 + 221 + + + + Search Activity + + + + + + + 0 + 1 + + + + + 200 + 16777215 + + + + + 0 + 0 + + + + + 0 + 0 + + + + true + + + Qt::CustomContextMenu + + + true + + + + KeyWords + + + + + Results + + + + + Search Id + + + + + + + + @@ -1238,38 +1238,5 @@ p, li { white-space: pre-wrap; } - - - toggleAdvancedSearchBtn - toggled(bool) - SimpleSearchPanel - setHidden(bool) - - - 29 - 35 - - - 72 - 43 - - - - - toggleAdvancedSearchBtn - toggled(bool) - AdvancedSearchPanel - setVisible(bool) - - - 28 - 29 - - - 80 - 64 - - - - + diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 3cb0d71b4..a6f150873 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -33,9 +33,13 @@ #include #include #include +#include #include "rsiface/rspeers.h" #include "rsiface/rsmsgs.h" +#include "rsiface/rsfiles.h" + +#include "gui/feeds/SubFileItem.h" #define appDir QApplication::applicationDirPath() @@ -76,7 +80,8 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name, connect(ui.chattextEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) )); connect(ui.sendButton, SIGNAL(clicked( ) ), this, SLOT(sendChat( ) )); - + connect(ui.addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); + connect(ui.textboldButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.textunderlineButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.textitalicButton, SIGNAL(clicked()), this, SLOT(setFont())); @@ -85,10 +90,13 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name, connect(ui.emoteiconButton, SIGNAL(clicked()), this, SLOT(smileyWidget())); connect(ui.styleButton, SIGNAL(clicked()), SLOT(changeStyle())); + connect(ui.textBrowser, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &))); + // Create the status bar resetStatusBar() ; ui.textBrowser->setOpenExternalLinks ( false ); + ui.textBrowser->setOpenLinks ( false ); QString title = QString::fromStdString(name) + " :" + tr(" RetroShare - Encrypted Chat") ; setWindowTitle(title); @@ -131,7 +139,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name, void PopupChatDialog::resetStatusBar() { - statusBar()->showMessage(QString("Chatting with ") + QString::fromStdString(dialogName) + " (" +QString::fromStdString(dialogId)+ ")") ; + statusBar()->showMessage(tr("Chatting with ") + QString::fromStdString(dialogName) + " (" +QString::fromStdString(dialogId)+ ")") ; } void PopupChatDialog::updateStatusTyping() @@ -243,6 +251,19 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci) QString name = QString::fromStdString(ci ->name); QString message = QString::fromStdWString(ci -> msg); + //replace url by a link + //first, avoid DTD link taht stands at the beginning of the string + QString messageSubString = message.mid(110, -1); + //replace http:// and www. with links + messageSubString.replace(QRegExp("(http://[^ <]*)|(www\\.[^ <]*)"), "\\1\\2"); + //rebuild the full message + message = message.left(109) + messageSubString; + +#ifdef CHAT_DEBUG +std::cout << "PopupChatDialog:addChatMsg message : " << message.toStdString() << std::endl; +#endif + + /*QHashIterator i(smileys); while(i.hasNext()) { @@ -294,7 +315,7 @@ void PopupChatDialog::checkChat() void PopupChatDialog::sendChat() { - QTextEdit *chatWidget = ui.chattextEdit; + QTextEdit *chatWidget = ui.chattextEdit; ChatInfo ci; @@ -678,3 +699,123 @@ void PopupChatDialog::getAvatar() } } +void PopupChatDialog::addExtraFile() +{ + // select a file + QString qfile = QFileDialog::getOpenFileName(this, tr("Add Extra File"), "", "", 0, + QFileDialog::DontResolveSymlinks); + std::string filePath = qfile.toStdString(); + if (filePath != "") + { + /* add a SubFileItem to the attachment section */ + std::cerr << "PopupChatDialog::addExtraFile() hashing file."; + std::cerr << std::endl; + + /* add widget in for new destination */ + SubFileItem *file = new SubFileItem(filePath); + //file-> + + ui.vboxLayout->addWidget(file, 1, 0); + + //when the file is local or is finished hashing, call the fileHashingFinished method to send a chat message + if (file->getState() == SFI_STATE_LOCAL) { + fileHashingFinished(file); + } else { + QObject::connect(file,SIGNAL(fileFinished(SubFileItem *)), SLOT(fileHashingFinished(SubFileItem *))) ; + } + + } +} + +void PopupChatDialog::fileHashingFinished(SubFileItem* file) { + std::cerr << "PopupChatDialog::fileHashingFinished() started."; + std::cerr << std::endl; + + ChatInfo ci; + + + { + rsiface->lockData(); /* Lock Interface */ + const RsConfig &conf = rsiface->getConfig(); + + ci.rsid = conf.ownId; + ci.name = conf.ownName; + + rsiface->unlockData(); /* Unlock Interface */ + } + + //convert fileSize from uint_64 to string for html link + char fileSizeChar [100]; + sprintf(fileSizeChar, "%lld", file->FileSize()); + std::string fileSize = *(&fileSizeChar); + + std::string mesgString = "" + (file->FileName()) + ""; +#ifdef CHAT_DEBUG + std::cerr << "PopupChatDialog::anchorClicked mesgString : " << mesgString << std::endl; +#endif + + const char * messageString = mesgString.c_str (); + + //convert char massageString to w_char + wchar_t* message; + int requiredSize = mbstowcs(NULL, messageString, 0); // C4996 + /* Add one to leave room for the NULL terminator */ + message = (wchar_t *)malloc( (requiredSize + 1) * sizeof( wchar_t )); + if (! message) + { + std::cerr << ("Memory allocation failure.\n"); + } + int size = mbstowcs( message, messageString, requiredSize + 1); // C4996 + if (size == (size_t) (-1)) + { + printf("Couldn't convert string--invalid multibyte character.\n"); + } + + ci.msg = message; + ci.chatflags = RS_CHAT_PRIVATE; + + addChatMsg(&ci); + + /* put proper destination */ + ci.rsid = dialogId; + ci.name = dialogName; + + rsMsgs -> ChatSend(ci); +} + +void PopupChatDialog::anchorClicked (const QUrl& link ) { + #ifdef CHAT_DEBUG + std::cerr << "PopupChatDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl; + #endif + if (link.scheme() == "file") { + std::string fileName = link.queryItemValue(QString("fileName")).toStdString(); + std::string fileHash = link.queryItemValue(QString("fileHash")).toStdString(); + uint32_t fileSize = link.queryItemValue(QString("fileSize")).toInt(); + #ifdef CHAT_DEBUG + std::cerr << "PopupChatDialog::anchorClicked FileRequest : fileName : " << fileName << ". fileHash : " << fileHash << ". fileSize : " << fileSize; + std::cerr << ". source id : " << dialogId << std::endl; + #endif + if (fileName != "" && + fileHash != "") { + std::list srcIds; + srcIds.push_front(dialogId); + rsFiles->FileRequest(fileName, fileHash, fileSize, "", 0, 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.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.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)); + } + +} diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.h b/retroshare-gui/src/gui/chat/PopupChatDialog.h index 9e34c9e57..f23cfd343 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.h +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.h @@ -30,6 +30,7 @@ #include #include "rsiface/rsiface.h" +#include "gui/feeds/SubFileItem.h" @@ -74,15 +75,19 @@ public slots: void addSmiley(); void changeStyle(); + void fileHashingFinished(SubFileItem* file); void resetStatusBar() ; void updateStatusTyping() ; void updateStatusString(const QString&) ; + void anchorClicked (const QUrl &); + + protected: void closeEvent (QCloseEvent * event); private slots: - + void addExtraFile(); void showAvatarFrame(bool show); void setColor(); @@ -95,7 +100,6 @@ private slots: void getAvatar(); - private: void colorChanged(const QColor &c); @@ -120,10 +124,9 @@ private: QStringList history; QString wholeChat; - - /** Qt Designer generated object */ Ui::PopupChatDialog ui; + }; #endif diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.ui b/retroshare-gui/src/gui/chat/PopupChatDialog.ui index 72ccb32ef..f6d694148 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.ui +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.ui @@ -6,7 +6,7 @@ 0 0 484 - 437 + 439 @@ -446,7 +446,7 @@ p, li { white-space: pre-wrap; } - + 0 @@ -456,23 +456,30 @@ p, li { white-space: pre-wrap; } 2 - - 6 - - + + + + + + + :/images/add-share24.png + + + + Qt::Horizontal - 351 + 331 20 - + Send @@ -481,6 +488,9 @@ p, li { white-space: pre-wrap; } + + +