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
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
|
diff --git a/RetroShare.pro b/RetroShare.pro
index 833173029..d22af1418 100644
--- a/RetroShare.pro
+++ b/RetroShare.pro
@@ -56,12 +56,6 @@ retroshare_qml_app {
}
}
-retroshare_plugins {
- SUBDIRS += plugins
- plugins.file = plugins/plugins.pro
- plugins.depends = retroshare_gui
- plugins.target = plugins
-}
wikipoos {
SUBDIRS += pegmarkdown
diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp
index bdeda264c..d7b864094 100644
--- a/retroshare-gui/src/gui/NetworkDialog.cpp
+++ b/retroshare-gui/src/gui/NetworkDialog.cpp
@@ -71,7 +71,7 @@
#define COLUMN_LAST_USED 5
#define COLUMN_COUNT 6
-RsPeerId getNeighRsCertId(QTreeWidgetItem *i);
+//RsPeerId getNeighRsCertId(QTreeWidgetItem *i);
/******
* #define NET_DEBUG 1
@@ -81,85 +81,69 @@ static const unsigned int ROLE_SORT = Qt::UserRole + 1 ;
/** Constructor */
NetworkDialog::NetworkDialog(QWidget *parent)
-: RsAutoUpdatePage(10000,parent) // updates every 10 sec.
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
- connect( ui.connectTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connectTreeWidgetCostumPopupMenu( QPoint ) ) );
- connect( ui.connectTreeWidget, SIGNAL( itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT( peerdetails () ) );
-
connect( ui.filterLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterItems(QString)));
connect( ui.filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int)));
- connect( ui.onlyTrustedKeys, SIGNAL(clicked()), this, SLOT(securedUpdateDisplay()));
+// connect( ui.onlyTrustedKeys, SIGNAL(clicked()), this, SLOT(securedUpdateDisplay()));
+
+
+
+/* compareNetworkRole = new RSTreeWidgetItemCompareRole;
+ compareNetworkRole->setRole(COLUMN_LAST_USED, ROLE_SORT); */
+
+ //list data model
+ float f = QFontMetricsF(font()).height()/14.0 ;
+ PGPIdItemModel = new pgpid_item_model(neighs, f, this);
+ PGPIdItemProxy = new pgpid_item_proxy(this);
+ connect(ui.onlyTrustedKeys, SIGNAL(toggled(bool)), PGPIdItemProxy, SLOT(use_only_trusted_keys(bool)));
+ PGPIdItemProxy->setSourceModel(PGPIdItemModel);
+ PGPIdItemProxy->setFilterKeyColumn(COLUMN_PEERNAME);
+ PGPIdItemProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
+ ui.connectTreeWidget->setModel(PGPIdItemProxy);
+ ui.connectTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
+ ui.connectTreeWidget->verticalHeader()->hide();
+ ui.connectTreeWidget->setShowGrid(false);
+ ui.connectTreeWidget->setUpdatesEnabled(true);
+ ui.connectTreeWidget->setSortingEnabled(true);
+ ui.connectTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
+ connect(ui.connectTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connectTreeWidgetCostumPopupMenu( QPoint ) ) );
+ connect(ui.connectTreeWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(peerdetails()));
- /* hide the Tree +/- */
- ui.connectTreeWidget -> setRootIsDecorated( false );
- ui.connectTreeWidget -> setColumnCount(6);
- compareNetworkRole = new RSTreeWidgetItemCompareRole;
- compareNetworkRole->setRole(COLUMN_LAST_USED, ROLE_SORT);
/* Set header resize modes and initial section sizes */
- QHeaderView * _header = ui.connectTreeWidget->header () ;
+/* QHeaderView * _header = ui.connectTreeWidget->header () ;
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_CHECK, QHeaderView::Custom);
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEERNAME, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_I_AUTH_PEER, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEER_AUTH_ME, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_PEERID, QHeaderView::Interactive);
- QHeaderView_setSectionResizeModeColumn(_header, COLUMN_LAST_USED, QHeaderView::Interactive);
-
- _header->model()->setHeaderData(COLUMN_CHECK, Qt::Horizontal, tr(""));
- _header->model()->setHeaderData(COLUMN_PEERNAME, Qt::Horizontal, tr("Profile"));
- _header->model()->setHeaderData(COLUMN_I_AUTH_PEER, Qt::Horizontal, tr("Trust level"));
- _header->model()->setHeaderData(COLUMN_PEER_AUTH_ME, Qt::Horizontal, tr("Has signed your key?"));
- _header->model()->setHeaderData(COLUMN_PEERID, Qt::Horizontal, tr("Id"));
- _header->model()->setHeaderData(COLUMN_LAST_USED, Qt::Horizontal, tr("Last used"));
-
- _header->model()->setHeaderData(COLUMN_CHECK, Qt::Horizontal, tr(" Do you accept connections signed by this profile?"),Qt::ToolTipRole);
- _header->model()->setHeaderData(COLUMN_PEERNAME, Qt::Horizontal, tr("Name of the profile"),Qt::ToolTipRole);
- _header->model()->setHeaderData(COLUMN_I_AUTH_PEER, Qt::Horizontal, tr("This column indicates trust level and whether you signed the profile PGP key"),Qt::ToolTipRole);
- _header->model()->setHeaderData(COLUMN_PEER_AUTH_ME, Qt::Horizontal, tr("Did that peer sign your own profile PGP key"),Qt::ToolTipRole);
- _header->model()->setHeaderData(COLUMN_PEERID, Qt::Horizontal, tr("PGP Key Id of that profile"),Qt::ToolTipRole);
- _header->model()->setHeaderData(COLUMN_LAST_USED, Qt::Horizontal, tr("Last time this key was used (received time, or to check connection)"),Qt::ToolTipRole);
-
- float f = QFontMetricsF(font()).height()/14.0 ;
+ QHeaderView_setSectionResizeModeColumn(_header, COLUMN_LAST_USED, QHeaderView::Interactive); */
- _header->resizeSection ( COLUMN_CHECK, 25*f );
- _header->resizeSection ( COLUMN_PEERNAME, 200*f );
- _header->resizeSection ( COLUMN_I_AUTH_PEER, 200*f );
- _header->resizeSection ( COLUMN_PEER_AUTH_ME, 200*f );
- _header->resizeSection ( COLUMN_LAST_USED, 75*f );
- // set header text aligment
- QTreeWidgetItem * headerItem = ui.connectTreeWidget->headerItem();
- headerItem->setTextAlignment(COLUMN_CHECK, Qt::AlignHCenter | Qt::AlignVCenter);
- headerItem->setTextAlignment(COLUMN_PEERNAME, Qt::AlignHCenter | Qt::AlignVCenter);
- headerItem->setTextAlignment(COLUMN_I_AUTH_PEER, Qt::AlignHCenter | Qt::AlignVCenter);
- headerItem->setTextAlignment(COLUMN_PEER_AUTH_ME, Qt::AlignHCenter | Qt::AlignVCenter);
- headerItem->setTextAlignment(COLUMN_PEERID, Qt::AlignVCenter);
- headerItem->setTextAlignment(COLUMN_LAST_USED, Qt::AlignVCenter);
+ ui.onlyTrustedKeys->setMinimumWidth(20*f);
- headerItem->setText(0,QString()) ;
- ui.connectTreeWidget->sortItems( COLUMN_PEERNAME, Qt::AscendingOrder );
- ui.onlyTrustedKeys->setMinimumWidth(20*f);
-
- QMenu *menu = new QMenu();
+/* QMenu *menu = new QMenu();
menu->addAction(ui.actionTabsright);
menu->addAction(ui.actionTabswest);
menu->addAction(ui.actionTabssouth);
menu->addAction(ui.actionTabsnorth);
menu->addSeparator();
menu->addAction(ui.actionTabsTriangular);
- menu->addAction(ui.actionTabsRounded);
+ menu->addAction(ui.actionTabsRounded); */
/* add filter actions */
ui.filterLineEdit->addFilter(QIcon(), tr("Name"), COLUMN_PEERNAME, tr("Search name"));
ui.filterLineEdit->addFilter(QIcon(), tr("Peer ID"), COLUMN_PEERID, tr("Search peer ID"));
ui.filterLineEdit->setCurrentFilter(COLUMN_PEERNAME);
+ connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), PGPIdItemProxy, SLOT(setFilterWildcard(QString)));
+
}
void NetworkDialog::changeEvent(QEvent *e)
@@ -177,14 +161,14 @@ void NetworkDialog::changeEvent(QEvent *e)
void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ )
{
- //std::cerr << "NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint point ) called" << std::endl;
- QTreeWidgetItem *wi = getCurrentNeighbour();
- if (!wi)
- return;
+
+ QModelIndexList l = ui.connectTreeWidget->selectionModel()->selection().indexes();
+ if(l.empty())
+ return;
QMenu *contextMnu = new QMenu;
- RsPgpId peer_id(wi->text(COLUMN_PEERID).toStdString()) ;
+ RsPgpId peer_id(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()) ;
// That's what context menus are made for
RsPeerDetails detail;
@@ -271,13 +255,17 @@ void NetworkDialog::removeUnusedKeys()
}
QMessageBox::warning(NULL,tr("Keyring info"),tr("Key removal has failed. Your keyring remains intact.\n\nReported error:")+" "+error_string ) ;
}
- insertConnect() ;
+ updateDisplay();
+// insertConnect() ;
}
void NetworkDialog::denyFriend()
{
- QTreeWidgetItem *wi = getCurrentNeighbour();
- RsPgpId peer_id( wi->text(COLUMN_PEERID).toStdString() );
+ QModelIndexList l = ui.connectTreeWidget->selectionModel()->selection().indexes();
+ if(l.empty())
+ return;
+
+ RsPgpId peer_id(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString());
rsPeers->removeFriend(peer_id) ;
securedUpdateDisplay();
@@ -300,27 +288,32 @@ void NetworkDialog::denyFriend()
void NetworkDialog::makeFriend()
{
- PGPKeyDialog::showIt(RsPgpId(getCurrentNeighbour()->text(COLUMN_PEERID).toStdString()), PGPKeyDialog::PageDetails);
+
+ QModelIndexList l = ui.connectTreeWidget->selectionModel()->selection().indexes();
+ if(l.empty())
+ return;
+
+ PGPKeyDialog::showIt(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()), PGPKeyDialog::PageDetails);
}
/** Shows Peer Information/Auth Dialog */
void NetworkDialog::peerdetails()
{
- QTreeWidgetItem* item = getCurrentNeighbour();
- if (item == NULL) {
- return;
- }
- PGPKeyDialog::showIt(RsPgpId(item->text(COLUMN_PEERID).toStdString()), PGPKeyDialog::PageDetails);
+ QModelIndexList l = ui.connectTreeWidget->selectionModel()->selection().indexes();
+ if(l.empty())
+ return;
+
+ PGPKeyDialog::showIt(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()), PGPKeyDialog::PageDetails);
}
void NetworkDialog::copyLink()
{
- QTreeWidgetItem *wi = getCurrentNeighbour();
- if (wi == NULL) {
- return;
- }
+ QModelIndexList l = ui.connectTreeWidget->selectionModel()->selection().indexes();
+ if(l.empty())
+ return;
- RsPgpId peer_id ( wi->text(COLUMN_PEERID).toStdString() ) ;
+
+ RsPgpId peer_id (ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()) ;
QList<RetroShareLink> urls;
RetroShareLink link = RetroShareLink::createPerson(peer_id);
@@ -356,137 +349,39 @@ void NetworkDialog::copyLink()
// /* window will destroy itself! */
//}
-void NetworkDialog::updateDisplay()
-{
- insertConnect() ;
-}
-
/* get the list of Neighbours from the RsIface. */
-void NetworkDialog::insertConnect()
-{
+//void NetworkDialog::insertConnect()
+//{
// static time_t last_time = 0 ;
- if (!rsPeers)
- return;
-
-// // Because this is called from a qt signal, there's no limitation between calls.
- time_t now = time(NULL);
+// if (!rsPeers)
+// return;
- std::list<RsPgpId> neighs; //these are GPG ids
- std::list<RsPgpId>::iterator it;
- rsPeers->getGPGAllList(neighs);
+ //these are GPG ids
+// std::list<RsPgpId>::iterator it;
+// rsPeers->getGPGAllList(neighs);
/* get a link to the table */
- QTreeWidget *connectWidget = ui.connectTreeWidget;
+// QTreeView *connectWidget = ui.connectTreeWidget;
/* disable sorting while editing the table */
- connectWidget->setSortingEnabled(false);
+// connectWidget->setSortingEnabled(false);
//remove items
- int index = 0;
- while (index < connectWidget->topLevelItemCount())
- {
- RsPgpId gpg_widget_id( (connectWidget->topLevelItem(index))->text(COLUMN_PEERID).toStdString() );
- RsPeerDetails detail;
- if ( (!rsPeers->getGPGDetails(gpg_widget_id, detail)) || (ui.onlyTrustedKeys->isChecked() && (detail.validLvl < RS_TRUST_LVL_MARGINAL && !detail.accept_connection)))
- delete (connectWidget->takeTopLevelItem(index));
- else
- ++index;
- }
+// int index = 0;
- for(it = neighs.begin(); it != neighs.end(); ++it)
- {
+/* for(it = neighs.begin(); it != neighs.end(); ++it)
+ {
#ifdef NET_DEBUG
std::cerr << "NetworkDialog::insertConnect() inserting gpg key : " << *it << std::endl;
-#endif
- if (*it == rsPeers->getGPGOwnId()) {
- continue;
- }
-
- RsPeerDetails detail;
- if (!rsPeers->getGPGDetails(*it, detail))
- {
- continue; /* BAD */
- }
-
- /* make a widget per friend */
- QTreeWidgetItem *item;
- QList<QTreeWidgetItem *> list = connectWidget->findItems(QString::fromStdString( (*it).toStdString() ), Qt::MatchExactly, COLUMN_PEERID);
- if (list.size() == 1) {
- item = list.front();
- } else {
- //create new item
-#ifdef NET_DEBUG
- std::cerr << "NetworkDialog::insertConnect() creating new tree widget item : " << *it << std::endl;
-#endif
- item = new RSTreeWidgetItem(compareNetworkRole, 0);
- item -> setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
-
- int S = QFontMetricsF(font()).height() ;
- item -> setSizeHint(COLUMN_CHECK, QSize( S,S ) );
-
- /* (1) Person */
- item -> setText(COLUMN_PEERNAME, QString::fromUtf8(detail.name.c_str()));
-
- /* (4) key id */
- item -> setText(COLUMN_PEERID, QString::fromStdString(detail.gpg_id.toStdString()));
- }
-
- //QString TrustLevelString ;
-
- /* (2) Key validity */
- if (detail.ownsign)
- {
- item -> setText(COLUMN_I_AUTH_PEER, tr("Personal signature"));
- item -> setToolTip(COLUMN_I_AUTH_PEER, tr("PGP key signed by you"));
- }
- else
- switch(detail.trustLvl)
- {
- case RS_TRUST_LVL_MARGINAL: item->setText(COLUMN_I_AUTH_PEER,tr("Marginally trusted peer")) ; break;
- case RS_TRUST_LVL_FULL:
- case RS_TRUST_LVL_ULTIMATE: item->setText(COLUMN_I_AUTH_PEER,tr("Fully trusted peer")) ; break ;
- case RS_TRUST_LVL_UNKNOWN:
- case RS_TRUST_LVL_UNDEFINED:
- case RS_TRUST_LVL_NEVER:
- default: item->setText(2,tr("Untrusted peer")) ; break ;
- }
-
- /* (3) has me auth */
- QString PeerAuthenticationString ;
-
- if (detail.hasSignedMe)
- PeerAuthenticationString = tr("Yes");
- else
- PeerAuthenticationString = tr("No");
-
- item->setText(COLUMN_PEER_AUTH_ME,PeerAuthenticationString) ;
-
- uint64_t last_time_used = now - detail.lastUsed ;
- QString lst_used_str ;
-
- if(last_time_used < 3600)
- lst_used_str = tr("Last hour") ;
- else if(last_time_used < 86400)
- lst_used_str = tr("Today") ;
- else if(last_time_used > 86400 * 15000)
- lst_used_str = tr("Never");
- else
- lst_used_str = tr("%1 days ago").arg((int)( last_time_used / 86400 )) ;
-
- QString lst_used_sort_str = QString::number(detail.lastUsed,'f',10);
-
- item->setText(COLUMN_LAST_USED,lst_used_str) ;
- item->setData(COLUMN_LAST_USED,ROLE_SORT,lst_used_sort_str) ;
+#endif */
/**
* Determinated the Background Color
*/
- QColor backgrndcolor;
+/* QColor backgrndcolor;
if (detail.accept_connection)
{
- item -> setText(COLUMN_CHECK, "0");
- item -> setIcon(COLUMN_CHECK,(QIcon(IMAGE_AUTHED)));
if (detail.ownsign)
{
backgrndcolor = backgroundColorOwnSign();
@@ -498,19 +393,14 @@ void NetworkDialog::insertConnect()
}
else
{
- item -> setText(COLUMN_CHECK, "1");
if (detail.hasSignedMe)
{
backgrndcolor = backgroundColorHasSignedMe();
- item -> setIcon(COLUMN_CHECK,(QIcon(IMAGE_DENIED)));
- for(int k=0;k<COLUMN_COUNT;++k)
- item -> setToolTip(k, QString::fromUtf8(detail.name.c_str()) + tr(" has authenticated you. \nRight-click and select 'make friend' to be able to connect."));
}
else
{
backgrndcolor = backgroundColorDenied();
- item -> setIcon(COLUMN_CHECK,(QIcon(IMAGE_DENIED)));
}
}
@@ -520,14 +410,14 @@ void NetworkDialog::insertConnect()
item -> setBackground(i,QBrush(backgrndcolor));
if( (detail.accept_connection || detail.validLvl >= RS_TRUST_LVL_MARGINAL) || !ui.onlyTrustedKeys->isChecked())
- connectWidget->addTopLevelItem(item);
- }
+ connectWidget->addTopLevelItem(item); */
+// }
// add self to network.
- RsPeerDetails ownGPGDetails;
- rsPeers->getGPGDetails(rsPeers->getGPGOwnId(), ownGPGDetails);
+// RsPeerDetails ownGPGDetails;
+// rsPeers->getGPGDetails(rsPeers->getGPGOwnId(), ownGPGDetails);
/* make a widget per friend */
- QTreeWidgetItem *self_item;
+/* QTreeWidgetItem *self_item;
QList<QTreeWidgetItem *> list = connectWidget->findItems(QString::fromStdString(ownGPGDetails.gpg_id.toStdString()), Qt::MatchExactly, COLUMN_PEERID);
if (list.size() == 1) {
self_item = list.front();
@@ -546,35 +436,26 @@ void NetworkDialog::insertConnect()
{
self_item->setBackground(i,backgroundColorSelf()) ;
}
- connectWidget->addTopLevelItem(self_item);
+ connectWidget->addTopLevelItem(self_item); */
/* enable sorting */
- connectWidget->setSortingEnabled(true);
+// connectWidget->setSortingEnabled(true);
/* update display */
- connectWidget->update();
-
- if (ui.filterLineEdit->text().isEmpty() == false) {
- filterItems(ui.filterLineEdit->text());
- }
+// connectWidget->update();
-}
+// if (ui.filterLineEdit->text().isEmpty() == false) {
+// filterItems(ui.filterLineEdit->text());
+// }
-QTreeWidgetItem *NetworkDialog::getCurrentNeighbour()
-{
- if (ui.connectTreeWidget->selectedItems().size() != 0)
- {
- return ui.connectTreeWidget -> currentItem();
- }
+//}
- return NULL;
-}
/* Utility Fns */
-RsPeerId getNeighRsCertId(QTreeWidgetItem *i)
+/*RsPeerId getNeighRsCertId(QTreeWidgetItem *i)
{
RsPeerId id ( (i -> text(COLUMN_PEERID)).toStdString() );
return id;
-}
+} */
void NetworkDialog::on_actionAddFriend_activated()
{
// /* Create a new input dialog, which allows users to create files, too */
@@ -700,12 +581,14 @@ void NetworkDialog::on_actionCreate_New_Profile_activated()
// Settings->endGroup();
// }
-void NetworkDialog::filterColumnChanged(int)
+void NetworkDialog::filterColumnChanged(int col)
{
- filterItems(ui.filterLineEdit->text());
+ if(PGPIdItemProxy)
+ PGPIdItemProxy->setFilterKeyColumn(col);
+ //filterItems(ui.filterLineEdit->text());
}
-void NetworkDialog::filterItems(const QString &text)
+/*void NetworkDialog::filterItems(const QString &text)
{
int filterColumn = ui.filterLineEdit->currentFilter();
@@ -713,9 +596,9 @@ void NetworkDialog::filterItems(const QString &text)
for (int index = 0; index < count; ++index) {
filterItem(ui.connectTreeWidget->topLevelItem(index), text, filterColumn);
}
-}
+}*/
-bool NetworkDialog::filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn)
+/*bool NetworkDialog::filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn)
{
bool visible = true;
@@ -740,4 +623,16 @@ bool NetworkDialog::filterItem(QTreeWidgetItem *item, const QString &text, int f
}
return (visible || visibleChildCount);
+} */
+
+void NetworkDialog::updateDisplay()
+{
+ if (!rsPeers)
+ return;
+ //update ids list
+ std::list<RsPgpId> new_neighs;
+ rsPeers->getGPGAllList(new_neighs);
+ //refresh model
+ PGPIdItemModel->data_updated(new_neighs);
}
+
diff --git a/retroshare-gui/src/gui/NetworkDialog.h b/retroshare-gui/src/gui/NetworkDialog.h
index 2d90e98e7..5c73c0a51 100644
--- a/retroshare-gui/src/gui/NetworkDialog.h
+++ b/retroshare-gui/src/gui/NetworkDialog.h
@@ -25,6 +25,11 @@
#include "ui_NetworkDialog.h"
#include "RsAutoUpdatePage.h"
+#include "gui/NetworkDialog/pgpid_item_model.h"
+#include "gui/NetworkDialog/pgpid_item_proxy.h"
+
+//tmp
+class QTreeWidgetItem;
class RSTreeWidgetItemCompareRole ;
@@ -42,9 +47,8 @@ public:
/** Default Constructor */
NetworkDialog(QWidget *parent = 0);
- //void load();
virtual void updateDisplay() ; // overloaded from RsAutoUpdatePage
-
+
QColor backgroundColorSelf() const { return mBackgroundColorSelf; }
QColor backgroundColorOwnSign() const { return mBackgroundColorOwnSign; }
QColor backgroundColorAcceptConnection() const { return mBackgroundColorAcceptConnection; }
@@ -58,7 +62,7 @@ public:
void setBackgroundColorDenied(QColor color) { mBackgroundColorDenied = color; }
private:
- void insertConnect();
+// void insertConnect();
// std::string loadneighbour();
/* void loadneighbour(); */
//void updateNewDiscoveryInfo() ;
@@ -68,7 +72,7 @@ protected:
private slots:
- void removeUnusedKeys() ;
+ void removeUnusedKeys() ;
void makeFriend() ;
void denyFriend() ;
// void deleteCert() ;
@@ -104,14 +108,15 @@ private slots:
// void on_actionTabsTriangular_activated();
void filterColumnChanged(int);
- void filterItems(const QString &text);
+// void filterItems(const QString &text);
+
+
private:
- QTreeWidgetItem *getCurrentNeighbour();
// class NetworkView *networkview;
- bool filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn);
+// bool filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn);
/* Color definitions (for standard see qss.default) */
QColor mBackgroundColorSelf;
@@ -122,6 +127,12 @@ private:
RSTreeWidgetItemCompareRole *compareNetworkRole ;
+ //iinternal long lived data
+ std::list<RsPgpId> neighs;
+
+ pgpid_item_model *PGPIdItemModel;
+ pgpid_item_proxy *PGPIdItemProxy;
+
/** Qt Designer generated object */
Ui::NetworkDialog ui;
};
diff --git a/retroshare-gui/src/gui/NetworkDialog.ui b/retroshare-gui/src/gui/NetworkDialog.ui
index 3c0fb4c93..833fb542b 100644
--- a/retroshare-gui/src/gui/NetworkDialog.ui
+++ b/retroshare-gui/src/gui/NetworkDialog.ui
@@ -41,7 +41,7 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
- <widget class="QTreeWidget" name="connectTreeWidget">
+ <widget class="QTableView" name="connectTreeWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
@@ -66,63 +66,6 @@
<height>16</height>
</size>
</property>
- <property name="uniformRowHeights">
- <bool>true</bool>
- </property>
- <property name="sortingEnabled">
- <bool>true</bool>
- </property>
- <property name="animated">
- <bool>true</bool>
- </property>
- <property name="allColumnsShowFocus">
- <bool>true</bool>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- <attribute name="headerCascadingSectionResizes">
- <bool>true</bool>
- </attribute>
- <attribute name="headerDefaultSectionSize">
- <number>200</number>
- </attribute>
- <attribute name="headerStretchLastSection">
- <bool>true</bool>
- </attribute>
- <column>
- <property name="text">
- <string/>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Profile</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Did I authenticated peer</string>
- </property>
- <property name="toolTip">
- <string>Did I sign his PGP key</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Has signed my key</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Cert Id</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Last used</string>
- </property>
- </column>
</widget>
</widget>
</item>
diff --git a/retroshare-gui/src/gui/NetworkDialog/pgpid_item_model.cpp b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_model.cpp
new file mode 100644
index 000000000..e6f9eaa90
--- /dev/null
+++ b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_model.cpp
@@ -0,0 +1,375 @@
+#include "pgpid_item_model.h"
+#include <retroshare/rspeers.h>
+#include <QIcon>
+
+#define IMAGE_AUTHED ":/images/accepted16.png"
+#define IMAGE_DENIED ":/images/denied16.png"
+#define IMAGE_TRUSTED ":/images/rs-2.png"
+
+/*TODO:
+ * using list here for internal data storage is not best options
+*/
+pgpid_item_model::pgpid_item_model(std::list<RsPgpId> &neighs_, float &_font_height, QObject *parent)
+ : QAbstractTableModel(parent), neighs(neighs_), font_height(_font_height)
+{
+}
+
+QVariant pgpid_item_model::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if(orientation == Qt::Horizontal)
+ {
+ if(role == Qt::ToolTipRole)
+ {
+ switch(section)
+ {
+ case COLUMN_CHECK:
+ return QString(tr(" Do you accept connections signed by this profile?"));
+ break;
+ case COLUMN_PEERNAME:
+ return QString(tr("Name of the profile"));
+ break;
+ case COLUMN_I_AUTH_PEER:
+ return QString(tr("This column indicates trust level and whether you signed the profile PGP key"));
+ break;
+ case COLUMN_PEER_AUTH_ME:
+ return QString(tr("Did that peer sign your own profile PGP key"));
+ break;
+ case COLUMN_PEERID:
+ return QString(tr("PGP Key Id of that profile"));
+ break;
+ case COLUMN_LAST_USED:
+ return QString(tr("Last time this key was used (received time, or to check connection)"));
+ break;
+ }
+ }
+ else if(role == Qt::DisplayRole)
+ {
+ switch(section)
+ {
+ case COLUMN_CHECK:
+ return QString(tr(""));
+ break;
+ case COLUMN_PEERNAME:
+ return QString(tr("Profile"));
+ break;
+ case COLUMN_I_AUTH_PEER:
+ return QString(tr("Trust level"));
+ break;
+ case COLUMN_PEER_AUTH_ME:
+ return QString(tr("Has signed your key?"));
+ break;
+ case COLUMN_PEERID:
+ return QString(tr("Id"));
+ break;
+ case COLUMN_LAST_USED:
+ return QString(tr("Last used"));
+ break;
+ }
+ }
+ else if (role == Qt::TextAlignmentRole)
+ {
+ switch(section)
+ {
+ default:
+ return (uint32_t)(Qt::AlignHCenter | Qt::AlignVCenter);
+ break;
+ }
+ }
+ else if(role == Qt::SizeHintRole)
+ {
+ switch(section)
+ {
+ case COLUMN_CHECK:
+ return 25*font_height;
+ break;
+ case COLUMN_PEERNAME: case COLUMN_I_AUTH_PEER: case COLUMN_PEER_AUTH_ME:
+ return 200*font_height;
+ break;
+ case COLUMN_LAST_USED:
+ return 75*font_height;
+ break;
+ }
+
+ }
+ }
+ return QVariant();
+}
+
+/*QModelIndex pgpid_item_model::index(int row, int column, const QModelIndex &parent) const
+{
+ return createIndex(row, column);
+}*/
+
+/*QModelIndex pgpid_item_model::parent(const QModelIndex &index) const
+{
+ if(index.row() > -1 && index.column() > -1)
+ return createIndex(-1, -1);
+ if (!index.isValid())
+ return QModelIndex();
+ return QModelIndex();
+}*/
+
+/*bool pgpid_item_model::hasChildren(const QModelIndex &parent) const
+{
+ if(parent.column() == -1 && parent.row() == -1)
+ return true;
+ return false;
+} */
+
+int pgpid_item_model::rowCount(const QModelIndex &/*parent*/) const
+{
+ return neighs.size();
+}
+
+int pgpid_item_model::columnCount(const QModelIndex &/*parent*/) const
+{
+ return COLUMN_COUNT;
+}
+
+//bool pgpid_item_model::insertRows(int position, int rows, const QModelIndex &/*index*/)
+//{
+// beginInsertRows(QModelIndex(), position, position+rows-1);
+// endInsertRows();
+// return true;
+//}
+
+//bool pgpid_item_model::removeRows(int position, int rows, const QModelIndex &/*index*/)
+//{
+// beginRemoveRows(QModelIndex(), position, position+rows-1);
+// endRemoveRows();
+// return true;
+//}
+
+
+QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if((unsigned)index.row() >= neighs.size())
+ return QVariant();
+
+
+ //shit code (please rewrite it)
+
+ std::list<RsPgpId>::iterator it = neighs.begin();
+ for(int i = 0; i < index.row(); i++)
+ it++;
+ RsPeerDetails detail;
+ if (!rsPeers->getGPGDetails(*it, detail))
+ return QVariant();
+ //shit code end
+ if(role == Qt::DisplayRole)
+ {
+ switch(index.column())
+ {
+ case COLUMN_PEERNAME:
+ return QString::fromUtf8(detail.name.c_str());
+ break;
+ case COLUMN_PEERID:
+ return QString::fromStdString(detail.gpg_id.toStdString());
+ break;
+ case COLUMN_I_AUTH_PEER:
+ {
+ if (detail.ownsign)
+ return tr("Personal signature");
+ else
+ {
+ switch(detail.trustLvl)
+ {
+ case RS_TRUST_LVL_MARGINAL: return tr("Marginally trusted peer") ; break;
+ case RS_TRUST_LVL_FULL:
+ case RS_TRUST_LVL_ULTIMATE: return tr("Fully trusted peer") ; break ;
+ case RS_TRUST_LVL_UNKNOWN:
+ case RS_TRUST_LVL_UNDEFINED:
+ case RS_TRUST_LVL_NEVER:
+ default: return tr("Untrusted peer") ; break ;
+ }
+ }
+ }
+ break;
+ case COLUMN_PEER_AUTH_ME:
+ {
+ if (detail.hasSignedMe)
+ return tr("Yes");
+ else
+ return tr("No");
+ }
+ break;
+ case COLUMN_LAST_USED:
+ {
+ time_t now = time(NULL);
+ uint64_t last_time_used = now - detail.lastUsed ;
+ QString lst_used_str ;
+
+ if(last_time_used < 3600)
+ lst_used_str = tr("Last hour") ;
+ else if(last_time_used < 86400)
+ lst_used_str = tr("Today") ;
+ else if(last_time_used > 86400 * 15000)
+ lst_used_str = tr("Never");
+ else
+ lst_used_str = tr("%1 days ago").arg((int)( last_time_used / 86400 )) ;
+
+// QString lst_used_sort_str = QString::number(detail.lastUsed,'f',10);
+
+ return lst_used_str;
+// item->setData(COLUMN_LAST_USED,ROLE_SORT,lst_used_sort_str) ;
+ }
+ break;
+ case COLUMN_CHECK:
+ {
+ if (detail.accept_connection)
+ {
+ return QString("0");
+ }
+ else
+ {
+ return QString("1");
+ }
+ }
+ break;
+
+
+ }
+ }
+ else if(role == Qt::ToolTipRole)
+ {
+ switch(index.column())
+ {
+ case COLUMN_I_AUTH_PEER:
+ {
+ if (detail.ownsign)
+ return tr("PGP key signed by you");
+ }
+ break;
+ default:
+ {
+ if (!detail.accept_connection && detail.hasSignedMe)
+ {
+ return QString::fromUtf8(detail.name.c_str()) + tr(" has authenticated you. \nRight-click and select 'make friend' to be able to connect.");
+ }
+ }
+ break;
+
+ }
+ }
+ else if(role == Qt::DecorationRole)
+ {
+ switch(index.column())
+ {
+ case COLUMN_CHECK:
+ {
+ if (detail.accept_connection)
+ return QIcon(IMAGE_AUTHED);
+ else
+ return QIcon(IMAGE_DENIED);
+
+ }
+ break;
+ }
+ }
+ else if(role == Qt::BackgroundRole)
+ {
+ switch(index.column())
+ {
+ default:
+ {
+ //TODO: add access to bckground colors from networkdialog
+ if (detail.accept_connection)
+ {
+ if (detail.ownsign)
+ ;
+ }
+ }
+ break;
+
+ }
+ }
+
+
+ return QVariant();
+}
+
+/*void pgpid_item_model::sort(int column, Qt::SortOrder order)
+{
+
+} */
+
+
+//following code is just a poc, it's still suboptimal, unefficient, but much better then existing rs code
+
+void pgpid_item_model::data_updated(std::list<RsPgpId> &new_neighs)
+{
+
+ //shit code follow (rewrite this please)
+ size_t old_size = neighs.size(), new_size = 0;
+ std::list<RsPgpId> old_neighs = neighs;
+
+ //find all bad elements in list
+ std::list<RsPgpId> bad_elements;
+ for(std::list<RsPgpId>::iterator it = new_neighs.begin(); it != new_neighs.end(); ++it)
+ {
+ if (*it == rsPeers->getGPGOwnId())
+ bad_elements.push_back(*it);
+ RsPeerDetails detail;
+ if (!rsPeers->getGPGDetails(*it, detail))
+ bad_elements.push_back(*it);
+
+ }
+ //remove all bad elements from list
+ for(std::list<RsPgpId>::iterator it = bad_elements.begin(); it != bad_elements.end(); ++it)
+ {
+ std::list<RsPgpId>::iterator it2 = std::find(new_neighs.begin(), new_neighs.end(), *it);
+ if(it2 != new_neighs.end())
+ new_neighs.remove(*it2);
+ }
+ new_size = new_neighs.size();
+ //set model data to new cleaned up data
+ neighs = new_neighs;
+
+ //reflect actual row count in model
+ if(old_size < new_size)
+ {
+ beginInsertRows(QModelIndex(), old_size - 1, old_size - 1 + new_size - old_size);
+ insertRows(old_size - 1 , new_size - old_size);
+ endInsertRows();
+ }
+ else if(new_size < old_size)
+ {
+ beginRemoveRows(QModelIndex(), new_size - 1, new_size - 1 + old_size - new_size);
+ removeRows(old_size - 1, old_size - new_size);
+ endRemoveRows();
+ }
+ //update data in ui, to avoid unnecessary redraw and ui updates, updating only changed elements
+ //i guessing what order is unchanged between rsPeers->getGPGAllList() calls
+ //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();
+ }
+
+ //shit code end
+}
+
diff --git a/retroshare-gui/src/gui/NetworkDialog/pgpid_item_model.h b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_model.h
new file mode 100644
index 000000000..84bae523b
--- /dev/null
+++ b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_model.h
@@ -0,0 +1,48 @@
+#ifndef KEY_ITEM_MODEL_H
+#define KEY_ITEM_MODEL_H
+
+#include <QAbstractItemModel>
+#include <retroshare/rspeers.h>
+
+#define COLUMN_CHECK 0
+#define COLUMN_PEERNAME 1
+#define COLUMN_I_AUTH_PEER 2
+#define COLUMN_PEER_AUTH_ME 3
+#define COLUMN_PEERID 4
+#define COLUMN_LAST_USED 5
+#define COLUMN_COUNT 6
+
+
+class pgpid_item_model : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ explicit pgpid_item_model(std::list<RsPgpId> &neighs, float &font_height, QObject *parent = nullptr);
+
+ // Header:
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
+
+ // Basic functionality:
+// QModelIndex index(int row, int column,
+// const QModelIndex &parent = QModelIndex()) const override;
+// QModelIndex parent(const QModelIndex &index) const override;
+// bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+// bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex()) override;
+// bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex()) override;
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+
+// void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
+public slots:
+ void data_updated(std::list<RsPgpId> &new_neighs);
+
+private:
+ std::list<RsPgpId> &neighs;
+ float &font_height;
+};
+
+#endif // KEY_ITEM_MODEL_H
diff --git a/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.cpp b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.cpp
new file mode 100644
index 000000000..5df377f5a
--- /dev/null
+++ b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.cpp
@@ -0,0 +1,91 @@
+#include "pgpid_item_proxy.h"
+
+//TODO: include only required headers here
+#include <retroshare/rsiface.h>
+#include <retroshare/rspeers.h>
+#include <retroshare/rsdisc.h>
+#include <retroshare/rsmsgs.h>
+
+
+//TODO: set this defines in one place
+// Defines for key list columns
+#define COLUMN_CHECK 0
+#define COLUMN_PEERNAME 1
+#define COLUMN_I_AUTH_PEER 2
+#define COLUMN_PEER_AUTH_ME 3
+#define COLUMN_PEERID 4
+#define COLUMN_LAST_USED 5
+#define COLUMN_COUNT 6
+
+
+
+pgpid_item_proxy::pgpid_item_proxy(QObject *parent) :
+ //QAbstractProxyModel(parent)
+ QSortFilterProxyModel(parent)
+{
+
+}
+
+
+/*QModelIndex pgpid_item_proxy::mapFromSource(const QModelIndex &sourceIndex) const
+{
+ if(sourceIndex.isValid())
+ return createIndex(sourceIndex.row(), sourceIndex.column(), sourceIndex.internalPointer());
+ else
+ return QModelIndex();
+}
+
+
+QModelIndex pgpid_item_proxy::mapToSource(const QModelIndex &proxyIndex) const
+{
+ if(proxyIndex.isValid())
+ return sourceModel()->index(proxyIndex.row(), proxyIndex.column());
+ else
+ return QModelIndex();}
+
+
+QModelIndex pgpid_item_proxy::index(int row, int column, const QModelIndex &parent) const
+{
+ const QModelIndex sourceParent = mapToSource(parent);
+ const QModelIndex sourceIndex = sourceModel()->index(row, column, sourceParent);
+ return mapFromSource(sourceIndex);
+}
+
+QModelIndex pgpid_item_proxy::parent(const QModelIndex &child) const
+{
+ const QModelIndex sourceIndex = mapToSource(child);
+ const QModelIndex sourceParent = sourceIndex.parent();
+ return mapFromSource(sourceParent);
+}
+int pgpid_item_proxy::rowCount(const QModelIndex &parent) const
+{
+ //TODO:
+ return sourceModel()->rowCount(parent);
+}
+int pgpid_item_proxy::columnCount(const QModelIndex &parent) const
+{
+ return sourceModel()->columnCount(parent);
+}
+*/
+
+void pgpid_item_proxy::use_only_trusted_keys(bool val)
+{
+ only_trusted_keys = val;
+ filterChanged();
+}
+
+bool pgpid_item_proxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
+{
+ if(only_trusted_keys)
+ {
+ if(!rsPeers)
+ return false;
+ RsPgpId peer_id (sourceModel()->data(sourceModel()->index(sourceRow, COLUMN_PEERID, sourceParent)).toString().toStdString());
+ RsPeerDetails details;
+ if(!rsPeers->getGPGDetails(peer_id, details))
+ return false;
+ if(details.validLvl < RS_TRUST_LVL_MARGINAL)
+ return false;
+ }
+ return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
+}
diff --git a/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.h b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.h
new file mode 100644
index 000000000..5713ad7c9
--- /dev/null
+++ b/retroshare-gui/src/gui/NetworkDialog/pgpid_item_proxy.h
@@ -0,0 +1,29 @@
+#ifndef PGPID_ITEM_PROXY_H
+#define PGPID_ITEM_PROXY_H
+
+#include <QSortFilterProxyModel>
+
+class pgpid_item_proxy :
+ //public QAbstractProxyModel
+ public QSortFilterProxyModel
+{
+ Q_OBJECT
+
+public:
+ pgpid_item_proxy(QObject *parent = nullptr);
+/* virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
+ QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex parent(const QModelIndex &child) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+*/
+ bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
+public slots:
+ void use_only_trusted_keys(bool val);
+
+private:
+ bool only_trusted_keys = false;
+};
+
+#endif // PGPID_ITEM_PROXY_H
diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp
index 2430a1984..8dfa43c48 100644
--- a/retroshare-gui/src/main.cpp
+++ b/retroshare-gui/src/main.cpp
@@ -416,7 +416,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool)));
QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus()));
- QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->friendsDialog->networkDialog,SLOT(setLogInfo(QString))) ;
+// QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->friendsDialog->networkDialog,SLOT(setLogInfo(QString))) ;
QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->friendsDialog->networkView,SLOT(update()),Qt::QueuedConnection) ;
QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ;
diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro
index b7bc361ce..6c4c821d1 100644
--- a/retroshare-gui/src/retroshare-gui.pro
+++ b/retroshare-gui/src/retroshare-gui.pro
@@ -565,7 +565,9 @@ HEADERS += rshare.h \
gui/GetStartedDialog.h \
gui/statistics/BWGraph.h \
util/RsSyntaxHighlighter.h \
- util/imageutil.h
+ util/imageutil.h \
+ gui/NetworkDialog/pgpid_item_model.h \
+ gui/NetworkDialog/pgpid_item_proxy.h
# gui/ForumsDialog.h \
# gui/forums/ForumDetails.h \
@@ -925,7 +927,9 @@ SOURCES += main.cpp \
gui/statistics/RttStatistics.cpp \
gui/statistics/BWGraph.cpp \
util/RsSyntaxHighlighter.cpp \
- util/imageutil.cpp
+ util/imageutil.cpp \
+ gui/NetworkDialog/pgpid_item_model.cpp \
+ gui/NetworkDialog/pgpid_item_proxy.cpp
# gui/ForumsDialog.cpp \
# gui/forums/ForumDetails.cpp \
|