mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-01 20:52:05 -04:00
added open file/folder actions in local sharedfiles dialog
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1330 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
902c475b9d
commit
cfc2aa89c7
3 changed files with 140 additions and 79 deletions
|
@ -15,7 +15,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
|
@ -65,6 +65,8 @@
|
||||||
#define IMAGE_FRIEND ":/images/peers_16x16.png"
|
#define IMAGE_FRIEND ":/images/peers_16x16.png"
|
||||||
#define IMAGE_PROGRESS ":/images/browse-looking.gif"
|
#define IMAGE_PROGRESS ":/images/browse-looking.gif"
|
||||||
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
#define IMAGE_COPYLINK ":/images/copyrslink.png"
|
||||||
|
#define IMAGE_OPENFOLDER ":/images/folderopen.png"
|
||||||
|
#define IMAGE_OPENFILE ":/images/fileopen.png"
|
||||||
|
|
||||||
const QString Image_AddNewAssotiationForFile = ":/images/kcmsystem24.png";
|
const QString Image_AddNewAssotiationForFile = ":/images/kcmsystem24.png";
|
||||||
|
|
||||||
|
@ -75,7 +77,7 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck()));
|
connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck()));
|
||||||
|
@ -93,10 +95,10 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
connect( ui.remoteDirTreeView, SIGNAL( itemExpanded( QTreeWidgetItem * ) ),
|
connect( ui.remoteDirTreeView, SIGNAL( itemExpanded( QTreeWidgetItem * ) ),
|
||||||
this, SLOT( checkForLocalDirRequest( QTreeWidgetItem * ) ) );
|
this, SLOT( checkForLocalDirRequest( QTreeWidgetItem * ) ) );
|
||||||
|
|
||||||
connect( ui.localDirTreeWidget, SIGNAL( itemExpanded( QTreeWidgetItem * ) ),
|
connect( ui.localDirTreeWidget, SIGNAL( itemExpanded( QTreeWidgetItem * ) ),
|
||||||
this, SLOT( checkForRemoteDirRequest( QTreeWidgetItem * ) ) );
|
this, SLOT( checkForRemoteDirRequest( QTreeWidgetItem * ) ) );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -116,21 +118,21 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
||||||
connect( ui.localDirTreeView, SIGNAL( expanded(const QModelIndex & ) ),
|
connect( ui.localDirTreeView, SIGNAL( expanded(const QModelIndex & ) ),
|
||||||
localModel, SLOT( expanded(const QModelIndex & ) ) );
|
localModel, SLOT( expanded(const QModelIndex & ) ) );
|
||||||
|
|
||||||
|
|
||||||
/* Set header resize modes and initial section sizes */
|
/* Set header resize modes and initial section sizes */
|
||||||
QHeaderView * l_header = ui.localDirTreeView->header () ;
|
QHeaderView * l_header = ui.localDirTreeView->header () ;
|
||||||
l_header->setResizeMode (0, QHeaderView::Interactive);
|
l_header->setResizeMode (0, QHeaderView::Interactive);
|
||||||
l_header->setResizeMode (1, QHeaderView::Interactive);
|
l_header->setResizeMode (1, QHeaderView::Interactive);
|
||||||
l_header->setResizeMode (2, QHeaderView::Interactive);
|
l_header->setResizeMode (2, QHeaderView::Interactive);
|
||||||
l_header->setResizeMode (3, QHeaderView::Interactive);
|
l_header->setResizeMode (3, QHeaderView::Interactive);
|
||||||
|
|
||||||
l_header->resizeSection ( 0, 490 );
|
l_header->resizeSection ( 0, 490 );
|
||||||
l_header->resizeSection ( 1, 70 );
|
l_header->resizeSection ( 1, 70 );
|
||||||
l_header->resizeSection ( 2, 60 );
|
l_header->resizeSection ( 2, 60 );
|
||||||
l_header->resizeSection ( 3, 100 );
|
l_header->resizeSection ( 3, 100 );
|
||||||
|
|
||||||
/* Set header resize modes and initial section sizes */
|
/* Set header resize modes and initial section sizes */
|
||||||
QHeaderView * r_header = ui.remoteDirTreeView->header () ;
|
QHeaderView * r_header = ui.remoteDirTreeView->header () ;
|
||||||
|
|
||||||
r_header->setResizeMode (0, QHeaderView::Interactive);
|
r_header->setResizeMode (0, QHeaderView::Interactive);
|
||||||
r_header->setStretchLastSection(false);
|
r_header->setStretchLastSection(false);
|
||||||
|
@ -138,13 +140,13 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
||||||
r_header->setResizeMode (1, QHeaderView::Fixed);
|
r_header->setResizeMode (1, QHeaderView::Fixed);
|
||||||
r_header->setResizeMode (2, QHeaderView::Fixed);
|
r_header->setResizeMode (2, QHeaderView::Fixed);
|
||||||
r_header->setResizeMode (3, QHeaderView::Fixed);
|
r_header->setResizeMode (3, QHeaderView::Fixed);
|
||||||
|
|
||||||
|
|
||||||
r_header->resizeSection ( 0, 490 );
|
r_header->resizeSection ( 0, 490 );
|
||||||
r_header->resizeSection ( 1, 70 );
|
r_header->resizeSection ( 1, 70 );
|
||||||
r_header->resizeSection ( 2, 60 );
|
r_header->resizeSection ( 2, 60 );
|
||||||
r_header->resizeSection ( 3, 100 );
|
r_header->resizeSection ( 3, 100 );
|
||||||
|
|
||||||
l_header->setHighlightSections(false);
|
l_header->setHighlightSections(false);
|
||||||
r_header->setHighlightSections(false);
|
r_header->setHighlightSections(false);
|
||||||
|
|
||||||
|
@ -196,19 +198,20 @@ void SharedFilesDialog::shareddirtreeviewCostumPopupMenu( QPoint point )
|
||||||
{
|
{
|
||||||
QMenu contextMnu( this );
|
QMenu contextMnu( this );
|
||||||
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
||||||
|
|
||||||
downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), this );
|
downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), this );
|
||||||
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) );
|
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) );
|
||||||
|
|
||||||
copyremotelinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this );
|
copyremotelinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this );
|
||||||
connect( copyremotelinkAct , SIGNAL( triggered() ), this, SLOT( copyLinkRemote() ) );
|
connect( copyremotelinkAct , SIGNAL( triggered() ), this, SLOT( copyLinkRemote() ) );
|
||||||
|
|
||||||
sendremotelinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link" ), this );
|
sendremotelinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link" ), this );
|
||||||
connect( sendremotelinkAct , SIGNAL( triggered() ), this, SLOT( sendremoteLinkTo( ) ) );
|
connect( sendremotelinkAct , SIGNAL( triggered() ), this, SLOT( sendremoteLinkTo( ) ) );
|
||||||
|
|
||||||
|
|
||||||
// addMsgAct = new QAction( tr( "Add to Message" ), this );
|
// addMsgAct = new QAction( tr( "Add to Message" ), this );
|
||||||
// connect( addMsgAct , SIGNAL( triggered() ), this, SLOT( addMsgRemoteSelected() ) );
|
// connect( addMsgAct , SIGNAL( triggered() ), this, SLOT( addMsgRemoteSelected() ) );
|
||||||
|
|
||||||
|
|
||||||
contextMnu.clear();
|
contextMnu.clear();
|
||||||
contextMnu.addAction( downloadAct);
|
contextMnu.addAction( downloadAct);
|
||||||
|
@ -425,7 +428,7 @@ void SharedFilesDialog::recommendFilesTo( std::string rsid )
|
||||||
/* create a message */
|
/* create a message */
|
||||||
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
|
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
|
||||||
|
|
||||||
/* fill it in
|
/* fill it in
|
||||||
* files are receommended already
|
* files are receommended already
|
||||||
* just need to set peers
|
* just need to set peers
|
||||||
*/
|
*/
|
||||||
|
@ -470,21 +473,21 @@ void SharedFilesDialog::openfile()
|
||||||
{
|
{
|
||||||
/* call back to the model (which does all the interfacing? */
|
/* call back to the model (which does all the interfacing? */
|
||||||
|
|
||||||
std::cerr << "Opening File";
|
std::cerr << "SharedFilesDialog::openfile" << std::endl;
|
||||||
std::cerr << std::endl;
|
|
||||||
|
|
||||||
QItemSelectionModel *qism = ui.localDirTreeView->selectionModel();
|
|
||||||
model -> openSelected(qism->selectedIndexes());
|
|
||||||
|
|
||||||
|
QModelIndexList qmil = ui.localDirTreeView->selectionModel()->selectedIndexes();
|
||||||
|
localModel->openSelected(qmil, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SharedFilesDialog::openfolder()
|
void SharedFilesDialog::openfolder()
|
||||||
{
|
{
|
||||||
|
std::cerr << "SharedFilesDialog::openfolder" << std::endl;
|
||||||
|
|
||||||
|
QModelIndexList qmil = ui.localDirTreeView->selectionModel()->selectedIndexes();
|
||||||
|
localModel->openSelected(qmil, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SharedFilesDialog::preModDirectories(bool update_local)
|
void SharedFilesDialog::preModDirectories(bool update_local)
|
||||||
{
|
{
|
||||||
std::cerr << "SharedFilesDialog::preModDirectories called with update_local = " << update_local << std::endl ;
|
std::cerr << "SharedFilesDialog::preModDirectories called with update_local = " << update_local << std::endl ;
|
||||||
|
@ -516,7 +519,7 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
|
||||||
RemoteDirModel::FileNameRole).toString();
|
RemoteDirModel::FileNameRole).toString();
|
||||||
|
|
||||||
QMenu contextMnu2( this );
|
QMenu contextMnu2( this );
|
||||||
//
|
//
|
||||||
|
|
||||||
QAction* menuAction = fileAssotiationAction(currentFile) ;
|
QAction* menuAction = fileAssotiationAction(currentFile) ;
|
||||||
//new QAction(QIcon(IMAGE_PLAY), currentFile, this);
|
//new QAction(QIcon(IMAGE_PLAY), currentFile, this);
|
||||||
|
@ -577,21 +580,29 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
|
||||||
|
|
||||||
}
|
}
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
copylinklocalAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this );
|
copylinklocalAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this );
|
||||||
connect( copylinklocalAct , SIGNAL( triggered() ), this, SLOT( copyLinkLocal() ) );
|
connect( copylinklocalAct , SIGNAL( triggered() ), this, SLOT( copyLinkLocal() ) );
|
||||||
|
|
||||||
sendlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link" ), this );
|
sendlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link" ), this );
|
||||||
connect( sendlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinkTo( /*std::string rsid*/ ) ) );
|
connect( sendlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinkTo( /*std::string rsid*/ ) ) );
|
||||||
|
|
||||||
|
openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this);
|
||||||
|
connect(openfileAct, SIGNAL(triggered()), this, SLOT(openfile()));
|
||||||
|
|
||||||
contextMnu2.addAction( menuAction );
|
openfolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this);
|
||||||
//contextMnu2.addAction( openfileAct);
|
connect(openfolderAct, SIGNAL(triggered()), this, SLOT(openfolder()));
|
||||||
contextMnu2.addAction( copylinklocalAct);
|
|
||||||
contextMnu2.addAction( sendlinkAct);
|
|
||||||
contextMnu2.addSeparator();
|
contextMnu2.addAction( menuAction );
|
||||||
contextMnu2.addMenu( recMenu);
|
contextMnu2.addAction( copylinklocalAct);
|
||||||
contextMnu2.addMenu( msgMenu);
|
contextMnu2.addAction( sendlinkAct);
|
||||||
|
contextMnu2.addSeparator();
|
||||||
|
contextMnu2.addAction( openfileAct);
|
||||||
|
contextMnu2.addAction( openfolderAct);
|
||||||
|
contextMnu2.addSeparator();
|
||||||
|
contextMnu2.addMenu( recMenu);
|
||||||
|
contextMnu2.addMenu( msgMenu);
|
||||||
|
|
||||||
|
|
||||||
QMouseEvent *mevent2 = new QMouseEvent( QEvent::MouseButtonPress, point,
|
QMouseEvent *mevent2 = new QMouseEvent( QEvent::MouseButtonPress, point,
|
||||||
|
@ -643,7 +654,7 @@ SharedFilesDialog::runCommandForFile()
|
||||||
tsl.append( currentFile );
|
tsl.append( currentFile );
|
||||||
QProcess::execute( currentCommand, tsl);
|
QProcess::execute( currentCommand, tsl);
|
||||||
//QString("%1 %2").arg(currentCommand).arg(currentFile) );
|
//QString("%1 %2").arg(currentCommand).arg(currentFile) );
|
||||||
|
|
||||||
// QString tmess = "Some command(%1) should be executed here for file %2";
|
// QString tmess = "Some command(%1) should be executed here for file %2";
|
||||||
// tmess = tmess.arg(currentCommand).arg(currentFile);
|
// tmess = tmess.arg(currentCommand).arg(currentFile);
|
||||||
// QMessageBox::warning(this, tr("RetroShare"), tmess, QMessageBox::Ok);
|
// QMessageBox::warning(this, tr("RetroShare"), tmess, QMessageBox::Ok);
|
||||||
|
@ -666,10 +677,10 @@ SharedFilesDialog::tryToAddNewAssotiation()
|
||||||
//QSettings settings( qApp->applicationDirPath()+"/sett.ini",
|
//QSettings settings( qApp->applicationDirPath()+"/sett.ini",
|
||||||
// QSettings::IniFormat);
|
// QSettings::IniFormat);
|
||||||
settings->beginGroup("FileAssotiations");
|
settings->beginGroup("FileAssotiations");
|
||||||
|
|
||||||
QString currType = afad.resultFileType() ;
|
QString currType = afad.resultFileType() ;
|
||||||
QString currCmd = afad.resultCommand() ;
|
QString currCmd = afad.resultCommand() ;
|
||||||
|
|
||||||
settings->setValue(currType, currCmd);
|
settings->setValue(currType, currCmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -677,7 +688,7 @@ SharedFilesDialog::tryToAddNewAssotiation()
|
||||||
//============================================================================
|
//============================================================================
|
||||||
/**
|
/**
|
||||||
Toggles the Lokal TreeView on and off, changes toggle button text
|
Toggles the Lokal TreeView on and off, changes toggle button text
|
||||||
|
|
||||||
void SharedFilesDialog::showFrame(bool show)
|
void SharedFilesDialog::showFrame(bool show)
|
||||||
{
|
{
|
||||||
if (show) {
|
if (show) {
|
||||||
|
|
|
@ -69,8 +69,8 @@ void RemoteDirModel::treeStyle()
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (details.type == DIR_TYPE_FILE)
|
if (details.type == DIR_TYPE_FILE)
|
||||||
{
|
{
|
||||||
#ifdef RDM_DEBUG
|
#ifdef RDM_DEBUG
|
||||||
std::cerr << "lookup FILE -> false";
|
std::cerr << "lookup FILE -> false";
|
||||||
|
@ -123,7 +123,7 @@ void RemoteDirModel::treeStyle()
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else PERSON/DIR*/
|
/* else PERSON/DIR*/
|
||||||
#ifdef RDM_DEBUG
|
#ifdef RDM_DEBUG
|
||||||
std::cerr << "lookup PER/DIR #" << details.count;
|
std::cerr << "lookup PER/DIR #" << details.count;
|
||||||
|
@ -151,7 +151,7 @@ void RemoteDirModel::treeStyle()
|
||||||
|
|
||||||
/* get the data from the index */
|
/* get the data from the index */
|
||||||
void *ref = index.internalPointer();
|
void *ref = index.internalPointer();
|
||||||
int coln = index.column();
|
int coln = index.column();
|
||||||
|
|
||||||
DirDetails details;
|
DirDetails details;
|
||||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||||
|
@ -175,8 +175,8 @@ void RemoteDirModel::treeStyle()
|
||||||
r = 200 + r * 5; /* 0->250 */
|
r = 200 + r * 5; /* 0->250 */
|
||||||
|
|
||||||
/*** age: log2(age) ***
|
/*** age: log2(age) ***
|
||||||
* 1 hour = 3,600 - 250
|
* 1 hour = 3,600 - 250
|
||||||
* 1 day = 86,400 - 200
|
* 1 day = 86,400 - 200
|
||||||
* 1 week = 604,800 - 100
|
* 1 week = 604,800 - 100
|
||||||
* 1 month = 2,419,200 - 50
|
* 1 month = 2,419,200 - 50
|
||||||
*
|
*
|
||||||
|
@ -245,10 +245,10 @@ void RemoteDirModel::treeStyle()
|
||||||
{
|
{
|
||||||
FileInfo finfo;
|
FileInfo finfo;
|
||||||
rsFiles->FileDetails(details.hash, 0, finfo);
|
rsFiles->FileDetails(details.hash, 0, finfo);
|
||||||
|
|
||||||
return QString::fromStdString(finfo.path) ;
|
return QString::fromStdString(finfo.path) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == Qt::DecorationRole)
|
if (role == Qt::DecorationRole)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -257,12 +257,12 @@ void RemoteDirModel::treeStyle()
|
||||||
switch(coln)
|
switch(coln)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return (QIcon(peerIcon));
|
return (QIcon(peerIcon));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (details.type == DIR_TYPE_DIR)
|
else if (details.type == DIR_TYPE_DIR)
|
||||||
{
|
{
|
||||||
switch(coln)
|
switch(coln)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -274,7 +274,7 @@ void RemoteDirModel::treeStyle()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return(QIcon(categoryIcon));
|
return(QIcon(categoryIcon));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -372,7 +372,7 @@ void RemoteDirModel::treeStyle()
|
||||||
if (role == Qt::DisplayRole)
|
if (role == Qt::DisplayRole)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Person: name, id, 0, 0;
|
* Person: name, id, 0, 0;
|
||||||
* File : name, size, rank, (0) ts
|
* File : name, size, rank, (0) ts
|
||||||
* Dir : name, (0) count, (0) path, (0) ts
|
* Dir : name, (0) count, (0) path, (0) ts
|
||||||
|
@ -464,7 +464,7 @@ void RemoteDirModel::treeStyle()
|
||||||
{
|
{
|
||||||
return int( Qt::AlignLeft | Qt::AlignVCenter);
|
return int( Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -519,7 +519,7 @@ void RemoteDirModel::treeStyle()
|
||||||
return QString("Row %1").arg(section);
|
return QString("Row %1").arg(section);
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex RemoteDirModel::index(int row, int column,
|
QModelIndex RemoteDirModel::index(int row, int column,
|
||||||
const QModelIndex & parent) const
|
const QModelIndex & parent) const
|
||||||
{
|
{
|
||||||
#ifdef RDM_DEBUG
|
#ifdef RDM_DEBUG
|
||||||
|
@ -528,7 +528,7 @@ void RemoteDirModel::treeStyle()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void *ref = NULL;
|
void *ref = NULL;
|
||||||
|
|
||||||
if (parent.isValid())
|
if (parent.isValid())
|
||||||
{
|
{
|
||||||
ref = parent.internalPointer();
|
ref = parent.internalPointer();
|
||||||
|
@ -557,7 +557,7 @@ void RemoteDirModel::treeStyle()
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now iterate through the details to
|
/* now iterate through the details to
|
||||||
* get the reference number
|
* get the reference number
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -566,13 +566,13 @@ void RemoteDirModel::treeStyle()
|
||||||
for(it = details.children.begin();
|
for(it = details.children.begin();
|
||||||
((i < row) && (it != details.children.end())); it++, i++) ;
|
((i < row) && (it != details.children.end())); it++, i++) ;
|
||||||
|
|
||||||
if (it == details.children.end())
|
if (it == details.children.end())
|
||||||
{
|
{
|
||||||
#ifdef RDM_DEBUG
|
#ifdef RDM_DEBUG
|
||||||
std::cerr << "wrong number of children -> invalid";
|
std::cerr << "wrong number of children -> invalid";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RDM_DEBUG
|
#ifdef RDM_DEBUG
|
||||||
|
@ -668,7 +668,7 @@ void RemoteDirModel::treeStyle()
|
||||||
}
|
}
|
||||||
else if (details.type == DIR_TYPE_DIR)
|
else if (details.type == DIR_TYPE_DIR)
|
||||||
{
|
{
|
||||||
return ( Qt::ItemIsSelectable |
|
return ( Qt::ItemIsSelectable |
|
||||||
Qt::ItemIsEnabled);
|
Qt::ItemIsEnabled);
|
||||||
|
|
||||||
// Qt::ItemIsDragEnabled |
|
// Qt::ItemIsDragEnabled |
|
||||||
|
@ -677,7 +677,7 @@ void RemoteDirModel::treeStyle()
|
||||||
}
|
}
|
||||||
else // (details.type == DIR_TYPE_FILE)
|
else // (details.type == DIR_TYPE_FILE)
|
||||||
{
|
{
|
||||||
return ( Qt::ItemIsSelectable |
|
return ( Qt::ItemIsSelectable |
|
||||||
Qt::ItemIsDragEnabled |
|
Qt::ItemIsDragEnabled |
|
||||||
Qt::ItemIsEnabled);
|
Qt::ItemIsEnabled);
|
||||||
|
|
||||||
|
@ -734,7 +734,7 @@ void RemoteDirModel::downloadSelected(QModelIndexList list)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* so for all the selected .... get the name out,
|
/* so for all the selected .... get the name out,
|
||||||
* make it into something the RsControl can understand
|
* make it into something the RsControl can understand
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -822,7 +822,7 @@ void RemoteDirModel::getFileInfoFromIndexList(const QModelIndexList& list, std::
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/* Fire off requests */
|
/* Fire off requests */
|
||||||
|
|
||||||
std::set<std::string> already_in ;
|
std::set<std::string> already_in ;
|
||||||
|
|
||||||
for(QModelIndexList::const_iterator it(list.begin()); it != list.end(); ++it)
|
for(QModelIndexList::const_iterator it(list.begin()); it != list.end(); ++it)
|
||||||
|
@ -923,11 +923,61 @@ void RemoteDirModel::recommendSelectedOnly(QModelIndexList list)
|
||||||
* OLD RECOMMEND SYSTEM - DISABLED
|
* OLD RECOMMEND SYSTEM - DISABLED
|
||||||
******/
|
******/
|
||||||
|
|
||||||
void RemoteDirModel::openSelected(QModelIndexList)
|
void RemoteDirModel::openSelected(QModelIndexList qmil, bool openFolder)
|
||||||
{
|
{
|
||||||
//recommendSelected(list);
|
#ifdef RDM_DEBUG
|
||||||
}
|
std::cerr << "RemoteDirModel::openSelected()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (RemoteMode) {
|
||||||
|
#ifdef RDM_DEBUG
|
||||||
|
std::cerr << "Cannot open remote. Download first." << std::endl;
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list<std::string> dirs_to_open;
|
||||||
|
|
||||||
|
std::list<DirDetails> files_info;
|
||||||
|
std::list<DirDetails>::iterator it;
|
||||||
|
getFileInfoFromIndexList(qmil, files_info);
|
||||||
|
|
||||||
|
for (it = files_info.begin(); it != files_info.end(); it++) {
|
||||||
|
if ((*it).type & DIR_TYPE_PERSON) continue;
|
||||||
|
|
||||||
|
std::string fullpath, name;
|
||||||
|
rsFiles->ConvertSharedFilePath((*it).path, fullpath);
|
||||||
|
int len = fullpath.length();
|
||||||
|
if (len && (fullpath[len - 1] != '/')) fullpath += '/';
|
||||||
|
|
||||||
|
if ((*it).type & DIR_TYPE_FILE) {
|
||||||
|
name = fullpath + (*it).name;
|
||||||
|
} else if ((*it).type & DIR_TYPE_DIR) {
|
||||||
|
name = fullpath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!openFolder) {
|
||||||
|
if ((*it).type & DIR_TYPE_FILE) {
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(name.c_str()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (dirs_to_open.end() == std::find(dirs_to_open.begin(), dirs_to_open.end(), fullpath)) {
|
||||||
|
dirs_to_open.push_back(fullpath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (openFolder) {
|
||||||
|
std::list<std::string>::iterator dit;
|
||||||
|
for (dit = dirs_to_open.begin(); dit != dirs_to_open.end(); dit++) {
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile((*dit).c_str()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef RDM_DEBUG
|
||||||
|
std::cerr << "::::::::::::Done RemoteDirModel::openSelected()" << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void RemoteDirModel::getFilePaths(QModelIndexList list, std::list<std::string> &fullpaths)
|
void RemoteDirModel::getFilePaths(QModelIndexList list, std::list<std::string> &fullpaths)
|
||||||
{
|
{
|
||||||
|
@ -1105,7 +1155,7 @@ RemoteDirModel::isDir ( const QModelIndex & index ) const
|
||||||
void *ref = index.internalPointer();
|
void *ref = index.internalPointer();
|
||||||
if (!ref)
|
if (!ref)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DirDetails details;
|
DirDetails details;
|
||||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||||
if (RemoteMode)
|
if (RemoteMode)
|
||||||
|
@ -1118,7 +1168,7 @@ RemoteDirModel::isDir ( const QModelIndex & index ) const
|
||||||
return false;//not good, but....
|
return false;//not good, but....
|
||||||
}
|
}
|
||||||
|
|
||||||
return (details.type == DIR_TYPE_DIR) ;
|
return (details.type == DIR_TYPE_DIR) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
class RemoteDirModel : public QAbstractItemModel
|
class RemoteDirModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Roles{ FileNameRole = Qt::UserRole+1 };
|
enum Roles{ FileNameRole = Qt::UserRole+1 };
|
||||||
|
|
||||||
RemoteDirModel(bool mode, QObject *parent = 0);
|
RemoteDirModel(bool mode, QObject *parent = 0);
|
||||||
|
|
||||||
/* These are all overloaded Virtual Functions */
|
/* These are all overloaded Virtual Functions */
|
||||||
|
@ -26,7 +26,7 @@ public:
|
||||||
QVariant headerData(int section, Qt::Orientation orientation,
|
QVariant headerData(int section, Qt::Orientation orientation,
|
||||||
int role = Qt::DisplayRole) const;
|
int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
QModelIndex index(int row, int column,
|
QModelIndex index(int row, int column,
|
||||||
const QModelIndex & parent = QModelIndex() ) const;
|
const QModelIndex & parent = QModelIndex() ) const;
|
||||||
QModelIndex parent ( const QModelIndex & index ) const;
|
QModelIndex parent ( const QModelIndex & index ) const;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public:
|
||||||
|
|
||||||
/* Callback from GUI */
|
/* Callback from GUI */
|
||||||
void downloadSelected(QModelIndexList list);
|
void downloadSelected(QModelIndexList list);
|
||||||
|
|
||||||
void getDirDetailsFromSelect (QModelIndexList list, std::vector <DirDetails>& dirVec);
|
void getDirDetailsFromSelect (QModelIndexList list, std::vector <DirDetails>& dirVec);
|
||||||
|
|
||||||
bool isDir ( const QModelIndex & index ) const ;
|
bool isDir ( const QModelIndex & index ) const ;
|
||||||
|
@ -48,16 +48,16 @@ public:
|
||||||
//#if 0 /****** REMOVED ******/
|
//#if 0 /****** REMOVED ******/
|
||||||
// void recommendSelected(QModelIndexList list);
|
// void recommendSelected(QModelIndexList list);
|
||||||
// void recommendSelectedOnly(QModelIndexList list);
|
// void recommendSelectedOnly(QModelIndexList list);
|
||||||
//#endif
|
//#endif
|
||||||
void getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& files_info) ;
|
void getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& files_info) ;
|
||||||
|
|
||||||
void openSelected(QModelIndexList list);
|
void openSelected(QModelIndexList list, bool openFolder);
|
||||||
|
|
||||||
void getFilePaths(QModelIndexList list, std::list<std::string> &fullpaths);
|
void getFilePaths(QModelIndexList list, std::list<std::string> &fullpaths);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void collapsed ( const QModelIndex & index ) { update(index); }
|
void collapsed ( const QModelIndex & index ) { update(index); }
|
||||||
void expanded ( const QModelIndex & index ) { update(index); }
|
void expanded ( const QModelIndex & index ) { update(index); }
|
||||||
|
|
||||||
/* Drag and Drop Functionality */
|
/* Drag and Drop Functionality */
|
||||||
|
@ -72,28 +72,28 @@ virtual QStringList mimeTypes () const;
|
||||||
|
|
||||||
QIcon categoryIcon;
|
QIcon categoryIcon;
|
||||||
QIcon peerIcon;
|
QIcon peerIcon;
|
||||||
|
|
||||||
class RemoteIndex
|
class RemoteIndex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RemoteIndex() {}
|
RemoteIndex() {}
|
||||||
RemoteIndex(std::string in_person,
|
RemoteIndex(std::string in_person,
|
||||||
std::string in_path,
|
std::string in_path,
|
||||||
int in_idx,
|
int in_idx,
|
||||||
int in_row,
|
int in_row,
|
||||||
int in_column,
|
int in_column,
|
||||||
std::string in_name,
|
std::string in_name,
|
||||||
int in_size,
|
int in_size,
|
||||||
int in_type,
|
int in_type,
|
||||||
int in_ts, int in_rank)
|
int in_ts, int in_rank)
|
||||||
:id(in_person), path(in_path), parent(in_idx),
|
:id(in_person), path(in_path), parent(in_idx),
|
||||||
row(in_row), column(in_column),
|
row(in_row), column(in_column),
|
||||||
name(in_name), size(in_size),
|
name(in_name), size(in_size),
|
||||||
type(in_type), timestamp(in_ts), rank(in_rank)
|
type(in_type), timestamp(in_ts), rank(in_rank)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string id;
|
std::string id;
|
||||||
std::string path;
|
std::string path;
|
||||||
int parent;
|
int parent;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue