mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 15:28:28 -05:00
Added new Patch from Phenom (AddRSCollectionEditor_v0.6_7386)
Some Improvements : added submenu, Edit and view mode. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7388 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5e1099f47f
commit
e65f73a44d
@ -70,9 +70,8 @@
|
||||
/* Images for context menu icons */
|
||||
#define IMAGE_INFO ":/images/fileinfo.png"
|
||||
#define IMAGE_CANCEL ":/images/delete.png"
|
||||
#define IMAGE_LIBRARY ":/images/library.png"
|
||||
#define IMAGE_CLEARCOMPLETED ":/images/deleteall.png"
|
||||
#define IMAGE_PLAY ":/images/player_play.png"
|
||||
#define IMAGE_PLAY ":/images/player_play.png"
|
||||
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
||||
#define IMAGE_PASTELINK ":/images/pasterslink.png"
|
||||
#define IMAGE_PAUSE ":/images/pause.png"
|
||||
@ -86,12 +85,17 @@
|
||||
#define IMAGE_PRIORITYNORMAL ":/images/prioritynormal.png"
|
||||
#define IMAGE_PRIORITYHIGH ":/images/priorityhigh.png"
|
||||
#define IMAGE_PRIORITYAUTO ":/images/priorityauto.png"
|
||||
#define IMAGE_SEARCH ":/images/filefind.png"
|
||||
#define IMAGE_EXPAND ":/images/edit_add24.png"
|
||||
#define IMAGE_COLLAPSE ":/images/edit_remove24.png"
|
||||
#define IMAGE_FRIENDSFILES ":/images/fileshare16.png"
|
||||
#define IMAGE_MYFILES ":images/my_documents_16.png"
|
||||
#define IMAGE_RENAMEFILE ":images/filecomments.png"
|
||||
#define IMAGE_SEARCH ":/images/filefind.png"
|
||||
#define IMAGE_EXPAND ":/images/edit_add24.png"
|
||||
#define IMAGE_COLLAPSE ":/images/edit_remove24.png"
|
||||
#define IMAGE_LIBRARY ":/images/library.png"
|
||||
#define IMAGE_COLLCREATE ":/images/library_add.png"
|
||||
#define IMAGE_COLLMODIF ":/images/library_edit.png"
|
||||
#define IMAGE_COLLVIEW ":/images/library_view.png"
|
||||
#define IMAGE_COLLOPEN ":/images/library.png"
|
||||
#define IMAGE_FRIENDSFILES ":/images/fileshare16.png"
|
||||
#define IMAGE_MYFILES ":images/my_documents_16.png"
|
||||
#define IMAGE_RENAMEFILE ":images/filecomments.png"
|
||||
#define IMAGE_STREAMING ":images/streaming.png"
|
||||
|
||||
Q_DECLARE_METATYPE(FileProgressInfo)
|
||||
@ -367,9 +371,6 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
||||
toggleShowCacheTransfersAct->setCheckable(true) ;
|
||||
connect(toggleShowCacheTransfersAct,SIGNAL(triggered()),this,SLOT(toggleShowCacheTransfers())) ;
|
||||
|
||||
openCollectionAct = new QAction(QIcon(IMAGE_LIBRARY), tr( "Download from collection file..." ), this );
|
||||
connect(openCollectionAct, SIGNAL(triggered()), this, SLOT(openCollection()));
|
||||
|
||||
// Actions. Only need to be defined once.
|
||||
pauseAct = new QAction(QIcon(IMAGE_PAUSE), tr("Pause"), this);
|
||||
connect(pauseAct, SIGNAL(triggered()), this, SLOT(pauseFileTransfer()));
|
||||
@ -431,14 +432,22 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
||||
connect(chunkProgressiveAct, SIGNAL(triggered()), this, SLOT(chunkProgressive()));
|
||||
playAct = new QAction(QIcon(IMAGE_PLAY), tr( "Play" ), this );
|
||||
connect( playAct , SIGNAL( triggered() ), this, SLOT( openTransfer() ) );
|
||||
renameFileAct = new QAction(QIcon(IMAGE_RENAMEFILE), tr("Rename file..."), this);
|
||||
connect(renameFileAct, SIGNAL(triggered()), this, SLOT(renameFile()));
|
||||
specifyDestinationDirectoryAct = new QAction(QIcon(IMAGE_SEARCH),tr("Specify..."),this) ;
|
||||
connect(specifyDestinationDirectoryAct,SIGNAL(triggered()),this,SLOT(chooseDestinationDirectory())) ;
|
||||
expandAllAct= new QAction(QIcon(IMAGE_EXPAND),tr("Expand all"),this);
|
||||
connect(expandAllAct,SIGNAL(triggered()),this,SLOT(expandAll())) ;
|
||||
collapseAllAct= new QAction(QIcon(IMAGE_COLLAPSE),tr("Collapse all"),this);
|
||||
connect(collapseAllAct,SIGNAL(triggered()),this,SLOT(collapseAll())) ;
|
||||
renameFileAct = new QAction(QIcon(IMAGE_RENAMEFILE), tr("Rename file..."), this);
|
||||
connect(renameFileAct, SIGNAL(triggered()), this, SLOT(renameFile()));
|
||||
specifyDestinationDirectoryAct = new QAction(QIcon(IMAGE_SEARCH),tr("Specify..."),this) ;
|
||||
connect(specifyDestinationDirectoryAct,SIGNAL(triggered()),this,SLOT(chooseDestinationDirectory()));
|
||||
expandAllAct= new QAction(QIcon(IMAGE_EXPAND),tr("Expand all"),this);
|
||||
connect(expandAllAct,SIGNAL(triggered()),this,SLOT(expandAll()));
|
||||
collapseAllAct= new QAction(QIcon(IMAGE_COLLAPSE),tr("Collapse all"),this);
|
||||
connect(collapseAllAct,SIGNAL(triggered()),this,SLOT(collapseAll()));
|
||||
collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this);
|
||||
connect(collCreateAct,SIGNAL(triggered()),this,SLOT(collCreate()));
|
||||
collModifAct= new QAction(QIcon(IMAGE_COLLMODIF), tr("Modify Collection..."), this);
|
||||
connect(collModifAct,SIGNAL(triggered()),this,SLOT(collModif()));
|
||||
collViewAct= new QAction(QIcon(IMAGE_COLLVIEW), tr("View Collection..."), this);
|
||||
connect(collViewAct,SIGNAL(triggered()),this,SLOT(collView()));
|
||||
collOpenAct = new QAction(QIcon(IMAGE_COLLOPEN), tr( "Download from collection file..." ), this );
|
||||
connect(collOpenAct, SIGNAL(triggered()), this, SLOT(collOpen()));
|
||||
|
||||
/** Setup the actions for the header context menu */
|
||||
showDLSizeAct= new QAction(tr("Size"),this);
|
||||
@ -618,23 +627,24 @@ void TransfersDialog::processSettings(bool bLoad)
|
||||
|
||||
void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ )
|
||||
{
|
||||
std::set<RsFileHash> items;
|
||||
getSelectedItems(&items, NULL);
|
||||
std::set<RsFileHash> items ;
|
||||
getSelectedItems(&items, NULL) ;
|
||||
|
||||
bool single = (items.size() == 1) ;
|
||||
|
||||
bool atLeastOne_Waiting = false;
|
||||
bool atLeastOne_Downloading = false;
|
||||
bool atLeastOne_Complete = false;
|
||||
bool atLeastOne_Queued = false;
|
||||
bool atLeastOne_Paused = false;
|
||||
bool atLeastOne_Waiting = false ;
|
||||
bool atLeastOne_Downloading = false ;
|
||||
bool atLeastOne_Complete = false ;
|
||||
bool atLeastOne_Queued = false ;
|
||||
bool atLeastOne_Paused = false ;
|
||||
|
||||
bool add_PlayOption = false ;
|
||||
bool add_PreviewOption=false ;
|
||||
bool add_OpenFileOption = false ;
|
||||
bool add_CopyLink = false ;
|
||||
bool add_PasteLink = false ;
|
||||
bool add_CollActions = false ;
|
||||
|
||||
bool add_PlayOption = false;
|
||||
bool add_PreviewOption=false;
|
||||
bool add_OpenFileOption = false;
|
||||
bool add_CopyLink = false;
|
||||
bool add_PasteLink = false;
|
||||
|
||||
FileInfo info;
|
||||
|
||||
QMenu priorityQueueMenu(tr("Move in Queue..."), this);
|
||||
@ -656,157 +666,168 @@ void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ )
|
||||
chunkMenu.addAction(chunkProgressiveAct);
|
||||
chunkMenu.addAction(chunkRandomAct);
|
||||
|
||||
QMenu collectionMenu(tr("Collection"), this);
|
||||
collectionMenu.setIcon(QIcon(IMAGE_LIBRARY));
|
||||
collectionMenu.addAction(collCreateAct);
|
||||
collectionMenu.addAction(collModifAct);
|
||||
collectionMenu.addAction(collViewAct);
|
||||
collectionMenu.addAction(collOpenAct);
|
||||
|
||||
QMenu contextMnu( this );
|
||||
|
||||
if(!RSLinkClipboard::empty(RetroShareLink::TYPE_FILE))
|
||||
add_PasteLink=true;
|
||||
if(!RSLinkClipboard::empty(RetroShareLink::TYPE_FILE)) add_PasteLink=true;
|
||||
|
||||
if(!items.empty())
|
||||
{
|
||||
add_CopyLink = true;
|
||||
add_CopyLink = true ;
|
||||
|
||||
QModelIndexList lst = ui.downloadList->selectionModel ()->selectedIndexes ();
|
||||
|
||||
//Look for all selected items
|
||||
for (int i = 0; i < lst.count (); i++)
|
||||
{
|
||||
//Look only for first column == File List
|
||||
if ( lst[i].column() == 0)
|
||||
{
|
||||
//Get Info for current item
|
||||
if (rsFiles->FileDetails(RsFileHash(getID(lst[i].row(), DLListModel).toStdString()), RS_FILE_HINTS_DOWNLOAD, info))
|
||||
{
|
||||
/*const uint32_t FT_STATE_FAILED = 0x0000 ;
|
||||
const uint32_t FT_STATE_OKAY = 0x0001 ;
|
||||
const uint32_t FT_STATE_WAITING = 0x0002 ;
|
||||
const uint32_t FT_STATE_DOWNLOADING = 0x0003 ;
|
||||
const uint32_t FT_STATE_COMPLETE = 0x0004 ;
|
||||
const uint32_t FT_STATE_QUEUED = 0x0005 ;
|
||||
const uint32_t FT_STATE_PAUSED = 0x0006 ;
|
||||
const uint32_t FT_STATE_CHECKING_HASH = 0x0007 ;
|
||||
*/
|
||||
if (info.downloadStatus == FT_STATE_WAITING)
|
||||
{
|
||||
atLeastOne_Waiting = true;
|
||||
}
|
||||
if (info.downloadStatus == FT_STATE_DOWNLOADING)
|
||||
{
|
||||
atLeastOne_Downloading=true;
|
||||
}
|
||||
if (info.downloadStatus == FT_STATE_COMPLETE)
|
||||
{
|
||||
atLeastOne_Complete = true;
|
||||
add_OpenFileOption = single;
|
||||
}
|
||||
if(info.downloadStatus == FT_STATE_QUEUED)
|
||||
{
|
||||
atLeastOne_Queued = true;
|
||||
}
|
||||
if (info.downloadStatus == FT_STATE_PAUSED)
|
||||
{
|
||||
atLeastOne_Paused = true;
|
||||
}
|
||||
//Look for all selected items
|
||||
for (int i = 0; i < lst.count(); i++) {
|
||||
//Look only for first column == File List
|
||||
if ( lst[i].column() == 0) {
|
||||
//Get Info for current item
|
||||
if (rsFiles->FileDetails(RsFileHash(getID(lst[i].row(), DLListModel).toStdString())
|
||||
, RS_FILE_HINTS_DOWNLOAD, info)) {
|
||||
/*const uint32_t FT_STATE_FAILED = 0x0000;
|
||||
*const uint32_t FT_STATE_OKAY = 0x0001;
|
||||
*const uint32_t FT_STATE_WAITING = 0x0002;
|
||||
*const uint32_t FT_STATE_DOWNLOADING = 0x0003;
|
||||
*const uint32_t FT_STATE_COMPLETE = 0x0004;
|
||||
*const uint32_t FT_STATE_QUEUED = 0x0005;
|
||||
*const uint32_t FT_STATE_PAUSED = 0x0006;
|
||||
*const uint32_t FT_STATE_CHECKING_HASH = 0x0007;
|
||||
*/
|
||||
if (info.downloadStatus == FT_STATE_WAITING) {
|
||||
atLeastOne_Waiting = true ;
|
||||
}//if (info.downloadStatus == FT_STATE_WAITING)
|
||||
if (info.downloadStatus == FT_STATE_DOWNLOADING) {
|
||||
atLeastOne_Downloading=true ;
|
||||
}//if (info.downloadStatus == FT_STATE_DOWNLOADING)
|
||||
if (info.downloadStatus == FT_STATE_COMPLETE) {
|
||||
atLeastOne_Complete = true ;
|
||||
add_OpenFileOption = single ;
|
||||
}//if (info.downloadStatus == FT_STATE_COMPLETE)
|
||||
if (info.downloadStatus == FT_STATE_QUEUED) {
|
||||
atLeastOne_Queued = true ;
|
||||
}//if(info.downloadStatus == FT_STATE_QUEUED)
|
||||
if (info.downloadStatus == FT_STATE_PAUSED) {
|
||||
atLeastOne_Paused = true ;
|
||||
}//if (info.downloadStatus == FT_STATE_PAUSED)
|
||||
|
||||
size_t pos = info.fname.find_last_of('.');
|
||||
/* check if the file is a media file */
|
||||
if(pos != std::string::npos)
|
||||
{
|
||||
if (misc::isPreviewable(info.fname.substr(pos + 1).c_str()))
|
||||
{
|
||||
add_PreviewOption = (info.downloadStatus != FT_STATE_COMPLETE);
|
||||
add_PlayOption = !add_PreviewOption;
|
||||
}
|
||||
}
|
||||
size_t pos = info.fname.find_last_of('.') ;
|
||||
if (pos != std::string::npos) {
|
||||
// Check if the file is a media file
|
||||
if (misc::isPreviewable(info.fname.substr(pos + 1).c_str())) {
|
||||
add_PreviewOption = (info.downloadStatus != FT_STATE_COMPLETE) ;
|
||||
add_PlayOption = !add_PreviewOption ;
|
||||
}// if (misc::isPreviewable(info.fname.substr(pos + 1).c_str()))
|
||||
// Check if the file is a collection
|
||||
if (RsCollectionFile::ExtensionString == info.fname.substr(pos + 1).c_str()) {
|
||||
add_CollActions = (info.downloadStatus == FT_STATE_COMPLETE);
|
||||
}//if (RsCollectionFile::ExtensionString == info
|
||||
}// if(pos != std::string::npos)
|
||||
|
||||
}//if (rsFiles->FileDetails(lst[i].data(COLUMN_ID), RS_FILE_HINTS_DOWNLOAD, info))
|
||||
}//if (lst[i].column() == 0)
|
||||
}// for (int i = 0; i < lst.count (); i++)
|
||||
}//if(!items.empty())
|
||||
}// if (rsFiles->FileDetails(lst[i].data(COLUMN_ID), RS_FILE_HINTS_DOWNLOAD, info))
|
||||
}// if (lst[i].column() == 0)
|
||||
}// for (int i = 0; i < lst.count(); i++)
|
||||
}// if (!items.empty())
|
||||
|
||||
if(atLeastOne_Downloading)
|
||||
contextMnu.addMenu(&prioritySpeedMenu);
|
||||
if(atLeastOne_Queued)
|
||||
contextMnu.addMenu(&priorityQueueMenu) ;
|
||||
if (atLeastOne_Downloading) {
|
||||
contextMnu.addMenu( &prioritySpeedMenu) ;
|
||||
}//if (atLeastOne_Downloading)
|
||||
if (atLeastOne_Queued) {
|
||||
contextMnu.addMenu( &priorityQueueMenu) ;
|
||||
}//if (atLeastOne_Queued)
|
||||
|
||||
if( (!items.empty()) && (atLeastOne_Downloading || atLeastOne_Queued || atLeastOne_Waiting || atLeastOne_Paused))
|
||||
{
|
||||
contextMnu.addMenu( &chunkMenu);
|
||||
if ( (!items.empty())
|
||||
&& (atLeastOne_Downloading || atLeastOne_Queued || atLeastOne_Waiting || atLeastOne_Paused)) {
|
||||
contextMnu.addMenu(&chunkMenu) ;
|
||||
|
||||
if(single)
|
||||
contextMnu.addAction(renameFileAct) ;
|
||||
if (single) {
|
||||
contextMnu.addAction( renameFileAct) ;
|
||||
}//if (single)
|
||||
|
||||
QMenu *directoryMenu = contextMnu.addMenu(QIcon(IMAGE_OPENFOLDER),tr("Set destination directory")) ;
|
||||
directoryMenu->addAction(specifyDestinationDirectoryAct);
|
||||
QMenu *directoryMenu = contextMnu.addMenu(QIcon(IMAGE_OPENFOLDER), tr("Set destination directory")) ;
|
||||
directoryMenu->addAction(specifyDestinationDirectoryAct) ;
|
||||
|
||||
// Now get the list of existing directories.
|
||||
// Now get the list of existing directories.
|
||||
|
||||
std::list<SharedDirInfo> dirs ;
|
||||
rsFiles->getSharedDirectories(dirs) ;
|
||||
std::list< SharedDirInfo> dirs ;
|
||||
rsFiles->getSharedDirectories( dirs) ;
|
||||
|
||||
for(std::list<SharedDirInfo>::const_iterator it(dirs.begin());it!=dirs.end();++it)
|
||||
{
|
||||
// check for existence of directory name
|
||||
QFile directory(QString::fromUtf8((*it).filename.c_str())) ;
|
||||
for (std::list<SharedDirInfo>::const_iterator it(dirs.begin());it!=dirs.end();++it){
|
||||
// Check for existence of directory name
|
||||
QFile directory( QString::fromUtf8((*it).filename.c_str())) ;
|
||||
|
||||
if(!directory.exists()) continue ;
|
||||
if(!(directory.permissions() & QFile::WriteOwner)) continue ;
|
||||
if (!directory.exists()) continue ;
|
||||
if (!(directory.permissions() & QFile::WriteOwner)) continue ;
|
||||
|
||||
QAction *act = new QAction(QString::fromUtf8((*it).virtualname.c_str()),directoryMenu) ;
|
||||
act->setData(QString::fromUtf8((*it).filename.c_str())) ;
|
||||
connect(act,SIGNAL(triggered()),this,SLOT(setDestinationDirectory())) ;
|
||||
directoryMenu->addAction(act) ;
|
||||
}
|
||||
}
|
||||
QAction *act = new QAction(QString::fromUtf8((*it).virtualname.c_str()), directoryMenu) ;
|
||||
act->setData(QString::fromUtf8( (*it).filename.c_str() ) ) ;
|
||||
connect(act, SIGNAL(triggered()), this, SLOT(setDestinationDirectory())) ;
|
||||
directoryMenu->addAction( act) ;
|
||||
}//for (std::list<SharedDirInfo>::const_iterator it
|
||||
}//if ( (!items.empty()) &&
|
||||
|
||||
if(atLeastOne_Paused)
|
||||
contextMnu.addAction( resumeAct);
|
||||
if(atLeastOne_Downloading || atLeastOne_Queued || atLeastOne_Waiting)
|
||||
contextMnu.addAction( pauseAct);
|
||||
if (atLeastOne_Paused) {
|
||||
contextMnu.addAction(resumeAct) ;
|
||||
}//if (atLeastOne_Paused)
|
||||
if (atLeastOne_Downloading || atLeastOne_Queued || atLeastOne_Waiting) {
|
||||
contextMnu.addAction(pauseAct) ;
|
||||
}//if (atLeastOne_Downloading || atLeastOne_Queued || atLeastOne_Waiting)
|
||||
|
||||
if(!atLeastOne_Complete && !items.empty())
|
||||
{
|
||||
contextMnu.addAction( forceCheckAct);
|
||||
contextMnu.addAction( cancelAct);
|
||||
}
|
||||
if (add_PlayOption)
|
||||
{
|
||||
contextMnu.addAction(playAct);
|
||||
}
|
||||
if (!atLeastOne_Complete && !items.empty()) {
|
||||
contextMnu.addAction(forceCheckAct) ;
|
||||
contextMnu.addAction(cancelAct) ;
|
||||
}//if (!atLeastOne_Complete && !items.empty())
|
||||
if (add_PlayOption) {
|
||||
contextMnu.addAction(playAct) ;
|
||||
}//if (add_PlayOption)
|
||||
|
||||
if(atLeastOne_Paused || atLeastOne_Downloading || atLeastOne_Complete || add_PlayOption)
|
||||
contextMnu.addSeparator();//------------------------------------------------
|
||||
if (atLeastOne_Paused || atLeastOne_Downloading || atLeastOne_Complete || add_PlayOption) {
|
||||
contextMnu.addSeparator() ;//------------------------------------------------
|
||||
}//if (atLeastOne_Paused ||
|
||||
|
||||
if(single)
|
||||
{
|
||||
if (add_OpenFileOption) contextMnu.addAction( openFileAct);
|
||||
if (add_PreviewOption) contextMnu.addAction( previewFileAct);
|
||||
contextMnu.addAction( openFolderAct);
|
||||
contextMnu.addAction( detailsFileAct);
|
||||
contextMnu.addSeparator();//--------------------------------------------
|
||||
}
|
||||
if (single) {
|
||||
if (add_OpenFileOption) contextMnu.addAction( openFileAct) ;
|
||||
if (add_PreviewOption) contextMnu.addAction( previewFileAct) ;
|
||||
contextMnu.addAction( openFolderAct) ;
|
||||
contextMnu.addAction( detailsFileAct) ;
|
||||
contextMnu.addSeparator() ;//--------------------------------------------
|
||||
}//if (single)
|
||||
|
||||
contextMnu.addAction( clearCompletedAct);
|
||||
contextMnu.addSeparator();//------------------------------------------------
|
||||
contextMnu.addAction( clearCompletedAct) ;
|
||||
contextMnu.addSeparator() ;//------------------------------------------------
|
||||
|
||||
if (add_CopyLink)
|
||||
contextMnu.addAction( copyLinkAct);
|
||||
if (add_PasteLink)
|
||||
contextMnu.addAction( pasteLinkAct);
|
||||
if (add_CopyLink || add_PasteLink)
|
||||
contextMnu.addSeparator();//--------------------------------------------
|
||||
if (add_CopyLink) {
|
||||
contextMnu.addAction( copyLinkAct) ;
|
||||
}//if (add_CopyLink)
|
||||
if (add_PasteLink) {
|
||||
contextMnu.addAction( pasteLinkAct) ;
|
||||
}//if (add_PasteLink)
|
||||
if (add_CopyLink || add_PasteLink) {
|
||||
contextMnu.addSeparator() ;//--------------------------------------------
|
||||
}//if (add_CopyLink || add_PasteLink)
|
||||
|
||||
if (DLListModel->rowCount()>0 ) {
|
||||
contextMnu.addAction( expandAllAct ) ;
|
||||
contextMnu.addAction( collapseAllAct ) ;
|
||||
}
|
||||
|
||||
contextMnu.addSeparator();//-----------------------------------------------
|
||||
contextMnu.addSeparator() ;//-----------------------------------------------
|
||||
|
||||
contextMnu.addAction( toggleShowCacheTransfersAct ) ;
|
||||
toggleShowCacheTransfersAct->setChecked(_show_cache_transfers) ;
|
||||
contextMnu.addAction( openCollectionAct ) ;
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
|
||||
collCreateAct->setEnabled(true) ;
|
||||
collModifAct->setEnabled(single && add_CollActions) ;
|
||||
collViewAct->setEnabled(single && add_CollActions) ;
|
||||
collOpenAct->setEnabled(true) ;
|
||||
contextMnu.addMenu(&collectionMenu) ;
|
||||
|
||||
contextMnu.exec(QCursor::pos()) ;
|
||||
}
|
||||
|
||||
void TransfersDialog::downloadListHeaderCustomPopupMenu( QPoint /*point*/ )
|
||||
@ -1777,8 +1798,8 @@ void TransfersDialog::openTransfer()
|
||||
{
|
||||
FileInfo info;
|
||||
|
||||
std::set<RsFileHash> items;
|
||||
std::set<RsFileHash>::iterator it;
|
||||
std::set<RsFileHash> items ;
|
||||
std::set<RsFileHash>::iterator it ;
|
||||
getSelectedItems(&items, NULL);
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||
@ -2049,13 +2070,130 @@ QString TransfersDialog::getSources(int row, QStandardItemModel *model)
|
||||
return temp;
|
||||
}
|
||||
|
||||
void TransfersDialog::openCollection()
|
||||
void TransfersDialog::collCreate()
|
||||
{
|
||||
RsCollectionFile Collection;
|
||||
if (Collection.load(this)) {
|
||||
Collection.downloadFiles();
|
||||
}
|
||||
std::vector <DirDetails> dirVec;
|
||||
|
||||
std::set<RsFileHash> items ;
|
||||
std::set<RsFileHash>::iterator it ;
|
||||
getSelectedItems(&items, NULL);
|
||||
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
FileInfo info;
|
||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||
|
||||
DirDetails details;
|
||||
details.name = info.fname;
|
||||
details.hash = info.hash;
|
||||
details.count = info.size;
|
||||
details.type = DIR_TYPE_FILE;
|
||||
|
||||
dirVec.push_back(details);
|
||||
}//for (it = items.begin();
|
||||
|
||||
RsCollectionFile(dirVec).openNewColl(this);
|
||||
}
|
||||
|
||||
void TransfersDialog::collModif()
|
||||
{
|
||||
FileInfo info;
|
||||
|
||||
std::set<RsFileHash> items ;
|
||||
std::set<RsFileHash>::iterator it ;
|
||||
getSelectedItems(&items, NULL);
|
||||
|
||||
if (items.size() != 1) return;
|
||||
it = items.begin();
|
||||
RsFileHash hash = *it;
|
||||
if (!rsFiles->FileDetails(hash, RS_FILE_HINTS_DOWNLOAD, info)) return;
|
||||
|
||||
/* make path for downloaded files */
|
||||
if (info.downloadStatus == FT_STATE_COMPLETE) {
|
||||
std::string path;
|
||||
path = info.path + "/" + info.fname;
|
||||
|
||||
/* open collection */
|
||||
QFileInfo qinfo;
|
||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||
if (qinfo.exists()) {
|
||||
if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) {
|
||||
RsCollectionFile collection;
|
||||
collection.openColl(qinfo.absoluteFilePath());
|
||||
}//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString))
|
||||
}//if (qinfo.exists())
|
||||
}//if (info.downloadStatus == FT_STATE_COMPLETE)
|
||||
}
|
||||
|
||||
void TransfersDialog::collView()
|
||||
{
|
||||
FileInfo info;
|
||||
|
||||
std::set<RsFileHash> items;
|
||||
std::set<RsFileHash>::iterator it;
|
||||
getSelectedItems(&items, NULL);
|
||||
|
||||
if (items.size() != 1) return;
|
||||
it = items.begin();
|
||||
RsFileHash hash = *it;
|
||||
if (!rsFiles->FileDetails(hash, RS_FILE_HINTS_DOWNLOAD, info)) return;
|
||||
|
||||
/* make path for downloaded files */
|
||||
if (info.downloadStatus == FT_STATE_COMPLETE) {
|
||||
std::string path;
|
||||
path = info.path + "/" + info.fname;
|
||||
|
||||
/* open collection */
|
||||
QFileInfo qinfo;
|
||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||
if (qinfo.exists()) {
|
||||
if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) {
|
||||
RsCollectionFile collection;
|
||||
collection.openColl(qinfo.absoluteFilePath(), true);
|
||||
}//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString))
|
||||
}//if (qinfo.exists())
|
||||
}//if (info.downloadStatus == FT_STATE_COMPLETE)
|
||||
}
|
||||
|
||||
void TransfersDialog::collOpen()
|
||||
{
|
||||
FileInfo info;
|
||||
|
||||
std::set<RsFileHash> items;
|
||||
std::set<RsFileHash>::iterator it;
|
||||
getSelectedItems(&items, NULL);
|
||||
|
||||
if (items.size() == 1) {
|
||||
it = items.begin();
|
||||
RsFileHash hash = *it;
|
||||
if (rsFiles->FileDetails(hash, RS_FILE_HINTS_DOWNLOAD, info)) {
|
||||
|
||||
/* make path for downloaded files */
|
||||
if (info.downloadStatus == FT_STATE_COMPLETE) {
|
||||
std::string path;
|
||||
path = info.path + "/" + info.fname;
|
||||
|
||||
/* open file with a suitable application */
|
||||
QFileInfo qinfo;
|
||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||
if (qinfo.exists()) {
|
||||
if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) {
|
||||
RsCollectionFile collection;
|
||||
if (collection.load(qinfo.absoluteFilePath(), this)) {
|
||||
collection.downloadFiles();
|
||||
return;
|
||||
}//if (collection.load(this))
|
||||
}//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString))
|
||||
}//if (qinfo.exists())
|
||||
}//if (info.downloadStatus == FT_STATE_COMPLETE)
|
||||
}//if (rsFiles->FileDetails(
|
||||
}//if (items.size() == 1)
|
||||
|
||||
RsCollectionFile collection;
|
||||
if (collection.load(this)) {
|
||||
collection.downloadFiles();
|
||||
}//if (collection.load(this))
|
||||
}
|
||||
|
||||
void TransfersDialog::setShowDLSizeColumn(bool show)
|
||||
{
|
||||
if (!ui.downloadList->isColumnHidden(COLUMN_SIZE) != show) {
|
||||
|
@ -131,13 +131,16 @@ private slots:
|
||||
void chunkProgressive();
|
||||
void chunkStreaming();
|
||||
|
||||
void showDetailsDialog();
|
||||
void updateDetailsDialog();
|
||||
|
||||
void openCollection();
|
||||
|
||||
void setShowDLSizeColumn(bool show);
|
||||
void setShowDLCompleteColumn(bool show);
|
||||
void showDetailsDialog();
|
||||
void updateDetailsDialog();
|
||||
|
||||
void collCreate();
|
||||
void collModif();
|
||||
void collView();
|
||||
void collOpen();
|
||||
|
||||
void setShowDLSizeColumn(bool show);
|
||||
void setShowDLCompleteColumn(bool show);
|
||||
void setShowDLDLSpeedColumn(bool show);
|
||||
void setShowDLProgressColumn(bool show);
|
||||
void setShowDLSourcesColumn(bool show);
|
||||
@ -164,21 +167,21 @@ private:
|
||||
ULListDelegate *ULDelegate;
|
||||
|
||||
/** Create the actions on the tray menu or menubar */
|
||||
void createActions();
|
||||
|
||||
/** Defines the actions for the context menu */
|
||||
QAction* showdownInfoAct;
|
||||
QAction* playAct;
|
||||
QAction* cancelAct;
|
||||
QAction* forceCheckAct;
|
||||
QAction* clearCompletedAct;
|
||||
QAction* copyLinkAct;
|
||||
QAction* pasteLinkAct;
|
||||
QAction* rootIsNotDecoratedAct;
|
||||
QAction* rootIsDecoratedAct;
|
||||
QAction *pauseAct;
|
||||
QAction *resumeAct;
|
||||
QAction *openFolderAct;
|
||||
void createActions();
|
||||
|
||||
/** Defines the actions for the context menu */
|
||||
QAction *showdownInfoAct;
|
||||
QAction *playAct;
|
||||
QAction *cancelAct;
|
||||
QAction *forceCheckAct;
|
||||
QAction *clearCompletedAct;
|
||||
QAction *copyLinkAct;
|
||||
QAction *pasteLinkAct;
|
||||
QAction *rootIsNotDecoratedAct;
|
||||
QAction *rootIsDecoratedAct;
|
||||
QAction *pauseAct;
|
||||
QAction *resumeAct;
|
||||
QAction *openFolderAct;
|
||||
QAction *openFileAct;
|
||||
QAction *previewFileAct;
|
||||
// QAction *clearQueuedDwlAct;
|
||||
@ -193,17 +196,20 @@ private:
|
||||
QAction *queueBottomAct;
|
||||
QAction *chunkRandomAct;
|
||||
QAction *chunkProgressiveAct;
|
||||
QAction *chunkStreamingAct;
|
||||
QAction *detailsFileAct;
|
||||
QAction *toggleShowCacheTransfersAct;
|
||||
QAction *openCollectionAct;
|
||||
QAction *renameFileAct;
|
||||
QAction *specifyDestinationDirectoryAct;
|
||||
QAction *expandAllAct;
|
||||
QAction *collapseAllAct;
|
||||
|
||||
/** Defines the actions for the header context menu */
|
||||
QAction* showDLSizeAct;
|
||||
QAction *chunkStreamingAct;
|
||||
QAction *detailsFileAct;
|
||||
QAction *toggleShowCacheTransfersAct;
|
||||
QAction *renameFileAct;
|
||||
QAction *specifyDestinationDirectoryAct;
|
||||
QAction *expandAllAct;
|
||||
QAction *collapseAllAct;
|
||||
QAction *collCreateAct;
|
||||
QAction *collModifAct;
|
||||
QAction *collViewAct;
|
||||
QAction *collOpenAct;
|
||||
|
||||
/** Defines the actions for the header context menu */
|
||||
QAction* showDLSizeAct;
|
||||
QAction* showDLCompleteAct;
|
||||
QAction* showDLDLSpeedAct;
|
||||
QAction* showDLProgressAct;
|
||||
|
@ -100,6 +100,7 @@
|
||||
#include "gui/Posted/PostedDialog.h"
|
||||
|
||||
#include "gui/connect/ConnectFriendWizard.h"
|
||||
#include "gui/common/RsCollectionFile.h"
|
||||
#include "util/rsguiversion.h"
|
||||
#include "settings/rsettingswin.h"
|
||||
#include "settings/rsharesettings.h"
|
||||
@ -149,6 +150,7 @@
|
||||
#define IMAGE_GAMES ":/images/kgames.png"
|
||||
#define IMAGE_PHOTO ":/images/lphoto.png"
|
||||
#define IMAGE_ADDFRIEND ":/images/user/add_user24.png"
|
||||
#define IMAGE_NEWRSCOLLECTION ":/images/library.png"
|
||||
#define IMAGE_ADDSHARE ":/images/directoryadd_24x24_shadow.png"
|
||||
#define IMAGE_OPTIONS ":/images/settings.png"
|
||||
#define IMAGE_QUIT ":/images/exit_24x24.png"
|
||||
@ -480,6 +482,7 @@ void MainWindow::initStackedPage()
|
||||
|
||||
/** Add icon on Action bar */
|
||||
addAction(new QAction(QIcon(IMAGE_ADDFRIEND), tr("Add"), ui->toolBarAction), &MainWindow::addFriend, SLOT(addFriend()));
|
||||
addAction(new QAction(QIcon(IMAGE_NEWRSCOLLECTION), tr("New"), ui->toolBarAction), &MainWindow::newRsCollection, SLOT(newRsCollection()));
|
||||
addAction(new QAction(QIcon(IMAGE_PREFERENCES), tr("Options"), ui->toolBarAction), &MainWindow::showSettings, SLOT(showSettings()));
|
||||
addAction(new QAction(QIcon(IMAGE_ABOUT), tr("About"), ui->toolBarAction), &MainWindow::showabout, SLOT(showabout()));
|
||||
addAction(new QAction(QIcon(IMAGE_QUIT), tr("Quit"), ui->toolBarAction), &MainWindow::doQuit, SLOT(doQuit()));
|
||||
@ -1050,6 +1053,14 @@ void MainWindow::addFriend()
|
||||
connwiz.exec ();
|
||||
}
|
||||
|
||||
/** New RSCollection ShortCut */
|
||||
void MainWindow::newRsCollection()
|
||||
{
|
||||
std::vector <DirDetails> dirVec;
|
||||
|
||||
RsCollectionFile(dirVec).openNewColl(this);
|
||||
}
|
||||
|
||||
/** Shows Share Manager */
|
||||
void MainWindow::openShareManager()
|
||||
{
|
||||
|
@ -192,6 +192,7 @@ private slots:
|
||||
|
||||
/** Toolbar fns. */
|
||||
void addFriend();
|
||||
void newRsCollection();
|
||||
void showMessengerWindow();
|
||||
void showDhtWindow();
|
||||
void showBwCtrlWindow();
|
||||
|
@ -915,16 +915,16 @@ const DirDetailsVector *RetroshareDirModel::requestDirDetails(void *ref, bool re
|
||||
|
||||
void RetroshareDirModel::createCollectionFile(QWidget *parent, const QModelIndexList &list)
|
||||
{
|
||||
if(RemoteMode)
|
||||
/* if(RemoteMode)
|
||||
{
|
||||
std::cerr << "Cannot create a collection file from remote" << std::endl;
|
||||
return ;
|
||||
}
|
||||
}*/
|
||||
|
||||
std::vector <DirDetails> dirVec;
|
||||
getDirDetailsFromSelect(list, dirVec);
|
||||
|
||||
RsCollectionFile(dirVec).save(parent);
|
||||
RsCollectionFile(dirVec).openNewColl(parent);
|
||||
}
|
||||
|
||||
void RetroshareDirModel::downloadSelected(const QModelIndexList &list)
|
||||
@ -980,7 +980,7 @@ void RetroshareDirModel::downloadDirectory(const DirDetails & dirDetails, int pr
|
||||
{
|
||||
if (dirDetails.type & DIR_TYPE_FILE)
|
||||
{
|
||||
std::list<RsPeerId> srcIds;
|
||||
std::list<RsPeerId> srcIds ;
|
||||
QString cleanPath = QDir::cleanPath(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()) + "/" + QString::fromUtf8(dirDetails.path.substr(prefixLen).c_str()));
|
||||
|
||||
srcIds.push_back(dirDetails.id);
|
||||
|
@ -75,7 +75,7 @@ class RetroshareDirModel : public QAbstractItemModel
|
||||
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }
|
||||
|
||||
const DirDetailsVector *requestDirDetails(void *ref, bool remote) const;
|
||||
virtual void update() {} ;
|
||||
virtual void update() {}
|
||||
|
||||
public:
|
||||
virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
|
||||
|
@ -45,25 +45,30 @@
|
||||
/* Images for context menu icons */
|
||||
#define IMAGE_START ":/images/download.png"
|
||||
#define IMAGE_REMOVE ":/images/delete.png"
|
||||
#define IMAGE_REMOVEALL ":/images/deleteall.png"
|
||||
#define IMAGE_DIRECTORY ":/images/folder16.png"
|
||||
#define IMAGE_OPENFOLDER ":/images/folderopen.png"
|
||||
#define IMAGE_REMOVEALL ":/images/deleteall.png"
|
||||
#define IMAGE_DIRECTORY ":/images/folder16.png"
|
||||
#define IMAGE_OPENFOLDER ":/images/folderopen.png"
|
||||
#define IMAGE_LIBRARY ":/images/library.png"
|
||||
#define IMAGE_COLLCREATE ":/images/library_add.png"
|
||||
#define IMAGE_COLLMODIF ":/images/library_edit.png"
|
||||
#define IMAGE_COLLVIEW ":/images/library_view.png"
|
||||
#define IMAGE_COLLOPEN ":/images/library.png"
|
||||
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
||||
|
||||
/* Key for UI Preferences */
|
||||
#define UI_PREF_ADVANCED_SEARCH "UIOptions/AdvancedSearch"
|
||||
|
||||
/* indicies for search summary item columns SS_ = Search Summary */
|
||||
#define SS_TEXT_COL 0
|
||||
#define SS_COUNT_COL 1
|
||||
#define SS_KEYWORDS_COL 0
|
||||
#define SS_RESULTS_COL 1
|
||||
#define SS_SEARCH_ID_COL 2
|
||||
#define SS_FILE_TYPE_COL 3
|
||||
#define SS_DATA_COL SS_TEXT_COL
|
||||
#define SS_COL_COUNT 3 //4 ???
|
||||
#define SS_DATA_COL SS_KEYWORDS_COL
|
||||
|
||||
#define ROLE_KEYWORDS Qt::UserRole
|
||||
#define ROLE_SORT Qt::UserRole + 1
|
||||
|
||||
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
||||
|
||||
/* static members */
|
||||
/* These indices MUST be identical to their equivalent indices in the combobox */
|
||||
const int SearchDialog::FILETYPE_IDX_ANY = 0;
|
||||
@ -89,20 +94,29 @@ SearchDialog::SearchDialog(QWidget *parent)
|
||||
|
||||
m_bProcessSettings = false;
|
||||
|
||||
_queueIsAlreadyTakenCareOf = false ;
|
||||
_queueIsAlreadyTakenCareOf = false;
|
||||
ui.lineEdit->setFocus();
|
||||
|
||||
collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this);
|
||||
connect(collCreateAct,SIGNAL(triggered()),this,SLOT(collCreate()));
|
||||
collModifAct= new QAction(QIcon(IMAGE_COLLMODIF), tr("Modify Collection..."), this);
|
||||
connect(collModifAct,SIGNAL(triggered()),this,SLOT(collModif()));
|
||||
collViewAct= new QAction(QIcon(IMAGE_COLLVIEW), tr("View Collection..."), this);
|
||||
connect(collViewAct,SIGNAL(triggered()),this,SLOT(collView()));
|
||||
collOpenAct = new QAction(QIcon(IMAGE_COLLOPEN), tr( "Download from collection file..." ), this );
|
||||
connect(collOpenAct, SIGNAL(triggered()), this, SLOT(collOpen()));
|
||||
|
||||
/* initialise the filetypes mapping */
|
||||
if (!SearchDialog::initialised)
|
||||
{
|
||||
initialiseFileTypeMappings();
|
||||
initialiseFileTypeMappings() ;
|
||||
}
|
||||
|
||||
connect(ui.toggleAdvancedSearchBtn, SIGNAL(clicked()), this, SLOT(showAdvSearchDialog()));
|
||||
|
||||
connect( ui.searchResultWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( searchtableWidgetCostumPopupMenu( QPoint ) ) );
|
||||
connect( ui.searchResultWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( searchResultWidgetCustomPopupMenu( QPoint ) ) );
|
||||
|
||||
connect( ui.searchSummaryWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( searchtableWidget2CostumPopupMenu( QPoint ) ) );
|
||||
connect( ui.searchSummaryWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( searchSummaryWidgetCustomPopupMenu( QPoint ) ) );
|
||||
|
||||
connect( ui.lineEdit, SIGNAL( returnPressed ( void ) ), this, SLOT( searchKeywords( void ) ) );
|
||||
connect( ui.lineEdit, SIGNAL( textChanged ( const QString& ) ), this, SLOT( checkText( const QString& ) ) );
|
||||
@ -121,12 +135,12 @@ SearchDialog::SearchDialog(QWidget *parent)
|
||||
connect(ui.filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterItems()));
|
||||
|
||||
compareSummaryRole = new RSTreeWidgetItemCompareRole;
|
||||
compareSummaryRole->setRole(SS_COUNT_COL, ROLE_SORT);
|
||||
compareSummaryRole->setRole(SS_RESULTS_COL, ROLE_SORT);
|
||||
|
||||
compareResultRole = new RSTreeWidgetItemCompareRole;
|
||||
compareResultRole->setRole(SR_SIZE_COL, ROLE_SORT);
|
||||
compareResultRole->setRole(SR_AGE_COL, ROLE_SORT);
|
||||
compareResultRole->setRole(SR_ID_COL, ROLE_SORT);
|
||||
compareResultRole->setRole(SR_SOURCES_COL, ROLE_SORT);
|
||||
|
||||
/* hide the Tree +/- */
|
||||
ui.searchResultWidget -> setRootIsDecorated( true );
|
||||
@ -134,43 +148,43 @@ SearchDialog::SearchDialog(QWidget *parent)
|
||||
ui.searchSummaryWidget -> setRootIsDecorated( false );
|
||||
|
||||
// We set some delegates to handle the display of size and date.
|
||||
// To allow a proper sorting, be careful to pad at right with spaces. This
|
||||
// is achieved by using QString("%1").arg(number,15,10).
|
||||
//
|
||||
ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL,new RSHumanReadableSizeDelegate()) ;
|
||||
ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL,new RSHumanReadableAgeDelegate()) ;
|
||||
// To allow a proper sorting, be careful to pad at right with spaces. This
|
||||
// is achieved by using QString("%1").arg(number,15,10).
|
||||
//
|
||||
ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, new RSHumanReadableSizeDelegate()) ;
|
||||
ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, new RSHumanReadableAgeDelegate()) ;
|
||||
|
||||
/* make it extended selection */
|
||||
ui.searchResultWidget -> setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
ui.searchSummaryWidget->setColumnCount(3);
|
||||
ui.searchSummaryWidget->setColumnHidden ( 2, true);
|
||||
ui.searchSummaryWidget->setColumnCount(SS_COL_COUNT);
|
||||
ui.searchSummaryWidget->setColumnHidden(SS_SEARCH_ID_COL, true);
|
||||
|
||||
QHeaderView * _smheader = ui.searchSummaryWidget->header () ;
|
||||
QHeaderView_setSectionResizeMode(_smheader, 0, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeMode(_smheader, 1, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeMode(_smheader, SS_KEYWORDS_COL, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeMode(_smheader, SS_RESULTS_COL, QHeaderView::Interactive);
|
||||
|
||||
_smheader->resizeSection ( 0, 160 );
|
||||
_smheader->resizeSection ( 1, 50 );
|
||||
_smheader->resizeSection ( SS_KEYWORDS_COL, 160 );
|
||||
_smheader->resizeSection ( SS_RESULTS_COL, 50 );
|
||||
|
||||
ui.searchResultWidget->setColumnCount(6);
|
||||
ui.searchResultWidget->setColumnCount(SR_COL_COUNT);
|
||||
_smheader = ui.searchResultWidget->header () ;
|
||||
QHeaderView_setSectionResizeMode(_smheader, 0, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeMode(_smheader, 1, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeMode(_smheader, 2, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeMode(_smheader, SR_NAME_COL, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeMode(_smheader, SR_SIZE_COL, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeMode(_smheader, SR_SOURCES_COL, QHeaderView::Interactive);
|
||||
|
||||
_smheader->resizeSection ( 0, 240 );
|
||||
_smheader->resizeSection ( 1, 75 );
|
||||
_smheader->resizeSection ( 2, 75 );
|
||||
_smheader->resizeSection ( 3, 75 );
|
||||
_smheader->resizeSection ( 4, 90 );
|
||||
_smheader->resizeSection ( 5, 240 );
|
||||
_smheader->resizeSection ( SR_NAME_COL, 240 );
|
||||
_smheader->resizeSection ( SR_SIZE_COL, 75 );
|
||||
_smheader->resizeSection ( SR_SOURCES_COL, 75 );
|
||||
_smheader->resizeSection ( SR_TYPE_COL, 75 );
|
||||
_smheader->resizeSection ( SR_AGE_COL, 90 );
|
||||
_smheader->resizeSection ( SR_HASH_COL, 240 );
|
||||
|
||||
// set header text aligment
|
||||
QTreeWidgetItem * headerItem = ui.searchResultWidget->headerItem();
|
||||
headerItem->setTextAlignment(1, Qt::AlignRight | Qt::AlignRight);
|
||||
headerItem->setTextAlignment(2, Qt::AlignRight | Qt::AlignRight);
|
||||
headerItem->setTextAlignment(SR_NAME_COL, Qt::AlignRight | Qt::AlignRight);
|
||||
headerItem->setTextAlignment(SR_SIZE_COL, Qt::AlignRight | Qt::AlignRight);
|
||||
|
||||
ui.searchResultWidget->sortItems(SR_NAME_COL, Qt::AscendingOrder);
|
||||
|
||||
@ -181,7 +195,7 @@ SearchDialog::SearchDialog(QWidget *parent)
|
||||
|
||||
/* add filter actions */
|
||||
ui.filterLineEdit->addFilter(QIcon(), tr("File Name"), SR_NAME_COL);
|
||||
// ui.filterLineEdit->addFilter(QIcon(), tr("File Size"), SR_SIZE_COL);
|
||||
//ui.filterLineEdit->addFilter(QIcon(), tr("File Size"), SR_SIZE_COL);
|
||||
ui.filterLineEdit->setCurrentFilter(SR_NAME_COL);
|
||||
|
||||
// load settings
|
||||
@ -189,11 +203,11 @@ SearchDialog::SearchDialog(QWidget *parent)
|
||||
|
||||
ui._ownFiles_CB->setMinimumWidth(20);
|
||||
ui._friendListsearch_SB->setMinimumWidth(20);
|
||||
ui._anonF2Fsearch_CB->setMinimumWidth(20);
|
||||
ui.label->setMinimumWidth(20);
|
||||
ui._anonF2Fsearch_CB->setMinimumWidth(20);
|
||||
ui.label->setMinimumWidth(20);
|
||||
|
||||
// workaround for Qt bug, should be solved in next Qt release 4.7.0
|
||||
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
|
||||
// workaround for Qt bug, be solved in next Qt release 4.7.0
|
||||
// https://bugreports.qt-project.org/browse/QTBUG-8270
|
||||
QShortcut *Shortcut = new QShortcut(QKeySequence (Qt::Key_Delete), ui.searchSummaryWidget, 0, 0, Qt::WidgetShortcut);
|
||||
connect(Shortcut, SIGNAL(activated()), this, SLOT(searchRemove()));
|
||||
|
||||
@ -300,29 +314,49 @@ void SearchDialog::initialiseFileTypeMappings()
|
||||
SearchDialog::initialised = true;
|
||||
}
|
||||
|
||||
void SearchDialog::searchtableWidgetCostumPopupMenu( QPoint /*point*/ )
|
||||
void SearchDialog::searchResultWidgetCustomPopupMenu( QPoint /*point*/ )
|
||||
{
|
||||
// block the popup if no results available
|
||||
if ((ui.searchResultWidget->selectedItems()).size() == 0) return;
|
||||
// Block the popup if no results available
|
||||
if ((ui.searchResultWidget->selectedItems()).size() == 0) return ;
|
||||
|
||||
QMenu contextMnu(this);
|
||||
bool add_CollActions = false ;
|
||||
|
||||
contextMnu.addAction(QIcon(IMAGE_START), tr("Download"), this, SLOT(download()));
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyResultLink()));
|
||||
contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Send RetroShare Link"), this, SLOT(sendLinkTo()));
|
||||
QMenu contextMnu(this) ;
|
||||
|
||||
// contextMnu.addAction(tr("Broadcast on Channel"), this, SLOT(broadcastonchannel()));
|
||||
// contextMnu.addAction(tr("Recommend to Friends"), this, SLOT(recommendtofriends()));
|
||||
contextMnu.addAction(QIcon(IMAGE_START), tr("Download"), this, SLOT(download())) ;
|
||||
contextMnu.addSeparator();//--------------------------------------
|
||||
|
||||
if (ui.searchResultWidget->selectedItems().size() == 1){
|
||||
QList<QTreeWidgetItem*> item =ui.searchResultWidget->selectedItems();
|
||||
if (item.at(0)->data(SR_DATA_COL, SR_ROLE_LOCAL).toBool()){
|
||||
contextMnu.addAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this, SLOT(openFolderSearch()));
|
||||
}
|
||||
}
|
||||
contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyResultLink())) ;
|
||||
contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Send RetroShare Link"), this, SLOT(sendLinkTo())) ;
|
||||
contextMnu.addSeparator();//--------------------------------------
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
QMenu collectionMenu(tr("Collection"), this);
|
||||
collectionMenu.setIcon(QIcon(IMAGE_LIBRARY));
|
||||
collectionMenu.addAction(collCreateAct);
|
||||
collectionMenu.addAction(collModifAct);
|
||||
collectionMenu.addAction(collViewAct);
|
||||
collectionMenu.addAction(collOpenAct);
|
||||
|
||||
//contextMnu.addAction(tr("Broadcast on Channel"), this, SLOT(broadcastonchannel()));
|
||||
//contextMnu.addAction(tr("Recommend to Friends"), this, SLOT(recommendtofriends()));
|
||||
|
||||
if (ui.searchResultWidget->selectedItems().size() == 1) {
|
||||
QList<QTreeWidgetItem*> item =ui.searchResultWidget->selectedItems() ;
|
||||
if (item.at(0)->data(SR_DATA_COL, SR_ROLE_LOCAL).toBool()) {
|
||||
contextMnu.addAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this, SLOT(openFolderSearch())) ;
|
||||
if (item.at(0)->text(SR_NAME_COL).endsWith(RsCollectionFile::ExtensionString)) {
|
||||
add_CollActions = true ;
|
||||
}//if (item.at(0)->text(SR_NAME_COL).endsWith(RsCollectionFile::ExtensionString))
|
||||
}//if (item.at(0)->data(SR_DATA_COL, SR_ROLE_LOCAL).toBool())
|
||||
}//if (ui.searchResultWidget->selectedItems().size() == 1)
|
||||
|
||||
collCreateAct->setEnabled(true) ;
|
||||
collModifAct->setEnabled(add_CollActions) ;
|
||||
collViewAct->setEnabled(add_CollActions) ;
|
||||
collOpenAct->setEnabled(true) ;
|
||||
contextMnu.addMenu(&collectionMenu) ;
|
||||
|
||||
contextMnu.exec(QCursor::pos()) ;
|
||||
}
|
||||
|
||||
void SearchDialog::getSourceFriendsForHash(const RsFileHash& hash,std::list<RsPeerId>& srcIds)
|
||||
@ -342,40 +376,178 @@ void SearchDialog::getSourceFriendsForHash(const RsFileHash& hash,std::list<RsPe
|
||||
|
||||
void SearchDialog::download()
|
||||
{
|
||||
/* should also be able to handle multi-selection */
|
||||
QList<QTreeWidgetItem*> itemsForDownload = ui.searchResultWidget->selectedItems();
|
||||
int numdls = itemsForDownload.size();
|
||||
QTreeWidgetItem * item;
|
||||
bool attemptDownloadLocal = false;
|
||||
/* should also be able to handle multi-selection */
|
||||
QList<QTreeWidgetItem*> itemsForDownload = ui.searchResultWidget->selectedItems() ;
|
||||
int numdls = itemsForDownload.size() ;
|
||||
QTreeWidgetItem * item ;
|
||||
bool attemptDownloadLocal = false ;
|
||||
|
||||
for (int i = 0; i < numdls; ++i)
|
||||
{
|
||||
item = itemsForDownload.at(i);
|
||||
// call the download
|
||||
//
|
||||
if (item->text(SR_HASH_COL).isEmpty()) // we have a folder
|
||||
downloadDirectory(item, tr(""));
|
||||
else
|
||||
{
|
||||
std::cerr << "SearchDialog::download() Calling File Request";
|
||||
std::cerr << std::endl;
|
||||
std::list<RsPeerId> srcIds;
|
||||
for (int i = 0; i < numdls; ++i) {
|
||||
item = itemsForDownload.at(i) ;
|
||||
// call the download
|
||||
// *
|
||||
if (item->text(SR_HASH_COL).isEmpty()) { // we have a folder
|
||||
downloadDirectory(item, tr("")) ;
|
||||
} else {
|
||||
std::cerr << "SearchDialog::download() Calling File Request" << std::endl ;
|
||||
std::list<RsPeerId> srcIds ;
|
||||
|
||||
RsFileHash hash ( item->text(SR_HASH_COL).toStdString());
|
||||
getSourceFriendsForHash(hash,srcIds) ;
|
||||
RsFileHash hash( item->text(SR_HASH_COL).toStdString()) ;
|
||||
getSourceFriendsForHash( hash, srcIds) ;
|
||||
|
||||
if(!rsFiles -> FileRequest((item->text(SR_NAME_COL)).toUtf8().constData(), hash, (item->text(SR_SIZE_COL)).toULongLong(), "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds))
|
||||
attemptDownloadLocal = true ;
|
||||
else
|
||||
{
|
||||
std::cout << "isuing file request from search dialog: -" << (item->text(SR_NAME_COL)).toStdString() << "-" << hash << "-" << (item->text(SR_SIZE_COL)).toULongLong() << "-ids=" ;
|
||||
for(std::list<RsPeerId>::const_iterator it(srcIds.begin());it!=srcIds.end();++it)
|
||||
std::cout << *it << "-" << std::endl ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (attemptDownloadLocal)
|
||||
QMessageBox::information(this, tr("Download Notice"), tr("Skipping Local Files"));
|
||||
if(!rsFiles -> FileRequest( (item->text(SR_NAME_COL)).toUtf8().constData()
|
||||
, hash, (item->text(SR_SIZE_COL)).toULongLong()
|
||||
, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds)) {
|
||||
attemptDownloadLocal = true;
|
||||
} else {
|
||||
std::cout << "isuing file request from search dialog: -"
|
||||
<< (item->text(SR_NAME_COL)).toStdString()
|
||||
<< "-" << hash << "-" << (item->text(SR_SIZE_COL)).toULongLong() << "-ids=" ;
|
||||
for(std::list<RsPeerId>::const_iterator it(srcIds.begin()); it!=srcIds.end(); ++it) {
|
||||
std::cout << *it << "-" << std::endl;
|
||||
}//for(std::list<RsPeerId>::const_iterator
|
||||
}//if(!rsFiles -> FileRequest(
|
||||
}//if (item->text(SR_HASH_COL).isEmpty())
|
||||
}//for (int i = 0
|
||||
if (attemptDownloadLocal) {
|
||||
QMessageBox::information(this, tr("Download Notice"), tr("Skipping Local Files")) ;
|
||||
}//if (attemptDownloadLocal)
|
||||
}
|
||||
|
||||
void SearchDialog::collCreate()
|
||||
{
|
||||
std::vector <DirDetails> dirVec;
|
||||
|
||||
QList<QTreeWidgetItem*> selectedItems = ui.searchResultWidget->selectedItems() ;
|
||||
int selectedCount = selectedItems.size() ;
|
||||
QTreeWidgetItem * item ;
|
||||
|
||||
for (int i = 0; i < selectedCount; ++i) {
|
||||
item = selectedItems.at(i) ;
|
||||
|
||||
if (!item->text(SR_HASH_COL).isEmpty()) {
|
||||
std::string name = item->text(SR_NAME_COL).toUtf8().constData();
|
||||
RsFileHash hash( item->text(SR_HASH_COL).toStdString() );
|
||||
uint64_t count = item->text(SR_SIZE_COL).toULongLong();
|
||||
|
||||
DirDetails details;
|
||||
details.name = name;
|
||||
details.hash = hash;
|
||||
details.count = count;
|
||||
details.type = DIR_TYPE_FILE;
|
||||
|
||||
dirVec.push_back(details);
|
||||
}//if (!item->text(SR_HASH_COL).isEmpty())
|
||||
}//for (int i = 0; i < numdls; ++i)
|
||||
|
||||
RsCollectionFile(dirVec).openNewColl(this);
|
||||
}
|
||||
|
||||
void SearchDialog::collModif()
|
||||
{
|
||||
FileInfo info;
|
||||
|
||||
QList<QTreeWidgetItem*> selectedItems = ui.searchResultWidget->selectedItems() ;
|
||||
if (selectedItems.size() != 1) return;
|
||||
QTreeWidgetItem* item ;
|
||||
|
||||
item = selectedItems.at(0) ;
|
||||
if (!item->data(SR_DATA_COL, SR_ROLE_LOCAL).toBool()) return;
|
||||
|
||||
RsFileHash hash( item->text(SR_HASH_COL).toStdString() );
|
||||
|
||||
if (!rsFiles->FileDetails(hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL
|
||||
| RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE
|
||||
| RS_FILE_HINTS_SPEC_ONLY, info)) return;
|
||||
|
||||
/* make path for downloaded files */
|
||||
std::string path;
|
||||
path = info.path;
|
||||
|
||||
/* open file with a suitable application */
|
||||
QFileInfo qinfo;
|
||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||
if (qinfo.exists()) {
|
||||
if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) {
|
||||
RsCollectionFile collection;
|
||||
collection.openColl(qinfo.absoluteFilePath());
|
||||
}//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString))
|
||||
}//if (qinfo.exists())
|
||||
}
|
||||
|
||||
void SearchDialog::collView()
|
||||
{
|
||||
FileInfo info;
|
||||
|
||||
QList<QTreeWidgetItem*> selectedItems = ui.searchResultWidget->selectedItems() ;
|
||||
if (selectedItems.size() != 1) return;
|
||||
QTreeWidgetItem* item ;
|
||||
|
||||
item = selectedItems.at(0) ;
|
||||
if (!item->data(SR_DATA_COL, SR_ROLE_LOCAL).toBool()) return;
|
||||
|
||||
RsFileHash hash( item->text(SR_HASH_COL).toStdString() );
|
||||
|
||||
if (!rsFiles->FileDetails(hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL
|
||||
| RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE
|
||||
| RS_FILE_HINTS_SPEC_ONLY, info)) return;
|
||||
|
||||
/* make path for downloaded files */
|
||||
std::string path;
|
||||
path = info.path;
|
||||
|
||||
/* open file with a suitable application */
|
||||
QFileInfo qinfo;
|
||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||
if (qinfo.exists()) {
|
||||
if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) {
|
||||
RsCollectionFile collection;
|
||||
collection.openColl(qinfo.absoluteFilePath(), true);
|
||||
}//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString))
|
||||
}//if (qinfo.exists())
|
||||
}
|
||||
|
||||
void SearchDialog::collOpen()
|
||||
{
|
||||
FileInfo info;
|
||||
|
||||
QList<QTreeWidgetItem*> selectedItems = ui.searchResultWidget->selectedItems() ;
|
||||
if (selectedItems.size() == 1) {
|
||||
QTreeWidgetItem* item ;
|
||||
|
||||
item = selectedItems.at(0) ;
|
||||
if (item->data(SR_DATA_COL, SR_ROLE_LOCAL).toBool()) {
|
||||
|
||||
RsFileHash hash( item->text(SR_HASH_COL).toStdString() );
|
||||
|
||||
if (rsFiles->FileDetails(hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL
|
||||
| RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE
|
||||
| RS_FILE_HINTS_SPEC_ONLY, info)) {
|
||||
|
||||
/* make path for downloaded files */
|
||||
std::string path;
|
||||
path = info.path;
|
||||
|
||||
/* open file with a suitable application */
|
||||
QFileInfo qinfo;
|
||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||
if (qinfo.exists()) {
|
||||
if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) {
|
||||
RsCollectionFile collection;
|
||||
if (collection.load(qinfo.absoluteFilePath(), this)) {
|
||||
collection.downloadFiles();
|
||||
return;
|
||||
}//if (collection.load(this))
|
||||
}//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString))
|
||||
}//if (qinfo.exists())
|
||||
}//if (!rsFiles->FileDetails(
|
||||
}//if (!item->data(SR_DATA_COL, SR_ROLE_LOCAL).toBool())
|
||||
}//if (selectedItems.size() != 1)
|
||||
|
||||
RsCollectionFile collection;
|
||||
if (collection.load(this)) {
|
||||
collection.downloadFiles();
|
||||
}//if (collection.load(this))
|
||||
}
|
||||
|
||||
void SearchDialog::downloadDirectory(const QTreeWidgetItem *item, const QString &base)
|
||||
@ -445,7 +617,7 @@ void SearchDialog::recommendtofriends()
|
||||
|
||||
|
||||
/** context menu searchTablewidget2 **/
|
||||
void SearchDialog::searchtableWidget2CostumPopupMenu( QPoint /*point*/ )
|
||||
void SearchDialog::searchSummaryWidgetCustomPopupMenu( QPoint /*point*/ )
|
||||
{
|
||||
// block the popup if no results available
|
||||
if ((ui.searchSummaryWidget->selectedItems()).size() == 0) return;
|
||||
@ -527,7 +699,7 @@ void SearchDialog::copySearchLink()
|
||||
return;
|
||||
|
||||
/* get the keywords */
|
||||
QString keywords = ci->text(SS_TEXT_COL);
|
||||
QString keywords = ci->text(SS_KEYWORDS_COL);
|
||||
|
||||
std::cerr << "SearchDialog::copySearchLink(): keywords: " << keywords.toStdString();
|
||||
std::cerr << std::endl;
|
||||
@ -585,12 +757,12 @@ void SearchDialog::initSearchResult(const QString& txt, qulonglong searchId, int
|
||||
|
||||
QTreeWidgetItem *item2 = new RSTreeWidgetItem(compareSummaryRole);
|
||||
if (fileType == FILETYPE_IDX_ANY) {
|
||||
item2->setText(SS_TEXT_COL, txt);
|
||||
item2->setText(SS_KEYWORDS_COL, txt);
|
||||
} else {
|
||||
item2->setText(SS_TEXT_COL, txt + " (" + ui.FileTypeComboBox->itemText(fileType) + ")");
|
||||
item2->setText(SS_KEYWORDS_COL, txt + " (" + ui.FileTypeComboBox->itemText(fileType) + ")");
|
||||
}
|
||||
item2->setText(SS_COUNT_COL, QString::number(0));
|
||||
item2->setData(SS_COUNT_COL, ROLE_SORT, 0);
|
||||
item2->setText(SS_RESULTS_COL, QString::number(0));
|
||||
item2->setData(SS_RESULTS_COL, ROLE_SORT, 0);
|
||||
item2->setText(SS_SEARCH_ID_COL, sid_hexa);
|
||||
item2->setText(SS_FILE_TYPE_COL, QString::number(fileType));
|
||||
|
||||
@ -798,10 +970,10 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons
|
||||
child->setText(SR_AGE_COL, QString::number(dir.age));
|
||||
child->setData(SR_AGE_COL, ROLE_SORT, dir.age);
|
||||
child->setTextAlignment( SR_SIZE_COL, Qt::AlignRight );
|
||||
|
||||
child->setText(SR_ID_COL, QString::number(1));
|
||||
child->setData(SR_ID_COL, ROLE_SORT, 1);
|
||||
child->setTextAlignment( SR_ID_COL, Qt::AlignRight );
|
||||
|
||||
child->setText(SR_SOURCES_COL, QString::number(1));
|
||||
child->setData(SR_SOURCES_COL, ROLE_SORT, 1);
|
||||
child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight );
|
||||
|
||||
child->setText(SR_SEARCH_ID_COL, sid_hexa);
|
||||
setIconAndType(child, QString::fromUtf8(dir.name.c_str()));
|
||||
@ -824,9 +996,9 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons
|
||||
child->setText(SR_AGE_COL, QString::number(dir.age));
|
||||
child->setData(SR_AGE_COL, ROLE_SORT, dir.age);
|
||||
child->setTextAlignment( SR_SIZE_COL, Qt::AlignRight );
|
||||
child->setText(SR_ID_COL, QString::number(1));
|
||||
child->setData(SR_ID_COL, ROLE_SORT, 1);
|
||||
child->setTextAlignment( SR_ID_COL, Qt::AlignRight );
|
||||
child->setText(SR_SOURCES_COL, QString::number(1));
|
||||
child->setData(SR_SOURCES_COL, ROLE_SORT, 1);
|
||||
child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight );
|
||||
child->setText(SR_SEARCH_ID_COL, sid_hexa);
|
||||
child->setText(SR_TYPE_COL, tr("Folder"));
|
||||
|
||||
@ -843,19 +1015,19 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons
|
||||
if(ui.searchSummaryWidget->topLevelItem(i)->text(SS_SEARCH_ID_COL) == sid_hexa)
|
||||
{
|
||||
// increment result since every item is new
|
||||
int s = ui.searchSummaryWidget->topLevelItem(i)->text(SS_COUNT_COL).toInt() ;
|
||||
ui.searchSummaryWidget->topLevelItem(i)->setText(SS_COUNT_COL,QString::number(s+1));
|
||||
ui.searchSummaryWidget->topLevelItem(i)->setData(SS_COUNT_COL, ROLE_SORT, s+1);
|
||||
int s = ui.searchSummaryWidget->topLevelItem(i)->text(SS_RESULTS_COL).toInt() ;
|
||||
ui.searchSummaryWidget->topLevelItem(i)->setText(SS_RESULTS_COL, QString::number(s+1));
|
||||
ui.searchSummaryWidget->topLevelItem(i)->setData(SS_RESULTS_COL, ROLE_SORT, s+1);
|
||||
found = true ;
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
{
|
||||
QTreeWidgetItem *item2 = new RSTreeWidgetItem(compareSummaryRole);
|
||||
item2->setText(SS_TEXT_COL, txt);
|
||||
item2->setText(SS_COUNT_COL, QString::number(1));
|
||||
item2->setData(SS_COUNT_COL, ROLE_SORT, 1);
|
||||
item2->setTextAlignment( SS_COUNT_COL, Qt::AlignRight );
|
||||
item2->setText(SS_KEYWORDS_COL, txt);
|
||||
item2->setText(SS_RESULTS_COL, QString::number(1));
|
||||
item2->setData(SS_RESULTS_COL, ROLE_SORT, 1);
|
||||
item2->setTextAlignment( SS_RESULTS_COL, Qt::AlignRight );
|
||||
item2->setText(SS_SEARCH_ID_COL, sid_hexa);
|
||||
|
||||
ui.searchSummaryWidget->addTopLevelItem(item2);
|
||||
@ -892,9 +1064,9 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons
|
||||
child->setText(SR_AGE_COL, QString::number(dir.min_age));
|
||||
child->setData(SR_AGE_COL, ROLE_SORT, dir.min_age);
|
||||
child->setTextAlignment( SR_SIZE_COL, Qt::AlignRight );
|
||||
child->setText(SR_ID_COL, QString::number(1));
|
||||
child->setData(SR_ID_COL, ROLE_SORT, 1);
|
||||
child->setTextAlignment( SR_ID_COL, Qt::AlignRight );
|
||||
child->setText(SR_SOURCES_COL, QString::number(1));
|
||||
child->setData(SR_SOURCES_COL, ROLE_SORT, 1);
|
||||
child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight );
|
||||
child->setText(SR_SEARCH_ID_COL, sid_hexa);
|
||||
child->setText(SR_TYPE_COL, tr("Folder"));
|
||||
|
||||
@ -910,19 +1082,19 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons
|
||||
if(ui.searchSummaryWidget->topLevelItem(i)->text(SS_SEARCH_ID_COL) == sid_hexa)
|
||||
{
|
||||
// increment result since every item is new
|
||||
int s = ui.searchSummaryWidget->topLevelItem(i)->text(SS_COUNT_COL).toInt() ;
|
||||
ui.searchSummaryWidget->topLevelItem(i)->setText(SS_COUNT_COL,QString::number(s+1));
|
||||
ui.searchSummaryWidget->topLevelItem(i)->setData(SS_COUNT_COL, ROLE_SORT, s+1);
|
||||
int s = ui.searchSummaryWidget->topLevelItem(i)->text(SS_RESULTS_COL).toInt() ;
|
||||
ui.searchSummaryWidget->topLevelItem(i)->setText(SS_RESULTS_COL, QString::number(s+1));
|
||||
ui.searchSummaryWidget->topLevelItem(i)->setData(SS_RESULTS_COL, ROLE_SORT, s+1);
|
||||
found = true ;
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
{
|
||||
RSTreeWidgetItem *item2 = new RSTreeWidgetItem(compareSummaryRole);
|
||||
item2->setText(SS_TEXT_COL, txt);
|
||||
item2->setText(SS_COUNT_COL, QString::number(1));
|
||||
item2->setData(SS_COUNT_COL, ROLE_SORT, 1);
|
||||
item2->setTextAlignment( SS_COUNT_COL, Qt::AlignRight );
|
||||
item2->setText(SS_KEYWORDS_COL, txt);
|
||||
item2->setText(SS_RESULTS_COL, QString::number(1));
|
||||
item2->setData(SS_RESULTS_COL, ROLE_SORT, 1);
|
||||
item2->setTextAlignment( SS_RESULTS_COL, Qt::AlignRight );
|
||||
item2->setText(SS_SEARCH_ID_COL, sid_hexa);
|
||||
|
||||
ui.searchSummaryWidget->addTopLevelItem(item2);
|
||||
@ -995,8 +1167,8 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s
|
||||
for(QList<QTreeWidgetItem*>::const_iterator it(itms.begin());it!=itms.end();++it)
|
||||
if((*it)->text(SR_SEARCH_ID_COL) == sid_hexa)
|
||||
{
|
||||
QString resultCount = (*it)->text(SR_ID_COL);
|
||||
QStringList modifiedResultCount = resultCount.split("/", QString::SkipEmptyParts);
|
||||
QString resultCount = (*it)->text(SR_SOURCES_COL);
|
||||
QStringList modifiedResultCount = resultCount.split("/", QString::SkipEmptyParts);
|
||||
if(searchType == FRIEND_SEARCH)
|
||||
{
|
||||
friendSource = modifiedResultCount.at(0).toInt() + 1;
|
||||
@ -1009,8 +1181,8 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s
|
||||
}
|
||||
modifiedResult = QString::number(friendSource) + "/" + QString::number(anonymousSource);
|
||||
float fltRes = friendSource + (float)anonymousSource/1000;
|
||||
(*it)->setText(SR_ID_COL,modifiedResult);
|
||||
(*it)->setData(SR_ID_COL, ROLE_SORT, fltRes);
|
||||
(*it)->setText(SR_SOURCES_COL,modifiedResult);
|
||||
(*it)->setData(SR_SOURCES_COL, ROLE_SORT, fltRes);
|
||||
QTreeWidgetItem *item = (*it);
|
||||
found = true ;
|
||||
|
||||
@ -1084,9 +1256,9 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s
|
||||
|
||||
modifiedResult =QString::number(friendSource) + "/" + QString::number(anonymousSource);
|
||||
float fltRes = friendSource + (float)anonymousSource/1000;
|
||||
item->setText(SR_ID_COL,modifiedResult);
|
||||
item->setData(SR_ID_COL, ROLE_SORT, fltRes);
|
||||
item->setTextAlignment( SR_ID_COL, Qt::AlignRight );
|
||||
item->setText(SR_SOURCES_COL,modifiedResult);
|
||||
item->setData(SR_SOURCES_COL, ROLE_SORT, fltRes);
|
||||
item->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight );
|
||||
item->setText(SR_SEARCH_ID_COL, sid_hexa);
|
||||
|
||||
QColor foreground;
|
||||
@ -1100,7 +1272,7 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s
|
||||
} else {
|
||||
item->setData(SR_DATA_COL, SR_ROLE_LOCAL, false);
|
||||
|
||||
sources = item->text(SR_ID_COL).toInt();
|
||||
sources = item->text(SR_SOURCES_COL).toInt();
|
||||
if (sources == 1)
|
||||
{
|
||||
foreground = ui.searchResultWidget->palette().color(QPalette::Text);
|
||||
@ -1125,9 +1297,9 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s
|
||||
/* update the summary as well */
|
||||
if(!found) // only increment result when it's a new item.
|
||||
{
|
||||
int s = ui.searchSummaryWidget->topLevelItem(summaryItemIndex)->text(SS_COUNT_COL).toInt() ;
|
||||
ui.searchSummaryWidget->topLevelItem(summaryItemIndex)->setText(SS_COUNT_COL,QString::number(s+1));
|
||||
ui.searchSummaryWidget->topLevelItem(summaryItemIndex)->setData(SS_COUNT_COL, ROLE_SORT, s+1);
|
||||
int s = ui.searchSummaryWidget->topLevelItem(summaryItemIndex)->text(SS_RESULTS_COL).toInt() ;
|
||||
ui.searchSummaryWidget->topLevelItem(summaryItemIndex)->setText(SS_RESULTS_COL, QString::number(s+1));
|
||||
ui.searchSummaryWidget->topLevelItem(summaryItemIndex)->setData(SS_RESULTS_COL, ROLE_SORT, s+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,18 +65,23 @@ public slots:
|
||||
private slots:
|
||||
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void searchtableWidgetCostumPopupMenu( QPoint point );
|
||||
void searchResultWidgetCustomPopupMenu( QPoint point );
|
||||
|
||||
void processResultQueue();
|
||||
void searchtableWidget2CostumPopupMenu( QPoint point );
|
||||
void searchSummaryWidgetCustomPopupMenu( QPoint point );
|
||||
|
||||
void download();
|
||||
|
||||
void collCreate();
|
||||
void collModif();
|
||||
void collView();
|
||||
void collOpen();
|
||||
|
||||
void broadcastonchannel();
|
||||
|
||||
void recommendtofriends();
|
||||
void checkText(const QString&) ;
|
||||
|
||||
void checkText(const QString&);
|
||||
|
||||
void copyResultLink();
|
||||
void copySearchLink();
|
||||
void openFolderSearch();
|
||||
@ -152,6 +157,11 @@ private:
|
||||
QColor mTextColorLowSources;
|
||||
QColor mTextColorHighSources;
|
||||
|
||||
QAction *collCreateAct;
|
||||
QAction *collModifAct;
|
||||
QAction *collViewAct;
|
||||
QAction *collOpenAct;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::SearchDialog ui;
|
||||
|
||||
|
@ -27,12 +27,13 @@
|
||||
/* indicies for search results item columns SR_ = Search Result */
|
||||
#define SR_NAME_COL 0
|
||||
#define SR_SIZE_COL 1
|
||||
#define SR_ID_COL 2
|
||||
#define SR_SOURCES_COL 2
|
||||
#define SR_TYPE_COL 3
|
||||
#define SR_AGE_COL 4
|
||||
#define SR_HASH_COL 5
|
||||
#define SR_SEARCH_ID_COL 6
|
||||
#define SR_UID_COL 7
|
||||
#define SR_COL_COUNT 6//8 ??
|
||||
#define SR_DATA_COL SR_NAME_COL
|
||||
|
||||
#define SR_ROLE_LOCAL Qt::UserRole
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "ShareDialog.h"
|
||||
#include "common/PeerDefs.h"
|
||||
#include "util/QtVersion.h"
|
||||
#include "gui/common/RsCollectionFile.h"
|
||||
#include "notifyqt.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
@ -57,11 +58,27 @@
|
||||
#define IMAGE_PROGRESS ":/images/browse-looking.gif"
|
||||
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
||||
#define IMAGE_OPENFOLDER ":/images/folderopen.png"
|
||||
#define IMAGE_OPENFILE ":/images/fileopen.png"
|
||||
#define IMAGE_COLLECTION ":/images/mimetypes/rscollection-16.png"
|
||||
#define IMAGE_OPENFILE ":/images/fileopen.png"
|
||||
#define IMAGE_LIBRARY ":/images/library.png"
|
||||
#define IMAGE_COLLCREATE ":/images/library_add.png"
|
||||
#define IMAGE_COLLMODIF ":/images/library_edit.png"
|
||||
#define IMAGE_COLLVIEW ":/images/library_view.png"
|
||||
#define IMAGE_COLLOPEN ":/images/library.png"
|
||||
#define IMAGE_EDITSHARE ":/images/edit_16.png"
|
||||
#define IMAGE_MYFILES ":images/my_documents_22.png"
|
||||
|
||||
/*define dirTreeView Column */
|
||||
#define COLUMN_NAME 0
|
||||
#define COLUMN_SIZE 1
|
||||
#define COLUMN_AGE 2
|
||||
#define COLUMN_FRIEND 3
|
||||
#define COLUMN_DIR 4
|
||||
#define COLUMN_COUNT 5
|
||||
|
||||
/*define viewType_CB value */
|
||||
#define VIEW_TYPE_TREE 0
|
||||
#define VIEW_TYPE_FLAT 1
|
||||
|
||||
// Define to avoid using the search in treeview, because it is really slow for now.
|
||||
//
|
||||
#define DONT_USE_SEARCH_IN_TREE_VIEW 1
|
||||
@ -121,14 +138,14 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD
|
||||
tree_proxyModel->setSourceModel(tree_model);
|
||||
tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
tree_proxyModel->setSortRole(RetroshareDirModel::SortRole);
|
||||
tree_proxyModel->sort(0);
|
||||
tree_proxyModel->sort(COLUMN_NAME);
|
||||
|
||||
flat_proxyModel = new SFDSortFilterProxyModel(flat_model, this);
|
||||
flat_proxyModel->setDynamicSortFilter(true);
|
||||
flat_proxyModel->setSourceModel(flat_model);
|
||||
flat_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
flat_proxyModel->setSortRole(RetroshareDirModel::SortRole);
|
||||
flat_proxyModel->sort(0);
|
||||
flat_proxyModel->sort(COLUMN_NAME);
|
||||
|
||||
connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||
connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter()));
|
||||
@ -138,11 +155,11 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView * header = ui.dirTreeView->header () ;
|
||||
|
||||
header->resizeSection ( 0, 490 );
|
||||
header->resizeSection ( 1, 70 );
|
||||
header->resizeSection ( 2, 100 );
|
||||
header->resizeSection ( 3, 100 );
|
||||
header->resizeSection ( 4, 100 );
|
||||
header->resizeSection ( COLUMN_NAME, 490 );
|
||||
header->resizeSection ( COLUMN_SIZE, 70 );
|
||||
header->resizeSection ( COLUMN_AGE, 100 );
|
||||
header->resizeSection ( COLUMN_FRIEND, 100 );
|
||||
header->resizeSection ( COLUMN_DIR, 100 );
|
||||
|
||||
header->setStretchLastSection(false);
|
||||
|
||||
@ -162,13 +179,22 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD
|
||||
addlinkCloudAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Add Links to Cloud" ), this );
|
||||
connect( addlinkCloudAct , SIGNAL( triggered() ), this, SLOT( addLinkToCloud( ) ) );
|
||||
#endif
|
||||
|
||||
collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this) ;
|
||||
connect(collCreateAct,SIGNAL(triggered()),this,SLOT(collCreate())) ;
|
||||
collModifAct= new QAction(QIcon(IMAGE_COLLMODIF), tr("Modify Collection..."), this) ;
|
||||
connect(collModifAct,SIGNAL(triggered()),this,SLOT(collModif())) ;
|
||||
collViewAct= new QAction(QIcon(IMAGE_COLLVIEW), tr("View Collection..."), this) ;
|
||||
connect(collViewAct,SIGNAL(triggered()),this,SLOT(collView())) ;
|
||||
collOpenAct = new QAction(QIcon(IMAGE_COLLOPEN), tr( "Download from collection file..." ), this ) ;
|
||||
connect(collOpenAct, SIGNAL(triggered()), this, SLOT(collOpen())) ;
|
||||
}
|
||||
|
||||
LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent)
|
||||
: SharedFilesDialog(new TreeStyle_RDM(false),new FlatStyle_RDM(false),parent)
|
||||
{
|
||||
// Hide columns after loading the settings
|
||||
ui.dirTreeView->setColumnHidden(4,false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_DIR, false) ;
|
||||
ui.downloadButton->hide() ;
|
||||
|
||||
// load settings
|
||||
@ -177,27 +203,24 @@ LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent)
|
||||
//
|
||||
changeCurrentViewModel(ui.viewType_CB->currentIndex()) ;
|
||||
|
||||
connect(ui.addShares_PB, SIGNAL(clicked()), this, SLOT(addShares()));
|
||||
connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck()));
|
||||
connect(ui.addShares_PB, SIGNAL(clicked()), this, SLOT(addShares())) ;
|
||||
connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck())) ;
|
||||
|
||||
createcollectionfileAct = new QAction(QIcon(IMAGE_COLLECTION), tr("Create collection file"), this);
|
||||
openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this);
|
||||
openfolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this);
|
||||
editshareAct = new QAction(QIcon(IMAGE_EDITSHARE), tr("Edit Share Permissions"), this);
|
||||
openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this) ;
|
||||
connect(openfileAct, SIGNAL(triggered()), this, SLOT(openfile())) ;
|
||||
openfolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this) ;
|
||||
connect(openfolderAct, SIGNAL(triggered()), this, SLOT(openfolder())) ;
|
||||
editshareAct = new QAction(QIcon(IMAGE_EDITSHARE), tr("Edit Share Permissions"), this) ;
|
||||
connect(editshareAct, SIGNAL(triggered()), this, SLOT(editSharePermissions())) ;
|
||||
|
||||
connect(createcollectionfileAct, SIGNAL(triggered()), this, SLOT(createCollectionFile()));
|
||||
connect(openfileAct, SIGNAL(triggered()), this, SLOT(openfile()));
|
||||
connect(openfolderAct, SIGNAL(triggered()), this, SLOT(openfolder()));
|
||||
connect(editshareAct, SIGNAL(triggered()), this, SLOT(editSharePermissions()));
|
||||
|
||||
ui.titleBarPixmap->setPixmap(QPixmap(IMAGE_MYFILES));
|
||||
ui.titleBarPixmap->setPixmap(QPixmap(IMAGE_MYFILES)) ;
|
||||
}
|
||||
|
||||
RemoteSharedFilesDialog::RemoteSharedFilesDialog(QWidget *parent)
|
||||
: SharedFilesDialog(new TreeStyle_RDM(true),new FlatStyle_RDM(true),parent)
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(3,false) ;
|
||||
ui.dirTreeView->setColumnHidden(4,true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_DIR, true) ;
|
||||
ui.checkButton->hide() ;
|
||||
|
||||
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadRemoteSelected()));
|
||||
@ -302,15 +325,15 @@ void RemoteSharedFilesDialog::processSettings(bool bLoad)
|
||||
Settings->endGroup();
|
||||
}
|
||||
|
||||
void SharedFilesDialog::changeCurrentViewModel(int c)
|
||||
void SharedFilesDialog::changeCurrentViewModel(int viewTypeIndex)
|
||||
{
|
||||
disconnect( ui.dirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), 0, 0 );
|
||||
disconnect( ui.dirTreeView, SIGNAL( expanded(const QModelIndex & ) ), 0, 0 );
|
||||
//disconnect( ui.dirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), NULL, NULL );
|
||||
//disconnect( ui.dirTreeView, SIGNAL( expanded(const QModelIndex & ) ), NULL, NULL );
|
||||
|
||||
if(model!=NULL)
|
||||
model->setVisible(false) ;
|
||||
|
||||
if(c==0)
|
||||
if(viewTypeIndex==VIEW_TYPE_TREE)
|
||||
{
|
||||
model = tree_model ;
|
||||
proxyModel = tree_proxyModel ;
|
||||
@ -329,19 +352,19 @@ void SharedFilesDialog::changeCurrentViewModel(int c)
|
||||
model->update() ;
|
||||
}
|
||||
|
||||
connect( ui.dirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), model, SLOT( collapsed(const QModelIndex & ) ) );
|
||||
connect( ui.dirTreeView, SIGNAL( expanded(const QModelIndex & ) ), model, SLOT( expanded(const QModelIndex & ) ) );
|
||||
//connect( ui.dirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), model, SLOT( collapsed(const QModelIndex & ) ) );
|
||||
//connect( ui.dirTreeView, SIGNAL( expanded(const QModelIndex & ) ), model, SLOT( expanded(const QModelIndex & ) ) );
|
||||
|
||||
ui.dirTreeView->setModel(proxyModel);
|
||||
ui.dirTreeView->update();
|
||||
|
||||
QHeaderView * header = ui.dirTreeView->header () ;
|
||||
QHeaderView_setSectionResizeMode(header, 0, QHeaderView::Interactive);
|
||||
QHeaderView_setSectionResizeMode(header, COLUMN_NAME, QHeaderView::Interactive);
|
||||
|
||||
ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal,0,4) ;
|
||||
ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal, COLUMN_NAME, COLUMN_DIR) ;
|
||||
|
||||
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||
if(c == 1)
|
||||
if(viewTypeIndex == VIEW_TYPE_FLAT)
|
||||
#endif
|
||||
FilterItems();
|
||||
}
|
||||
@ -350,8 +373,8 @@ void LocalSharedFilesDialog::showProperColumns()
|
||||
{
|
||||
if(model == tree_model)
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(3,false) ;
|
||||
ui.dirTreeView->setColumnHidden(4,false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_DIR, false) ;
|
||||
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||
ui.filterLabel->hide();
|
||||
ui.filterPatternLineEdit->hide();
|
||||
@ -361,8 +384,8 @@ void LocalSharedFilesDialog::showProperColumns()
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(3,true) ;
|
||||
ui.dirTreeView->setColumnHidden(4,false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND, true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_DIR, false) ;
|
||||
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||
ui.filterLabel->show();
|
||||
ui.filterPatternLineEdit->show();
|
||||
@ -373,8 +396,8 @@ void RemoteSharedFilesDialog::showProperColumns()
|
||||
{
|
||||
if(model == tree_model)
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(3,true) ;
|
||||
ui.dirTreeView->setColumnHidden(4,true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND, true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_DIR, true) ;
|
||||
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||
ui.filterLabel->hide();
|
||||
ui.filterPatternLineEdit->hide();
|
||||
@ -384,8 +407,8 @@ void RemoteSharedFilesDialog::showProperColumns()
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(3,false) ;
|
||||
ui.dirTreeView->setColumnHidden(4,false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_DIR, false) ;
|
||||
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||
ui.filterLabel->show();
|
||||
ui.filterPatternLineEdit->show();
|
||||
@ -418,70 +441,78 @@ void LocalSharedFilesDialog::forceCheck()
|
||||
|
||||
void RemoteSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
||||
{
|
||||
QModelIndex idx = ui.dirTreeView->indexAt(point);
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
QModelIndex midx = proxyModel->mapToSource(idx);
|
||||
if (!midx.isValid())
|
||||
return;
|
||||
if (!rsPeers) return; /* not ready yet! */
|
||||
|
||||
int type = model->getType(midx);
|
||||
if (type != DIR_TYPE_DIR && type != DIR_TYPE_FILE) {
|
||||
return;
|
||||
}
|
||||
QModelIndex idx = ui.dirTreeView->indexAt(point) ;
|
||||
if (!idx.isValid()) return;
|
||||
|
||||
QMenu contextMnu( this );
|
||||
QModelIndex midx = proxyModel->mapToSource(idx) ;
|
||||
if (!midx.isValid()) return;
|
||||
|
||||
QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), &contextMnu );
|
||||
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) );
|
||||
contextMnu.addAction( downloadAct);
|
||||
currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ;
|
||||
int type = model->getType(midx) ;
|
||||
if (type != DIR_TYPE_DIR && type != DIR_TYPE_FILE) return;
|
||||
|
||||
if (type == DIR_TYPE_FILE) {
|
||||
//QAction *copyremotelinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), &contextMnu );
|
||||
//connect( copyremotelinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) );
|
||||
|
||||
//QAction *sendremotelinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link" ), &contextMnu );
|
||||
//connect( sendremotelinkAct , SIGNAL( triggered() ), this, SLOT( sendremoteLinkTo( ) ) );
|
||||
QMenu contextMnu( this ) ;
|
||||
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction( copylinkAct);
|
||||
contextMnu.addAction( sendlinkAct);
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to"), this, SLOT(recommendFilesToMsg()));
|
||||
}
|
||||
//bool bIsRsColl = currentFile.endsWith(RsCollectionFile::ExtensionString);
|
||||
collCreateAct->setEnabled(true);
|
||||
//collModifAct->setEnabled(bIsRsColl);
|
||||
//collViewAct->setEnabled(bIsRsColl);
|
||||
collOpenAct->setEnabled(true);
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
QMenu collectionMenu(tr("Collection"), this);
|
||||
collectionMenu.setIcon(QIcon(IMAGE_LIBRARY));
|
||||
collectionMenu.addAction(collCreateAct);
|
||||
//collectionMenu.addAction(collModifAct);
|
||||
//collectionMenu.addAction(collViewAct);
|
||||
collectionMenu.addAction(collOpenAct);
|
||||
|
||||
QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), &contextMnu ) ;
|
||||
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ;
|
||||
contextMnu.addAction( downloadAct) ;
|
||||
|
||||
if ( type == DIR_TYPE_FILE ) {
|
||||
//QAction *copyremotelinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), &contextMnu ) ;
|
||||
//connect( copyremotelinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) ) ;
|
||||
|
||||
//QAction *sendremotelinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link" ), &contextMnu ) ;
|
||||
//connect( sendremotelinkAct , SIGNAL( triggered() ), this, SLOT( sendremoteLinkTo( ) ) ) ;
|
||||
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addAction( copylinkAct) ;
|
||||
contextMnu.addAction( sendlinkAct) ;
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to"), this, SLOT(recommendFilesToMsg())) ;
|
||||
}//if (type == DIR_TYPE_FILE)
|
||||
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addMenu(&collectionMenu) ;
|
||||
|
||||
contextMnu.exec(QCursor::pos()) ;
|
||||
}
|
||||
|
||||
QModelIndexList SharedFilesDialog::getSelected()
|
||||
{
|
||||
QModelIndexList list = ui.dirTreeView->selectionModel()->selectedIndexes();
|
||||
QModelIndexList proxyList;
|
||||
for (QModelIndexList::iterator index = list.begin(); index != list.end(); index++) {
|
||||
proxyList.append(proxyModel->mapToSource(*index));
|
||||
}
|
||||
QModelIndexList list = ui.dirTreeView->selectionModel()->selectedIndexes() ;
|
||||
QModelIndexList proxyList ;
|
||||
for (QModelIndexList::iterator index = list.begin(); index != list.end(); index++ ) {
|
||||
proxyList.append(proxyModel->mapToSource(*index)) ;
|
||||
}//for (QModelIndexList::iterator index
|
||||
|
||||
return proxyList;
|
||||
}
|
||||
|
||||
void LocalSharedFilesDialog::createCollectionFile()
|
||||
{
|
||||
/* call back to the model (which does all the interfacing? */
|
||||
|
||||
std::cerr << "Creating a collection file!" << std::endl;
|
||||
QModelIndexList lst = getSelected();
|
||||
model->createCollectionFile(this, lst);
|
||||
return proxyList ;
|
||||
}
|
||||
|
||||
void RemoteSharedFilesDialog::downloadRemoteSelected()
|
||||
{
|
||||
/* call back to the model (which does all the interfacing? */
|
||||
/* call back to the model (which does all the interfacing? */
|
||||
|
||||
std::cerr << "Downloading Files";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "Downloading Files" ;
|
||||
std::cerr << std::endl ;
|
||||
|
||||
QModelIndexList lst = getSelected();
|
||||
model -> downloadSelected(lst);
|
||||
QModelIndexList lst = getSelected() ;
|
||||
model -> downloadSelected(lst) ;
|
||||
}
|
||||
|
||||
void LocalSharedFilesDialog::editSharePermissions()
|
||||
@ -607,6 +638,112 @@ void SharedFilesDialog::addLinkToCloud()
|
||||
}
|
||||
#endif
|
||||
|
||||
void SharedFilesDialog::collCreate()
|
||||
{
|
||||
QModelIndexList lst = getSelected();
|
||||
model->createCollectionFile(this, lst);
|
||||
}
|
||||
|
||||
void SharedFilesDialog::collModif()
|
||||
{
|
||||
std::list<DirDetails> files_info ;
|
||||
|
||||
model->getFileInfoFromIndexList(getSelected(),files_info);
|
||||
|
||||
if(files_info.size() != 1) return ;
|
||||
|
||||
/* make path for downloaded files */
|
||||
std::list<DirDetails>::iterator it = files_info.begin();
|
||||
DirDetails details = (*it);
|
||||
FileInfo info;
|
||||
if (!rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL
|
||||
| RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE
|
||||
| RS_FILE_HINTS_SPEC_ONLY, info)) return;
|
||||
|
||||
std::string path;
|
||||
path = info.path;
|
||||
|
||||
/* open file with a suitable application */
|
||||
QFileInfo qinfo;
|
||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||
if (qinfo.exists()) {
|
||||
if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) {
|
||||
RsCollectionFile collection;
|
||||
collection.openColl(qinfo.absoluteFilePath());
|
||||
}//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString))
|
||||
}//if (qinfo.exists())
|
||||
}
|
||||
|
||||
void SharedFilesDialog::collView()
|
||||
{
|
||||
std::list<DirDetails> files_info ;
|
||||
|
||||
model->getFileInfoFromIndexList(getSelected(),files_info);
|
||||
|
||||
if(files_info.size() != 1) return ;
|
||||
|
||||
/* make path for downloaded files */
|
||||
std::list<DirDetails>::iterator it = files_info.begin();
|
||||
DirDetails details = (*it);
|
||||
FileInfo info;
|
||||
if (!rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL
|
||||
| RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE
|
||||
| RS_FILE_HINTS_SPEC_ONLY, info)) return;
|
||||
|
||||
std::string path;
|
||||
path = info.path;
|
||||
|
||||
/* open file with a suitable application */
|
||||
QFileInfo qinfo;
|
||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||
if (qinfo.exists()) {
|
||||
if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) {
|
||||
RsCollectionFile collection;
|
||||
collection.openColl(qinfo.absoluteFilePath(), true);
|
||||
}//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString))
|
||||
}//if (qinfo.exists())
|
||||
}
|
||||
|
||||
void SharedFilesDialog::collOpen()
|
||||
{
|
||||
std::list<DirDetails> files_info ;
|
||||
|
||||
model->getFileInfoFromIndexList(getSelected(),files_info);
|
||||
|
||||
if(files_info.size() == 1) {
|
||||
|
||||
/* make path for downloaded files */
|
||||
std::list<DirDetails>::iterator it = files_info.begin();
|
||||
DirDetails details = (*it);
|
||||
FileInfo info;
|
||||
if (rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL
|
||||
| RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE
|
||||
| RS_FILE_HINTS_SPEC_ONLY, info)) {
|
||||
|
||||
std::string path;
|
||||
path = info.path;
|
||||
|
||||
/* open file with a suitable application */
|
||||
QFileInfo qinfo;
|
||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||
if (qinfo.exists()) {
|
||||
if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString)) {
|
||||
RsCollectionFile collection;
|
||||
if (collection.load(qinfo.absoluteFilePath(), this)) {
|
||||
collection.downloadFiles();
|
||||
return;
|
||||
}//if (collection.load(this))
|
||||
}//if (qinfo.absoluteFilePath().endsWith(RsCollectionFile::ExtensionString))
|
||||
}//if (qinfo.exists())
|
||||
}//if (rsFiles->FileDetails(
|
||||
}//if(files_info.size() == 1)
|
||||
|
||||
RsCollectionFile collection;
|
||||
if (collection.load(this)) {
|
||||
collection.downloadFiles();
|
||||
}//if (collection.load(this))
|
||||
}
|
||||
|
||||
void LocalSharedFilesDialog::playselectedfiles()
|
||||
{
|
||||
/* call back to the model (which does all the interfacing? */
|
||||
@ -706,56 +843,64 @@ void SharedFilesDialog::postModDirectories(bool local)
|
||||
QCoreApplication::flush();
|
||||
}
|
||||
|
||||
|
||||
void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
||||
{
|
||||
if (!rsPeers)
|
||||
{
|
||||
/* not ready yet! */
|
||||
return;
|
||||
}
|
||||
if (!rsPeers) return; /* not ready yet! */
|
||||
|
||||
QModelIndex idx = ui.dirTreeView->indexAt(point);
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
QModelIndex midx = proxyModel->mapToSource(idx);
|
||||
if (!midx.isValid())
|
||||
return;
|
||||
QModelIndex idx = ui.dirTreeView->indexAt(point) ;
|
||||
if (!idx.isValid()) return ;
|
||||
|
||||
currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString();
|
||||
QModelIndex midx = proxyModel->mapToSource(idx) ;
|
||||
if (!midx.isValid()) return ;
|
||||
|
||||
int type = model->getType(midx);
|
||||
|
||||
QMenu contextMnu(this);
|
||||
currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ;
|
||||
int type = model->getType(midx) ;
|
||||
if (type != DIR_TYPE_DIR && type != DIR_TYPE_FILE) return;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DIR_TYPE_DIR:
|
||||
contextMnu.addAction(openfolderAct);
|
||||
contextMnu.addSeparator() ;
|
||||
contextMnu.addAction(createcollectionfileAct) ;
|
||||
break;
|
||||
case DIR_TYPE_FILE:
|
||||
contextMnu.addAction(openfileAct);
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction(copylinkAct);
|
||||
contextMnu.addAction(sendlinkAct);
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction(createcollectionfileAct) ;
|
||||
contextMnu.addSeparator();
|
||||
QMenu contextMnu(this) ;
|
||||
|
||||
bool bIsRsColl = currentFile.endsWith(RsCollectionFile::ExtensionString);
|
||||
collCreateAct->setEnabled(true);
|
||||
collModifAct->setEnabled(bIsRsColl);
|
||||
collViewAct->setEnabled(bIsRsColl);
|
||||
collOpenAct->setEnabled(true);
|
||||
|
||||
QMenu collectionMenu(tr("Collection"), this);
|
||||
collectionMenu.setIcon(QIcon(IMAGE_LIBRARY));
|
||||
collectionMenu.addAction(collCreateAct);
|
||||
collectionMenu.addAction(collModifAct);
|
||||
collectionMenu.addAction(collViewAct);
|
||||
collectionMenu.addAction(collOpenAct);
|
||||
|
||||
switch (type) {
|
||||
case DIR_TYPE_DIR :
|
||||
contextMnu.addAction(openfolderAct) ;
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addMenu(&collectionMenu) ;
|
||||
break ;
|
||||
|
||||
case DIR_TYPE_FILE :
|
||||
contextMnu.addAction(openfileAct) ;
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addAction(copylinkAct) ;
|
||||
contextMnu.addAction(sendlinkAct) ;
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addMenu(&collectionMenu) ;
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
#ifdef RS_USE_LINKS
|
||||
contextMnu.addAction(sendlinkCloudAct);
|
||||
contextMnu.addAction(addlinkCloudAct);
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction(sendlinkCloudAct) ;
|
||||
contextMnu.addAction(addlinkCloudAct) ;
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
#endif
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to"), this, SLOT(recommendFilesToMsg()));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to"), this, SLOT(recommendFilesToMsg())) ;
|
||||
break ;
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
default :
|
||||
return ;
|
||||
}//switch (type)
|
||||
|
||||
contextMnu.exec(QCursor::pos()) ;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
@ -763,7 +908,7 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
||||
QAction*
|
||||
LocalSharedFilesDialog::fileAssotiationAction(const QString /*fileName*/)
|
||||
{
|
||||
QAction* result = 0;
|
||||
QAction* result = NULL;
|
||||
|
||||
Settings->beginGroup("FileAssotiations");
|
||||
|
||||
@ -826,11 +971,11 @@ void SharedFilesDialog::indicatorChanged(int index)
|
||||
model->changeAgeIndicator(correct_indicator[index]);
|
||||
|
||||
ui.dirTreeView->update(ui.dirTreeView->rootIndex());
|
||||
|
||||
|
||||
if (correct_indicator[index] != IND_ALWAYS)
|
||||
ui.dirTreeView->sortByColumn(2, Qt::AscendingOrder);
|
||||
ui.dirTreeView->sortByColumn(COLUMN_AGE, Qt::AscendingOrder);
|
||||
else
|
||||
ui.dirTreeView->sortByColumn(0, Qt::AscendingOrder);
|
||||
ui.dirTreeView->sortByColumn(COLUMN_NAME, Qt::AscendingOrder);
|
||||
|
||||
updateDisplay() ;
|
||||
}
|
||||
@ -878,11 +1023,11 @@ void SharedFilesDialog::FilterItems()
|
||||
QCoreApplication::processEvents() ;
|
||||
|
||||
int rowCount = ui.dirTreeView->model()->rowCount();
|
||||
for (int row = 0; row < rowCount; row++)
|
||||
for (int row = 0; row < rowCount; row++)
|
||||
if(proxyModel == tree_proxyModel)
|
||||
tree_FilterItem(ui.dirTreeView->model()->index(row, 0), text, 0);
|
||||
tree_FilterItem(ui.dirTreeView->model()->index(row, COLUMN_NAME), text, 0);
|
||||
else
|
||||
flat_FilterItem(ui.dirTreeView->model()->index(row, 0), text, 0);
|
||||
flat_FilterItem(ui.dirTreeView->model()->index(row, COLUMN_NAME), text, 0);
|
||||
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
@ -67,6 +67,11 @@ private slots:
|
||||
void addLinkToCloud();
|
||||
#endif
|
||||
|
||||
void collCreate();
|
||||
void collModif();
|
||||
void collView();
|
||||
void collOpen();
|
||||
|
||||
//== void showFrame(bool show);
|
||||
//== void showFrameRemote(bool show);
|
||||
//== void showFrameSplitted(bool show);
|
||||
@ -80,7 +85,7 @@ private slots:
|
||||
void startFilter();
|
||||
|
||||
public slots:
|
||||
void changeCurrentViewModel(int) ;
|
||||
void changeCurrentViewModel(int viewTypeIndex);
|
||||
signals:
|
||||
void playFiles(QStringList files);
|
||||
|
||||
@ -115,6 +120,11 @@ protected:
|
||||
QAction* sendchatlinkAct;
|
||||
QAction* copylinkhtmlAct;
|
||||
|
||||
QAction *collCreateAct;
|
||||
QAction *collModifAct;
|
||||
QAction *collViewAct;
|
||||
QAction *collOpenAct;
|
||||
|
||||
/* RetroshareDirModel */
|
||||
RetroshareDirModel *tree_model;
|
||||
RetroshareDirModel *flat_model;
|
||||
@ -147,7 +157,6 @@ class LocalSharedFilesDialog : public SharedFilesDialog
|
||||
|
||||
private slots:
|
||||
void addShares();
|
||||
void createCollectionFile();
|
||||
void checkUpdate() ;
|
||||
void editSharePermissions();
|
||||
void playselectedfiles();
|
||||
@ -161,10 +170,10 @@ class LocalSharedFilesDialog : public SharedFilesDialog
|
||||
|
||||
private:
|
||||
QAction* openfileAct;
|
||||
QAction* createcollectionfileAct;
|
||||
QAction* openfolderAct;
|
||||
QAction* editshareAct;
|
||||
};
|
||||
|
||||
class RemoteSharedFilesDialog : public SharedFilesDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -23,31 +23,67 @@
|
||||
|
||||
#include "ui_RsCollectionDialog.h"
|
||||
#include "RsCollectionFile.h"
|
||||
#include <QFileSystemModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
class QCheckBox ;
|
||||
|
||||
class RsCollectionDialog: public QDialog, public Ui::RsCollectionDialog
|
||||
class RsCollectionDialog: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RsCollectionDialog(const QString& filename,const std::vector<RsCollectionFile::DLinfo>& dlinfos) ;
|
||||
|
||||
private slots:
|
||||
void download() ;
|
||||
void selectAll() ;
|
||||
void deselectAll() ;
|
||||
void cancel() ;
|
||||
void updateSizes() ;
|
||||
void itemChanged(QTreeWidgetItem *item, int column);
|
||||
RsCollectionDialog(const QString& filename
|
||||
, const std::vector<ColFileInfo> &colFileInfos
|
||||
, const bool& creation
|
||||
, const bool& readOnly = false) ;
|
||||
virtual ~RsCollectionDialog();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
|
||||
private:
|
||||
void selectDeselectAll(bool select);
|
||||
void connectUpdate(bool doConnect);
|
||||
private slots:
|
||||
void directoryLoaded(QString dirLoaded);
|
||||
void updateSizes() ;
|
||||
void changeFileName() ;
|
||||
void add() ;
|
||||
void addRecursive() ;
|
||||
void remove() ;
|
||||
void processItem(QMap<QString, QString> &dirToAdd
|
||||
, int &index
|
||||
, ColFileInfo &parent
|
||||
) ;
|
||||
void makeDir() ;
|
||||
void fileHashingFinished(QList<HashedFile> hashedFiles) ;
|
||||
void itemChanged(QTreeWidgetItem* item,int col) ;
|
||||
void cancel() ;
|
||||
void download() ;
|
||||
void save() ;
|
||||
|
||||
const std::vector<RsCollectionFile::DLinfo>& _dlinfos ;
|
||||
QString _filename ;
|
||||
signals:
|
||||
void saveColl(std::vector<ColFileInfo>, QString);
|
||||
|
||||
private:
|
||||
void processSettings(bool bLoad) ;
|
||||
QTreeWidgetItem* getRootItem();
|
||||
bool updateList();
|
||||
bool addChild(QTreeWidgetItem *parent, const std::vector<ColFileInfo> &child);
|
||||
void addRecursive(bool recursive) ;
|
||||
bool addAllChild(QFileInfo &fileInfoParent
|
||||
, QMap<QString, QString > &dirToAdd
|
||||
, QStringList &fileToHash
|
||||
, int &count);
|
||||
void saveChild(QTreeWidgetItem *parentItem, ColFileInfo *parentInfo = NULL);
|
||||
|
||||
Ui::RsCollectionDialog ui;
|
||||
QString _fileName ;
|
||||
const bool _creationMode ;
|
||||
const bool _readOnly;
|
||||
std::vector<ColFileInfo> _newColFileInfos ;
|
||||
|
||||
QFileSystemModel *_dirModel;
|
||||
QSortFilterProxyModel *_tree_proxyModel;
|
||||
QItemSelectionModel *_selectionProxy;
|
||||
bool _dirLoaded;
|
||||
QHash<QString,QString> _listOfFilesAddedInDir;
|
||||
};
|
||||
|
@ -3,73 +3,138 @@
|
||||
<class>RsCollectionDialog</class>
|
||||
<widget class="QDialog" name="RsCollectionDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>434</width>
|
||||
<height>310</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>693</width>
|
||||
<height>331</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Collection</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/mimetypes/rscollection-16.png</normaloff>:/images/mimetypes/rscollection-16.png</iconset>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>File name :</string>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QSplitter" name="_mainSplitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QFrame" name="_FrameEdit">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="_frameInfo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_filename">
|
||||
<property name="text">
|
||||
<string>File name :</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Total size :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_totalsize">
|
||||
<property name="text">
|
||||
<string>Total size :</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Selected files:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_selectedFiles">
|
||||
<property name="text">
|
||||
<string>Selected files :</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="_filename_TL">
|
||||
<property name="text">
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="_filename_TL">
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="_totalSize_TL">
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_changeFile">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>14</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Change the file were collection will be saved.</p><p>If you select an existing file, you could merge it.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="_totalSize_TL">
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -80,88 +145,252 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="_fileEntriesTW">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="_frameLists">
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSplitter" name="_listSplitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QFrame" name="_treeViewFrame">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeView" name="_systemFileTW">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="_add_PB">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Add selected item to collection one by one.</p><p>Select parent dir to add this too.</p><p><span style=" font-style:italic; vertical-align:sub;">&lt;Enter&gt;</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_addRecur_PB">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Add selected item to collection.</p><p>If a directory is selected, all of his children will be added.</p><p><span style=" text-decoration: underline; vertical-align:sub;">&lt;Shift + Enter&gt;</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>>></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_remove_PB">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Remove selected item of collection.</p><p><span style=" font-style:italic; vertical-align:sub;">&lt;Del&gt;</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_makeDir_PB">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Make a new directory in the collection.</p><p><span style=" font-style:italic; vertical-align:sub;">&lt;+&gt;</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QTreeWidget" name="_fileEntriesTW">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="allColumnsShowFocus">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="allColumnsShowFocus">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">1</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_selectAll_PB">
|
||||
<property name="text">
|
||||
<string>Select all</string>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_cancel_PB">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_deselectAll_PB">
|
||||
<property name="text">
|
||||
<string>Deselect all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_cancel_PB">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_download_PB">
|
||||
<property name="text">
|
||||
<string>Download!</string>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_save_PB">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_download_PB">
|
||||
<property name="text">
|
||||
<string>Download!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="HashBox" name="_hashBox">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>HashBox</class>
|
||||
<extends>QScrollArea</extends>
|
||||
<header location="global">gui/common/HashBox.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "RsCollectionDialog.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
#include <QTextStream>
|
||||
@ -39,8 +38,22 @@
|
||||
|
||||
const QString RsCollectionFile::ExtensionString = QString("rscollection") ;
|
||||
|
||||
RsCollectionFile::RsCollectionFile()
|
||||
: _xml_doc("RsCollection")
|
||||
RsCollectionFile::RsCollectionFile(QObject *parent)
|
||||
: QObject(parent), _xml_doc("RsCollection")
|
||||
{
|
||||
}
|
||||
|
||||
RsCollectionFile::RsCollectionFile(const std::vector<DirDetails>& file_infos, QObject *parent)
|
||||
: QObject(parent), _xml_doc("RsCollection")
|
||||
{
|
||||
QDomElement root = _xml_doc.createElement("RsCollection");
|
||||
_xml_doc.appendChild(root);
|
||||
|
||||
for(uint32_t i = 0;i<file_infos.size();++i)
|
||||
recursAddElements(_xml_doc,file_infos[i],root) ;
|
||||
}
|
||||
|
||||
RsCollectionFile::~RsCollectionFile()
|
||||
{
|
||||
}
|
||||
|
||||
@ -50,11 +63,11 @@ void RsCollectionFile::downloadFiles() const
|
||||
// of the outermost element.
|
||||
QDomElement docElem = _xml_doc.documentElement();
|
||||
|
||||
std::vector<DLinfo> dlinfos ;
|
||||
std::vector<ColFileInfo> colFileInfos ;
|
||||
|
||||
recursCollectDLinfos(docElem,dlinfos,QString(),false) ;
|
||||
recursCollectColFileInfos(docElem,colFileInfos,QString(),false) ;
|
||||
|
||||
RsCollectionDialog(_filename, dlinfos).exec() ;
|
||||
RsCollectionDialog(_fileName, colFileInfos, false).exec() ;
|
||||
}
|
||||
|
||||
static QString purifyFileName(const QString& input,bool& bad)
|
||||
@ -74,7 +87,7 @@ static QString purifyFileName(const QString& input,bool& bad)
|
||||
return output ;
|
||||
}
|
||||
|
||||
void RsCollectionFile::recursCollectDLinfos(const QDomElement& e,std::vector<DLinfo>& dlinfos,const QString& current_path, bool bad_chars_in_parent) const
|
||||
void RsCollectionFile::recursCollectColFileInfos(const QDomElement& e,std::vector<ColFileInfo>& colFileInfos,const QString& current_path, bool bad_chars_in_parent) const
|
||||
{
|
||||
QDomNode n = e.firstChild() ;
|
||||
|
||||
@ -88,22 +101,37 @@ void RsCollectionFile::recursCollectDLinfos(const QDomElement& e,std::vector<DLi
|
||||
|
||||
if(ee.tagName() == QString("File"))
|
||||
{
|
||||
DLinfo i ;
|
||||
i.hash = ee.attribute(QString("sha1")) ;
|
||||
ColFileInfo newChild ;
|
||||
newChild.hash = ee.attribute(QString("sha1")) ;
|
||||
bool bad_chars_detected = false ;
|
||||
i.name = purifyFileName(ee.attribute(QString("name")), bad_chars_detected) ;
|
||||
i.filename_has_wrong_characters = bad_chars_detected || bad_chars_in_parent ;
|
||||
i.size = ee.attribute(QString("size")).toULongLong() ;
|
||||
i.path = current_path ;
|
||||
newChild.name = purifyFileName(ee.attribute(QString("name")), bad_chars_detected) ;
|
||||
newChild.filename_has_wrong_characters = bad_chars_detected || bad_chars_in_parent ;
|
||||
newChild.size = ee.attribute(QString("size")).toULongLong() ;
|
||||
newChild.path = current_path ;
|
||||
newChild.type = DIR_TYPE_FILE ;
|
||||
|
||||
dlinfos.push_back(i) ;
|
||||
colFileInfos.push_back(newChild) ;
|
||||
}
|
||||
else if(ee.tagName() == QString("Directory"))
|
||||
{
|
||||
ColFileInfo newParent ;
|
||||
bool bad_chars_detected = false ;
|
||||
QString cleanDirName = purifyFileName(ee.attribute(QString("name")),bad_chars_detected) ;
|
||||
newParent.name=cleanDirName;
|
||||
newParent.filename_has_wrong_characters = bad_chars_detected || bad_chars_in_parent ;
|
||||
newParent.size = 0;
|
||||
newParent.path = current_path ;
|
||||
newParent.type = DIR_TYPE_DIR ;
|
||||
|
||||
recursCollectDLinfos(ee,dlinfos,current_path + "/" + cleanDirName, bad_chars_in_parent || bad_chars_detected) ;
|
||||
recursCollectColFileInfos(ee,newParent.children,current_path + "/" + cleanDirName, bad_chars_in_parent || bad_chars_detected) ;
|
||||
uint32_t size = newParent.children.size();
|
||||
for(uint32_t i=0;i<size;++i)
|
||||
{
|
||||
const ColFileInfo &colFileInfo = newParent.children[i];
|
||||
newParent.size +=colFileInfo.size ;
|
||||
}
|
||||
|
||||
colFileInfos.push_back(newParent) ;
|
||||
}
|
||||
|
||||
n = n.nextSibling() ;
|
||||
@ -147,41 +175,84 @@ void RsCollectionFile::recursAddElements(QDomDocument& doc,const DirDetails& det
|
||||
}
|
||||
}
|
||||
|
||||
RsCollectionFile::RsCollectionFile(const std::vector<DirDetails>& file_infos)
|
||||
: _xml_doc("RsCollection")
|
||||
void RsCollectionFile::recursAddElements(QDomDocument& doc,const ColFileInfo& colFileInfo,QDomElement& e) const
|
||||
{
|
||||
QDomElement root = _xml_doc.createElement("RsCollection");
|
||||
_xml_doc.appendChild(root);
|
||||
if (colFileInfo.type == DIR_TYPE_FILE)
|
||||
{
|
||||
QDomElement f = doc.createElement("File") ;
|
||||
|
||||
for(uint32_t i = 0;i<file_infos.size();++i)
|
||||
recursAddElements(_xml_doc,file_infos[i],root) ;
|
||||
f.setAttribute(QString("name"),colFileInfo.name) ;
|
||||
f.setAttribute(QString("sha1"),colFileInfo.hash) ;
|
||||
f.setAttribute(QString("size"),QString::number(colFileInfo.size)) ;
|
||||
|
||||
e.appendChild(f) ;
|
||||
}
|
||||
else if (colFileInfo.type == DIR_TYPE_DIR)
|
||||
{
|
||||
QDomElement d = doc.createElement("Directory") ;
|
||||
|
||||
d.setAttribute(QString("name"),colFileInfo.name) ;
|
||||
|
||||
for (std::vector<ColFileInfo>::const_iterator it = colFileInfo.children.begin(); it != colFileInfo.children.end(); it++)
|
||||
{
|
||||
recursAddElements(doc,(*it),d) ;
|
||||
}
|
||||
|
||||
e.appendChild(d) ;
|
||||
}
|
||||
}
|
||||
|
||||
static void showErrorBox(const QString& filename, const QString& error)
|
||||
static void showErrorBox(const QString& fileName, const QString& error)
|
||||
{
|
||||
QMessageBox mb(QMessageBox::Warning, QObject::tr("Failed to process collection file"), QObject::tr("The collection file %1 could not be opened.\nReported error is: \n\n%2").arg(filename).arg(error), QMessageBox::Ok);
|
||||
QMessageBox mb(QMessageBox::Warning, QObject::tr("Failed to process collection file"), QObject::tr("The collection file %1 could not be opened.\nReported error is: \n\n%2").arg(fileName).arg(error), QMessageBox::Ok);
|
||||
mb.setWindowIcon(QIcon(":/images/rstray3.png"));
|
||||
mb.exec();
|
||||
}
|
||||
|
||||
bool RsCollectionFile::load(const QString& filename, bool showError /* = true*/)
|
||||
bool RsCollectionFile::load(const QString& fileName, bool showError /* = true*/)
|
||||
{
|
||||
QFile file(filename);
|
||||
|
||||
if (!checkFile(fileName,showError)) return false;
|
||||
QFile file(fileName);
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
std::cerr << "Cannot open file " << filename.toStdString() << " !!" << std::endl;
|
||||
std::cerr << "Cannot open file " << fileName.toStdString() << " !!" << std::endl;
|
||||
if (showError) {
|
||||
showErrorBox(filename, QApplication::translate("RsCollectionFile", "Cannot open file %1").arg(filename));
|
||||
showErrorBox(fileName, QApplication::translate("RsCollectionFile", "Cannot open file %1").arg(fileName));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// check that the file is a valid rscollection file, and not a lol bomb or some shit like this
|
||||
|
||||
std::cerr << "Checking this file for bomb elements and various wrong stuff" << std::endl;
|
||||
bool ok = _xml_doc.setContent(&file) ;
|
||||
file.close();
|
||||
|
||||
FILE *f = fopen(filename.toStdString().c_str(),"r") ;
|
||||
if (ok) {
|
||||
_fileName = fileName;
|
||||
} else {
|
||||
if (showError) {
|
||||
showErrorBox(fileName, QApplication::translate("RsCollectionFile", "Error parsing xml file"));
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
// check that the file is a valid rscollection file, and not a lol bomb or some shit like this
|
||||
bool RsCollectionFile::checkFile(const QString& fileName, bool showError)
|
||||
{
|
||||
QFile file(fileName);
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
std::cerr << "Cannot open file " << fileName.toStdString() << " !!" << std::endl;
|
||||
if (showError) {
|
||||
showErrorBox(fileName, QApplication::translate("RsCollectionFile", "Cannot open file %1").arg(fileName));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (file.reset()){
|
||||
std::cerr << "Checking this file for bomb elements and various wrong stuff" << std::endl;
|
||||
char c ;
|
||||
|
||||
std::vector<std::string> bad_strings ;
|
||||
@ -189,13 +260,18 @@ bool RsCollectionFile::load(const QString& filename, bool showError /* = true*/)
|
||||
static const int max_size = 12 ; // should be as large as the largest element in bad_strings
|
||||
char current[max_size] = { 0,0,0,0,0,0,0,0,0,0,0,0 } ;
|
||||
int n=0 ;
|
||||
|
||||
while( (c = fgetc(f)) != EOF || n >= 0)
|
||||
|
||||
while( !file.atEnd() || n >= 0)
|
||||
{
|
||||
if (!file.atEnd())
|
||||
file.getChar(&c);
|
||||
else
|
||||
c=0;
|
||||
|
||||
if(c == '\t' || c == '\n' || c == '\b' || c == '\r')
|
||||
continue ;
|
||||
|
||||
if(n == max_size || c==EOF)
|
||||
if(n == max_size || file.atEnd())
|
||||
for(int i=0;i<n-1;++i)
|
||||
current[i] = current[i+1] ;
|
||||
|
||||
@ -204,63 +280,51 @@ bool RsCollectionFile::load(const QString& filename, bool showError /* = true*/)
|
||||
|
||||
if(c >= 'A' && c <= 'Z') c += 'a' - 'A' ;
|
||||
|
||||
if(c != EOF)
|
||||
if(!file.atEnd())
|
||||
current[n] = c ;
|
||||
else
|
||||
current[n] = 0 ;
|
||||
|
||||
//std::cerr << "n==" << n <<" Checking string " << std::string(current,n+1) << " c = " << std::hex << (int)c << std::dec << std::endl;
|
||||
|
||||
for(int i=0;i<bad_strings.size();++i)
|
||||
for(uint i=0;i<bad_strings.size();++i)
|
||||
if(std::string(current,bad_strings[i].length()) == bad_strings[i])
|
||||
{
|
||||
showErrorBox(filename, QApplication::translate("RsCollectionFile", "This file contains the string \"%1\" and is therefore an invalid collection file. \n\nIf you believe it is correct, remove the corresponding line from the file and re-open it with Retroshare.").arg(bad_strings[i].c_str()));
|
||||
showErrorBox(file.fileName(), QApplication::translate("RsCollectionFile", "This file contains the string \"%1\" and is therefore an invalid collection file. \n\nIf you believe it is correct, remove the corresponding line from the file and re-open it with Retroshare.").arg(bad_strings[i].c_str()));
|
||||
file.close();
|
||||
return false ;
|
||||
//std::cerr << "Bad string detected" << std::endl;
|
||||
}
|
||||
|
||||
if(c == EOF)
|
||||
if(file.atEnd())
|
||||
n-- ;
|
||||
else if(n < max_size)
|
||||
n++ ;
|
||||
}
|
||||
fclose(f) ;
|
||||
|
||||
// std::cerr << "File is clean!" << std::endl;
|
||||
// return false ;
|
||||
|
||||
bool ok = _xml_doc.setContent(&file) ;
|
||||
file.close();
|
||||
|
||||
if (ok) {
|
||||
_filename = filename;
|
||||
} else {
|
||||
if (showError) {
|
||||
showErrorBox(filename, QApplication::translate("RsCollectionFile", "Error parsing xml file"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RsCollectionFile::load(QWidget *parent)
|
||||
{
|
||||
QString filename;
|
||||
if (!misc::getOpenFileName(parent, RshareSettings::LASTDIR_EXTRAFILE, QApplication::translate("RsCollectionFile", "Open collection file"), QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionFile::ExtensionString + ")", filename))
|
||||
QString fileName;
|
||||
if (!misc::getOpenFileName(parent, RshareSettings::LASTDIR_EXTRAFILE, QApplication::translate("RsCollectionFile", "Open collection file"), QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionFile::ExtensionString + ")", fileName))
|
||||
return false;
|
||||
|
||||
std::cerr << "Got file name: " << filename.toStdString() << std::endl;
|
||||
std::cerr << "Got file name: " << fileName.toStdString() << std::endl;
|
||||
|
||||
return load(filename, true);
|
||||
return load(fileName, true);
|
||||
}
|
||||
|
||||
bool RsCollectionFile::save(const QString& filename) const
|
||||
bool RsCollectionFile::save(const QString& fileName) const
|
||||
{
|
||||
QFile file(filename);
|
||||
QFile file(fileName);
|
||||
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
std::cerr << "Cannot write to file " << filename.toStdString() << " !!" << std::endl;
|
||||
std::cerr << "Cannot write to file " << fileName.toStdString() << " !!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -276,37 +340,135 @@ bool RsCollectionFile::save(const QString& filename) const
|
||||
|
||||
bool RsCollectionFile::save(QWidget *parent) const
|
||||
{
|
||||
QString filename;
|
||||
if(!misc::getSaveFileName(parent, RshareSettings::LASTDIR_EXTRAFILE, QApplication::translate("RsCollectionFile", "Create collection file"), QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionFile::ExtensionString + ")", filename))
|
||||
QString fileName;
|
||||
if(!misc::getSaveFileName(parent, RshareSettings::LASTDIR_EXTRAFILE, QApplication::translate("RsCollectionFile", "Create collection file"), QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionFile::ExtensionString + ")", fileName))
|
||||
return false;
|
||||
|
||||
if (!filename.endsWith("." + RsCollectionFile::ExtensionString))
|
||||
filename += "." + RsCollectionFile::ExtensionString ;
|
||||
if (!fileName.endsWith("." + RsCollectionFile::ExtensionString))
|
||||
fileName += "." + RsCollectionFile::ExtensionString ;
|
||||
|
||||
std::cerr << "Got file name: " << filename.toStdString() << std::endl;
|
||||
std::cerr << "Got file name: " << fileName.toStdString() << std::endl;
|
||||
|
||||
return save(filename);
|
||||
return save(fileName);
|
||||
}
|
||||
|
||||
|
||||
bool RsCollectionFile::openNewColl(QWidget *parent)
|
||||
{
|
||||
QString fileName;
|
||||
if(!misc::getSaveFileName(parent, RshareSettings::LASTDIR_EXTRAFILE
|
||||
, QApplication::translate("RsCollectionFile", "Create collection file")
|
||||
, QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionFile::ExtensionString + ")"
|
||||
, fileName,0, QFileDialog::DontConfirmOverwrite))
|
||||
return false;
|
||||
|
||||
if (!fileName.endsWith("." + RsCollectionFile::ExtensionString))
|
||||
fileName += "." + RsCollectionFile::ExtensionString ;
|
||||
|
||||
std::cerr << "Got file name: " << fileName.toStdString() << std::endl;
|
||||
|
||||
QFile file(fileName) ;
|
||||
|
||||
if(file.exists())
|
||||
{
|
||||
if (!checkFile(fileName,true)) return false;
|
||||
|
||||
QMessageBox mb;
|
||||
mb.setText(tr("Save Collection File."));
|
||||
mb.setInformativeText(tr("File already exist.")+"\n"+tr("What do you want to do?"));
|
||||
QAbstractButton *btnOwerWrite = mb.addButton(tr("Overwrite"), QMessageBox::YesRole);
|
||||
QAbstractButton *btnMerge = mb.addButton(tr("Merge"), QMessageBox::NoRole);
|
||||
QAbstractButton *btnCancel = mb.addButton(tr("Cancel"), QMessageBox::ResetRole);
|
||||
mb.setIcon(QMessageBox::Question);
|
||||
mb.exec();
|
||||
|
||||
if (mb.clickedButton()==btnOwerWrite) {
|
||||
//Nothing to do _xml_doc already up to date
|
||||
} else if (mb.clickedButton()==btnMerge) {
|
||||
//Open old file to merge it with _xml_doc
|
||||
QDomDocument qddOldFile("RsCollection");
|
||||
if (qddOldFile.setContent(&file)) {
|
||||
QDomElement docOldElem = qddOldFile.elementsByTagName("RsCollection").at(0).toElement();
|
||||
std::vector<ColFileInfo> colOldFileInfos;
|
||||
recursCollectColFileInfos(docOldElem,colOldFileInfos,QString(),false);
|
||||
|
||||
QDomElement root = _xml_doc.elementsByTagName("RsCollection").at(0).toElement();
|
||||
for(uint32_t i = 0;i<colOldFileInfos.size();++i){
|
||||
recursAddElements(_xml_doc,colOldFileInfos[i],root) ;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (mb.clickedButton()==btnCancel) {
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}//if(file.exists())
|
||||
|
||||
_fileName=fileName;
|
||||
std::vector<ColFileInfo> colFileInfos ;
|
||||
|
||||
recursCollectColFileInfos(_xml_doc.documentElement(),colFileInfos,QString(),false) ;
|
||||
|
||||
RsCollectionDialog* rcd = new RsCollectionDialog(fileName, colFileInfos,true);
|
||||
connect(rcd,SIGNAL(saveColl(std::vector<ColFileInfo>, QString)),this,SLOT(saveColl(std::vector<ColFileInfo>, QString))) ;
|
||||
_saved=false;
|
||||
rcd->exec() ;
|
||||
delete rcd;
|
||||
|
||||
return _saved;
|
||||
}
|
||||
|
||||
bool RsCollectionFile::openColl(const QString& fileName, bool readOnly /* = false */, bool showError /* = true*/)
|
||||
{
|
||||
if (load(fileName, showError)) {
|
||||
std::vector<ColFileInfo> colFileInfos ;
|
||||
|
||||
recursCollectColFileInfos(_xml_doc.documentElement(),colFileInfos,QString(),false) ;
|
||||
|
||||
RsCollectionDialog* rcd = new RsCollectionDialog(fileName, colFileInfos, true, readOnly);
|
||||
connect(rcd,SIGNAL(saveColl(std::vector<ColFileInfo>, QString)),this,SLOT(saveColl(std::vector<ColFileInfo>, QString))) ;
|
||||
_saved=false;
|
||||
rcd->exec() ;
|
||||
delete rcd;
|
||||
|
||||
return _saved;
|
||||
}//if (load(fileName, showError))
|
||||
return false;
|
||||
}
|
||||
|
||||
qulonglong RsCollectionFile::size()
|
||||
{
|
||||
QDomElement docElem = _xml_doc.documentElement();
|
||||
|
||||
std::vector<DLinfo> dlinfos;
|
||||
recursCollectDLinfos(docElem, dlinfos, QString(),false);
|
||||
std::vector<ColFileInfo> colFileInfos;
|
||||
recursCollectColFileInfos(docElem, colFileInfos, QString(),false);
|
||||
|
||||
uint64_t size = 0;
|
||||
|
||||
for (uint32_t i = 0; i < dlinfos.size(); ++i) {
|
||||
size += dlinfos[i].size;
|
||||
for (uint32_t i = 0; i < colFileInfos.size(); ++i) {
|
||||
size += colFileInfos[i].size;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
bool RsCollectionFile::isCollectionFile(const QString &filename)
|
||||
bool RsCollectionFile::isCollectionFile(const QString &fileName)
|
||||
{
|
||||
QString ext = QFileInfo(filename).suffix().toLower();
|
||||
QString ext = QFileInfo(fileName).suffix().toLower();
|
||||
|
||||
return (ext == RsCollectionFile::ExtensionString);
|
||||
}
|
||||
|
||||
void RsCollectionFile::saveColl(std::vector<ColFileInfo> colFileInfos, const QString &fileName)
|
||||
{
|
||||
|
||||
QDomElement root = _xml_doc.elementsByTagName("RsCollection").at(0).toElement();
|
||||
while (root.childNodes().count()>0) root.removeChild(root.firstChild());
|
||||
for(uint32_t i = 0;i<colFileInfos.size();++i)
|
||||
recursAddElements(_xml_doc,colFileInfos[i],root) ;
|
||||
|
||||
_saved=save(fileName);
|
||||
|
||||
}
|
||||
|
@ -29,53 +29,82 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QDomDocument>
|
||||
#include <QFile>
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <QMetaType>
|
||||
|
||||
class QDomElement ;
|
||||
class QWidget;
|
||||
|
||||
class RsCollectionFile
|
||||
class ColFileInfo
|
||||
{
|
||||
public:
|
||||
static const QString ExtensionString ;
|
||||
ColFileInfo(): name(""), size(0), path(""), hash(""), type(0), filename_has_wrong_characters(false), checked(false) {}
|
||||
|
||||
RsCollectionFile() ;
|
||||
public:
|
||||
QString name ;
|
||||
qulonglong size ;
|
||||
QString path ;
|
||||
QString hash ;
|
||||
uint8_t type;
|
||||
bool filename_has_wrong_characters ;
|
||||
std::vector<ColFileInfo> children;
|
||||
bool checked;
|
||||
};
|
||||
Q_DECLARE_METATYPE(ColFileInfo)
|
||||
|
||||
class RsCollectionFile : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
RsCollectionFile(QObject *parent = 0) ;
|
||||
// create from list of files and directories
|
||||
RsCollectionFile(const std::vector<DirDetails>& file_entries) ;
|
||||
RsCollectionFile(const std::vector<DirDetails>& file_entries, QObject *parent = 0) ;
|
||||
virtual ~RsCollectionFile() ;
|
||||
|
||||
static const QString ExtensionString ;
|
||||
|
||||
|
||||
|
||||
// Loads file from disk.
|
||||
bool load(QWidget *parent);
|
||||
bool load(const QString& filename, bool showError = true);
|
||||
bool load(const QString& fileName, bool showError = true);
|
||||
|
||||
// Save to disk
|
||||
bool save(QWidget *parent) const ;
|
||||
bool save(const QString& filename) const ;
|
||||
bool save(const QString& fileName) const ;
|
||||
|
||||
// Open new collection
|
||||
bool openNewColl(QWidget *parent);
|
||||
// Open existing collection
|
||||
bool openColl(const QString& fileName, bool readOnly = false, bool showError = true);
|
||||
|
||||
// Download the content.
|
||||
void downloadFiles() const ;
|
||||
|
||||
qulonglong size();
|
||||
|
||||
static bool isCollectionFile(const QString& filename);
|
||||
static bool isCollectionFile(const QString& fileName);
|
||||
|
||||
private slots:
|
||||
void saveColl(std::vector<ColFileInfo> colFileInfos, const QString& fileName);
|
||||
|
||||
private:
|
||||
struct DLinfo
|
||||
{
|
||||
QString name ;
|
||||
qulonglong size ;
|
||||
QString path ;
|
||||
QString hash ;
|
||||
bool filename_has_wrong_characters ;
|
||||
};
|
||||
|
||||
void recursAddElements(QDomDocument&,const DirDetails&,QDomElement&) const ;
|
||||
void recursCollectDLinfos(const QDomElement&,std::vector<DLinfo>& dlinfos,const QString& current_dir,bool bad_chars_in_parent) const ;
|
||||
void recursAddElements(QDomDocument&,const ColFileInfo&,QDomElement&) const;
|
||||
void recursCollectColFileInfos(const QDomElement&,std::vector<ColFileInfo>& colFileInfos,const QString& current_dir,bool bad_chars_in_parent) const ;
|
||||
// check that the file is a valid rscollection file, and not a lol bomb or some shit like this
|
||||
static bool checkFile(const QString &fileName, bool showError);
|
||||
|
||||
QDomDocument _xml_doc ;
|
||||
QString _filename ;
|
||||
QString _fileName ;
|
||||
bool _saved;
|
||||
|
||||
friend class RsCollectionDialog ;
|
||||
};
|
||||
|
@ -683,5 +683,8 @@
|
||||
<file>images/view-certificate-sign-48.png</file>
|
||||
<file>images/toasterEnable.png</file>
|
||||
<file>images/toasterDisable.png</file>
|
||||
<file>images/library_edit.png</file>
|
||||
<file>images/library_view.png</file>
|
||||
<file>images/library_add.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.3 KiB |
BIN
retroshare-gui/src/gui/images/library_add.png
Normal file
BIN
retroshare-gui/src/gui/images/library_add.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
BIN
retroshare-gui/src/gui/images/library_edit.png
Normal file
BIN
retroshare-gui/src/gui/images/library_edit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
retroshare-gui/src/gui/images/library_view.png
Normal file
BIN
retroshare-gui/src/gui/images/library_view.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
@ -297,11 +297,13 @@ QPixmap misc::getOpenThumbnailedPicture(QWidget *parent, const QString &caption,
|
||||
//return QPixmap(fileName).scaledToHeight(width, height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
bool misc::getOpenFileName(QWidget *parent, RshareSettings::enumLastDir type, const QString &caption, const QString &filter, QString &file)
|
||||
bool misc::getOpenFileName(QWidget *parent, RshareSettings::enumLastDir type
|
||||
, const QString &caption, const QString &filter
|
||||
, QString &file, QFileDialog::Options options)
|
||||
{
|
||||
QString lastDir = Settings->getLastDir(type);
|
||||
|
||||
file = QFileDialog::getOpenFileName(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks);
|
||||
file = QFileDialog::getOpenFileName(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks | options);
|
||||
|
||||
if (file.isEmpty())
|
||||
return false;
|
||||
@ -318,11 +320,13 @@ bool misc::getOpenFileName(QWidget *parent, RshareSettings::enumLastDir type, co
|
||||
return true;
|
||||
}
|
||||
|
||||
bool misc::getOpenFileNames(QWidget *parent, RshareSettings::enumLastDir type, const QString &caption, const QString &filter, QStringList &files)
|
||||
bool misc::getOpenFileNames(QWidget *parent, RshareSettings::enumLastDir type
|
||||
, const QString &caption, const QString &filter
|
||||
, QStringList &files, QFileDialog::Options options)
|
||||
{
|
||||
QString lastDir = Settings->getLastDir(type);
|
||||
|
||||
files = QFileDialog::getOpenFileNames(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks);
|
||||
files = QFileDialog::getOpenFileNames(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks | options);
|
||||
|
||||
if (files.isEmpty())
|
||||
return false;
|
||||
@ -341,11 +345,14 @@ bool misc::getOpenFileNames(QWidget *parent, RshareSettings::enumLastDir type, c
|
||||
return true;
|
||||
}
|
||||
|
||||
bool misc::getSaveFileName(QWidget *parent, RshareSettings::enumLastDir type, const QString &caption, const QString &filter, QString &file)
|
||||
bool misc::getSaveFileName(QWidget *parent, RshareSettings::enumLastDir type
|
||||
, const QString &caption , const QString &filter
|
||||
, QString &file, QString *selectedFilter
|
||||
, QFileDialog::Options options)
|
||||
{
|
||||
QString lastDir = Settings->getLastDir(type);
|
||||
|
||||
file = QFileDialog::getSaveFileName(parent, caption, lastDir, filter);
|
||||
file = QFileDialog::getSaveFileName(parent, caption, lastDir, filter, selectedFilter, options);
|
||||
|
||||
if (file.isEmpty())
|
||||
return false;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
#include <QThread>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
|
||||
@ -159,10 +160,17 @@ class misc : public QObject
|
||||
|
||||
static bool getOpenAvatarPicture(QWidget *parent, QByteArray &image_data);
|
||||
static QPixmap getOpenThumbnailedPicture(QWidget *parent, const QString &caption, int width, int height);
|
||||
static bool getOpenFileName(QWidget *parent, RshareSettings::enumLastDir type, const QString &caption, const QString &filter, QString &file);
|
||||
static bool getOpenFileNames(QWidget *parent, RshareSettings::enumLastDir type, const QString &caption, const QString &filter, QStringList &files);
|
||||
static bool getOpenFileName(QWidget *parent, RshareSettings::enumLastDir type
|
||||
, const QString &caption, const QString &filter
|
||||
, QString &file, QFileDialog::Options options = 0);
|
||||
static bool getOpenFileNames(QWidget *parent, RshareSettings::enumLastDir type
|
||||
, const QString &caption, const QString &filter
|
||||
, QStringList &files, QFileDialog::Options options = 0);
|
||||
|
||||
static bool getSaveFileName(QWidget *parent, RshareSettings::enumLastDir type, const QString &caption, const QString &filter, QString &file);
|
||||
static bool getSaveFileName(QWidget *parent, RshareSettings::enumLastDir type
|
||||
, const QString &caption , const QString &filter
|
||||
, QString &file, QString *selectedFilter = NULL
|
||||
, QFileDialog::Options options = 0);
|
||||
};
|
||||
|
||||
// Trick to get a portable sleep() function
|
||||
|
Loading…
x
Reference in New Issue
Block a user