2009-08-11 17:59:40 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 - 2009 RetroShare Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2009-08-12 15:20:32 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2009-08-11 17:59:40 -04:00
|
|
|
* Boston, MA 02110-1301, USA.
|
2009-08-12 15:20:32 -04:00
|
|
|
****************************************************************/
|
2009-08-11 17:59:40 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
#ifndef REMOTE_DIR_MODEL
|
|
|
|
#define REMOTE_DIR_MODEL
|
|
|
|
|
|
|
|
#include <QAbstractItemModel>
|
|
|
|
#include <vector>
|
2008-03-31 14:37:50 -04:00
|
|
|
#include <list>
|
|
|
|
#include <string>
|
2009-08-12 15:20:32 -04:00
|
|
|
#include "rsiface/rsfiles.h"
|
2008-11-17 20:42:17 -05:00
|
|
|
#include "util/misc.h"
|
2009-05-18 10:23:55 -04:00
|
|
|
#include "rsiface/rstypes.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-10-13 16:36:29 -04:00
|
|
|
#define IND_DEFAULT 0
|
|
|
|
#define IND_LAST_DAY 1
|
|
|
|
#define IND_LAST_WEEK 2
|
|
|
|
#define IND_LAST_MONTH 3
|
|
|
|
#define IND_OLDER 4
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
class RemoteDirModel : public QAbstractItemModel
|
2009-04-07 04:08:03 -04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
public:
|
|
|
|
enum Roles{ FileNameRole = Qt::UserRole+1 };
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2008-07-04 10:41:24 -04:00
|
|
|
RemoteDirModel(bool mode, QObject *parent = 0);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* These are all overloaded Virtual Functions */
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
|
|
|
|
QVariant data(const QModelIndex &index, int role) const;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation,
|
|
|
|
int role = Qt::DisplayRole) const;
|
|
|
|
|
2009-07-07 14:56:31 -04:00
|
|
|
QModelIndex index(int row, int column,
|
2007-11-14 22:18:48 -05:00
|
|
|
const QModelIndex & parent = QModelIndex() ) const;
|
|
|
|
QModelIndex parent ( const QModelIndex & index ) const;
|
|
|
|
|
|
|
|
Qt::ItemFlags flags ( const QModelIndex & index ) const;
|
|
|
|
bool hasChildren(const QModelIndex & parent = QModelIndex()) const;
|
|
|
|
|
|
|
|
/* Callback from Core */
|
|
|
|
void preMods();
|
|
|
|
void postMods();
|
|
|
|
|
|
|
|
/* Callback from GUI */
|
|
|
|
void downloadSelected(QModelIndexList list);
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2009-05-18 10:23:55 -04:00
|
|
|
void getDirDetailsFromSelect (QModelIndexList list, std::vector <DirDetails>& dirVec);
|
2008-07-02 12:59:56 -04:00
|
|
|
|
2009-04-07 04:08:03 -04:00
|
|
|
bool isDir ( const QModelIndex & index ) const ;
|
|
|
|
//void openFile(QModelIndex fileIndex, const QString command);
|
|
|
|
|
2009-05-17 15:38:42 -04:00
|
|
|
//#if 0 /****** REMOVED ******/
|
|
|
|
// void recommendSelected(QModelIndexList list);
|
|
|
|
// void recommendSelectedOnly(QModelIndexList list);
|
2009-07-07 14:56:31 -04:00
|
|
|
//#endif
|
2009-05-17 15:38:42 -04:00
|
|
|
void getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& files_info) ;
|
2008-07-02 12:59:56 -04:00
|
|
|
|
2009-07-07 14:56:31 -04:00
|
|
|
void openSelected(QModelIndexList list, bool openFolder);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-03-31 14:37:50 -04:00
|
|
|
void getFilePaths(QModelIndexList list, std::list<std::string> &fullpaths);
|
|
|
|
|
2009-10-13 16:36:29 -04:00
|
|
|
void changeAgeIndicator(int indicator) { ageIndicator = indicator; }
|
|
|
|
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
public slots:
|
|
|
|
|
2009-07-07 14:56:31 -04:00
|
|
|
void collapsed ( const QModelIndex & index ) { update(index); }
|
2007-11-14 22:18:48 -05:00
|
|
|
void expanded ( const QModelIndex & index ) { update(index); }
|
|
|
|
|
2008-07-04 10:41:24 -04:00
|
|
|
/* Drag and Drop Functionality */
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
|
|
|
|
virtual QStringList mimeTypes () const;
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
private:
|
|
|
|
void update (const QModelIndex &index );
|
2009-05-31 19:06:14 -04:00
|
|
|
void treeStyle();
|
2009-07-17 16:07:43 -04:00
|
|
|
void downloadDirectory(const DirDetails & details, int prefixLen);
|
2009-08-10 14:55:49 -04:00
|
|
|
static QString getFlagsString(uint32_t) ;
|
2009-10-13 16:36:29 -04:00
|
|
|
QString getAgeIndicatorString(const DirDetails &) const;
|
|
|
|
void getAgeIndicatorRec(DirDetails &details, QString &ret) const;
|
|
|
|
|
|
|
|
int ageIndicator;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-05-31 19:06:14 -04:00
|
|
|
QIcon categoryIcon;
|
|
|
|
QIcon peerIcon;
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
class RemoteIndex
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RemoteIndex() {}
|
2009-07-07 14:56:31 -04:00
|
|
|
RemoteIndex(std::string in_person,
|
|
|
|
std::string in_path,
|
|
|
|
int in_idx,
|
|
|
|
int in_row,
|
2007-11-14 22:18:48 -05:00
|
|
|
int in_column,
|
|
|
|
std::string in_name,
|
|
|
|
int in_size,
|
|
|
|
int in_type,
|
|
|
|
int in_ts, int in_rank)
|
|
|
|
:id(in_person), path(in_path), parent(in_idx),
|
2009-07-07 14:56:31 -04:00
|
|
|
row(in_row), column(in_column),
|
|
|
|
name(in_name), size(in_size),
|
2007-11-14 22:18:48 -05:00
|
|
|
type(in_type), timestamp(in_ts), rank(in_rank)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2009-07-07 14:56:31 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
std::string id;
|
|
|
|
std::string path;
|
|
|
|
int parent;
|
|
|
|
int row;
|
|
|
|
int column;
|
|
|
|
|
|
|
|
/* display info */
|
|
|
|
std::string name;
|
|
|
|
int size;
|
|
|
|
int type;
|
|
|
|
int timestamp;
|
|
|
|
int rank;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
bool RemoteMode;
|
|
|
|
|
|
|
|
mutable int nIndex;
|
|
|
|
mutable std::vector<RemoteIndex> indexSet;
|
2008-11-17 20:42:17 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|