2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
#include "RemoteDirModel.h"
|
2008-07-02 12:59:56 -04:00
|
|
|
#include "rsfiles.h"
|
|
|
|
|
2008-07-04 10:41:24 -04:00
|
|
|
#include <QtGui>
|
2008-08-06 17:53:41 -04:00
|
|
|
#include <QIcon>
|
2007-11-14 22:18:48 -05:00
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
#include <math.h>
|
2008-11-02 10:20:42 -05:00
|
|
|
#include <algorithm>
|
2008-11-17 20:42:17 -05:00
|
|
|
#include "util/misc.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
/*****
|
|
|
|
* #define RDM_DEBUG
|
|
|
|
****/
|
|
|
|
|
2008-07-04 10:41:24 -04:00
|
|
|
RemoteDirModel::RemoteDirModel(bool mode, QObject *parent)
|
|
|
|
: QAbstractItemModel(parent),
|
|
|
|
RemoteMode(mode), nIndex(1), indexSet(1) /* ass zero index cant be used */
|
|
|
|
{
|
|
|
|
setSupportedDragActions(Qt::CopyAction);
|
2008-11-17 20:42:17 -05:00
|
|
|
|
|
|
|
|
2008-07-04 10:41:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
bool RemoteDirModel::hasChildren(const QModelIndex &parent) const
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "RemoteDirModel::hasChildren() :" << parent.internalPointer();
|
|
|
|
std::cerr << ": ";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!parent.isValid())
|
|
|
|
{
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "root -> true ";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *ref = parent.internalPointer();
|
|
|
|
|
|
|
|
DirDetails details;
|
|
|
|
uint32_t flags = DIR_FLAGS_CHILDREN;
|
|
|
|
if (RemoteMode)
|
|
|
|
flags |= DIR_FLAGS_REMOTE;
|
|
|
|
else
|
|
|
|
flags |= DIR_FLAGS_LOCAL;
|
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
/* error */
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "lookup failed -> false";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (details.type == DIR_TYPE_FILE)
|
|
|
|
{
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "lookup FILE -> false";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
/* PERSON/DIR*/
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "lookup PER/DIR #" << details.count;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
return (details.count > 0); /* do we have children? */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int RemoteDirModel::rowCount(const QModelIndex &parent) const
|
|
|
|
{
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "RemoteDirModel::rowCount(): " << parent.internalPointer();
|
|
|
|
std::cerr << ": ";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void *ref = NULL;
|
|
|
|
if (parent.isValid())
|
|
|
|
{
|
|
|
|
ref = parent.internalPointer();
|
|
|
|
}
|
|
|
|
|
|
|
|
DirDetails details;
|
|
|
|
uint32_t flags = DIR_FLAGS_CHILDREN;
|
|
|
|
if (RemoteMode)
|
|
|
|
flags |= DIR_FLAGS_REMOTE;
|
|
|
|
else
|
|
|
|
flags |= DIR_FLAGS_LOCAL;
|
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "lookup failed -> 0";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (details.type == DIR_TYPE_FILE)
|
|
|
|
{
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "lookup FILE: 0";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* else PERSON/DIR*/
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "lookup PER/DIR #" << details.count;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return details.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RemoteDirModel::columnCount(const QModelIndex &parent) const
|
|
|
|
{
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant RemoteDirModel::data(const QModelIndex &index, int role) const
|
|
|
|
{
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "RemoteDirModel::data(): " << index.internalPointer();
|
|
|
|
std::cerr << ": ";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!index.isValid())
|
|
|
|
return QVariant();
|
|
|
|
|
|
|
|
/* get the data from the index */
|
|
|
|
void *ref = index.internalPointer();
|
|
|
|
int coln = index.column();
|
|
|
|
|
|
|
|
DirDetails details;
|
|
|
|
uint32_t flags = DIR_FLAGS_DETAILS;
|
|
|
|
if (RemoteMode)
|
|
|
|
flags |= DIR_FLAGS_REMOTE;
|
|
|
|
else
|
|
|
|
flags |= DIR_FLAGS_LOCAL;
|
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
2008-08-17 12:14:03 -04:00
|
|
|
#if 0
|
2008-08-06 17:53:41 -04:00
|
|
|
/*if (role == Qt::BackgroundRole)
|
|
|
|
{*/
|
2007-11-14 22:18:48 -05:00
|
|
|
/*** colour entries based on rank/age/count **/
|
|
|
|
/*** rank (0-10) ***/
|
2008-08-17 12:14:03 -04:00
|
|
|
/ *uint32_t r = details.rank;
|
2007-11-14 22:18:48 -05:00
|
|
|
if (r > 10) r = 10;
|
|
|
|
r = 200 + r * 5; /* 0->250 */
|
|
|
|
|
|
|
|
/*** age: log2(age) ***
|
|
|
|
* 1 hour = 3,600 - 250
|
|
|
|
* 1 day = 86,400 - 200
|
|
|
|
* 1 week = 604,800 - 100
|
|
|
|
* 1 month = 2,419,200 - 50
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 250 - log2( 1 + (age / 100) ) * 10
|
|
|
|
* 0 => 1 => 0 => 0 => 250
|
|
|
|
* 900 => 10 => 3.2 => 32 => 220
|
|
|
|
* 3600 => 37 => 5.2 => 52 => 200
|
|
|
|
* 86400 => 865 => 9.2 => 92 => 160
|
|
|
|
* 604800 => 6049 => 12.3 => 120 => 130
|
|
|
|
* 2419200 => 24193 => 14.4 => 140 => 110
|
|
|
|
*
|
|
|
|
* value log2
|
|
|
|
*
|
|
|
|
* 1 0
|
|
|
|
* 2 1
|
|
|
|
* 4 2
|
|
|
|
* 8 3
|
|
|
|
* 16 4
|
|
|
|
* 32 5
|
|
|
|
* 64 6
|
|
|
|
* 128 7
|
|
|
|
* 256 8
|
|
|
|
* 512 9
|
|
|
|
* 1024 10
|
|
|
|
* 2048 11
|
|
|
|
* 4096 12
|
|
|
|
* 8192 13
|
|
|
|
* 16384 14
|
|
|
|
* 32K 15
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-08-06 17:53:41 -04:00
|
|
|
/*uint32_t g = (uint32_t) log2 ( 1.0 + ( details.age / 100 ) ) * 4;
|
2007-11-14 22:18:48 -05:00
|
|
|
if (g > 250) g = 250;
|
|
|
|
g = 250 - g;
|
|
|
|
|
|
|
|
if (details.type == DIR_TYPE_PERSON)
|
|
|
|
{
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
else if (details.type == DIR_TYPE_DIR)
|
|
|
|
{
|
|
|
|
uint32_t b = 200 + details.count;
|
|
|
|
if (b > 250) b = 250;
|
|
|
|
|
|
|
|
QBrush brush(QColor(r,g,b));
|
|
|
|
return brush;
|
|
|
|
}
|
|
|
|
else if (details.type == DIR_TYPE_FILE)
|
|
|
|
{
|
|
|
|
uint32_t b = (uint32_t) (200 + 2 * log2(details.count));
|
|
|
|
if (b > 250) b = 250;
|
|
|
|
|
|
|
|
QBrush brush(QColor(r,g,b));
|
|
|
|
return brush;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return QVariant();
|
|
|
|
}
|
2008-08-06 17:53:41 -04:00
|
|
|
}*/
|
2008-08-17 12:14:03 -04:00
|
|
|
#endif
|
2008-08-06 17:53:41 -04:00
|
|
|
|
|
|
|
if (role == Qt::DecorationRole)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (details.type == DIR_TYPE_PERSON)
|
|
|
|
{
|
2008-11-17 17:40:37 -05:00
|
|
|
switch(coln)
|
|
|
|
{
|
|
|
|
case 0:
|
2008-11-17 20:42:17 -05:00
|
|
|
return(QIcon(":/images/user/identity16.png"));
|
2008-11-17 17:40:37 -05:00
|
|
|
break;
|
|
|
|
}
|
2008-08-06 17:53:41 -04:00
|
|
|
}
|
|
|
|
else if (details.type == DIR_TYPE_DIR)
|
|
|
|
{
|
2008-11-17 17:40:37 -05:00
|
|
|
switch(coln)
|
|
|
|
{
|
|
|
|
case 0:
|
2008-11-29 21:21:02 -05:00
|
|
|
QString ext = QFileInfo(QString::fromStdString(details.name)).suffix();
|
|
|
|
if (ext == "avi" || ext == "mpg" || ext == "movie")
|
|
|
|
{
|
|
|
|
QIcon icon(":/images/folder_video.png");
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return(QIcon(":/images/folder16.png"));
|
|
|
|
}
|
2008-11-17 17:40:37 -05:00
|
|
|
break;
|
|
|
|
}
|
2008-08-06 17:53:41 -04:00
|
|
|
}
|
2008-08-07 13:12:50 -04:00
|
|
|
else if (details.type == DIR_TYPE_FILE) /* File */
|
|
|
|
{
|
|
|
|
// extensions predefined
|
2008-09-09 07:37:09 -04:00
|
|
|
//QString name;
|
2008-11-17 17:40:37 -05:00
|
|
|
switch(coln)
|
|
|
|
{
|
|
|
|
case 0:
|
2008-09-09 07:37:09 -04:00
|
|
|
QString ext = QFileInfo(QString::fromStdString(details.name)).suffix();
|
2008-08-07 13:12:50 -04:00
|
|
|
if (ext == "jpg" || ext == "jpeg" || ext == "png" || ext == "gif"
|
|
|
|
|| ext == "bmp" || ext == "ico" || ext == "svg")
|
|
|
|
{
|
|
|
|
//setIcon(0, QIcon(":/images/FileTypePicture.png"));
|
|
|
|
QIcon icon(":/images/FileTypePicture.png");
|
|
|
|
return icon;
|
|
|
|
}
|
2008-11-15 20:21:41 -05:00
|
|
|
else if (ext == "avi" || ext == "mpg" || ext == "mpeg" || ext == "wmv"
|
|
|
|
|| ext == "mkv" || ext == "mp4" || ext == "flv" || ext == "mov"
|
|
|
|
|| ext == "vob" || ext == "qt" || ext == "rm" || ext == "3gp")
|
2008-08-07 13:12:50 -04:00
|
|
|
{
|
|
|
|
//setIcon(0, QIcon(":/images/videofile.png"));
|
|
|
|
QIcon icon(":/images/FileTypeVideo.png");
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
else if (ext == "ogg" || ext == "mp3" || ext == "wav" || ext == "wma")
|
|
|
|
{
|
|
|
|
//setIcon(0, QIcon(":/images/soundfile.png"));
|
|
|
|
QIcon icon(":/images/FileTypeAudio.png");
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
else if (ext == "tar" || ext == "bz2" || ext == "zip" || ext == "gz"
|
|
|
|
|| ext == "rar" || ext == "rpm" || ext == "deb")
|
|
|
|
{
|
|
|
|
//setIcon(0, QIcon(":/images/compressedfile.png"));
|
|
|
|
QIcon icon(":/images/FileTypeArchive.png");
|
|
|
|
return icon;
|
|
|
|
}
|
2008-11-18 17:59:33 -05:00
|
|
|
else if (ext == "app" || ext == "bat" || ext == "cgi" || ext == "com"
|
|
|
|
|| ext == "bin" || ext == "exe" || ext == "js" || ext == "pif"
|
|
|
|
|| ext == "py" || ext == "pl" || ext == "sh" || ext == "vb" || ext == "ws")
|
|
|
|
{
|
|
|
|
return(QIcon(":/images/FileTypeProgram.png"));
|
|
|
|
}
|
|
|
|
else if (ext == "iso" || ext == "nrg" || ext == "mdf" )
|
|
|
|
{
|
|
|
|
//setIcon(0, QIcon(":/images/txtfile.png"));
|
|
|
|
QIcon icon(":/images/FileTypeCDImage.png");
|
|
|
|
return icon;
|
|
|
|
}
|
2008-08-07 13:12:50 -04:00
|
|
|
else if (ext == "txt" || ext == "cpp" || ext == "c" || ext == "h")
|
|
|
|
{
|
|
|
|
//setIcon(0, QIcon(":/images/txtfile.png"));
|
|
|
|
QIcon icon(":/images/FileTypeDocument.png");
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
else if (ext == "doc" || ext == "rtf" || ext == "sxw" || ext == "xls"
|
|
|
|
|| ext == "sxc" || ext == "odt" || ext == "ods")
|
|
|
|
{
|
|
|
|
//setIcon(0, QIcon(":/images/docfile.png"));
|
2008-11-17 17:40:37 -05:00
|
|
|
QIcon icon(":/images/FileTypeDocument.png");
|
2008-08-07 13:12:50 -04:00
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
else if (ext == "html" || ext == "htm" || ext == "php")
|
|
|
|
{
|
|
|
|
//setIcon(0, QIcon(":/images/netfile.png"));
|
|
|
|
QIcon icon(":/images/FileTypeDocument.png");
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//setIcon(0, QIcon(":/images/file.png"));
|
|
|
|
QIcon icon(":/images/FileTypeAny.png");
|
|
|
|
return icon;
|
|
|
|
}
|
2008-11-17 17:40:37 -05:00
|
|
|
break;
|
|
|
|
}
|
2008-08-07 13:12:50 -04:00
|
|
|
}
|
2008-08-06 17:53:41 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
}
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/*************
|
|
|
|
Qt::EditRole
|
|
|
|
Qt::ToolTipRole
|
|
|
|
Qt::StatusTipRole
|
|
|
|
Qt::WhatsThisRole
|
|
|
|
Qt::SizeHintRole
|
|
|
|
****************/
|
|
|
|
|
|
|
|
if (role == Qt::DisplayRole)
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Person: name, id, 0, 0;
|
|
|
|
* File : name, size, rank, (0) ts
|
|
|
|
* Dir : name, (0) count, (0) path, (0) ts
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
if (details.type == DIR_TYPE_PERSON) /* Person */
|
|
|
|
{
|
|
|
|
switch(coln)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return QString::fromStdString(details.name);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
//return QString("");
|
|
|
|
return QString::fromStdString(details.id);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
//return QString("");
|
|
|
|
return QString::fromStdString("P");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (details.type == DIR_TYPE_FILE) /* File */
|
|
|
|
{
|
|
|
|
switch(coln)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return QString::fromStdString(details.name);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
std::ostringstream out;
|
2008-11-17 20:42:17 -05:00
|
|
|
//out << details.count;
|
|
|
|
//return QString::fromStdString(out.str());
|
|
|
|
return misc::friendlyUnit(details.count);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
std::ostringstream out;
|
|
|
|
out << details.rank;
|
|
|
|
return QString::fromStdString(out.str());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
std::ostringstream out;
|
2008-11-17 17:40:37 -05:00
|
|
|
//out << details.age;
|
2008-11-17 20:42:17 -05:00
|
|
|
return misc::userFriendlyDuration(details.age);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return QString::fromStdString("FILE");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (details.type == DIR_TYPE_DIR) /* Dir */
|
|
|
|
{
|
|
|
|
switch(coln)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return QString::fromStdString(details.name);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
//return QString("");
|
|
|
|
{
|
|
|
|
std::ostringstream out;
|
|
|
|
out << details.count;
|
|
|
|
return QString::fromStdString(out.str());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
//return QString("");
|
|
|
|
return QString::fromStdString(details.path);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return QString::fromStdString("DIR");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* end of DisplayRole */
|
|
|
|
return QVariant();
|
2008-11-18 17:59:33 -05:00
|
|
|
|
|
|
|
if (role == Qt::TextAlignmentRole)
|
|
|
|
{
|
|
|
|
if(coln == 1)
|
|
|
|
{
|
|
|
|
return int( Qt::AlignLeft | Qt::AlignVCenter);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
return QVariant();
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2008-11-18 17:59:33 -05:00
|
|
|
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
QVariant RemoteDirModel::headerData(int section, Qt::Orientation orientation,
|
|
|
|
int role) const
|
|
|
|
{
|
|
|
|
if (role == Qt::SizeHintRole)
|
|
|
|
{
|
|
|
|
int defw = 50;
|
2008-06-16 09:37:30 -04:00
|
|
|
int defh = 21;
|
2007-11-14 22:18:48 -05:00
|
|
|
if (section < 2)
|
|
|
|
{
|
|
|
|
defw = 200;
|
|
|
|
}
|
|
|
|
return QSize(defw, defh);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (role != Qt::DisplayRole)
|
|
|
|
return QVariant();
|
|
|
|
|
|
|
|
if (orientation == Qt::Horizontal)
|
|
|
|
{
|
|
|
|
switch(section)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (RemoteMode)
|
|
|
|
{
|
|
|
|
return QString("Remote Directories");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return QString("Local Directories");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return QString("Size");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return QString("Rank");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
return QString("Age");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return QString("Column %1").arg(section);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return QString("Row %1").arg(section);
|
|
|
|
}
|
|
|
|
|
|
|
|
QModelIndex RemoteDirModel::index(int row, int column,
|
|
|
|
const QModelIndex & parent) const
|
|
|
|
{
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "RemoteDirModel::index(): " << parent.internalPointer();
|
|
|
|
std::cerr << ": row:" << row << " col:" << column << " ";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void *ref = NULL;
|
|
|
|
|
|
|
|
if (parent.isValid())
|
|
|
|
{
|
|
|
|
ref = parent.internalPointer();
|
|
|
|
}
|
|
|
|
|
|
|
|
/********
|
|
|
|
if (!RemoteMode)
|
|
|
|
{
|
|
|
|
remote = &(rsiface->getLocalDirectoryList());
|
|
|
|
}
|
|
|
|
********/
|
|
|
|
|
|
|
|
DirDetails details;
|
|
|
|
uint32_t flags = DIR_FLAGS_CHILDREN;
|
|
|
|
if (RemoteMode)
|
|
|
|
flags |= DIR_FLAGS_REMOTE;
|
|
|
|
else
|
|
|
|
flags |= DIR_FLAGS_LOCAL;
|
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "lookup failed -> invalid";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
return QModelIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now iterate through the details to
|
|
|
|
* get the reference number
|
|
|
|
*/
|
|
|
|
|
|
|
|
std::list<DirStub>::iterator it;
|
|
|
|
int i = 0;
|
|
|
|
for(it = details.children.begin();
|
|
|
|
(i < row) && (it != details.children.end()); it++, i++);
|
|
|
|
|
|
|
|
if (it == details.children.end())
|
|
|
|
{
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "wrong number of children -> invalid";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
return QModelIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "success index(" << row << "," << column << "," << it->ref << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* we can just grab the reference now */
|
|
|
|
QModelIndex qmi = createIndex(row, column, it->ref);
|
|
|
|
return qmi;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QModelIndex RemoteDirModel::parent( const QModelIndex & index ) const
|
|
|
|
{
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "RemoteDirModel::parent(): " << index.internalPointer();
|
|
|
|
std::cerr << ": ";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* create the index */
|
|
|
|
if (!index.isValid())
|
|
|
|
{
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "Invalid Index -> invalid";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
/* Parent is invalid too */
|
|
|
|
return QModelIndex();
|
|
|
|
}
|
|
|
|
void *ref = index.internalPointer();
|
|
|
|
|
|
|
|
DirDetails details;
|
|
|
|
uint32_t flags = DIR_FLAGS_PARENT;
|
|
|
|
if (RemoteMode)
|
|
|
|
flags |= DIR_FLAGS_REMOTE;
|
|
|
|
else
|
|
|
|
flags |= DIR_FLAGS_LOCAL;
|
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "Failed Lookup -> invalid";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
return QModelIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(details.parent))
|
|
|
|
{
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "success. parent is Root/NULL --> invalid";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
return QModelIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "success index(" << details.prow << ",0," << details.parent << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return createIndex(details.prow, 0, details.parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
Qt::ItemFlags RemoteDirModel::flags( const QModelIndex & index ) const
|
|
|
|
{
|
|
|
|
#ifdef RDM_DEBUG
|
|
|
|
std::cerr << "RemoteDirModel::flags()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!index.isValid())
|
|
|
|
return (Qt::ItemIsSelectable); // Error.
|
|
|
|
|
|
|
|
void *ref = index.internalPointer();
|
|
|
|
|
|
|
|
DirDetails details;
|
|
|
|
uint32_t flags = DIR_FLAGS_DETAILS;
|
|
|
|
if (RemoteMode)
|
|
|
|
flags |= DIR_FLAGS_REMOTE;
|
|
|
|
else
|
|
|
|
flags |= DIR_FLAGS_LOCAL;
|
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
return (Qt::ItemIsSelectable); // Error.
|
|
|
|
}
|
|
|
|
|
|
|
|
if (details.type == DIR_TYPE_PERSON)
|
|
|
|
{
|
|
|
|
return (Qt::ItemIsEnabled);
|
|
|
|
}
|
|
|
|
else if (details.type == DIR_TYPE_DIR)
|
|
|
|
{
|
|
|
|
return ( Qt::ItemIsSelectable |
|
|
|
|
Qt::ItemIsEnabled);
|
|
|
|
|
|
|
|
// Qt::ItemIsDragEnabled |
|
|
|
|
// Qt::ItemIsDropEnabled |
|
|
|
|
|
|
|
|
}
|
|
|
|
else // (details.type == DIR_TYPE_FILE)
|
|
|
|
{
|
|
|
|
return ( Qt::ItemIsSelectable |
|
2008-07-04 10:41:24 -04:00
|
|
|
Qt::ItemIsDragEnabled |
|
2007-11-14 22:18:48 -05:00
|
|
|
Qt::ItemIsEnabled);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The other flags...
|
|
|
|
//Qt::ItemIsUserCheckable
|
|
|
|
//Qt::ItemIsEditable
|
|
|
|
//Qt::ItemIsDropEnabled
|
|
|
|
//Qt::ItemIsTristate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Callback from */
|
|
|
|
void RemoteDirModel::preMods()
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "RemoteDirModel::preMods()" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
//modelAboutToBeReset();
|
|
|
|
reset();
|
|
|
|
layoutAboutToBeChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Callback from */
|
|
|
|
void RemoteDirModel::postMods()
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "RemoteDirModel::postMods()" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
//modelReset();
|
|
|
|
layoutChanged();
|
|
|
|
//reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RemoteDirModel::update (const QModelIndex &index )
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
//std::cerr << "Directory Request(" << id << ") : ";
|
|
|
|
//std::cerr << path << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-07-02 12:59:56 -04:00
|
|
|
//rsFiles -> RequestDirectories(id, path, 1);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RemoteDirModel::downloadSelected(QModelIndexList list)
|
|
|
|
{
|
|
|
|
if (!RemoteMode)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "Cannot download from local" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* so for all the selected .... get the name out,
|
|
|
|
* make it into something the RsControl can understand
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Fire off requests */
|
|
|
|
QModelIndexList::iterator it;
|
|
|
|
for(it = list.begin(); it != list.end(); it++)
|
|
|
|
{
|
|
|
|
void *ref = it -> internalPointer();
|
|
|
|
|
|
|
|
DirDetails details;
|
|
|
|
uint32_t flags = DIR_FLAGS_DETAILS;
|
|
|
|
if (RemoteMode)
|
|
|
|
{
|
|
|
|
flags |= DIR_FLAGS_REMOTE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flags |= DIR_FLAGS_LOCAL;
|
|
|
|
continue; /* don't try to download local stuff */
|
|
|
|
}
|
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* only request if it is a file */
|
|
|
|
if (details.type == DIR_TYPE_FILE)
|
|
|
|
{
|
2008-08-16 13:10:01 -04:00
|
|
|
std::cerr << "RemoteDirModel::downloadSelected() Calling File Request";
|
|
|
|
std::cerr << std::endl;
|
2008-08-17 12:14:03 -04:00
|
|
|
std::list<std::string> srcIds;
|
|
|
|
srcIds.push_back(details.id);
|
2008-07-02 12:59:56 -04:00
|
|
|
rsFiles -> FileRequest(details.name, details.hash,
|
2008-08-17 12:14:03 -04:00
|
|
|
details.count, "", 0, srcIds);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
/****************************************************************************
|
|
|
|
* OLD RECOMMEND SYSTEM - DISABLED
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if 0
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
void RemoteDirModel::recommendSelected(QModelIndexList list)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "recommendSelected()" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
if (RemoteMode)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "Cannot recommend remote! (should download)" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
/* Fire off requests */
|
|
|
|
QModelIndexList::iterator it;
|
|
|
|
for(it = list.begin(); it != list.end(); it++)
|
|
|
|
{
|
|
|
|
void *ref = it -> internalPointer();
|
|
|
|
|
|
|
|
DirDetails details;
|
|
|
|
uint32_t flags = DIR_FLAGS_DETAILS;
|
|
|
|
if (RemoteMode)
|
|
|
|
{
|
|
|
|
flags |= DIR_FLAGS_REMOTE;
|
|
|
|
continue; /* don't recommend remote stuff */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flags |= DIR_FLAGS_LOCAL;
|
|
|
|
}
|
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "::::::::::::FileRecommend:::: " << std::endl;
|
|
|
|
std::cerr << "Name: " << details.name << std::endl;
|
|
|
|
std::cerr << "Hash: " << details.hash << std::endl;
|
|
|
|
std::cerr << "Size: " << details.count << std::endl;
|
|
|
|
std::cerr << "Path: " << details.path << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
rsFiles -> FileRecommend(details.name, details.hash, details.count);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "::::::::::::Done FileRecommend" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RemoteDirModel::recommendSelectedOnly(QModelIndexList list)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "recommendSelectedOnly()" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
if (RemoteMode)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "Cannot recommend remote! (should download)" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
2008-07-02 12:59:56 -04:00
|
|
|
rsFiles->ClearInRecommend();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* Fire off requests */
|
|
|
|
QModelIndexList::iterator it;
|
|
|
|
for(it = list.begin(); it != list.end(); it++)
|
|
|
|
{
|
|
|
|
void *ref = it -> internalPointer();
|
|
|
|
|
|
|
|
DirDetails details;
|
|
|
|
uint32_t flags = DIR_FLAGS_DETAILS;
|
|
|
|
if (RemoteMode)
|
|
|
|
{
|
|
|
|
flags |= DIR_FLAGS_REMOTE;
|
|
|
|
continue; /* don't recommend remote stuff */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flags |= DIR_FLAGS_LOCAL;
|
|
|
|
}
|
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "::::::::::::FileRecommend:::: " << std::endl;
|
|
|
|
std::cerr << "Name: " << details.name << std::endl;
|
|
|
|
std::cerr << "Hash: " << details.hash << std::endl;
|
|
|
|
std::cerr << "Size: " << details.count << std::endl;
|
|
|
|
std::cerr << "Path: " << details.path << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
rsFiles -> FileRecommend(details.name, details.hash, details.count);
|
|
|
|
rsFiles -> SetInRecommend(details.name, true);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2007-11-14 22:18:48 -05:00
|
|
|
std::cerr << "::::::::::::Done FileRecommend" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
#endif
|
|
|
|
/****************************************************************************
|
|
|
|
* OLD RECOMMEND SYSTEM - DISABLED
|
|
|
|
******/
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
void RemoteDirModel::openSelected(QModelIndexList list)
|
|
|
|
{
|
2008-07-02 12:59:56 -04:00
|
|
|
//recommendSelected(list);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2008-03-31 14:37:50 -04:00
|
|
|
|
|
|
|
void RemoteDirModel::getFilePaths(QModelIndexList list, std::list<std::string> &fullpaths)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2008-03-31 14:37:50 -04:00
|
|
|
std::cerr << "RemoteDirModel::getFilePaths()" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-31 14:37:50 -04:00
|
|
|
if (RemoteMode)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2008-03-31 14:37:50 -04:00
|
|
|
std::cerr << "No File Paths for remote files" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-31 14:37:50 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* translate */
|
|
|
|
QModelIndexList::iterator it;
|
|
|
|
for(it = list.begin(); it != list.end(); it++)
|
|
|
|
{
|
|
|
|
void *ref = it -> internalPointer();
|
|
|
|
|
|
|
|
DirDetails details;
|
|
|
|
uint32_t flags = DIR_FLAGS_DETAILS;
|
|
|
|
flags |= DIR_FLAGS_LOCAL;
|
|
|
|
|
2008-07-02 12:59:56 -04:00
|
|
|
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
2008-03-31 14:37:50 -04:00
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2008-03-31 14:37:50 -04:00
|
|
|
std::cerr << "getFilePaths() Bad Request" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-31 14:37:50 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (details.type != DIR_TYPE_FILE)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2008-03-31 14:37:50 -04:00
|
|
|
std::cerr << "getFilePaths() Not File" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-31 14:37:50 -04:00
|
|
|
continue; /* not file! */
|
|
|
|
}
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2008-03-31 14:37:50 -04:00
|
|
|
std::cerr << "::::::::::::File Details:::: " << std::endl;
|
|
|
|
std::cerr << "Name: " << details.name << std::endl;
|
|
|
|
std::cerr << "Hash: " << details.hash << std::endl;
|
|
|
|
std::cerr << "Size: " << details.count << std::endl;
|
|
|
|
std::cerr << "Path: " << details.path << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-31 14:37:50 -04:00
|
|
|
|
|
|
|
std::string filepath = details.path + "/";
|
|
|
|
filepath += details.name;
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2008-03-31 14:37:50 -04:00
|
|
|
std::cerr << "Constructed FilePath: " << filepath << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-31 14:37:50 -04:00
|
|
|
if (fullpaths.end() == std::find(fullpaths.begin(), fullpaths.end(), filepath))
|
|
|
|
{
|
|
|
|
fullpaths.push_back(filepath);
|
|
|
|
}
|
|
|
|
}
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2008-03-31 14:37:50 -04:00
|
|
|
std::cerr << "::::::::::::Done getFilePaths" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-03-31 14:37:50 -04:00
|
|
|
}
|
|
|
|
|
2008-07-04 10:41:24 -04:00
|
|
|
/* Drag and Drop Functionality */
|
|
|
|
QMimeData * RemoteDirModel::mimeData ( const QModelIndexList & indexes ) const
|
|
|
|
{
|
|
|
|
/* extract from each the member text */
|
|
|
|
std::string text;
|
|
|
|
QModelIndexList::const_iterator it;
|
|
|
|
std::map<std::string, uint64_t> drags;
|
|
|
|
std::map<std::string, uint64_t>::iterator dit;
|
|
|
|
|
|
|
|
for(it = indexes.begin(); it != indexes.end(); it++)
|
|
|
|
{
|
|
|
|
void *ref = it -> internalPointer();
|
|
|
|
|
|
|
|
DirDetails details;
|
|
|
|
uint32_t flags = DIR_FLAGS_DETAILS;
|
|
|
|
if (RemoteMode)
|
|
|
|
{
|
|
|
|
flags |= DIR_FLAGS_REMOTE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flags |= DIR_FLAGS_LOCAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2008-07-04 10:41:24 -04:00
|
|
|
std::cerr << "::::::::::::FileDrag:::: " << std::endl;
|
|
|
|
std::cerr << "Name: " << details.name << std::endl;
|
|
|
|
std::cerr << "Hash: " << details.hash << std::endl;
|
|
|
|
std::cerr << "Size: " << details.count << std::endl;
|
|
|
|
std::cerr << "Path: " << details.path << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-07-04 10:41:24 -04:00
|
|
|
|
|
|
|
if (details.type != DIR_TYPE_FILE)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2008-07-04 10:41:24 -04:00
|
|
|
std::cerr << "RemoteDirModel::mimeData() Not File" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-07-04 10:41:24 -04:00
|
|
|
continue; /* not file! */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drags.end() != (dit = drags.find(details.hash)))
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2008-07-04 10:41:24 -04:00
|
|
|
std::cerr << "RemoteDirModel::mimeData() Duplicate" << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-07-04 10:41:24 -04:00
|
|
|
continue; /* duplicate */
|
|
|
|
}
|
|
|
|
|
|
|
|
drags[details.hash] = details.count;
|
|
|
|
|
|
|
|
std::string line = details.name;
|
|
|
|
line += "/";
|
|
|
|
line += details.hash;
|
|
|
|
line += "/";
|
|
|
|
|
|
|
|
{
|
|
|
|
std::ostringstream out;
|
|
|
|
out << details.count;
|
|
|
|
line += out.str();
|
|
|
|
line += "/";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RemoteMode)
|
|
|
|
{
|
|
|
|
line += "Remote";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
line += "Local";
|
|
|
|
}
|
|
|
|
line += "/\n";
|
|
|
|
|
|
|
|
text += line;
|
|
|
|
}
|
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef RDM_DEBUG
|
2008-07-04 10:41:24 -04:00
|
|
|
std::cerr << "Created MimeData:";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
std::cerr << text;
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-07-04 10:41:24 -04:00
|
|
|
|
|
|
|
QMimeData *data = new QMimeData();
|
|
|
|
data->setData("application/x-rsfilelist", QByteArray(text.c_str()));
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList RemoteDirModel::mimeTypes () const
|
|
|
|
{
|
|
|
|
QStringList list;
|
|
|
|
list.push_back("application/x-rsfilelist");
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2008-03-31 14:37:50 -04:00
|
|
|
|
2008-11-17 20:42:17 -05:00
|
|
|
|
|
|
|
|