summaryrefslogtreecommitdiff
path: root/net-p2p/retroshare/files/rs-ft-1169.diff
blob: 1896f9b7b998ff9c1f7be64cc1bee79a4c28b7ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
diff --git a/RetroShare.pro b/RetroShare.pro
index 833173029..dba75453e 100644
--- a/RetroShare.pro
+++ b/RetroShare.pro
@@ -56,12 +56,12 @@ retroshare_qml_app {
     }
 }
 
-retroshare_plugins {
-    SUBDIRS += plugins
-    plugins.file = plugins/plugins.pro
-    plugins.depends = retroshare_gui
-    plugins.target = plugins
-}
+#retroshare_plugins {
+#    SUBDIRS += plugins
+#    plugins.file = plugins/plugins.pro
+#    plugins.depends = retroshare_gui
+#    plugins.target = plugins
+#}
 
 wikipoos {
     SUBDIRS += pegmarkdown
diff --git a/libresapi/src/api/FileSharingHandler.cpp b/libresapi/src/api/FileSharingHandler.cpp
index 856275d9c..a6296973d 100644
--- a/libresapi/src/api/FileSharingHandler.cpp
+++ b/libresapi/src/api/FileSharingHandler.cpp
@@ -500,7 +500,7 @@ void FileSharingHandler::handleDownload(Request& req, Response& resp)
 	FileInfo finfo;
 	mRsFiles->FileDetails(hash, RS_FILE_HINTS_REMOTE, finfo);
 
-	for(std::list<TransferInfo>::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it)
+	for(std::vector<TransferInfo>::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it)
 		srcIds.push_back((*it).peerId);
 
 	if(!mRsFiles->FileRequest(name, hash, static_cast<uint64_t>(size), "",
diff --git a/libresapi/src/api/TransfersHandler.cpp b/libresapi/src/api/TransfersHandler.cpp
index f563f377c..c696411da 100644
--- a/libresapi/src/api/TransfersHandler.cpp
+++ b/libresapi/src/api/TransfersHandler.cpp
@@ -91,7 +91,7 @@ void TransfersHandler::handleControlDownload(Request &req, Response &resp)
 		FileInfo finfo;
 		mFiles->FileDetails(hash, RS_FILE_HINTS_REMOTE, finfo);
 
-		for(std::list<TransferInfo>::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it)
+		for(std::vector<TransferInfo>::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it)
 			srcIds.push_back((*it).peerId);
 
         bool ok = req.mStream.isOK();
@@ -213,8 +213,7 @@ void TransfersHandler::handleUploads(Request & /* req */, Response &resp)
 		FileInfo fi;
 		if(mFiles->FileDetails(*lit, RS_FILE_HINTS_UPLOAD, fi))
 		{
-			std::list<TransferInfo>::iterator pit;
-			for(pit = fi.peers.begin(); pit != fi.peers.end(); ++pit)
+			for( std::vector<TransferInfo>::iterator pit = fi.peers.begin(); pit != fi.peers.end(); ++pit)
 			{
 				if (pit->peerId == ownId) //don't display transfer to ourselves
 					continue ;
diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc
index 382d13cb6..29713cb3e 100644
--- a/libretroshare/src/ft/ftcontroller.cc
+++ b/libretroshare/src/ft/ftcontroller.cc
@@ -301,7 +301,7 @@ void ftController::searchForDirectSources()
 			FileInfo info ;	// Info needs to be re-allocated each time, to start with a clear list of peers (it's not cleared down there)
 
 			if( mSearch->search(it->first, RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY, info) )
-				for( std::list<TransferInfo>::const_iterator pit = info.peers.begin(); pit != info.peers.end(); ++pit )
+				for( std::vector<TransferInfo>::const_iterator pit = info.peers.begin(); pit != info.peers.end(); ++pit )
 				{
 					bool bAllowDirectDL = false;
                     switch (mFilePermDirectDLPolicy) {
@@ -1029,7 +1029,7 @@ bool 	ftController::FileRequest(const std::string& fname, const RsFileHash& hash
 	}
 
 	std::list<RsPeerId>::const_iterator it;
-	std::list<TransferInfo>::const_iterator pit;
+	std::vector<TransferInfo>::const_iterator pit;
 
 #ifdef CONTROL_DEBUG
 	std::cerr << "ftController::FileRequest(" << fname << ",";
@@ -1622,6 +1622,8 @@ bool 	ftController::FileDetails(const RsFileHash &hash, FileInfo &info)
 	bool isDownloading = false;
 	bool isSuspended = false;
 
+	info.peers.clear();
+
 	for(pit = peerIds.begin(); pit != peerIds.end(); ++pit)
 	{
 		if (it->second->mTransfer->getPeerState(*pit, state, tfRate))
diff --git a/libretroshare/src/retroshare/rstypes.h b/libretroshare/src/retroshare/rstypes.h
index 9c098db59..cc04d2312 100644
--- a/libretroshare/src/retroshare/rstypes.h
+++ b/libretroshare/src/retroshare/rstypes.h
@@ -208,7 +208,7 @@ class FileInfo
 		uint64_t transfered;
 		double   tfRate; /* in kbytes */
 		uint32_t  downloadStatus; 	// FT_STATE_DOWNLOADING & co. See rstypes.h
-		std::list<TransferInfo> peers;
+		std::vector<TransferInfo> peers;
 
 		DwlSpeed priority ;
 		time_t lastTS;
diff --git a/retroshare-gui/src/gui/FileTransfer/DLListDelegate.h b/retroshare-gui/src/gui/FileTransfer/DLListDelegate.h
index 7516b17af..11bfd149f 100644
--- a/retroshare-gui/src/gui/FileTransfer/DLListDelegate.h
+++ b/retroshare-gui/src/gui/FileTransfer/DLListDelegate.h
@@ -27,26 +27,25 @@
 
 
 // Defines for download list list columns
-#define COLUMN_NAME 0
-#define COLUMN_SIZE 1
-#define COLUMN_COMPLETED 2
-#define COLUMN_DLSPEED 3
-#define COLUMN_PROGRESS 4
-#define COLUMN_SOURCES 5
-#define COLUMN_STATUS 6
-#define COLUMN_PRIORITY 7
-#define COLUMN_REMAINING 8
+#define COLUMN_NAME         0
+#define COLUMN_SIZE         1
+#define COLUMN_COMPLETED    2
+#define COLUMN_DLSPEED      3
+#define COLUMN_PROGRESS     4
+#define COLUMN_SOURCES      5
+#define COLUMN_STATUS       6
+#define COLUMN_PRIORITY     7
+#define COLUMN_REMAINING    8
 #define COLUMN_DOWNLOADTIME 9
-#define COLUMN_ID 10
-#define COLUMN_LASTDL 11
-#define COLUMN_PATH 12
-#define COLUMN_COUNT 13
-
-#define PRIORITY_NULL 0.0
-#define PRIORITY_FASTER 0.1
-#define PRIORITY_AVERAGE 0.2
-#define PRIORITY_SLOWER 0.3
-
+#define COLUMN_ID          10
+#define COLUMN_LASTDL      11
+#define COLUMN_PATH        12
+#define COLUMN_COUNT       13
+
+#define PRIORITY_NULL     0.0
+#define PRIORITY_FASTER   0.1
+#define PRIORITY_AVERAGE  0.2
+#define PRIORITY_SLOWER   0.3
 
 #define MAX_CHAR_TMP 128
 
diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp
index ee85a1d92..bc2f08644 100644
--- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp
+++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp
@@ -368,7 +368,7 @@ void SearchDialog::getSourceFriendsForHash(const RsFileHash& hash,std::list<RsPe
 	FileInfo finfo ;
 	rsFiles->FileDetails(hash, RS_FILE_HINTS_REMOTE,finfo) ;
 
-	for(std::list<TransferInfo>::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it)
+	for(std::vector<TransferInfo>::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it)
 	{
 		std::cerr << "  adding peerid " << (*it).peerId << std::endl ;
 		srcIds.push_back((*it).peerId) ;
diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp
index 196bc90ac..5cda97e5c 100644
--- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp
+++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp
@@ -76,10 +76,10 @@
 #define IMAGE_STOP			           ":/images/stop.png"
 #define IMAGE_PREVIEW			         ":/images/preview.png"
 #define IMAGE_PRIORITY			       ":/images/filepriority.png"
-#define IMAGE_PRIORITYLOW			     ":/images/prioritylow.png"
-#define IMAGE_PRIORITYNORMAL			 ":/images/prioritynormal.png"
-#define IMAGE_PRIORITYHIGH			   ":/images/priorityhigh.png"
-#define IMAGE_PRIORITYAUTO			   ":/images/priorityauto.png"
+#define IMAGE_PRIORITYLOW	     ":/images/prioritylow.png"
+#define IMAGE_PRIORITYNORMAL		 ":/images/prioritynormal.png"
+#define IMAGE_PRIORITYHIGH		   ":/images/priorityhigh.png"
+#define IMAGE_PRIORITYAUTO		   ":/images/priorityauto.png"
 #define IMAGE_SEARCH               ":/icons/svg/magnifying-glass.svg"
 #define IMAGE_EXPAND               ":/images/edit_add24.png"
 #define IMAGE_COLLAPSE             ":/images/edit_remove24.png"
@@ -98,6 +98,591 @@
 
 Q_DECLARE_METATYPE(FileProgressInfo)
 
+class RsDownloadListModel : public QAbstractItemModel
+{
+	//    Q_OBJECT
+
+public:
+	explicit RsDownloadListModel(QObject *parent = NULL) : QAbstractItemModel(parent) {}
+	~RsDownloadListModel(){}
+
+	enum Roles{ SortRole = Qt::UserRole+1 };
+
+	int rowCount(const QModelIndex& parent = QModelIndex()) const
+	{
+		void *ref = (parent.isValid())?parent.internalPointer():NULL ;
+
+		if(!ref)
+			return mDownloads.size() ;
+
+		uint32_t entry = 0 ;
+		int source_id ;
+
+		if(!convertRefPointerToTabEntry(ref,entry,source_id) || entry >= mDownloads.size())
+			return 0 ;
+
+		return mDownloads[entry].peers.size();	// costly
+	}
+	int columnCount(const QModelIndex &parent = QModelIndex()) const
+	{
+		return 13 ;
+	}
+	bool hasChildren(const QModelIndex &parent = QModelIndex()) const
+	{
+		void *ref = (parent.isValid())?parent.internalPointer():NULL ;
+		uint32_t entry = 0;
+		int source_id=0 ;
+
+		if(!ref)
+			return true ;
+
+		if(!convertRefPointerToTabEntry(ref,entry,source_id) || entry >= mDownloads.size() || source_id > -1)
+			return false ;
+
+		return !mDownloads[entry].peers.empty();	// costly
+	}
+
+	QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const
+	{
+		if(row < 0)
+			return QModelIndex();
+
+		void *ref = (parent.isValid())?parent.internalPointer():NULL ;
+		uint32_t entry = 0;
+		int source_id=0 ;
+		void *subref = NULL ;
+
+		if(!ref)	// top level. The entry is that of a transfer
+		{
+			if(!convertTabEntryToRefPointer(row,-1,subref))
+				return QModelIndex() ;
+
+			return createIndex(row,column,subref) ;
+		}
+
+		if(!convertRefPointerToTabEntry(ref,entry,source_id) || entry >= mDownloads.size() || int(mDownloads[entry].peers.size()) <= source_id)
+			return QModelIndex() ;
+
+		if(source_id != -1)
+			std::cerr << "ERROR: parent.source_id != -1 in index()" << std::endl;
+
+		if(!convertTabEntryToRefPointer(entry,row,subref))
+			return QModelIndex() ;
+
+		return createIndex(row,column,subref) ;
+	}
+	QModelIndex parent(const QModelIndex& child) const
+	{
+		void *ref = (child.isValid())?child.internalPointer():NULL ;
+		uint32_t entry = 0;
+		int source_id=0 ;
+
+		if(!ref)
+			return QModelIndex() ;
+
+		if(!convertRefPointerToTabEntry(ref,entry,source_id) || entry >= mDownloads.size() || int(mDownloads[entry].peers.size()) <= source_id)
+			return QModelIndex() ;
+
+		if(source_id < 0)
+			return QModelIndex() ;
+
+		void *subref =NULL;
+
+		if(!convertTabEntryToRefPointer(entry,-1,subref))
+			return QModelIndex() ;
+
+		return createIndex(entry,0,subref) ;
+	}
+
+	QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
+	{
+		if(role != Qt::DisplayRole)
+			return QVariant();
+
+		switch(section)
+		{
+		default:
+		case COLUMN_NAME:         return tr("Name", "i.e: file name");
+		case COLUMN_SIZE:         return tr("Size", "i.e: file size");
+		case COLUMN_COMPLETED:    return tr("Completed", "");
+		case COLUMN_DLSPEED:      return tr("Speed", "i.e: Download speed");
+		case COLUMN_PROGRESS:     return tr("Progress / Availability", "i.e: % downloaded");
+		case COLUMN_SOURCES:      return tr("Sources", "i.e: Sources");
+		case COLUMN_STATUS:       return tr("Status");
+		case COLUMN_PRIORITY:     return tr("Speed / Queue position");
+		case COLUMN_REMAINING:    return tr("Remaining");
+		case COLUMN_DOWNLOADTIME: return tr("Download time", "i.e: Estimated Time of Arrival / Time left");
+		case COLUMN_ID:           return tr("Hash");
+		case COLUMN_LASTDL:       return tr("Last Time Seen", "i.e: Last Time Receiced Data");
+		case COLUMN_PATH:         return tr("Path", "i.e: Where file is saved");
+		}
+	}
+
+	QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const
+	{
+		if(!index.isValid())
+			return QVariant();
+
+		int coln = index.column() ;
+
+		switch(role)
+		{
+		case Qt::SizeHintRole:       return sizeHintRole(index.column()) ;
+		case Qt::TextAlignmentRole:
+		case Qt::TextColorRole:
+		case Qt::WhatsThisRole:
+		case Qt::EditRole:
+		case Qt::ToolTipRole:
+		case Qt::StatusTipRole:
+			return QVariant();
+		}
+
+		void *ref = (index.isValid())?index.internalPointer():NULL ;
+		uint32_t entry = 0;
+		int source_id=0 ;
+
+		if(!ref)
+			return false ;
+
+		if(!convertRefPointerToTabEntry(ref,entry,source_id) || entry >= mDownloads.size())
+		{
+			std::cerr << "Bad pointer: " << (void*)ref << std::endl;
+			return false ;
+		}
+
+		const FileInfo& finfo(mDownloads[entry]) ;
+
+		switch(role)
+		{
+		case Qt::DisplayRole:    return displayRole   (finfo,source_id,index.column()) ;
+		case Qt::DecorationRole: return decorationRole(finfo,source_id,index.column()) ;
+		case Qt::UserRole:       return userRole      (finfo,source_id,index.column()) ;
+		default:
+			return QVariant();
+		}
+	}
+
+	QVariant sizeHintRole(int col) const
+	{
+		switch(col)
+		{
+		default:
+		case COLUMN_NAME:         return QVariant( 170 );
+		case COLUMN_SIZE:         return QVariant( 70  );
+		case COLUMN_COMPLETED:    return QVariant( 75  );
+		case COLUMN_DLSPEED:      return QVariant( 75  );
+		case COLUMN_PROGRESS:     return QVariant( 170 );
+		case COLUMN_SOURCES:      return QVariant( 90  );
+		case COLUMN_STATUS:       return QVariant( 100 );
+		case COLUMN_PRIORITY:     return QVariant( 100 );
+		case COLUMN_REMAINING:    return QVariant( 100 );
+		case COLUMN_DOWNLOADTIME: return QVariant( 100 );
+		case COLUMN_ID:           return QVariant( 100 );
+		case COLUMN_LASTDL:       return QVariant( 100 );
+		case COLUMN_PATH:         return QVariant( 100 );
+		}
+	}
+
+
+	QVariant displayRole(const FileInfo& fileInfo,int source_id,int col) const
+	{
+		if(source_id == -1)  // toplevel
+			switch(col)
+			{
+			case COLUMN_NAME:           return QVariant(QString::fromUtf8(fileInfo.fname.c_str()));
+			case COLUMN_COMPLETED:      return QVariant((qlonglong)fileInfo.transfered);
+			case COLUMN_DLSPEED:        return QVariant((double)((fileInfo.downloadStatus == FT_STATE_DOWNLOADING) ? (fileInfo.tfRate * 1024.0) : 0.0));
+			case COLUMN_PROGRESS:       return QVariant((float)((fileInfo.size == 0) ? 0 : (fileInfo.transfered * 100.0 / (float)fileInfo.size)));
+			case COLUMN_STATUS:
+			{
+				QString status;
+				switch (fileInfo.downloadStatus)
+				{
+				case FT_STATE_FAILED:       status = tr("Failed"); break;
+				case FT_STATE_OKAY:         status = tr("Okay"); break;
+				case FT_STATE_WAITING:      status = tr("Waiting"); break;
+				case FT_STATE_DOWNLOADING:  status = tr("Downloading"); break;
+				case FT_STATE_COMPLETE:     status = tr("Complete"); break;
+				case FT_STATE_QUEUED:       status = tr("Queued"); break;
+				case FT_STATE_PAUSED:       status = tr("Paused"); break;
+				case FT_STATE_CHECKING_HASH:status = tr("Checking..."); break;
+				default:                    status = tr("Unknown"); break;
+				}
+				return QVariant(status);
+			}
+
+			case COLUMN_PRIORITY:
+			{
+				double priority = PRIORITY_NULL;
+
+				if (fileInfo.downloadStatus == FT_STATE_QUEUED)
+					priority = fileInfo.queue_position;
+				else if (fileInfo.downloadStatus == FT_STATE_COMPLETE)
+					priority = 0;
+				else
+					switch (fileInfo.priority)
+					{
+					case SPEED_LOW:     priority = PRIORITY_SLOWER; break;
+					case SPEED_NORMAL:  priority = PRIORITY_AVERAGE; break;
+					case SPEED_HIGH:    priority = PRIORITY_FASTER; break;
+					default:            priority = PRIORITY_AVERAGE; break;
+					}
+
+				return QVariant(priority);
+			}
+
+			case COLUMN_REMAINING:       return QVariant((qlonglong)(fileInfo.size - fileInfo.transfered));
+			case COLUMN_DOWNLOADTIME:    return QVariant((qlonglong)(fileInfo.tfRate > 0)?( (fileInfo.size - fileInfo.transfered) / (fileInfo.tfRate * 1024.0) ) : 0);
+			case COLUMN_LASTDL:
+			{
+				qint64 qi64LastDL = fileInfo.lastTS ;
+
+				if (qi64LastDL == 0)	// file is complete, or any raison why the time has not been set properly
+				{
+					QFileInfo file;
+
+					if (fileInfo.downloadStatus == FT_STATE_COMPLETE)
+						file = QFileInfo(QString::fromUtf8(fileInfo.path.c_str()), QString::fromUtf8(fileInfo.fname.c_str()));
+					else
+						file = QFileInfo(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str()), QString::fromUtf8(fileInfo.hash.toStdString().c_str()));
+
+					//Get Last Access on File
+					if (file.exists())
+						qi64LastDL = file.lastModified().toTime_t();
+				}
+				return QVariant(qi64LastDL) ;
+			}
+			case COLUMN_PATH:
+			{
+				QString strPath = QString::fromUtf8(fileInfo.path.c_str());
+				QString strPathAfterDL = strPath;
+				strPathAfterDL.replace(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()),"");
+
+				return QVariant(strPathAfterDL);
+			}
+
+			case COLUMN_SOURCES:
+			{
+				int active = 0;
+				QString fileHash = QString::fromStdString(fileInfo.hash.toStdString());
+
+				if (fileInfo.downloadStatus != FT_STATE_COMPLETE)
+					for (std::vector<TransferInfo>::const_iterator pit = fileInfo.peers.begin() ; pit != fileInfo.peers.end(); ++pit)
+					{
+						const TransferInfo& transferInfo = *pit;
+
+					//	//unique combination: fileHash + peerId, variant: hash + peerName (too long)
+					//	QString hashFileAndPeerId = fileHash + QString::fromStdString(transferInfo.peerId.toStdString());
+
+					//	double peerDlspeed = 0;
+					//	if ((uint32_t)transferInfo.status == FT_STATE_DOWNLOADING && fileInfo.downloadStatus != FT_STATE_PAUSED && fileInfo.downloadStatus != FT_STATE_COMPLETE)
+					//		peerDlspeed = transferInfo.tfRate * 1024.0;
+
+					//	FileProgressInfo peerpinfo;
+					//	peerpinfo.cmap = fcinfo.compressed_peer_availability_maps[transferInfo.peerId];
+					//	peerpinfo.type = FileProgressInfo::DOWNLOAD_SOURCE ;
+					//	peerpinfo.progress = 0.0;	// we don't display completion for sources.
+					//	peerpinfo.nb_chunks = peerpinfo.cmap._map.empty() ? 0 : fcinfo.chunks.size();
+
+						// get the sources (number of online peers)
+						if (transferInfo.tfRate > 0 && fileInfo.downloadStatus == FT_STATE_DOWNLOADING)
+							++active;
+					}
+
+				return QVariant( (float)active + fileInfo.peers.size()/1000.0f );
+
+			}
+
+			case COLUMN_SIZE: return QVariant((qlonglong) fileInfo.size);
+
+			case COLUMN_ID:   return QVariant(QString::fromStdString(fileInfo.hash.toStdString()));
+
+			default:
+				return QVariant("[ TODO ]");
+			}
+		else
+		{
+			uint32_t chunk_size = 1024*1024 ;
+
+			switch(col)
+			{
+			default:
+			case COLUMN_SOURCES:
+			case COLUMN_COMPLETED:
+			case COLUMN_REMAINING:
+			case COLUMN_LASTDL:
+			case COLUMN_ID:
+			case COLUMN_PATH:
+			case COLUMN_DOWNLOADTIME:
+			case COLUMN_SIZE:     return QVariant();
+			case COLUMN_PROGRESS: return QVariant( (fileInfo.size>0)?((fileInfo.peers[source_id].transfered % chunk_size)*100.0/fileInfo.size):0.0) ;
+			case COLUMN_DLSPEED:
+			{
+				double peerDlspeed = 0;
+				if((uint32_t)fileInfo.peers[source_id].status == FT_STATE_DOWNLOADING && fileInfo.downloadStatus != FT_STATE_PAUSED && fileInfo.downloadStatus != FT_STATE_COMPLETE)
+					peerDlspeed = fileInfo.peers[source_id].tfRate * 1024.0;
+
+				return QVariant((double)peerDlspeed) ;
+			}
+			case COLUMN_NAME:
+			{
+				QString iconName,tooltip;
+				return  QVariant(TransfersDialog::getPeerName(fileInfo.peers[source_id].peerId, iconName, tooltip));
+			}
+
+			case COLUMN_PRIORITY: return QVariant((double)PRIORITY_NULL);
+			}
+		}
+
+		return QVariant("[ERROR]");
+	}
+
+	virtual QVariant userRole(const FileInfo& fileInfo,int source_id,int col) const
+	{
+		if(source_id == -1)
+			switch(col)
+			{
+			case COLUMN_PROGRESS:
+			{
+				FileChunksInfo fcinfo;
+				if (!rsFiles->FileDownloadChunksDetails(fileInfo.hash, fcinfo))
+					return -1;
+
+				FileProgressInfo pinfo;
+				pinfo.cmap = fcinfo.chunks;
+				pinfo.type = FileProgressInfo::DOWNLOAD_LINE;
+				pinfo.progress = (fileInfo.size == 0) ? 0 : (fileInfo.transfered * 100.0 / fileInfo.size);
+				pinfo.nb_chunks = pinfo.cmap._map.empty() ? 0 : fcinfo.chunks.size();
+
+				for (uint32_t i = 0; i < fcinfo.chunks.size(); ++i)
+					switch(fcinfo.chunks[i])
+					{
+					case FileChunksInfo::CHUNK_CHECKING: pinfo.chunks_in_checking.push_back(i);
+						break ;
+					case FileChunksInfo::CHUNK_ACTIVE: 	 pinfo.chunks_in_progress.push_back(i);
+						break ;
+					case FileChunksInfo::CHUNK_DONE:
+					case FileChunksInfo::CHUNK_OUTSTANDING:
+						break ;
+					}
+
+				return QVariant::fromValue(pinfo);
+			}
+
+			case COLUMN_ID:   return QVariant(QString::fromStdString(fileInfo.hash.toStdString()));
+
+
+			default:
+				return QVariant();
+			}
+		else
+			switch(col)
+			{
+			case COLUMN_PROGRESS:
+			{
+				FileProgressInfo peerpinfo ;
+
+				if(!rsFiles->FileUploadChunksDetails(fileInfo.hash, fileInfo.peers[source_id].peerId, peerpinfo.cmap) )
+					return QVariant();
+
+				// Estimate the completion. We need something more accurate, meaning that we need to
+				// transmit the completion info.
+				//
+				uint32_t chunk_size = 1024*1024 ;
+				uint32_t nb_chunks = (uint32_t)((fileInfo.size + (uint64_t)chunk_size - 1) / (uint64_t)(chunk_size)) ;
+
+				uint32_t filled_chunks = peerpinfo.cmap.filledChunks(nb_chunks) ;
+				peerpinfo.type = FileProgressInfo::UPLOAD_LINE ;
+				peerpinfo.nb_chunks = peerpinfo.cmap._map.empty()?0:nb_chunks ;
+				qlonglong completed ;
+
+				if(filled_chunks > 0 && nb_chunks > 0)
+				{
+					completed = peerpinfo.cmap.computeProgress(fileInfo.size,chunk_size) ;
+					peerpinfo.progress = completed / (float)fileInfo.size * 100.0f ;
+				}
+				else
+				{
+					completed = fileInfo.peers[source_id].transfered % chunk_size ;	// use the position with respect to last request.
+					peerpinfo.progress = (fileInfo.size>0)?((fileInfo.peers[source_id].transfered % chunk_size)*100.0/fileInfo.size):0 ;
+				}
+
+				return QVariant::fromValue(peerpinfo);
+			}
+
+			case COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()) + QString::fromStdString(fileInfo.peers[source_id].peerId.toStdString()));
+
+			default:
+				return QVariant();
+			}
+
+	}
+
+	QVariant decorationRole(const FileInfo& fileInfo,int source_id,int col) const
+	{
+		if(col == COLUMN_NAME)
+		{
+			if(source_id == -1)
+				return QVariant(FilesDefs::getIconFromFilename(QString::fromUtf8(fileInfo.fname.c_str())));
+			else
+			{
+				QString iconName,tooltip;
+				TransfersDialog::getPeerName(fileInfo.peers[source_id].peerId, iconName, tooltip);
+
+				return QVariant(iconName);
+			}
+		}
+		else
+			return QVariant();
+	}
+
+	void update_transfers()
+	{
+//		beginResetModel();
+
+		std::list<RsFileHash> downHashes;
+		rsFiles->FileDownloads(downHashes);
+
+        size_t old_size = mDownloads.size();
+
+		mDownloads.resize(downHashes.size()) ;
+
+        if(old_size < mDownloads.size())
+        {
+            beginInsertRows(QModelIndex(), old_size, mDownloads.size());
+            insertRows(old_size, mDownloads.size() - old_size);
+            endInsertRows();
+        }
+        else if(mDownloads.size() < old_size)
+        {
+            beginRemoveRows(QModelIndex(), mDownloads.size(), old_size);
+            removeRows(old_size, old_size - mDownloads.size());
+            endRemoveRows();
+        }
+
+		//std::cerr << "updating file list: found " << mDownloads.size() << " transfers." << std::endl;
+
+		uint32_t i=0;
+
+		for(auto it(downHashes.begin());it!=downHashes.end();++it,++i)
+		{
+			FileInfo& fileInfo(mDownloads[i]);
+			rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, fileInfo);
+		}
+
+//		endResetModel();
+
+		QModelIndex topLeft = createIndex(0,0), bottomRight = createIndex(mDownloads.size(), COLUMN_COUNT-1);
+		emit dataChanged(topLeft, bottomRight);
+
+		//shit code follow (rewrite this please)
+		//		size_t old_size = neighs.size(), new_size = 0;
+		//		std::list<RsPgpId> old_neighs = neighs;
+		//
+		//    new_size = new_neighs.size();
+		//    //set model data to new cleaned up data
+		//    neighs = new_neighs;
+		//    neighs.sort();
+		//    neighs.unique(); //remove possible dups
+		//
+		//    //reflect actual row count in model
+		//    if(old_size < new_size)
+		//    {
+		//        beginInsertRows(QModelIndex(), old_size, new_size);
+		//        insertRows(old_size, new_size - old_size);
+		//        endInsertRows();
+		//    }
+		//    else if(new_size < old_size)
+		//    {
+		//        beginRemoveRows(QModelIndex(), new_size, old_size);
+		//        removeRows(old_size, old_size - new_size);
+		//        endRemoveRows();
+		//    }
+		//    //update data in ui, to avoid unnecessary redraw and ui updates, updating only changed elements
+		//    //TODO: libretroshare should implement a way to obtain only changed elements via some signalling non-blocking api.
+		//    {
+		//        size_t ii1 = 0;
+		//        for(auto i1 = neighs.begin(), end1 = neighs.end(), i2 = old_neighs.begin(), end2 = old_neighs.end(); i1 != end1; ++i1, ++i2, ii1++)
+		//        {
+		//            if(i2 == end2)
+		//                break;
+		//            if(*i1 != *i2)
+		//            {
+		//                QModelIndex topLeft = createIndex(ii1,0), bottomRight = createIndex(ii1, COLUMN_COUNT-1);
+		//                emit dataChanged(topLeft, bottomRight);
+		//            }
+		//        }
+		//    }
+		//    if(new_size > old_size)
+		//    {
+		//        QModelIndex topLeft = createIndex(old_size ? old_size -1 : 0 ,0), bottomRight = createIndex(new_size -1, COLUMN_COUNT-1);
+		//        emit dataChanged(topLeft, bottomRight);
+		//    }
+		//    //dirty solution for initial data fetch
+		//    //TODO: do it properly!
+		//    if(!old_size)
+		//    {
+		//        beginResetModel();
+		//        endResetModel();
+		//    }
+
+
+	}
+private:
+	static const uint32_t TRANSFERS_NB_DOWNLOADS_BITS_32BITS     = 22 ;			// Means 2^22 simultaneous transfers
+	static const uint32_t TRANSFERS_NB_DOWNLOADS_BIT_MASK_32BITS = 0x003fffff ;	// actual bit mask corresponding to previous number of bits
+	static const uint32_t TRANSFERS_NB_SOURCES_BITS_32BITS       = 10 ;			// Means 2^10 simultaneous sources
+
+	static bool convertTabEntryToRefPointer(uint32_t entry,int source_id,void *& ref)
+	{
+		if(source_id < -1)
+		{
+			std::cerr << "(EE) inconsistent source id = " << source_id << " in convertTabEntryToRefPointer()" << std::endl;
+			return false;
+		}
+		// the pointer is formed the following way:
+		//
+		//		[ 10 bits   |  22 bits ]
+		//
+		// This means that the whoel software has the following build-in limitation:
+		//	  * 1023 sources
+		//	  * 4M   simultaenous file transfers
+
+		if(uint32_t(source_id+1) >= (1u<<TRANSFERS_NB_SOURCES_BITS_32BITS) || (entry+1) >= (1u<< TRANSFERS_NB_DOWNLOADS_BITS_32BITS))
+		{
+			std::cerr << "(EE) cannot convert download index " << entry << " and source " << source_id << " to pointer." << std::endl;
+			return false ;
+		}
+
+		ref = reinterpret_cast<void*>( ( uint32_t(1+source_id) << TRANSFERS_NB_DOWNLOADS_BITS_32BITS ) + ( (entry+1) & TRANSFERS_NB_DOWNLOADS_BIT_MASK_32BITS)) ;
+
+		return true;
+	}
+
+	static bool convertRefPointerToTabEntry(void *ref,uint32_t& entry,int& source_id)
+	{
+		// we pack the couple (id of DL, id of source) into a single 32-bits pointer that is required by the AbstractItemModel class.
+
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+		uint32_t ntr = uint32_t(  *reinterpret_cast<uint32_t*>(&ref)   & TRANSFERS_NB_DOWNLOADS_BIT_MASK_32BITS ) ;
+		uint32_t src =  (  *reinterpret_cast<uint32_t*>(&ref)) >> TRANSFERS_NB_DOWNLOADS_BITS_32BITS ;
+#pragma GCC diagnostic pop
+
+		if(ntr == 0)
+		{
+			std::cerr << "ERROR! ntr=0!"<< std::endl;
+			return false ;
+		}
+
+		source_id = int(src) - 1 ;
+		entry = ntr - 1 ;
+
+		return true;
+	}
+
+	std::vector<FileInfo> mDownloads ;	// store the list of downloads, updated from rsFiles.
+};
+
 class SortByNameItem : public QStandardItem
 {
 public:
@@ -170,21 +755,9 @@ TransfersDialog::TransfersDialog(QWidget *parent)
 
     connect( ui.downloadList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( downloadListCustomPopupMenu( QPoint ) ) );
 
+	DLListModel = new RsDownloadListModel ;
+
     // Set Download list model
-    DLListModel = new QStandardItemModel(0,COLUMN_COUNT);
-    DLListModel->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
-    DLListModel->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
-    DLListModel->setHeaderData(COLUMN_COMPLETED, Qt::Horizontal, tr("Completed", ""));
-    DLListModel->setHeaderData(COLUMN_DLSPEED, Qt::Horizontal, tr("Speed", "i.e: Download speed"));
-    DLListModel->setHeaderData(COLUMN_PROGRESS, Qt::Horizontal, tr("Progress / Availability", "i.e: % downloaded"));
-    DLListModel->setHeaderData(COLUMN_SOURCES, Qt::Horizontal, tr("Sources", "i.e: Sources"));
-    DLListModel->setHeaderData(COLUMN_STATUS, Qt::Horizontal, tr("Status"));
-    DLListModel->setHeaderData(COLUMN_PRIORITY, Qt::Horizontal, tr("Speed / Queue position"));
-    DLListModel->setHeaderData(COLUMN_REMAINING, Qt::Horizontal, tr("Remaining"));
-    DLListModel->setHeaderData(COLUMN_DOWNLOADTIME, Qt::Horizontal, tr("Download time", "i.e: Estimated Time of Arrival / Time left"));
-    DLListModel->setHeaderData(COLUMN_ID, Qt::Horizontal, tr("Hash"));
-    DLListModel->setHeaderData(COLUMN_LASTDL, Qt::Horizontal, tr("Last Time Seen", "i.e: Last Time Receiced Data"));
-    DLListModel->setHeaderData(COLUMN_PATH, Qt::Horizontal, tr("Path", "i.e: Where file is saved"));
 
     DLLFilterModel = new QSortFilterProxyModel(this);
     DLLFilterModel->setSourceModel( DLListModel);
@@ -211,11 +784,9 @@ TransfersDialog::TransfersDialog(QWidget *parent)
     selection = ui.downloadList->selectionModel();
 
     ui.downloadList->setSelectionMode(QAbstractItemView::ExtendedSelection);
-
     ui.downloadList->setRootIsDecorated(true);
 
-
-    /* Set header resize modes and initial section sizes Downloads TreeView*/
+//    /* Set header resize modes and initial section sizes Downloads TreeView*/
     QHeaderView * dlheader = ui.downloadList->header () ;
     QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_NAME, QHeaderView::Interactive);
     QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_SIZE, QHeaderView::Interactive);
@@ -231,20 +802,6 @@ TransfersDialog::TransfersDialog(QWidget *parent)
     QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_LASTDL, QHeaderView::Interactive);
     QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_PATH, QHeaderView::Interactive);
 
-    dlheader->resizeSection ( COLUMN_NAME, 170 );
-    dlheader->resizeSection ( COLUMN_SIZE, 70 );
-    dlheader->resizeSection ( COLUMN_COMPLETED, 75 );
-    dlheader->resizeSection ( COLUMN_DLSPEED, 75 );
-    dlheader->resizeSection ( COLUMN_PROGRESS, 170 );
-    dlheader->resizeSection ( COLUMN_SOURCES, 90 );
-    dlheader->resizeSection ( COLUMN_STATUS, 100 );
-    dlheader->resizeSection ( COLUMN_PRIORITY, 100 );
-    dlheader->resizeSection ( COLUMN_REMAINING, 100 );
-    dlheader->resizeSection ( COLUMN_DOWNLOADTIME, 100 );
-    dlheader->resizeSection ( COLUMN_ID, 100 );
-    dlheader->resizeSection ( COLUMN_LASTDL, 100 );
-    dlheader->resizeSection ( COLUMN_PATH, 100 );
-
     // set default column and sort order for download
     ui.downloadList->sortByColumn(COLUMN_NAME, Qt::AscendingOrder);
 
@@ -309,24 +866,12 @@ TransfersDialog::TransfersDialog(QWidget *parent)
 
 	 ui.tabWidget->addTab(localSharedFiles = new LocalSharedFilesDialog(), QIcon(IMAGE_MYFILES), tr("My files")) ;
 
-	 //ui.tabWidget->addTab( new TurtleRouterStatistics(), tr("Router Statistics")) ;
-	 //ui.tabWidget->addTab( new TurtleRouterDialog(), tr("Router Requests")) ;
-
 	 for(int i=0;i<rsPlugins->nbPlugins();++i)
 		 if(rsPlugins->plugin(i) != NULL && rsPlugins->plugin(i)->qt_transfers_tab() != NULL)
 			 ui.tabWidget->addTab( rsPlugins->plugin(i)->qt_transfers_tab(),QString::fromUtf8(rsPlugins->plugin(i)->qt_transfers_tab_name().c_str()) ) ;
 
 	 ui.tabWidget->setCurrentWidget(ui.uploadsTab);
 
-//    TurtleRouterDialog *trdl = new TurtleRouterDialog();
-//    ui.tunnelInfoWidget->setWidget(trdl);
-//    ui.tunnelInfoWidget->setWidgetResizable(true);
-//    ui.tunnelInfoWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-//    ui.tunnelInfoWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
-//    ui.tunnelInfoWidget->viewport()->setBackgroundRole(QPalette::NoRole);
-//    ui.tunnelInfoWidget->setFrameStyle(QFrame::NoFrame);
-//    ui.tunnelInfoWidget->setFocusPolicy(Qt::NoFocus);
-
     /** Setup the actions for the context menu */
 
 	// Actions. Only need to be defined once.
@@ -336,14 +881,8 @@ TransfersDialog::TransfersDialog(QWidget *parent)
    resumeAct = new QAction(QIcon(IMAGE_RESUME), tr("Resume"), this);
    connect(resumeAct, SIGNAL(triggered()), this, SLOT(resumeFileTransfer()));
 
-//#ifdef USE_NEW_CHUNK_CHECKING_CODE
-	// *********WARNING**********
-	// csoler: this has been suspended because it needs the file transfer to consider a file as complete only if all chunks are
-	// 			verified by hash. As users are goign to slowly switch to new checking code, this will not be readily available.
-	//
    forceCheckAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Force Check" ), this );
    connect( forceCheckAct , SIGNAL( triggered() ), this, SLOT( forceCheck() ) );
-//#endif
 
    cancelAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Cancel" ), this );
    connect( cancelAct , SIGNAL( triggered() ), this, SLOT( cancel() ) );
@@ -564,18 +1103,6 @@ void TransfersDialog::processSettings(bool bLoad)
     m_bProcessSettings = false;
 }
 
-// replaced by shortcut
-//void TransfersDialog::keyPressEvent(QKeyEvent *e)
-//{
-//	if(e->key() == Qt::Key_Delete)
-//	{
-//		cancel() ;
-//		e->accept() ;
-//	}
-//	else
-//		RsAutoUpdatePage::keyPressEvent(e) ;
-//}
-
 void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ )
 {
 	std::set<RsFileHash> items ;
@@ -867,6 +1394,7 @@ void TransfersDialog::setDestinationDirectory()
 	}
 }
 
+/*
 int TransfersDialog::addDLItem(int row, const FileInfo &fileInfo)
 {
 	QString fileHash = QString::fromStdString(fileInfo.hash.toStdString());
@@ -915,7 +1443,7 @@ int TransfersDialog::addDLItem(int row, const FileInfo &fileInfo)
 		else 
             file = QFileInfo(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str()), QString::fromUtf8(fileInfo.hash.toStdString().c_str()));
 		
-		/*Get Last Access on File */
+		//Get Last Access on File
 		if (file.exists()) 
 			qi64LastDL = file.lastModified().toTime_t();
 	}
@@ -987,8 +1515,7 @@ int TransfersDialog::addDLItem(int row, const FileInfo &fileInfo)
 	int active = 0;
 
 	if (fileInfo.downloadStatus != FT_STATE_COMPLETE) {
-		for (std::list<TransferInfo>::const_iterator pit = fileInfo.peers.begin()
-		     ; pit != fileInfo.peers.end(); ++pit)
+		for (std::vector<TransferInfo>::const_iterator pit = fileInfo.peers.begin() ; pit != fileInfo.peers.end(); ++pit)
 		{
 			const TransferInfo &transferInfo = *pit;
 
@@ -1009,7 +1536,7 @@ int TransfersDialog::addDLItem(int row, const FileInfo &fileInfo)
 
 			used_rows.insert(row_id);
 
-			/* get the sources (number of online peers) */
+			// get the sources (number of online peers)
 			if (transferInfo.tfRate > 0 && fileInfo.downloadStatus == FT_STATE_DOWNLOADING)
 				++active;
 		}
@@ -1144,6 +1671,7 @@ int TransfersDialog::addPeerToDLItem(QStandardItem *dlItem, const RsPeerId& peer
 
 	return childRow;
 }
+*/
 
 int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
 {
@@ -1185,8 +1713,7 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
 	double peerULSpeedTotal = 0;
 	bool bOnlyOne = ( fileInfo.peers.size() == 1 );
 
-	for(std::list<TransferInfo>::const_iterator pit = fileInfo.peers.begin()
-	    ; pit != fileInfo.peers.end(); ++pit)
+	for(std::vector<TransferInfo>::const_iterator pit = fileInfo.peers.begin() ; pit != fileInfo.peers.end(); ++pit)
 	{
 		const TransferInfo &transferInfo = *pit;
 
@@ -1329,80 +1856,57 @@ void TransfersDialog::updateDisplay()
 
 void TransfersDialog::insertTransfers() 
 {
-	/* disable for performance issues, enable after insert all transfers */
-	ui.downloadList->setSortingEnabled(false);
+	// Since downloads use an AstractItemModel, we just need to update it, while saving the selected and expanded items.
 
-	/* get the download lists */
-	std::list<RsFileHash> downHashes;
-	rsFiles->FileDownloads(downHashes);
+	std::set<QString> expanded_hashes ;
+	std::set<QString> selected_hashes ;
 
-	/* build set for quick search */
-	std::set<RsFileHash> hashs;
+//	ui.downloadList->setSortingEnabled(false);
+//    ui.downloadList->blockSignals(true) ;
 
-	for (std::list<RsFileHash>::iterator it = downHashes.begin(); it != downHashes.end(); ++it) {
-		hashs.insert(*it);
-	}
-
-	/* add downloads, first iterate all rows in list */
-
-	int rowCount = DLListModel->rowCount();
-
-	for (int row = 0; row < rowCount; ) {
-		RsFileHash hash ( DLListModel->item(row, COLUMN_ID)->data(Qt::UserRole).toString().toStdString());
-
-		std::set<RsFileHash>::iterator hashIt = hashs.find(hash);
-		if (hashIt == hashs.end()) {
-			// remove not existing downloads
-			DLListModel->removeRow(row);
-			rowCount = DLListModel->rowCount();
-			continue;
-		}
+	std::cerr << "Updating transfers..." << std::endl;
 
-		FileInfo fileInfo;
-		if (!rsFiles->FileDetails(hash, RS_FILE_HINTS_DOWNLOAD, fileInfo)) {
-			DLListModel->removeRow(row);
-			rowCount = DLListModel->rowCount();
-			continue;
-		}
+/*	QAbstractItemModel *model = ui.downloadList->model();
 
-		hashs.erase(hashIt);
+    for(int row = 0; row < model->rowCount(); ++row)
+	{
+		QModelIndex index = model->index(row,0,QModelIndex());
 
-		if (addDLItem(row, fileInfo) < 0) {
-			DLListModel->removeRow(row);
-			rowCount = DLListModel->rowCount();
-			continue;
-		}
+		if(ui.downloadList->isExpanded(index))
+			expanded_hashes.insert(model->index(row,COLUMN_ID).data(Qt::DisplayRole).toString());
 
-		++row;
-	}
+		if(ui.downloadList->selectionModel()->selection().contains(index))
+			selected_hashes.insert(model->index(row,COLUMN_ID).data(Qt::DisplayRole).toString());
+    } */
 
-	/* then add new downloads to the list */
+	DLListModel->update_transfers();
 
-	for (std::set<RsFileHash>::iterator hashIt = hashs.begin()
-	     ; hashIt != hashs.end(); ++hashIt)
+/*    for(int row = 0; row < model->rowCount(); ++row)  //shitcode, even worse than mine )
 	{
-		FileInfo fileInfo;
-		if (!rsFiles->FileDetails(*hashIt, RS_FILE_HINTS_DOWNLOAD, fileInfo)) {
-			continue;
-		}
+		QModelIndex index = model->index(row,0,QModelIndex());
 
-		addDLItem(-1, fileInfo);
-	}
+		if(expanded_hashes.end() != expanded_hashes.find(model->index(row,COLUMN_ID).data(Qt::DisplayRole).toString()))
+			ui.downloadList->setExpanded(index,true);
+
+		if(selected_hashes.end() != selected_hashes.find(model->index(row,COLUMN_ID).data(Qt::DisplayRole).toString()))
+			ui.downloadList->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
+    } */
 
-	ui.downloadList->setSortingEnabled(true);
+//	ui.downloadList->setSortingEnabled(true);
+//    ui.downloadList->blockSignals(false) ;
 
-	// Now show upload hashes
+	// Now show upload hashes. Here we use the "old" way, since the number of uploads is generally not so large.
 	//
 
 	/* disable for performance issues, enable after insert all transfers */
-	ui.uploadsList->setSortingEnabled(false);
+    ui.uploadsList->setSortingEnabled(false);
 
 	/* get the upload lists */
 	std::list<RsFileHash> upHashes;
 	rsFiles->FileUploads(upHashes);
 
 	/* build set for quick search */
-	hashs.clear();
+	std::set<RsFileHash> hashs;
 
 	for(std::list<RsFileHash>::iterator it = upHashes.begin(); it != upHashes.end(); ++it) {
 		hashs.insert(*it);
@@ -1410,7 +1914,7 @@ void TransfersDialog::insertTransfers()
 
 	/* add uploads, first iterate all rows in list */
 
-	rowCount = ULListModel->rowCount();
+	int rowCount = ULListModel->rowCount();
 
 	for (int row = 0; row < rowCount; ) {
 		RsFileHash hash ( ULListModel->item(row, COLUMN_UHASH)->data(Qt::UserRole).toString().toStdString());
@@ -1464,7 +1968,7 @@ void TransfersDialog::insertTransfers()
 
 }
 
-QString TransfersDialog::getPeerName(const RsPeerId& id, QString &iconName, QString &tooltip) const
+QString TransfersDialog::getPeerName(const RsPeerId& id, QString &iconName, QString &tooltip)
 {
 	QString res = QString::fromUtf8(rsPeers->getPeerName(id).c_str()) ;
 
diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h
index 30efe212d..51bc205d3 100644
--- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h
+++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h
@@ -44,6 +44,7 @@ class FileProgressInfo;
 class SearchDialog;
 class LocalSharedFilesDialog;
 class RemoteSharedFilesDialog;
+class RsDownloadListModel;
 
 class TransfersDialog : public RsAutoUpdatePage
 {
@@ -78,6 +79,7 @@ public:
 	 LocalSharedFilesDialog *localSharedFiles ;
 	 RemoteSharedFilesDialog *remoteSharedFiles ;
 
+    static QString getPeerName(const RsPeerId &peer_id, QString &iconName, QString &tooltip) ;
 public slots:
     void insertTransfers();
 
@@ -164,9 +166,8 @@ signals:
     void playFiles(QStringList files);
 
 private:
-    QString getPeerName(const RsPeerId &peer_id, QString &iconName, QString &tooltip) const ;
 
-    QStandardItemModel *DLListModel;
+    RsDownloadListModel *DLListModel;
     QSortFilterProxyModel *DLLFilterModel;
     QStandardItemModel *ULListModel;
     QItemSelectionModel *selection;
@@ -260,8 +261,8 @@ private:
 
 public slots:
     // these four functions add entries to the transfers dialog, and return the row id of the entry modified/added
-    int addDLItem(int row, const FileInfo &fileInfo);
-    int addPeerToDLItem(QStandardItem* dlItem, const RsPeerId &peer_ID, const QString &coreID, double dlspeed, uint32_t status, const FileProgressInfo &peerInfo);
+//    int addDLItem(int row, const FileInfo &fileInfo);
+//    int addPeerToDLItem(QStandardItem* dlItem, const RsPeerId &peer_ID, const QString &coreID, double dlspeed, uint32_t status, const FileProgressInfo &peerInfo);
     int addULItem(int row, const FileInfo &fileInfo);
     int addPeerToULItem(QStandardItem* ulItem, const RsPeerId &peer_ID, const QString &coreID, qlonglong completed, double ulspeed, const FileProgressInfo &peerInfo);
 
diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp
index 266970a54..f4af64017 100644
--- a/retroshare-gui/src/gui/RetroShareLink.cpp
+++ b/retroshare-gui/src/gui/RetroShareLink.cpp
@@ -1572,7 +1572,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
 				FileInfo finfo ;
 				rsFiles->FileDetails(RsFileHash(link.hash().toStdString()), RS_FILE_HINTS_REMOTE, finfo) ;
 
-				for(std::list<TransferInfo>::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it)
+				for(std::vector<TransferInfo>::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it)
 				{
 #ifdef DEBUG_RSLINK
 					std::cerr << "  adding peerid " << (*it).peerId << std::endl ;
diff --git a/retroshare-gui/src/gui/feeds/SubFileItem.cpp b/retroshare-gui/src/gui/feeds/SubFileItem.cpp
index 250d85cad..0e3350127 100644
--- a/retroshare-gui/src/gui/feeds/SubFileItem.cpp
+++ b/retroshare-gui/src/gui/feeds/SubFileItem.cpp
@@ -630,7 +630,7 @@ void SubFileItem::download()
 	FileInfo finfo ;
 	rsFiles->FileDetails(mFileHash,RS_FILE_HINTS_REMOTE,finfo) ;
 
-	for(std::list<TransferInfo>::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it)
+	for(std::vector<TransferInfo>::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it)
 		sources.push_back((*it).peerId) ;
 
 	// TEMP
diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.cpp
index b9b84b894..b3170efa4 100644
--- a/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.cpp
+++ b/retroshare-gui/src/gui/gxschannels/GxsChannelFilesStatusWidget.cpp
@@ -248,7 +248,7 @@ void GxsChannelFilesStatusWidget::download()
 	FileInfo fileInfo;
 	rsFiles->FileDetails(mFile.mHash, RS_FILE_HINTS_REMOTE, fileInfo);
 
-	for(std::list<TransferInfo>::const_iterator it = fileInfo.peers.begin(); it != fileInfo.peers.end(); ++it) {
+	for(std::vector<TransferInfo>::const_iterator it = fileInfo.peers.begin(); it != fileInfo.peers.end(); ++it) {
 		sources.push_back((*it).peerId);
 	}
 
diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp
index 2f00bcded..38319bafc 100644
--- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp
+++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp
@@ -323,7 +323,7 @@ void MessageWidget::getcurrentrecommended()
 			fi.fname = it->data().toString().toUtf8().constData();
 			break ;
 		case COLUMN_FILE_SIZE:
-			fi.size = it->data().toULongLong() ;
+			fi.size = it->data(Qt::UserRole).toULongLong() ;
 			break ;
 		case COLUMN_FILE_HASH:
 			fi.hash = RsFileHash(it->data().toString().toStdString()) ;
@@ -502,6 +502,7 @@ void MessageWidget::fill(const std::string &msgId)
 		QTreeWidgetItem *item = new QTreeWidgetItem;
 		item->setText(COLUMN_FILE_NAME, QString::fromUtf8(it->fname.c_str()));
 		item->setText(COLUMN_FILE_SIZE, misc::friendlyUnit(it->size));
+		item->setData(COLUMN_FILE_SIZE, Qt::UserRole, QVariant(qulonglong(it->size)) );
 		item->setText(COLUMN_FILE_HASH, QString::fromStdString(it->hash.toStdString()));
 		item->setTextAlignment( COLUMN_FILE_SIZE, Qt::AlignRight );