mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-10 15:20:25 -04:00
fixed merge with upstream
This commit is contained in:
commit
5b9666855d
241 changed files with 20561 additions and 3381 deletions
|
@ -36,6 +36,8 @@
|
|||
#include "gui/settings/rsharesettings.h"
|
||||
#include "util/QtVersion.h"
|
||||
#include "util/RsAction.h"
|
||||
#include "util/misc.h"
|
||||
#include "util/rstime.h"
|
||||
|
||||
#include <retroshare/rsexpr.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
|
@ -81,6 +83,8 @@
|
|||
|
||||
#define MAX_SEARCH_RESULTS 3000
|
||||
|
||||
#define DISABLE_SEARCH_WHILE_TYPING 1
|
||||
|
||||
// Define to avoid using the search in treeview, because it is really slow for now.
|
||||
//
|
||||
//#define DONT_USE_SEARCH_IN_TREE_VIEW 1
|
||||
|
@ -146,7 +150,7 @@ public:
|
|||
|
||||
/** Constructor */
|
||||
SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareDirModel *_flat_model,QWidget *parent)
|
||||
: RsAutoUpdatePage(1000,parent),model(NULL)
|
||||
: RsAutoUpdatePage(1000,parent), model(NULL)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
@ -165,17 +169,24 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD
|
|||
flat_model = _flat_model ;
|
||||
connect(flat_model, SIGNAL(layoutChanged()), this, SLOT(updateDirTreeView()) );
|
||||
|
||||
// For filtering items we use a trick: the underlying model will use this FilterRole role to highlight selected items
|
||||
// while the filterProxyModel will select them using the pre-chosen string "filtered".
|
||||
|
||||
tree_proxyModel = new SFDSortFilterProxyModel(tree_model, this);
|
||||
tree_proxyModel->setSourceModel(tree_model);
|
||||
tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
tree_proxyModel->setSortRole(RetroshareDirModel::SortRole);
|
||||
tree_proxyModel->sort(COLUMN_NAME);
|
||||
tree_proxyModel->setFilterRole(RetroshareDirModel::FilterRole);
|
||||
tree_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ;
|
||||
|
||||
flat_proxyModel = new SFDSortFilterProxyModel(flat_model, this);
|
||||
flat_proxyModel->setSourceModel(flat_model);
|
||||
flat_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
flat_proxyModel->setSortRole(RetroshareDirModel::SortRole);
|
||||
flat_proxyModel->sort(COLUMN_NAME);
|
||||
flat_proxyModel->setFilterRole(RetroshareDirModel::FilterRole);
|
||||
flat_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ;
|
||||
|
||||
// Mr.Alice: I removed this because it causes a crash for some obscur reason. Apparently when the model is changed, the proxy model cannot
|
||||
// deal with the change by itself. Should I call something specific? I've no idea. Removing this does not seem to cause any harm either.
|
||||
|
@ -186,7 +197,14 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD
|
|||
connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||
connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter()));
|
||||
connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter()));
|
||||
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
||||
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(onFilterTextEdited()));
|
||||
//Hidden by default, shown on onFilterTextEdited
|
||||
ui.filterClearButton->hide();
|
||||
ui.filterStartButton->hide();
|
||||
|
||||
// mFilterTimer = new RsProtectedTimer( this );
|
||||
// mFilterTimer->setSingleShot( true ); // Ensure the timer will fire only once after it was started
|
||||
// connect(mFilterTimer, SIGNAL(timeout()), this, SLOT(filterRegExpChanged()));
|
||||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView * header = ui.dirTreeView->header () ;
|
||||
|
@ -410,7 +428,7 @@ void SharedFilesDialog::changeCurrentViewModel(int viewTypeIndex)
|
|||
ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal, COLUMN_NAME, COLUMN_WN_VISU_DIR) ;
|
||||
|
||||
// recursRestoreExpandedItems(ui.dirTreeView->rootIndex(),expanded_indexes);
|
||||
FilterItems();
|
||||
FilterItems();
|
||||
}
|
||||
|
||||
void LocalSharedFilesDialog::showProperColumns()
|
||||
|
@ -491,53 +509,63 @@ void RemoteSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
|||
{
|
||||
if (!rsPeers) return; /* not ready yet! */
|
||||
|
||||
QMenu *contextMenu = new QMenu(this);
|
||||
|
||||
QModelIndex idx = ui.dirTreeView->indexAt(point) ;
|
||||
if (!idx.isValid()) return;
|
||||
|
||||
QModelIndex midx = proxyModel->mapToSource(idx) ;
|
||||
if (!midx.isValid()) return;
|
||||
|
||||
currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ;
|
||||
int type = model->getType(midx) ;
|
||||
if (type != DIR_TYPE_DIR && type != DIR_TYPE_FILE) return;
|
||||
|
||||
|
||||
QMenu contextMnu( this ) ;
|
||||
|
||||
collCreateAct->setEnabled(true);
|
||||
collOpenAct->setEnabled(true);
|
||||
|
||||
QMenu collectionMenu(tr("Collection"), this);
|
||||
collectionMenu.setIcon(QIcon(IMAGE_LIBRARY));
|
||||
collectionMenu.addAction(collCreateAct);
|
||||
collectionMenu.addAction(collOpenAct);
|
||||
|
||||
QModelIndexList list = ui.dirTreeView->selectionModel()->selectedRows() ;
|
||||
|
||||
if(type == DIR_TYPE_DIR || list.size() > 1)
|
||||
if (idx.isValid())
|
||||
{
|
||||
QAction *downloadActI = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download..." ), &contextMnu ) ;
|
||||
connect( downloadActI , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelectedInteractive() ) ) ;
|
||||
contextMnu.addAction( downloadActI) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), &contextMnu ) ;
|
||||
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ;
|
||||
contextMnu.addAction( downloadAct) ;
|
||||
|
||||
QModelIndex midx = proxyModel->mapToSource(idx) ;
|
||||
if (midx.isValid())
|
||||
{
|
||||
|
||||
currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ;
|
||||
int type = model->getType(midx) ;
|
||||
if ( (type == DIR_TYPE_DIR) || (type == DIR_TYPE_FILE) )
|
||||
{
|
||||
collCreateAct->setEnabled(true);
|
||||
collOpenAct->setEnabled(true);
|
||||
|
||||
QModelIndexList list = ui.dirTreeView->selectionModel()->selectedRows() ;
|
||||
|
||||
if(type == DIR_TYPE_DIR || list.size() > 1)
|
||||
{
|
||||
QAction *downloadActI = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download..." ), contextMenu ) ;
|
||||
connect( downloadActI , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelectedInteractive() ) ) ;
|
||||
contextMenu->addAction( downloadActI) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), contextMenu ) ;
|
||||
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ;
|
||||
contextMenu->addAction( downloadAct) ;
|
||||
}
|
||||
|
||||
contextMenu->addSeparator() ;//------------------------------------
|
||||
contextMenu->addAction( copylinkAct) ;
|
||||
contextMenu->addAction( sendlinkAct) ;
|
||||
contextMenu->addSeparator() ;//------------------------------------
|
||||
contextMenu->addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ;
|
||||
|
||||
contextMenu->addSeparator() ;//------------------------------------
|
||||
|
||||
QMenu collectionMenu(tr("Collection"), this);
|
||||
collectionMenu.setIcon(QIcon(IMAGE_LIBRARY));
|
||||
collectionMenu.addAction(collCreateAct);
|
||||
collectionMenu.addAction(collOpenAct);
|
||||
contextMenu->addMenu(&collectionMenu) ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addAction( copylinkAct) ;
|
||||
contextMnu.addAction( sendlinkAct) ;
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ;
|
||||
contextMenu = model->getContextMenu(contextMenu);
|
||||
|
||||
if (!contextMenu->children().isEmpty())
|
||||
contextMenu->exec(QCursor::pos()) ;
|
||||
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addMenu(&collectionMenu) ;
|
||||
|
||||
contextMnu.exec(QCursor::pos()) ;
|
||||
delete contextMenu;
|
||||
}
|
||||
|
||||
QModelIndexList SharedFilesDialog::getSelected()
|
||||
|
@ -908,11 +936,44 @@ void SharedFilesDialog::restoreExpandedPathsAndSelection(const std::set<std::str
|
|||
std::string path = ui.dirTreeView->model()->index(row,0).data(Qt::DisplayRole).toString().toStdString();
|
||||
recursRestoreExpandedItems(ui.dirTreeView->model()->index(row,0),path,expanded_indexes,hidden_indexes,selected_indexes);
|
||||
}
|
||||
QItemSelection selection ;
|
||||
//QItemSelection selection ;
|
||||
|
||||
ui.dirTreeView->blockSignals(false) ;
|
||||
}
|
||||
|
||||
void SharedFilesDialog::expandAll()
|
||||
{
|
||||
if(ui.dirTreeView->model() == NULL || ui.dirTreeView->model() == flat_proxyModel) // this method causes infinite loops on flat models
|
||||
return ;
|
||||
|
||||
ui.dirTreeView->blockSignals(true) ;
|
||||
|
||||
#ifdef DEBUG_SHARED_FILES_DIALOG
|
||||
std::cerr << "Restoring expanded items. " << std::endl;
|
||||
#endif
|
||||
for(int row = 0; row < ui.dirTreeView->model()->rowCount(); ++row)
|
||||
{
|
||||
std::string path = ui.dirTreeView->model()->index(row,0).data(Qt::DisplayRole).toString().toStdString();
|
||||
recursExpandAll(ui.dirTreeView->model()->index(row,0));
|
||||
}
|
||||
|
||||
ui.dirTreeView->blockSignals(false) ;
|
||||
|
||||
}
|
||||
|
||||
void SharedFilesDialog::recursExpandAll(const QModelIndex& index)
|
||||
{
|
||||
ui.dirTreeView->setExpanded(index,true) ;
|
||||
|
||||
for(int row=0;row<ui.dirTreeView->model()->rowCount(index);++row)
|
||||
{
|
||||
QModelIndex idx(index.child(row,0)) ;
|
||||
|
||||
if(ui.dirTreeView->model()->rowCount(idx) > 0)
|
||||
recursExpandAll(idx) ;
|
||||
}
|
||||
}
|
||||
|
||||
void SharedFilesDialog::recursSaveExpandedItems(const QModelIndex& index,const std::string& path,std::set<std::string>& exp,
|
||||
std::set<std::string>& vis,
|
||||
std::set<std::string>& sel
|
||||
|
@ -964,8 +1025,8 @@ void SharedFilesDialog::recursRestoreExpandedItems(const QModelIndex& index, con
|
|||
bool invisible = vis.find(local_path) != vis.end();
|
||||
ui.dirTreeView->setRowHidden(index.row(),index.parent(),invisible ) ;
|
||||
|
||||
if(invisible)
|
||||
mHiddenIndexes.push_back(proxyModel->mapToSource(index));
|
||||
// if(invisible)
|
||||
// mHiddenIndexes.push_back(proxyModel->mapToSource(index));
|
||||
|
||||
if(!invisible && exp.find(local_path) != exp.end())
|
||||
{
|
||||
|
@ -997,12 +1058,12 @@ void SharedFilesDialog::postModDirectories(bool local)
|
|||
flat_model->postMods();
|
||||
ui.dirTreeView->update() ;
|
||||
|
||||
if (ui.filterPatternLineEdit->text().isEmpty() == false)
|
||||
if (ui.filterPatternLineEdit->text().isEmpty() == false)
|
||||
FilterItems();
|
||||
|
||||
ui.dirTreeView->setSortingEnabled(true);
|
||||
ui.dirTreeView->setSortingEnabled(true);
|
||||
|
||||
restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes) ;
|
||||
restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes) ;
|
||||
|
||||
#ifdef DEBUG_SHARED_FILES_DIALOG
|
||||
std::cerr << "****** updated directories! Re-enabling sorting ******" << std::endl;
|
||||
|
@ -1236,34 +1297,44 @@ void SharedFilesDialog::indicatorChanged(int index)
|
|||
updateDisplay() ;
|
||||
}
|
||||
|
||||
void SharedFilesDialog::filterRegExpChanged()
|
||||
void SharedFilesDialog::onFilterTextEdited()
|
||||
{
|
||||
QString text = ui.filterPatternLineEdit->text();
|
||||
QString text = ui.filterPatternLineEdit->text();
|
||||
|
||||
if (text.isEmpty()) {
|
||||
ui.filterClearButton->hide();
|
||||
} else {
|
||||
ui.filterClearButton->show();
|
||||
}
|
||||
if (text.isEmpty()) {
|
||||
ui.filterClearButton->hide();
|
||||
} else {
|
||||
ui.filterClearButton->show();
|
||||
}
|
||||
|
||||
if (text == lastFilterString) {
|
||||
ui.filterStartButton->hide();
|
||||
} else {
|
||||
ui.filterStartButton->show();
|
||||
}
|
||||
|
||||
//bool valid = false ;
|
||||
//QColor color ;
|
||||
if (text == lastFilterString) {
|
||||
ui.filterStartButton->hide();
|
||||
} else {
|
||||
ui.filterStartButton->show();
|
||||
}
|
||||
|
||||
if(text.length() > 0 && text.length() < 3)
|
||||
{
|
||||
//valid = false;
|
||||
|
||||
ui.filterStartButton->setEnabled(false) ;
|
||||
ui.filterPatternFrame->setToolTip(tr("Search string should be at least 3 characters long.")) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
ui.filterStartButton->setEnabled(true) ;
|
||||
ui.filterPatternFrame->setToolTip(QString());
|
||||
|
||||
//FilterItems();
|
||||
#ifndef DISABLE_SEARCH_WHILE_TYPING
|
||||
mFilterTimer->start( 500 ); // This will fire filterRegExpChanged after 500 ms.
|
||||
// If the user types something before it fires, the timer restarts counting
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEPRECATED_CODE
|
||||
void SharedFilesDialog::filterRegExpChanged()
|
||||
{
|
||||
QString text = ui.filterPatternLineEdit->text();
|
||||
|
||||
if(text.length() > 0 && proxyModel == tree_proxyModel)
|
||||
{
|
||||
std::list<DirDetails> result_list ;
|
||||
|
@ -1296,17 +1367,8 @@ void SharedFilesDialog::filterRegExpChanged()
|
|||
|
||||
ui.filterStartButton->setEnabled(true) ;
|
||||
ui.filterPatternFrame->setToolTip(QString());
|
||||
|
||||
/* unpolish widget to clear the stylesheet's palette cache */
|
||||
// ui.filterPatternFrame->style()->unpolish(ui.filterPatternFrame);
|
||||
|
||||
// QPalette palette = ui.filterPatternLineEdit->palette();
|
||||
// palette.setColor(ui.filterPatternLineEdit->backgroundRole(), color);
|
||||
// ui.filterPatternLineEdit->setPalette(palette);
|
||||
|
||||
// //ui.searchLineFrame->setProperty("valid", valid);
|
||||
// Rshare::refreshStyleSheet(ui.filterPatternFrame, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* clear Filter */
|
||||
void SharedFilesDialog::clearFilter()
|
||||
|
@ -1320,10 +1382,10 @@ void SharedFilesDialog::clearFilter()
|
|||
/* clear Filter */
|
||||
void SharedFilesDialog::startFilter()
|
||||
{
|
||||
ui.filterStartButton->hide();
|
||||
lastFilterString = ui.filterPatternLineEdit->text();
|
||||
ui.filterStartButton->hide();
|
||||
lastFilterString = ui.filterPatternLineEdit->text();
|
||||
|
||||
FilterItems();
|
||||
FilterItems();
|
||||
}
|
||||
|
||||
void SharedFilesDialog::updateDirTreeView()
|
||||
|
@ -1341,13 +1403,14 @@ void SharedFilesDialog::updateDirTreeView()
|
|||
ui.dirTreeView->setToolTip("");
|
||||
}
|
||||
|
||||
//#define DEBUG_SHARED_FILES_DIALOG
|
||||
|
||||
#ifdef DEPRECATED_CODE
|
||||
// This macro make the search expand all items that contain the searched text.
|
||||
// A bug however, makes RS expand everything when nothing is selected, which is a pain.
|
||||
|
||||
#define EXPAND_WHILE_SEARCHING 1
|
||||
|
||||
//#define DEBUG_SHARED_FILES_DIALOG
|
||||
|
||||
void recursMakeVisible(QTreeView *tree,const QSortFilterProxyModel *proxyModel,const QModelIndex& indx,uint32_t depth,const std::vector<std::set<void*> >& pointers,QList<QModelIndex>& hidden_list)
|
||||
{
|
||||
#ifdef DEBUG_SHARED_FILES_DIALOG
|
||||
|
@ -1403,6 +1466,8 @@ void recursMakeVisible(QTreeView *tree,const QSortFilterProxyModel *proxyModel,c
|
|||
|
||||
void SharedFilesDialog::restoreInvisibleItems()
|
||||
{
|
||||
std::cerr << "Restoring " << mHiddenIndexes.size() << " invisible indexes" << std::endl;
|
||||
|
||||
for(QList<QModelIndex>::const_iterator it(mHiddenIndexes.begin());it!=mHiddenIndexes.end();++it)
|
||||
{
|
||||
QModelIndex indx = proxyModel->mapFromSource(*it);
|
||||
|
@ -1413,6 +1478,7 @@ void SharedFilesDialog::restoreInvisibleItems()
|
|||
|
||||
mHiddenIndexes.clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
class QCursorContextBlocker
|
||||
{
|
||||
|
@ -1445,115 +1511,60 @@ void SharedFilesDialog::FilterItems()
|
|||
|
||||
if(mLastFilterText == text) // do not filter again if we already did. This is an optimization
|
||||
{
|
||||
#ifdef DEBUG_SHARED_FILES_DIALOG
|
||||
std::cerr << "Last text is equal to text. skipping" << std::endl;
|
||||
#endif
|
||||
return ;
|
||||
}
|
||||
|
||||
std::cerr << "New last text. Performing the filter" << std::endl;
|
||||
#ifdef DEBUG_SHARED_FILES_DIALOG
|
||||
std::cerr << "New last text. Performing the filter on string \"" << text.toStdString() << "\"" << std::endl;
|
||||
#endif
|
||||
mLastFilterText = text ;
|
||||
model->update() ;
|
||||
restoreInvisibleItems();
|
||||
|
||||
QCursorContextBlocker q(ui.dirTreeView) ;
|
||||
|
||||
if(proxyModel == tree_proxyModel)
|
||||
QCoreApplication::processEvents() ;
|
||||
|
||||
std::list<DirDetails> result_list ;
|
||||
uint32_t found = 0 ;
|
||||
|
||||
if(text == "")
|
||||
{
|
||||
QCoreApplication::processEvents() ;
|
||||
|
||||
std::list<std::string> keywords ;
|
||||
std::list<DirDetails> result_list ;
|
||||
|
||||
if(text == "")
|
||||
return ;
|
||||
|
||||
if(text.length() < 3)
|
||||
return ;
|
||||
|
||||
FileSearchFlags flags = isRemote()?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
|
||||
QStringList lst = text.split(" ",QString::SkipEmptyParts) ;
|
||||
|
||||
for(auto it(lst.begin());it!=lst.end();++it)
|
||||
keywords.push_back((*it).toStdString());
|
||||
|
||||
if(keywords.size() > 1)
|
||||
{
|
||||
RsRegularExpression::NameExpression exp(RsRegularExpression::ContainsAllStrings,keywords,true);
|
||||
rsFiles->SearchBoolExp(&exp,result_list, flags) ;
|
||||
}
|
||||
else
|
||||
rsFiles->SearchKeywords(keywords,result_list, flags) ;
|
||||
|
||||
#ifdef DEBUG_SHARED_FILES_DIALOG
|
||||
std::cerr << "Found " << result_list.size() << " results" << std::endl;
|
||||
#endif
|
||||
|
||||
if(result_list.size() > MAX_SEARCH_RESULTS)
|
||||
return ;
|
||||
#ifdef DEBUG_SHARED_FILES_DIALOG
|
||||
std::cerr << "Found this result: " << std::endl;
|
||||
#endif
|
||||
std::vector<std::set<void*> > pointers(2,std::set<void*>()); // at least two levels need to be here.
|
||||
|
||||
// Then show only the ones we need
|
||||
for(auto it(result_list.begin());it!=result_list.end();++it)
|
||||
{
|
||||
#ifdef DEBUG_SHARED_FILES_DIALOG
|
||||
std::cerr << (void*)(*it).ref << " parents: " ;
|
||||
#endif
|
||||
|
||||
DirDetails& det(*it) ;
|
||||
void *p = NULL;
|
||||
std::list<void*> lst ;
|
||||
|
||||
lst.push_back(det.ref) ;
|
||||
|
||||
while(det.type == DIR_TYPE_FILE || det.type == DIR_TYPE_DIR)
|
||||
{
|
||||
p = det.parent ;
|
||||
rsFiles->RequestDirDetails( p, det, flags);
|
||||
|
||||
#ifdef DEBUG_SHARED_FILES_DIALOG
|
||||
std::cerr << " " << (void*)p << "(" << (int)det.type << ")";
|
||||
#endif
|
||||
|
||||
lst.push_front(p) ;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_SHARED_FILES_DIALOG
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
uint32_t u=0;
|
||||
for(auto it2(lst.begin());it2!=lst.end();++it2,++u)
|
||||
{
|
||||
if(pointers.size() <= u)
|
||||
pointers.resize(u+5) ;
|
||||
|
||||
pointers[u].insert(*it2) ;
|
||||
}
|
||||
}
|
||||
|
||||
int rowCount = ui.dirTreeView->model()->rowCount();
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
recursMakeVisible(ui.dirTreeView,proxyModel,ui.dirTreeView->model()->index(row, COLUMN_NAME),0,pointers,mHiddenIndexes);
|
||||
model->filterItems(std::list<std::string>(),found) ;
|
||||
model->update() ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if(text.length() < 3)
|
||||
return ;
|
||||
|
||||
FileSearchFlags flags = isRemote()?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
|
||||
QStringList lst = text.split(" ",QString::SkipEmptyParts) ;
|
||||
std::list<std::string> keywords ;
|
||||
|
||||
for(auto it(lst.begin());it!=lst.end();++it)
|
||||
keywords.push_back((*it).toStdString());
|
||||
|
||||
model->filterItems(keywords,found) ;
|
||||
model->update() ;
|
||||
|
||||
if(found > 0)
|
||||
expandAll();
|
||||
|
||||
if(found == 0)
|
||||
ui.filterPatternFrame->setToolTip(tr("No result.")) ;
|
||||
else if(found > MAX_SEARCH_RESULTS)
|
||||
ui.filterPatternFrame->setToolTip(tr("More than %1 results. Add more/longer search words to select less.").arg(MAX_SEARCH_RESULTS)) ;
|
||||
else
|
||||
{
|
||||
int rowCount = ui.dirTreeView->model()->rowCount();
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
flat_FilterItem(ui.dirTreeView->model()->index(row, COLUMN_NAME), text, 0);
|
||||
}
|
||||
ui.filterPatternFrame->setToolTip(tr("Found %1 results.").arg(found)) ;
|
||||
|
||||
#ifdef DEPRECATED_CODE
|
||||
int rowCount = ui.dirTreeView->model()->rowCount();
|
||||
for (int row = 0; row < rowCount; ++row)
|
||||
if(proxyModel == tree_proxyModel)
|
||||
tree_FilterItem(ui.dirTreeView->model()->index(row, COLUMN_NAME), text, 0);
|
||||
else
|
||||
flat_FilterItem(ui.dirTreeView->model()->index(row, COLUMN_NAME), text, 0);
|
||||
#ifdef DEBUG_SHARED_FILES_DIALOG
|
||||
std::cerr << found << " results found by search." << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEPRECATED_CODE
|
||||
bool SharedFilesDialog::flat_FilterItem(const QModelIndex &index, const QString &text, int /*level*/)
|
||||
{
|
||||
if(index.data(RetroshareDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive))
|
||||
|
@ -1603,4 +1614,4 @@ bool SharedFilesDialog::tree_FilterItem(const QModelIndex &index, const QString
|
|||
|
||||
return (visible || visibleChildCount);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,10 +22,13 @@
|
|||
#ifndef _SHAREDFILESDIALOG_H
|
||||
#define _SHAREDFILESDIALOG_H
|
||||
|
||||
#include <set>
|
||||
#include "ui_SharedFilesDialog.h"
|
||||
|
||||
#include "RsAutoUpdatePage.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "ui_SharedFilesDialog.h"
|
||||
#include "util/RsProtectedTimer.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
class RetroshareDirModel;
|
||||
class QSortFilterProxyModel;
|
||||
|
@ -73,7 +76,8 @@ private slots:
|
|||
|
||||
void indicatorChanged(int index);
|
||||
|
||||
void filterRegExpChanged();
|
||||
void onFilterTextEdited();
|
||||
//void filterRegExpChanged();
|
||||
void clearFilter();
|
||||
void startFilter();
|
||||
|
||||
|
@ -93,6 +97,8 @@ protected:
|
|||
void recursSaveExpandedItems(const QModelIndex& index, const std::string &path, std::set<std::string> &exp,std::set<std::string>& vis, std::set<std::string>& sel);
|
||||
void saveExpandedPathsAndSelection(std::set<std::string>& paths,std::set<std::string>& visible_indexes, std::set<std::string>& selected_indexes) ;
|
||||
void restoreExpandedPathsAndSelection(const std::set<std::string>& paths,const std::set<std::string>& visible_indexes, const std::set<std::string>& selected_indexes) ;
|
||||
void recursExpandAll(const QModelIndex& index);
|
||||
void expandAll();
|
||||
|
||||
protected:
|
||||
//now context menu are created again every time theu are called ( in some
|
||||
|
@ -109,8 +115,6 @@ protected:
|
|||
bool tree_FilterItem(const QModelIndex &index, const QString &text, int level);
|
||||
bool flat_FilterItem(const QModelIndex &index, const QString &text, int level);
|
||||
|
||||
void restoreInvisibleItems();
|
||||
|
||||
QModelIndexList getSelected();
|
||||
|
||||
/** Defines the actions for the context menu for QTreeWidget */
|
||||
|
@ -137,8 +141,7 @@ protected:
|
|||
|
||||
QString lastFilterString;
|
||||
QString mLastFilterText ;
|
||||
|
||||
QList<QModelIndex> mHiddenIndexes;
|
||||
RsProtectedTimer* mFilterTimer;
|
||||
};
|
||||
|
||||
class LocalSharedFilesDialog : public SharedFilesDialog
|
||||
|
@ -195,7 +198,7 @@ class RemoteSharedFilesDialog : public SharedFilesDialog
|
|||
private slots:
|
||||
void downloadRemoteSelected();
|
||||
void downloadRemoteSelectedInteractive();
|
||||
void expanded(const QModelIndex& indx);
|
||||
void expanded(const QModelIndex& indx);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -233,7 +233,9 @@ void xProgressBar::paint()
|
|||
|
||||
uint32_t ss = _pinfo.nb_chunks ;
|
||||
|
||||
if(ss > 1) // for small files we use a more progressive display
|
||||
QRect bounding = painter->boundingRect(rect, Qt::AlignCenter, QLocale().toString(_pinfo.progress, 'f', 2) + "%");
|
||||
|
||||
if((ss > 1) && (rect.width() > (1.5*bounding.width()))) // for small files we use a more progressive display
|
||||
{
|
||||
if(!_pinfo.cmap._map.empty())
|
||||
{
|
||||
|
@ -303,7 +305,7 @@ void xProgressBar::paint()
|
|||
overPaintSelectedChunks( _pinfo.chunks_in_progress , QColor(170, 20,9), QColor(223,121,123), width,ss) ;
|
||||
overPaintSelectedChunks( _pinfo.chunks_in_checking , QColor(186,143,0), QColor(223,196, 61), width,ss) ;
|
||||
}
|
||||
else
|
||||
else if ((rect.width() < bounding.width()) || !displayText)
|
||||
{
|
||||
// calculate progress value
|
||||
int preWidth = static_cast<int>((rect.width() - 1 - hSpan)*(_pinfo.progress/100.0f));
|
||||
|
@ -318,11 +320,20 @@ void xProgressBar::paint()
|
|||
|
||||
|
||||
// paint text?
|
||||
if (displayText)
|
||||
if (displayText && (rect.width() >= bounding.width()))
|
||||
{
|
||||
QLocale locale;
|
||||
QColor colorInt (255-textColor.red(), 255-textColor.green(), 255-textColor.blue(), 127);
|
||||
QColor colorBor (255-textColor.red(), 255-textColor.green(), 255-textColor.blue(), 63);
|
||||
QRadialGradient radialGrad(bounding.x()+(bounding.width()/2), bounding.y()+(bounding.height()/2),bounding.width()/2);
|
||||
radialGrad.setColorAt(0.0, colorInt);
|
||||
radialGrad.setColorAt(1.0, colorBor);
|
||||
radialGrad.setSpread(QGradient::ReflectSpread);
|
||||
painter->setPen(colorBor);
|
||||
painter->setBrush(radialGrad);
|
||||
painter->drawRoundedRect(bounding.adjusted(-2,2,2,-3),4.0,4.0);
|
||||
|
||||
painter->setPen(textColor);
|
||||
painter->drawText(rect, Qt::AlignCenter, locale.toString(_pinfo.progress, 'f', 2) + "%");
|
||||
painter->drawText(rect, Qt::AlignCenter, QLocale().toString(_pinfo.progress, 'f', 2) + "%");
|
||||
}
|
||||
|
||||
backgroundColor.setRgb(255, 255, 255);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue