mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Restored file recommendation feature. Improved it a little.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1255 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
2ea7940501
commit
bda1306c01
@ -79,7 +79,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
connect(ui.actionPrintPreview, SIGNAL(triggered()), this, SLOT(printpreview()));
|
||||
|
||||
connect(ui.expandFilesButton, SIGNAL(clicked()), this, SLOT(togglefileview()));
|
||||
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getallrecommended()));
|
||||
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getcurrentrecommended()));
|
||||
|
||||
|
||||
mCurrCertId = "";
|
||||
@ -87,6 +87,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
|
||||
/* hide the Tree +/- */
|
||||
ui.msgList->setRootIsDecorated( false );
|
||||
ui.msgList->setSelectionMode( QAbstractItemView::ExtendedSelection );
|
||||
ui.msgWidget->setRootIsDecorated( false );
|
||||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
@ -197,16 +198,16 @@ void MessagesDialog::msgfilelistWidgetCostumPopupMenu( QPoint point )
|
||||
QMenu contextMnu( this );
|
||||
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
||||
|
||||
// getRecAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), this );
|
||||
// connect( getRecAct , SIGNAL( triggered() ), this, SLOT( getcurrentrecommended() ) );
|
||||
getRecAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), this );
|
||||
connect( getRecAct , SIGNAL( triggered() ), this, SLOT( getcurrentrecommended() ) );
|
||||
|
||||
getAllRecAct = new QAction(QIcon(IMAGE_DOWNLOADALL), tr( "Download All" ), this );
|
||||
connect( getAllRecAct , SIGNAL( triggered() ), this, SLOT( getallrecommended() ) );
|
||||
// getAllRecAct = new QAction(QIcon(IMAGE_DOWNLOADALL), tr( "Download" ), this );
|
||||
// connect( getAllRecAct , SIGNAL( triggered() ), this, SLOT( getallrecommended() ) );
|
||||
|
||||
|
||||
contextMnu.clear();
|
||||
// contextMnu.addAction( getRecAct);
|
||||
contextMnu.addAction( getAllRecAct);
|
||||
contextMnu.addAction( getRecAct);
|
||||
// contextMnu.addAction( getAllRecAct);
|
||||
contextMnu.exec( mevent->globalPos() );
|
||||
}
|
||||
|
||||
@ -405,10 +406,38 @@ void MessagesDialog::togglefileview()
|
||||
/* download the recommendations... */
|
||||
void MessagesDialog::getcurrentrecommended()
|
||||
{
|
||||
|
||||
MessageInfo msgInfo;
|
||||
if (!rsMsgs -> getMessage(mCurrMsgId, msgInfo))
|
||||
return;
|
||||
|
||||
std::list<std::string> srcIds;
|
||||
srcIds.push_back(msgInfo.srcId);
|
||||
|
||||
QModelIndexList list = ui.msgList->selectionModel()->selectedIndexes();
|
||||
|
||||
std::map<int,FileInfo> files ;
|
||||
|
||||
for(QModelIndexList::const_iterator it(list.begin());it!=list.end();++it)
|
||||
{
|
||||
FileInfo& f(files[it->row()]) ;
|
||||
|
||||
switch(it->column())
|
||||
{
|
||||
case 0: f.fname = it->data().toString().toStdString() ;
|
||||
break ;
|
||||
case 1: f.size = it->data().toString().toInt() ;
|
||||
break ;
|
||||
case 3: f.hash = it->data().toString().toStdString() ;
|
||||
break ;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
||||
for(std::map<int,FileInfo>::const_iterator it(files.begin());it!=files.end();++it)
|
||||
rsFiles -> FileRequest(it->second.fname,it->second.hash,it->second.size, "", 0, srcIds);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void MessagesDialog::getallrecommended()
|
||||
{
|
||||
/* get Message */
|
||||
@ -437,8 +466,7 @@ void MessagesDialog::getallrecommended()
|
||||
std::list<std::string>::const_iterator hit;
|
||||
std::list<int>::const_iterator sit;
|
||||
|
||||
for(fit = fnames.begin(), hit = hashes.begin(), sit = sizes.begin();
|
||||
fit != fnames.end(); fit++, hit++, sit++)
|
||||
for(fit = fnames.begin(), hit = hashes.begin(), sit = sizes.begin(); fit != fnames.end(); fit++, hit++, sit++)
|
||||
{
|
||||
std::cerr << "MessagesDialog::getallrecommended() Calling File Request";
|
||||
std::cerr << std::endl;
|
||||
@ -447,6 +475,7 @@ void MessagesDialog::getallrecommended()
|
||||
rsFiles -> FileRequest(*fit, *hit, *sit, "", 0, srcIds);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void MessagesDialog::changeBox(int)
|
||||
{
|
||||
@ -687,20 +716,9 @@ void MessagesDialog::insertMsgTxtAndFiles()
|
||||
item -> setText(0, QString::fromStdString(it->fname));
|
||||
//std::cerr << "Msg FileItem(" << it->fname.length() << ") :" << it->fname << std::endl;
|
||||
|
||||
/* (1) Size */
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << it->size;
|
||||
item -> setText(1, QString::fromStdString(out.str()));
|
||||
}
|
||||
/* (2) Rank */
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << it->rank;
|
||||
item -> setText(2, QString::fromStdString(out.str()));
|
||||
}
|
||||
|
||||
item -> setText(3, QString::fromStdString(it->hash));
|
||||
item -> setText(1, QString::number(it->size)); /* (1) Size */
|
||||
item -> setText(2, QString::number(0)); /* (2) Rank */ // what is this ???
|
||||
item -> setText(3, QString::fromStdString(it->hash));
|
||||
|
||||
/* add to the list */
|
||||
items.append(item);
|
||||
|
@ -61,7 +61,7 @@ private slots:
|
||||
void removemessage();
|
||||
|
||||
void getcurrentrecommended();
|
||||
void getallrecommended();
|
||||
// void getallrecommended();
|
||||
|
||||
/* handle splitter */
|
||||
void togglefileview();
|
||||
|
@ -251,97 +251,103 @@ void SharedFilesDialog::playselectedfiles()
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
//#if 0
|
||||
|
||||
void SharedFilesDialog::addMsgRemoteSelected()
|
||||
{
|
||||
/* call back to the model (which does all the interfacing? */
|
||||
|
||||
std::cerr << "Recommending Files";
|
||||
std::cerr << std::endl;
|
||||
|
||||
QItemSelectionModel *qism = ui.remoteDirTreeView->selectionModel();
|
||||
model -> recommendSelected(qism->selectedIndexes());
|
||||
//void SharedFilesDialog::addMsgRemoteSelected()
|
||||
//{
|
||||
// /* call back to the model (which does all the interfacing? */
|
||||
//
|
||||
// std::cerr << "Recommending Files";
|
||||
// std::cerr << std::endl;
|
||||
//
|
||||
// QItemSelectionModel *qism = ui.remoteDirTreeView->selectionModel();
|
||||
// model -> recommendSelected(qism->selectedIndexes());
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SharedFilesDialog::recommendfile()
|
||||
{
|
||||
/* call back to the model (which does all the interfacing? */
|
||||
|
||||
std::cerr << "Recommending Files";
|
||||
std::cerr << std::endl;
|
||||
|
||||
QItemSelectionModel *qism = ui.localDirTreeView->selectionModel();
|
||||
localModel -> recommendSelected(qism->selectedIndexes());
|
||||
}
|
||||
//void SharedFilesDialog::recommendfile()
|
||||
//{
|
||||
// /* call back to the model (which does all the interfacing? */
|
||||
//
|
||||
// std::cerr << "Recommending Files";
|
||||
// std::cerr << std::endl;
|
||||
//
|
||||
// QItemSelectionModel *qism = ui.localDirTreeView->selectionModel();
|
||||
// localModel -> recommendSelected(qism->selectedIndexes());
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
void SharedFilesDialog::recommendFileSetOnly()
|
||||
{
|
||||
/* call back to the model (which does all the interfacing? */
|
||||
|
||||
std::cerr << "Recommending File Set (clearing old selection)";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* clear current recommend Selection done by model */
|
||||
|
||||
QItemSelectionModel *qism = ui.localDirTreeView->selectionModel();
|
||||
localModel -> recommendSelectedOnly(qism->selectedIndexes());
|
||||
}
|
||||
//void SharedFilesDialog::recommendFileSetOnly()
|
||||
//{
|
||||
// /* call back to the model (which does all the interfacing? */
|
||||
//
|
||||
// std::cerr << "Recommending File Set (clearing old selection)";
|
||||
// std::cerr << std::endl;
|
||||
//
|
||||
// /* clear current recommend Selection done by model */
|
||||
//
|
||||
// QItemSelectionModel *qism = ui.localDirTreeView->selectionModel();
|
||||
// localModel -> recommendSelectedOnly(qism->selectedIndexes());
|
||||
//}
|
||||
|
||||
|
||||
void SharedFilesDialog::recommendFilesTo( std::string rsid )
|
||||
{
|
||||
recommendFileSetOnly();
|
||||
rsicontrol -> ClearInMsg();
|
||||
rsicontrol -> SetInMsg(rsid, true);
|
||||
|
||||
/* create a message */
|
||||
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
|
||||
// recommendFileSetOnly();
|
||||
// rsicontrol -> ClearInMsg();
|
||||
// rsicontrol -> SetInMsg(rsid, true);
|
||||
|
||||
/* fill it in
|
||||
* files are receommended already
|
||||
* just need to set peers
|
||||
*/
|
||||
std::cerr << "SharedFilesDialog::recommendFilesTo()" << std::endl;
|
||||
nMsgDialog->newMsg();
|
||||
nMsgDialog->insertTitleText("Recommendation(s)");
|
||||
nMsgDialog->insertMsgText("Recommendation(s)");
|
||||
std::list<DirDetails> files_info ;
|
||||
|
||||
nMsgDialog->sendMessage();
|
||||
nMsgDialog->close();
|
||||
localModel->getFileInfoFromIndexList(ui.localDirTreeView->selectionModel()->selectedIndexes(),files_info);
|
||||
|
||||
if(files_info.empty())
|
||||
return ;
|
||||
|
||||
/* create a message */
|
||||
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
|
||||
|
||||
/* fill it in
|
||||
* files are receommended already
|
||||
* just need to set peers
|
||||
*/
|
||||
|
||||
nMsgDialog->insertFileList(files_info) ;
|
||||
nMsgDialog->newMsg();
|
||||
nMsgDialog->insertTitleText("Recommendation(s)");
|
||||
nMsgDialog->insertMsgText(rsPeers->getPeerName(rsPeers->getOwnId())+" recommends " + ( (files_info.size()>1)?"a list of files":"a file")+" to you");
|
||||
nMsgDialog->addRecipient(rsid) ;
|
||||
|
||||
nMsgDialog->sendMessage();
|
||||
nMsgDialog->close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SharedFilesDialog::recommendFilesToMsg( std::string rsid )
|
||||
{
|
||||
recommendFileSetOnly();
|
||||
std::list<DirDetails> files_info ;
|
||||
|
||||
rsicontrol -> ClearInMsg();
|
||||
rsicontrol -> SetInMsg(rsid, true);
|
||||
localModel->getFileInfoFromIndexList(ui.localDirTreeView->selectionModel()->selectedIndexes(),files_info);
|
||||
|
||||
/* create a message */
|
||||
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
|
||||
if(files_info.empty())
|
||||
return ;
|
||||
|
||||
/* fill it in
|
||||
* files are receommended already
|
||||
* just need to set peers
|
||||
*/
|
||||
std::cerr << "SharedFilesDialog::recommendFilesToMsg()" << std::endl;
|
||||
nMsgDialog->newMsg();
|
||||
nMsgDialog->insertTitleText("Recommendation(s)");
|
||||
nMsgDialog->insertMsgText("Recommendation(s)");
|
||||
/* create a message */
|
||||
|
||||
nMsgDialog->show();
|
||||
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
|
||||
|
||||
nMsgDialog->insertFileList(files_info) ;
|
||||
nMsgDialog->newMsg();
|
||||
nMsgDialog->insertTitleText("Recommendation(s)");
|
||||
nMsgDialog->insertMsgText("Recommendation(s)");
|
||||
nMsgDialog->show();
|
||||
|
||||
std::cout << "recommending to " << rsid << std::endl ;
|
||||
nMsgDialog->addRecipient(rsid) ;
|
||||
}
|
||||
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
|
||||
void SharedFilesDialog::openfile()
|
||||
@ -385,27 +391,27 @@ void SharedFilesDialog::postModDirectories(bool update_local)
|
||||
|
||||
void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
|
||||
{
|
||||
//=== at this moment we'll show menu only for files, not for folders
|
||||
QModelIndex midx = ui.localDirTreeView->indexAt(point);
|
||||
if (localModel->isDir( midx ) )
|
||||
return;
|
||||
//=== at this moment we'll show menu only for files, not for folders
|
||||
QModelIndex midx = ui.localDirTreeView->indexAt(point);
|
||||
if (localModel->isDir( midx ) )
|
||||
return;
|
||||
|
||||
currentFile = localModel->data(midx,
|
||||
RemoteDirModel::FileNameRole).toString();
|
||||
currentFile = localModel->data(midx,
|
||||
RemoteDirModel::FileNameRole).toString();
|
||||
|
||||
QMenu contextMnu2( this );
|
||||
//
|
||||
QMenu contextMnu2( this );
|
||||
//
|
||||
|
||||
QAction* menuAction = fileAssotiationAction(currentFile) ;
|
||||
//new QAction(QIcon(IMAGE_PLAY), currentFile, this);
|
||||
//tr( "111Play File(s)" ), this );
|
||||
// connect( openfolderAct , SIGNAL( triggered() ), this,
|
||||
// SLOT( playselectedfiles() ) );
|
||||
QAction* menuAction = fileAssotiationAction(currentFile) ;
|
||||
//new QAction(QIcon(IMAGE_PLAY), currentFile, this);
|
||||
//tr( "111Play File(s)" ), this );
|
||||
// connect( openfolderAct , SIGNAL( triggered() ), this,
|
||||
// SLOT( playselectedfiles() ) );
|
||||
|
||||
#if 0
|
||||
openfileAct = new QAction(QIcon(IMAGE_ATTACHMENT), tr( "Add to Recommend List" ), this );
|
||||
connect( openfileAct , SIGNAL( triggered() ), this, SLOT( recommendfile() ) );
|
||||
|
||||
// openfileAct = new QAction(QIcon(IMAGE_ATTACHMENT), tr( "Add to Recommend List" ), this );
|
||||
// connect( openfileAct , SIGNAL( triggered() ), this, SLOT( recommendfile() ) );
|
||||
|
||||
// #if 0
|
||||
/* now we're going to ask who to recommend it to...
|
||||
* First Level.
|
||||
*
|
||||
@ -419,12 +425,12 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
|
||||
*
|
||||
*/
|
||||
|
||||
QMenu *recMenu = new QMenu( tr("Recommend To "), this );
|
||||
recMenu->setIcon(QIcon(IMAGE_ATTACHMENT));
|
||||
QMenu *msgMenu = new QMenu( tr("Message Friend "), &contextMnu2 );
|
||||
msgMenu->setIcon(QIcon(IMAGE_MSG));
|
||||
QMenu *recMenu = new QMenu( tr("Recommend (Automated message) To "), this );
|
||||
recMenu->setIcon(QIcon(IMAGE_ATTACHMENT));
|
||||
QMenu *msgMenu = new QMenu( tr("Recommend in a message to "), &contextMnu2 );
|
||||
msgMenu->setIcon(QIcon(IMAGE_MSG));
|
||||
|
||||
std::list<std::string> peers;
|
||||
std::list<std::string> peers;
|
||||
std::list<std::string>::iterator it;
|
||||
|
||||
if (!rsPeers)
|
||||
@ -432,7 +438,7 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
|
||||
/* not ready yet! */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
rsPeers->getFriendList(peers);
|
||||
|
||||
for(it = peers.begin(); it != peers.end(); it++)
|
||||
@ -443,33 +449,31 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
|
||||
* msgMenu
|
||||
*/
|
||||
|
||||
RsAction *qaf1 = new RsAction( QIcon(IMAGE_FRIEND), QString::fromStdString( name ), recMenu, *it );
|
||||
connect( qaf1 , SIGNAL( triggeredId( std::string ) ), this, SLOT( recommendFilesTo( std::string ) ) );
|
||||
recMenu->addAction(qaf1);
|
||||
RsAction *qaf1 = new RsAction( QIcon(IMAGE_FRIEND), QString::fromStdString( name ), recMenu, *it );
|
||||
connect( qaf1 , SIGNAL( triggeredId( std::string ) ), this, SLOT( recommendFilesTo( std::string ) ) );
|
||||
recMenu->addAction(qaf1);
|
||||
|
||||
RsAction *qaf2 = new RsAction( QIcon(IMAGE_FRIEND), QString::fromStdString( name ), msgMenu, *it );
|
||||
connect( qaf2 , SIGNAL( triggeredId( std::string ) ), this, SLOT( recommendFilesToMsg( std::string ) ) );
|
||||
msgMenu->addAction(qaf2);
|
||||
RsAction *qaf2 = new RsAction( QIcon(IMAGE_FRIEND), QString::fromStdString( name ), msgMenu, *it );
|
||||
connect( qaf2 , SIGNAL( triggeredId( std::string ) ), this, SLOT( recommendFilesToMsg( std::string ) ) );
|
||||
msgMenu->addAction(qaf2);
|
||||
|
||||
/* create list of ids */
|
||||
|
||||
}
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
|
||||
contextMnu2.addAction( menuAction );
|
||||
//contextMnu2.addAction( openfileAct);
|
||||
//contextMnu2.addSeparator();
|
||||
//contextMnu2.addMenu( recMenu);
|
||||
//contextMnu2.addMenu( msgMenu);
|
||||
|
||||
|
||||
QMouseEvent *mevent2 = new QMouseEvent( QEvent::MouseButtonPress, point,
|
||||
Qt::RightButton, Qt::RightButton,
|
||||
Qt::NoModifier );
|
||||
contextMnu2.exec( mevent2->globalPos() );
|
||||
contextMnu2.addAction( menuAction );
|
||||
//contextMnu2.addAction( openfileAct);
|
||||
contextMnu2.addSeparator();
|
||||
contextMnu2.addMenu( recMenu);
|
||||
contextMnu2.addMenu( msgMenu);
|
||||
|
||||
|
||||
QMouseEvent *mevent2 = new QMouseEvent( QEvent::MouseButtonPress, point,
|
||||
Qt::RightButton, Qt::RightButton,
|
||||
Qt::NoModifier );
|
||||
contextMnu2.exec( mevent2->globalPos() );
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
@ -70,8 +70,8 @@ private slots:
|
||||
void openfolder();
|
||||
|
||||
// void recommendFileSetOnly();
|
||||
// void recommendFilesTo( std::string rsid );
|
||||
// void recommendFilesToMsg( std::string rsid );
|
||||
void recommendFilesTo( std::string rsid );
|
||||
void recommendFilesToMsg( std::string rsid );
|
||||
void runCommandForFile();
|
||||
void tryToAddNewAssotiation();
|
||||
|
||||
|
@ -427,53 +427,40 @@ RsCertId getSenderRsCertId(QTreeWidgetItem *i)
|
||||
|
||||
|
||||
/* get the list of peers from the RsIface. */
|
||||
void ChanMsgDialog::insertFileList()
|
||||
void ChanMsgDialog::insertFileList(const std::list<DirDetails>& files_info)
|
||||
{
|
||||
rsiface->lockData(); /* Lock Interface */
|
||||
// rsiface->lockData(); /* Lock Interface */
|
||||
|
||||
_recList.clear() ;
|
||||
|
||||
const std::list<FileInfo> &recList = rsiface->getRecommendList();
|
||||
std::list<FileInfo>::const_iterator it;
|
||||
// const std::list<FileInfo> &recList = rsiface->getRecommendList();
|
||||
std::list<DirDetails>::const_iterator it;
|
||||
|
||||
/* get a link to the table */
|
||||
QTreeWidget *tree = ui.msgFileList;
|
||||
|
||||
tree->clear();
|
||||
tree->setColumnCount(5);
|
||||
tree->clear();
|
||||
tree->setColumnCount(5);
|
||||
|
||||
QList<QTreeWidgetItem *> items;
|
||||
for(it = recList.begin(); it != recList.end(); it++)
|
||||
QList<QTreeWidgetItem *> items;
|
||||
for(it = files_info.begin(); it != files_info.end(); it++)
|
||||
{
|
||||
/* make a widget per person */
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
/* (0) Filename */
|
||||
item -> setText(0, QString::fromStdString(it->fname));
|
||||
|
||||
/* (1) Size */
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << it->size;
|
||||
item -> setText(1, QString::fromStdString(out.str()));
|
||||
}
|
||||
/* (2) Rank */
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << it->rank;
|
||||
item -> setText(2, QString::fromStdString(out.str()));
|
||||
}
|
||||
|
||||
item -> setText(3, QString::fromStdString(it->hash));
|
||||
|
||||
item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
||||
FileInfo info ;
|
||||
info.fname = it->name ;
|
||||
info.hash = it->hash ;
|
||||
info.rank = it->rank ;
|
||||
info.size = it->count ;
|
||||
_recList.push_back(info) ;
|
||||
|
||||
if (it -> inRecommend)
|
||||
{
|
||||
item -> setCheckState(0, Qt::Checked);
|
||||
}
|
||||
else
|
||||
{
|
||||
item -> setCheckState(0, Qt::Unchecked);
|
||||
}
|
||||
/* make a widget per person */
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
|
||||
item->setText(0, QString::fromStdString(it->name)); /* (0) Filename */
|
||||
item->setText(1, QString::number(it->count)); /* (1) Size */
|
||||
item->setText(2, QString::number(it->rank));
|
||||
item->setText(3, QString::fromStdString(it->hash));
|
||||
item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
||||
item->setCheckState(0, Qt::Checked);
|
||||
|
||||
/* add to the list */
|
||||
items.append(item);
|
||||
@ -482,7 +469,7 @@ void ChanMsgDialog::insertFileList()
|
||||
/* add the items in! */
|
||||
tree->insertTopLevelItems(0, items);
|
||||
|
||||
rsiface->unlockData(); /* UnLock Interface */
|
||||
// rsiface->unlockData(); /* UnLock Interface */
|
||||
|
||||
tree->update(); /* update display */
|
||||
}
|
||||
@ -504,7 +491,7 @@ void ChanMsgDialog::newMsg()
|
||||
insertChannelSendList();
|
||||
}
|
||||
|
||||
insertFileList();
|
||||
// insertFileList(std::list<DirDetails>());
|
||||
}
|
||||
|
||||
void ChanMsgDialog::insertTitleText(std::string title)
|
||||
@ -538,8 +525,6 @@ void ChanMsgDialog::insertMsgText(std::string msg)
|
||||
|
||||
void ChanMsgDialog::sendMessage()
|
||||
{
|
||||
|
||||
|
||||
/* construct a message */
|
||||
MessageInfo mi;
|
||||
|
||||
@ -549,15 +534,10 @@ void ChanMsgDialog::sendMessage()
|
||||
|
||||
rsiface->lockData(); /* Lock Interface */
|
||||
|
||||
const std::list<FileInfo> &recList = rsiface->getRecommendList();
|
||||
std::list<FileInfo>::const_iterator it;
|
||||
for(it = recList.begin(); it != recList.end(); it++)
|
||||
{
|
||||
// const std::list<FileInfo>& recList = rsiface->getRecommendList();
|
||||
for(std::list<FileInfo>::const_iterator it(_recList.begin()); it != _recList.end(); ++it)
|
||||
if (it -> inRecommend)
|
||||
{
|
||||
mi.files.push_back(*it);
|
||||
}
|
||||
}
|
||||
|
||||
rsiface->unlockData(); /* UnLock Interface */
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <gui/Preferences/rsharesettings.h>
|
||||
|
||||
#include "ui_ChanMsgDialog.h"
|
||||
#include "rsiface/rsfiles.h"
|
||||
|
||||
class QAction;
|
||||
class QComboBox;
|
||||
@ -51,7 +52,7 @@ void newMsg();
|
||||
/* worker fns */
|
||||
void insertSendList(); /* for Msgs */
|
||||
void insertChannelSendList(); /* for Channels */
|
||||
void insertFileList(); /* for Both */
|
||||
void insertFileList(const std::list<DirDetails>&); /* for Both */
|
||||
void insertTitleText(std::string title);
|
||||
void insertPastedText(std::string msg) ;
|
||||
void insertForwardPastedText(std::string msg);
|
||||
@ -160,6 +161,7 @@ private:
|
||||
/** Qt Designer generated object */
|
||||
Ui::ChanMsgDialog ui;
|
||||
|
||||
std::list<FileInfo> _recList ;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <set>
|
||||
|
||||
#include "RemoteDirModel.h"
|
||||
#include "rsfiles.h"
|
||||
@ -770,10 +771,10 @@ void RemoteDirModel::downloadSelected(QModelIndexList list)
|
||||
*
|
||||
*/
|
||||
|
||||
#if 0
|
||||
|
||||
void RemoteDirModel::recommendSelected(QModelIndexList list)
|
||||
void RemoteDirModel::getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& file_details)
|
||||
{
|
||||
file_details.clear() ;
|
||||
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "recommendSelected()" << std::endl;
|
||||
#endif
|
||||
@ -784,27 +785,29 @@ void RemoteDirModel::recommendSelected(QModelIndexList list)
|
||||
#endif
|
||||
}
|
||||
/* Fire off requests */
|
||||
QModelIndexList::iterator it;
|
||||
for(it = list.begin(); it != list.end(); it++)
|
||||
|
||||
std::set<std::string> already_in ;
|
||||
|
||||
for(QModelIndexList::const_iterator it(list.begin()); it != list.end(); ++it)
|
||||
{
|
||||
void *ref = it -> internalPointer();
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||
if (RemoteMode)
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||
if (RemoteMode)
|
||||
{
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
continue; /* don't recommend remote stuff */
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
}
|
||||
|
||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
||||
{
|
||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "::::::::::::FileRecommend:::: " << std::endl;
|
||||
@ -814,14 +817,18 @@ void RemoteDirModel::recommendSelected(QModelIndexList list)
|
||||
std::cerr << "Path: " << details.path << std::endl;
|
||||
#endif
|
||||
|
||||
rsFiles -> FileRecommend(details.name, details.hash, details.count);
|
||||
if(already_in.find(details.hash) == already_in.end())
|
||||
{
|
||||
file_details.push_back(details) ;
|
||||
already_in.insert(details.hash) ;
|
||||
}
|
||||
}
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "::::::::::::Done FileRecommend" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
void RemoteDirModel::recommendSelectedOnly(QModelIndexList list)
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
@ -873,13 +880,13 @@ void RemoteDirModel::recommendSelectedOnly(QModelIndexList list)
|
||||
std::cerr << "::::::::::::Done FileRecommend" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* OLD RECOMMEND SYSTEM - DISABLED
|
||||
******/
|
||||
|
||||
void RemoteDirModel::openSelected(QModelIndexList list)
|
||||
void RemoteDirModel::openSelected(QModelIndexList)
|
||||
{
|
||||
//recommendSelected(list);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <rsiface/rsfiles.h>
|
||||
#include "util/misc.h"
|
||||
|
||||
class RemoteDirModel : public QAbstractItemModel
|
||||
@ -41,10 +42,11 @@ public:
|
||||
bool isDir ( const QModelIndex & index ) const ;
|
||||
//void openFile(QModelIndex fileIndex, const QString command);
|
||||
|
||||
#if 0 /****** REMOVED ******/
|
||||
void recommendSelected(QModelIndexList list);
|
||||
void recommendSelectedOnly(QModelIndexList list);
|
||||
#endif
|
||||
//#if 0 /****** REMOVED ******/
|
||||
// void recommendSelected(QModelIndexList list);
|
||||
// void recommendSelectedOnly(QModelIndexList list);
|
||||
//#endif
|
||||
void getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& files_info) ;
|
||||
|
||||
void openSelected(QModelIndexList list);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user