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
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
|
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at info@qt.nokia.com.
**
**************************************************************************/
#include "perforceplugin.h"
#include "changenumberdialog.h"
#include "pendingchangesdialog.h"
#include "perforceconstants.h"
#include "perforceeditor.h"
#include "perforcesubmiteditor.h"
#include "perforceversioncontrol.h"
#include "perforcechecker.h"
#include "settingspage.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/filemanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h>
#include <coreplugin/mimedatabase.h>
#include <locator/commandlocator.h>
#include <utils/qtcassert.h>
#include <utils/synchronousprocess.h>
#include <utils/parameteraction.h>
#include <utils/fileutils.h>
#include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/vcsbaseoutputwindow.h>
#include <vcsbase/vcsbaseeditorparameterwidget.h>
#include <QtCore/QtPlugin>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QSettings>
#include <QtCore/QTextCodec>
#include <QtGui/QAction>
#include <QtGui/QFileDialog>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QMessageBox>
static const VCSBase::VCSBaseEditorParameters editorParameters[] = {
{
VCSBase::RegularCommandOutput,
Perforce::Constants::PERFORCE_COMMANDLOG_EDITOR_ID,
Perforce::Constants::PERFORCE_COMMANDLOG_EDITOR_DISPLAY_NAME,
Perforce::Constants::PERFORCE_COMMANDLOG_EDITOR_CONTEXT,
"application/vnd.nokia.text.scs_commandlog",
"scslog"},
{ VCSBase::LogOutput,
Perforce::Constants::PERFORCE_LOG_EDITOR_ID,
Perforce::Constants::PERFORCE_LOG_EDITOR_DISPLAY_NAME,
Perforce::Constants::PERFORCE_LOG_EDITOR_CONTEXT,
"application/vnd.nokia.text.scs_filelog",
"scsfilelog"},
{ VCSBase::AnnotateOutput,
Perforce::Constants::PERFORCE_ANNOTATION_EDITOR_ID,
Perforce::Constants::PERFORCE_ANNOTATION_EDITOR_DISPLAY_NAME,
Perforce::Constants::PERFORCE_ANNOTATION_EDITOR_CONTEXT,
"application/vnd.nokia.text.scs_annotation",
"scsannotate"},
{ VCSBase::DiffOutput,
Perforce::Constants::PERFORCE_DIFF_EDITOR_ID,
Perforce::Constants::PERFORCE_DIFF_EDITOR_DISPLAY_NAME,
Perforce::Constants::PERFORCE_DIFF_EDITOR_CONTEXT,
"text/x-patch","diff"}
};
// Utility to find a parameter set by type
static inline const VCSBase::VCSBaseEditorParameters *findType(int ie)
{
const VCSBase::EditorContentType et = static_cast<VCSBase::EditorContentType>(ie);
return VCSBase::VCSBaseEditorWidget::findType(editorParameters, sizeof(editorParameters)/sizeof(VCSBase::VCSBaseEditorParameters), et);
}
static inline QString debugCodec(const QTextCodec *c)
{
return c ? QString::fromAscii(c->name()) : QString::fromAscii("Null codec");
}
// Ensure adding "..." to relative paths which is p4's convention
// for the current directory
static inline QStringList perforceRelativeFileArguments(const QStringList &args)
{
if (args.isEmpty())
return QStringList(QLatin1String("..."));
QTC_ASSERT(args.size() == 1, return QStringList())
QStringList p4Args = args;
p4Args.front() += QLatin1String("/...");
return p4Args;
}
static inline QStringList perforceRelativeProjectDirectory(const VCSBase::VCSBasePluginState &s)
{
return perforceRelativeFileArguments(s.relativeCurrentProject());
}
// Clean user setting off diff-binary for 'p4 resolve' and 'p4 diff'.
static inline QProcessEnvironment overrideDiffEnvironmentVariable()
{
QProcessEnvironment rc = QProcessEnvironment::systemEnvironment();
rc.remove(QLatin1String("P4DIFF"));
return rc;
}
static const char CMD_ID_PERFORCE_MENU[] = "Perforce.Menu";
static const char CMD_ID_EDIT[] = "Perforce.Edit";
static const char CMD_ID_ADD[] = "Perforce.Add";
static const char CMD_ID_DELETE_FILE[] = "Perforce.Delete";
static const char CMD_ID_OPENED[] = "Perforce.Opened";
static const char CMD_ID_PROJECTLOG[] = "Perforce.ProjectLog";
static const char CMD_ID_REPOSITORYLOG[] = "Perforce.RepositoryLog";
static const char CMD_ID_REVERT[] = "Perforce.Revert";
static const char CMD_ID_DIFF_CURRENT[] = "Perforce.DiffCurrent";
static const char CMD_ID_DIFF_PROJECT[] = "Perforce.DiffProject";
static const char CMD_ID_UPDATE_PROJECT[] = "Perforce.UpdateProject";
static const char CMD_ID_REVERT_PROJECT[] = "Perforce.RevertProject";
static const char CMD_ID_REVERT_UNCHANGED_PROJECT[] = "Perforce.RevertUnchangedProject";
static const char CMD_ID_DIFF_ALL[] = "Perforce.DiffAll";
static const char CMD_ID_RESOLVE[] = "Perforce.Resolve";
static const char CMD_ID_SUBMIT[] = "Perforce.Submit";
static const char CMD_ID_PENDING_CHANGES[] = "Perforce.PendingChanges";
static const char CMD_ID_DESCRIBE[] = "Perforce.Describe";
static const char CMD_ID_ANNOTATE_CURRENT[] = "Perforce.AnnotateCurrent";
static const char CMD_ID_ANNOTATE[] = "Perforce.Annotate";
static const char CMD_ID_FILELOG_CURRENT[] = "Perforce.FilelogCurrent";
static const char CMD_ID_FILELOG[] = "Perforce.Filelog";
static const char CMD_ID_UPDATEALL[] = "Perforce.UpdateAll";
static const char CMD_ID_SEPARATOR1[] = "Perforce.Separator1";
static const char CMD_ID_SEPARATOR2[] = "Perforce.Separator2";
static const char CMD_ID_SEPARATOR3[] = "Perforce.Separator3";
////
// PerforcePlugin
////
namespace Perforce {
namespace Internal {
PerforceResponse::PerforceResponse() :
error(true),
exitCode(-1)
{
}
PerforcePlugin *PerforcePlugin::m_perforcePluginInstance = NULL;
PerforcePlugin::PerforcePlugin() :
VCSBase::VCSBasePlugin(QLatin1String(Constants::PERFORCE_SUBMIT_EDITOR_ID)),
m_commandLocator(0),
m_editAction(0),
m_addAction(0),
m_deleteAction(0),
m_openedAction(0),
m_revertFileAction(0),
m_diffFileAction(0),
m_diffProjectAction(0),
m_updateProjectAction(0),
m_revertProjectAction(0),
m_revertUnchangedAction(0),
m_diffAllAction(0),
m_submitProjectAction(0),
m_pendingAction(0),
m_describeAction(0),
m_annotateCurrentAction(0),
m_annotateAction(0),
m_filelogCurrentAction(0),
m_filelogAction(0),
m_logProjectAction(0),
m_logRepositoryAction(0),
m_submitCurrentLogAction(0),
m_updateAllAction(0),
m_submitActionTriggered(false),
m_diffSelectedFiles(0),
m_undoAction(0),
m_redoAction(0)
{
}
static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = {
Perforce::Constants::SUBMIT_MIMETYPE,
Perforce::Constants::PERFORCE_SUBMIT_EDITOR_ID,
Perforce::Constants::PERFORCE_SUBMIT_EDITOR_DISPLAY_NAME,
Perforce::Constants::PERFORCESUBMITEDITOR_CONTEXT
};
static inline Core::Command *createSeparator(QObject *parent,
Core::ActionManager *ami,
const char *id,
const Core::Context &globalcontext)
{
QAction *tmpaction = new QAction(parent);
tmpaction->setSeparator(true);
return ami->registerAction(tmpaction, id, globalcontext);
}
bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *errorMessage)
{
typedef VCSBase::VCSEditorFactory<PerforceEditor> PerforceEditorFactory;
typedef VCSBase::VCSSubmitEditorFactory<PerforceSubmitEditor> PerforceSubmitEditorFactory;
VCSBase::VCSBasePlugin::initialize(new PerforceVersionControl(this));
Core::ICore *core = Core::ICore::instance();
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/trolltech.perforce/Perforce.mimetypes.xml"), errorMessage))
return false;
m_perforcePluginInstance = this;
if (QSettings *settings = core->settings())
m_settings.fromSettings(settings);
addAutoReleasedObject(new SettingsPage);
// Editor factories
addAutoReleasedObject(new PerforceSubmitEditorFactory(&submitParameters));
static const char *describeSlot = SLOT(describe(QString,QString));
const int editorCount = sizeof(editorParameters)/sizeof(VCSBase::VCSBaseEditorParameters);
for (int i = 0; i < editorCount; i++)
addAutoReleasedObject(new PerforceEditorFactory(editorParameters + i, this, describeSlot));
const QString prefix = QLatin1String("p4");
m_commandLocator = new Locator::CommandLocator(QLatin1String("Perforce"), prefix, prefix);
addAutoReleasedObject(m_commandLocator);
//register actions
Core::ActionManager *am = Core::ICore::instance()->actionManager();
Core::ActionContainer *mtools =
am->actionContainer(Core::Constants::M_TOOLS);
Core::ActionContainer *mperforce =
am->createMenu(Core::Id(CMD_ID_PERFORCE_MENU));
mperforce->menu()->setTitle(tr("&Perforce"));
mtools->addMenu(mperforce);
m_menuAction = mperforce->menu()->menuAction();
Core::Context globalcontext(Core::Constants::C_GLOBAL);
Core::Context perforcesubmitcontext(Constants::PERFORCESUBMITEDITOR_CONTEXT);
Core::Command *command;
m_diffFileAction = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_diffFileAction, CMD_ID_DIFF_CURRENT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultText(tr("Diff Current File"));
connect(m_diffFileAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
m_annotateCurrentAction = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_annotateCurrentAction, CMD_ID_ANNOTATE_CURRENT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultText(tr("Annotate Current File"));
connect(m_annotateCurrentAction, SIGNAL(triggered()), this, SLOT(annotateCurrentFile()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
m_filelogCurrentAction = new Utils::ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_filelogCurrentAction, CMD_ID_FILELOG_CURRENT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+F")));
command->setDefaultText(tr("Filelog Current File"));
connect(m_filelogCurrentAction, SIGNAL(triggered()), this, SLOT(filelogCurrentFile()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
mperforce->addAction(createSeparator(this, am, "Perforce.Sep.Edit", globalcontext));
m_editAction = new Utils::ParameterAction(tr("Edit"), tr("Edit \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_editAction, CMD_ID_EDIT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+E")));
command->setDefaultText(tr("Edit File"));
connect(m_editAction, SIGNAL(triggered()), this, SLOT(openCurrentFile()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
m_addAction = new Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_addAction, CMD_ID_ADD, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+A")));
command->setDefaultText(tr("Add File"));
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_deleteAction, CMD_ID_DELETE_FILE, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultText(tr("Delete File"));
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
m_revertFileAction = new Utils::ParameterAction(tr("Revert"), tr("Revert \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_revertFileAction, CMD_ID_REVERT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+R")));
command->setDefaultText(tr("Revert File"));
connect(m_revertFileAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
mperforce->addAction(createSeparator(this, am, "Perforce.Sep.Project", globalcontext));
const QString diffProjectDefaultText = tr("Diff Current Project/Session");
m_diffProjectAction = new Utils::ParameterAction(diffProjectDefaultText, tr("Diff Project \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
command = am->registerAction(m_diffProjectAction, CMD_ID_DIFF_PROJECT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+D")));
command->setDefaultText(diffProjectDefaultText);
connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffCurrentProject()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
m_logProjectAction = new Utils::ParameterAction(tr("Log Project"), tr("Log Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_logProjectAction, CMD_ID_PROJECTLOG, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
connect(m_logProjectAction, SIGNAL(triggered()), this, SLOT(logProject()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
m_submitProjectAction = new Utils::ParameterAction(tr("Submit Project"), tr("Submit Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_submitProjectAction, CMD_ID_SUBMIT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+S")));
connect(m_submitProjectAction, SIGNAL(triggered()), this, SLOT(startSubmitProject()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
const QString updateProjectDefaultText = tr("Update Current Project");
m_updateProjectAction = new Utils::ParameterAction(updateProjectDefaultText, tr("Update Project \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
command = am->registerAction(m_updateProjectAction, CMD_ID_UPDATE_PROJECT, globalcontext);
command->setDefaultText(updateProjectDefaultText);
command->setAttribute(Core::Command::CA_UpdateText);
connect(m_updateProjectAction, SIGNAL(triggered()), this, SLOT(updateCurrentProject()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
m_revertUnchangedAction = new Utils::ParameterAction(tr("Revert Unchanged"), tr("Revert Unchanged Files of Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_revertUnchangedAction, CMD_ID_REVERT_UNCHANGED_PROJECT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
connect(m_revertUnchangedAction, SIGNAL(triggered()), this, SLOT(revertUnchangedCurrentProject()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
m_revertProjectAction = new Utils::ParameterAction(tr("Revert Project"), tr("Revert Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = am->registerAction(m_revertProjectAction, CMD_ID_REVERT_PROJECT, globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
connect(m_revertProjectAction, SIGNAL(triggered()), this, SLOT(revertCurrentProject()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
mperforce->addAction(createSeparator(this, am, "Perforce.Sep.Repository", globalcontext));
m_diffAllAction = new QAction(tr("Diff Opened Files"), this);
command = am->registerAction(m_diffAllAction, CMD_ID_DIFF_ALL, globalcontext);
connect(m_diffAllAction, SIGNAL(triggered()), this, SLOT(diffAllOpened()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
m_openedAction = new QAction(tr("Opened"), this);
command = am->registerAction(m_openedAction, CMD_ID_OPENED, globalcontext);
command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+O")));
connect(m_openedAction, SIGNAL(triggered()), this, SLOT(printOpenedFileList()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
m_logRepositoryAction = new QAction(tr("Repository Log"), this);
command = am->registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, globalcontext);
connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
m_pendingAction = new QAction(tr("Pending Changes..."), this);
command = am->registerAction(m_pendingAction, CMD_ID_PENDING_CHANGES, globalcontext);
connect(m_pendingAction, SIGNAL(triggered()), this, SLOT(printPendingChanges()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
m_updateAllAction = new QAction(tr("Update All"), this);
command = am->registerAction(m_updateAllAction, CMD_ID_UPDATEALL, globalcontext);
connect(m_updateAllAction, SIGNAL(triggered()), this, SLOT(updateAll()));
mperforce->addAction(command);
m_commandLocator->appendCommand(command);
mperforce->addAction(createSeparator(this, am, "Perforce.Sep.Dialogs", globalcontext));
m_describeAction = new QAction(tr("Describe..."), this);
command = am->registerAction(m_describeAction, CMD_ID_DESCRIBE, globalcontext);
connect(m_describeAction, SIGNAL(triggered()), this, SLOT(describeChange()));
mperforce->addAction(command);
m_annotateAction = new QAction(tr("Annotate..."), this);
command = am->registerAction(m_annotateAction, CMD_ID_ANNOTATE, globalcontext);
connect(m_annotateAction, SIGNAL(triggered()), this, SLOT(annotate()));
mperforce->addAction(command);
m_filelogAction = new QAction(tr("Filelog..."), this);
command = am->registerAction(m_filelogAction, CMD_ID_FILELOG, globalcontext);
connect(m_filelogAction, SIGNAL(triggered()), this, SLOT(filelog()));
mperforce->addAction(command);
m_submitCurrentLogAction = new QAction(VCSBase::VCSBaseSubmitEditor::submitIcon(), tr("Submit"), this);
command = am->registerAction(m_submitCurrentLogAction, Constants::SUBMIT_CURRENT, perforcesubmitcontext);
command->setAttribute(Core::Command::CA_UpdateText);
connect(m_submitCurrentLogAction, SIGNAL(triggered()), this, SLOT(submitCurrentLog()));
m_diffSelectedFiles = new QAction(VCSBase::VCSBaseSubmitEditor::diffIcon(), tr("Diff &Selected Files"), this);
command = am->registerAction(m_diffSelectedFiles, Constants::DIFF_SELECTED, perforcesubmitcontext);
m_undoAction = new QAction(tr("&Undo"), this);
command = am->registerAction(m_undoAction, Core::Constants::UNDO, perforcesubmitcontext);
m_redoAction = new QAction(tr("&Redo"), this);
command = am->registerAction(m_redoAction, Core::Constants::REDO, perforcesubmitcontext);
return true;
}
void PerforcePlugin::extensionsInitialized()
{
VCSBase::VCSBasePlugin::extensionsInitialized();
getTopLevel();
}
void PerforcePlugin::openCurrentFile()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return)
vcsOpen(state.currentFileTopLevel(), state.relativeCurrentFile());
}
void PerforcePlugin::addCurrentFile()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return)
vcsAdd(state.currentFileTopLevel(), state.relativeCurrentFile());
}
void PerforcePlugin::revertCurrentFile()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return)
QTextCodec *codec = VCSBase::VCSBaseEditorWidget::getCodec(state.currentFile());
QStringList args;
args << QLatin1String("diff") << QLatin1String("-sa") << state.relativeCurrentFile();
PerforceResponse result = runP4Cmd(state.currentFileTopLevel(), args,
RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow,
QStringList(), QByteArray(), codec);
if (result.error)
return;
// "foo.cpp - file(s) not opened on this client."
if (result.stdOut.isEmpty() || result.stdOut.contains(QLatin1String(" - ")))
return;
const bool doNotRevert = QMessageBox::warning(0, tr("p4 revert"),
tr("The file has been changed. Do you want to revert it?"),
QMessageBox::Yes, QMessageBox::No) == QMessageBox::No;
if (doNotRevert)
return;
Core::FileChangeBlocker fcb(state.currentFile());
args.clear();
args << QLatin1String("revert") << state.relativeCurrentFile();
PerforceResponse result2 = runP4Cmd(state.currentFileTopLevel(), args,
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
if (!result2.error)
perforceVersionControl()->emitFilesChanged(QStringList(state.currentFile()));
}
void PerforcePlugin::diffCurrentFile()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return)
p4Diff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
}
void PerforcePlugin::diffCurrentProject()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return)
p4Diff(state.currentProjectTopLevel(), perforceRelativeProjectDirectory(state));
}
void PerforcePlugin::diffAllOpened()
{
p4Diff(m_settings.topLevel(), QStringList());
}
void PerforcePlugin::updateCurrentProject()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return)
updateCheckout(state.currentProjectTopLevel(), perforceRelativeProjectDirectory(state));
}
void PerforcePlugin::updateAll()
{
updateCheckout(m_settings.topLevel());
}
void PerforcePlugin::revertCurrentProject()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return)
const QString msg = tr("Do you want to revert all changes to the project \"%1\"?").arg(state.currentProjectName());
if (QMessageBox::warning(0, tr("p4 revert"), msg, QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
return;
revertProject(state.currentProjectTopLevel(), perforceRelativeProjectDirectory(state), false);
}
void PerforcePlugin::revertUnchangedCurrentProject()
{
// revert -a.
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return)
revertProject(state.currentProjectTopLevel(), perforceRelativeProjectDirectory(state), true);
}
bool PerforcePlugin::revertProject(const QString &workingDir, const QStringList &pathArgs, bool unchangedOnly)
{
QStringList args(QLatin1String("revert"));
if (unchangedOnly)
args.push_back(QLatin1String("-a"));
args.append(pathArgs);
const PerforceResponse resp = runP4Cmd(workingDir, args,
RunFullySynchronous|CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
return !resp.error;
}
void PerforcePlugin::updateCheckout(const QString &workingDir, const QStringList &dirs)
{
QStringList args(QLatin1String("sync"));
args.append(dirs);
const PerforceResponse resp = runP4Cmd(workingDir, args,
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
if (dirs.empty()) {
if (!workingDir.isEmpty())
perforceVersionControl()->emitRepositoryChanged(workingDir);
} else {
const QChar slash = QLatin1Char('/');
foreach(const QString &dir, dirs)
perforceVersionControl()->emitRepositoryChanged(workingDir + slash + dir);
}
}
void PerforcePlugin::printOpenedFileList()
{
const PerforceResponse perforceResponse
= runP4Cmd(m_settings.topLevel(), QStringList(QLatin1String("opened")),
CommandToWindow|StdErrToWindow|ErrorToWindow);
if (perforceResponse.error || perforceResponse.stdOut.isEmpty())
return;
// reformat "//depot/file.cpp#1 - description" into "file.cpp # - description"
// for context menu opening to work. This produces absolute paths, then.
VCSBase::VCSBaseOutputWindow *outWin = VCSBase::VCSBaseOutputWindow::instance();
QString errorMessage;
QString mapped;
const QChar delimiter = QLatin1Char('#');
foreach (const QString &line, perforceResponse.stdOut.split(QLatin1Char('\n'))) {
mapped.clear();
const int delimiterPos = line.indexOf(delimiter);
if (delimiterPos > 0)
mapped = fileNameFromPerforceName(line.left(delimiterPos), true, &errorMessage);
if (mapped.isEmpty()) {
outWin->appendSilently(line);
} else {
outWin->appendSilently(mapped + QLatin1Char(' ') + line.mid(delimiterPos));
}
}
outWin->popup();
}
void PerforcePlugin::startSubmitProject()
{
if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor())
return;
if (isCommitEditorOpen()) {
VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Another submit is currently executed."));
return;
}
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return)
// Revert all unchanged files.
if (!revertProject(state.currentProjectTopLevel(), perforceRelativeProjectDirectory(state), true))
return;
// Start a change
QStringList args;
args << QLatin1String("change") << QLatin1String("-o");
PerforceResponse result = runP4Cmd(state.currentProjectTopLevel(), args,
RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow);
if (result.error) {
cleanCommitMessageFile();
return;
}
Utils::TempFileSaver saver;
saver.setAutoRemove(false);
saver.write(result.stdOut.toAscii());
if (!saver.finalize()) {
VCSBase::VCSBaseOutputWindow::instance()->appendError(saver.errorString());
cleanCommitMessageFile();
return;
}
m_commitMessageFileName = saver.fileName();
args.clear();
args << QLatin1String("fstat");
args.append(perforceRelativeProjectDirectory(state));
PerforceResponse fstatResult = runP4Cmd(state.currentProjectTopLevel(), args,
RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow);
if (fstatResult.error) {
cleanCommitMessageFile();
return;
}
QStringList fstatLines = fstatResult.stdOut.split(QLatin1Char('\n'));
QStringList depotFileNames;
foreach (const QString &line, fstatLines) {
if (line.startsWith(QLatin1String("... depotFile")))
depotFileNames.append(line.mid(14));
}
if (depotFileNames.isEmpty()) {
VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Project has no files"));
cleanCommitMessageFile();
return;
}
openPerforceSubmitEditor(m_commitMessageFileName, depotFileNames);
}
Core::IEditor *PerforcePlugin::openPerforceSubmitEditor(const QString &fileName, const QStringList &depotFileNames)
{
Core::EditorManager *editorManager = Core::EditorManager::instance();
Core::IEditor *editor = editorManager->openEditor(fileName, Constants::PERFORCE_SUBMIT_EDITOR_ID,
Core::EditorManager::ModeSwitch);
PerforceSubmitEditor *submitEditor = static_cast<PerforceSubmitEditor*>(editor);
submitEditor->restrictToProjectFiles(depotFileNames);
submitEditor->registerActions(m_undoAction, m_redoAction, m_submitCurrentLogAction, m_diffSelectedFiles);
connect(submitEditor, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(slotSubmitDiff(QStringList)));
submitEditor->setCheckScriptWorkingDirectory(m_commitWorkingDirectory);
return editor;
}
void PerforcePlugin::printPendingChanges()
{
qApp->setOverrideCursor(Qt::WaitCursor);
PendingChangesDialog dia(pendingChangesData(), Core::ICore::instance()->mainWindow());
qApp->restoreOverrideCursor();
if (dia.exec() == QDialog::Accepted) {
const int i = dia.changeNumber();
QStringList args(QLatin1String("submit"));
args << QLatin1String("-c") << QString::number(i);
runP4Cmd(m_settings.topLevel(), args,
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
}
}
void PerforcePlugin::describeChange()
{
ChangeNumberDialog dia;
if (dia.exec() == QDialog::Accepted && dia.number() > 0)
describe(QString(), QString::number(dia.number()));
}
void PerforcePlugin::annotateCurrentFile()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return)
annotate(state.currentFileTopLevel(), state.relativeCurrentFile());
}
void PerforcePlugin::annotate()
{
const QString file = QFileDialog::getOpenFileName(0, tr("p4 annotate"));
if (!file.isEmpty()) {
const QFileInfo fi(file);
annotate(fi.absolutePath(), fi.fileName());
}
}
void PerforcePlugin::vcsAnnotate(const QString &file, const QString &revision, int lineNumber)
{
const QFileInfo fi(file);
annotate(fi.absolutePath(), fi.fileName(), revision, lineNumber);
}
void PerforcePlugin::annotate(const QString &workingDir,
const QString &fileName,
const QString &changeList /* = QString() */,
int lineNumber /* = -1 */)
{
const QStringList files = QStringList(fileName);
QTextCodec *codec = VCSBase::VCSBaseEditorWidget::getCodec(workingDir, files);
const QString id = VCSBase::VCSBaseEditorWidget::getTitleId(workingDir, files, changeList);
const QString source = VCSBase::VCSBaseEditorWidget::getSource(workingDir, files);
QStringList args;
args << QLatin1String("annotate") << QLatin1String("-cqi");
if (changeList.isEmpty()) {
args << fileName;
} else {
args << (fileName + QLatin1Char('@') + changeList);
}
const PerforceResponse result = runP4Cmd(workingDir, args,
CommandToWindow|StdErrToWindow|ErrorToWindow,
QStringList(), QByteArray(), codec);
if (!result.error) {
if (lineNumber < 1)
lineNumber = VCSBase::VCSBaseEditorWidget::lineNumberOfCurrentEditor();
const QFileInfo fi(fileName);
Core::IEditor *ed = showOutputInEditor(tr("p4 annotate %1").arg(id),
result.stdOut, VCSBase::AnnotateOutput,
source, codec);
VCSBase::VCSBaseEditorWidget::gotoLineOfEditor(ed, lineNumber);
}
}
void PerforcePlugin::filelogCurrentFile()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return)
filelog(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()), true);
}
void PerforcePlugin::filelog()
{
const QString file = QFileDialog::getOpenFileName(0, tr("p4 filelog"));
if (!file.isEmpty()) {
const QFileInfo fi(file);
filelog(fi.absolutePath(), QStringList(fi.fileName()));
}
}
void PerforcePlugin::logProject()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return)
filelog(state.currentProjectTopLevel(), perforceRelativeFileArguments(state.relativeCurrentProject()));
}
void PerforcePlugin::logRepository()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return)
filelog(state.topLevel(), perforceRelativeFileArguments(QStringList()));
}
void PerforcePlugin::filelog(const QString &workingDir, const QStringList &fileNames,
bool enableAnnotationContextMenu)
{
const QString id = VCSBase::VCSBaseEditorWidget::getTitleId(workingDir, fileNames);
QTextCodec *codec = VCSBase::VCSBaseEditorWidget::getCodec(workingDir, fileNames);
QStringList args;
args << QLatin1String("filelog") << QLatin1String("-li");
if (m_settings.logCount() > 0)
args << QLatin1String("-m") << QString::number(m_settings.logCount());
args.append(fileNames);
const PerforceResponse result = runP4Cmd(workingDir, args,
CommandToWindow|StdErrToWindow|ErrorToWindow,
QStringList(), QByteArray(), codec);
if (!result.error) {
const QString source = VCSBase::VCSBaseEditorWidget::getSource(workingDir, fileNames);
Core::IEditor *editor = showOutputInEditor(tr("p4 filelog %1").arg(id), result.stdOut,
VCSBase::LogOutput, source, codec);
if (enableAnnotationContextMenu)
VCSBase::VCSBaseEditorWidget::getVcsBaseEditor(editor)->setFileLogAnnotateEnabled(true);
}
}
void PerforcePlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
{
if (!enableMenuAction(as, m_menuAction)) {
m_commandLocator->setEnabled(false);
return;
}
const bool hasTopLevel = currentState().hasTopLevel();
m_commandLocator->setEnabled(hasTopLevel);
m_logRepositoryAction->setEnabled(hasTopLevel);
const QString fileName = currentState().currentFileName();
m_editAction->setParameter(fileName);
m_addAction->setParameter(fileName);
m_deleteAction->setParameter(fileName);
m_revertFileAction->setParameter(fileName);
m_diffFileAction->setParameter(fileName);
m_annotateCurrentAction->setParameter(fileName);
m_filelogCurrentAction->setParameter(fileName);
const QString projectName = currentState().currentProjectName();
m_logProjectAction->setParameter(projectName);
m_updateProjectAction->setParameter(projectName);
m_diffProjectAction->setParameter(projectName);
m_submitProjectAction->setParameter(projectName);
m_revertProjectAction->setParameter(projectName);
m_revertUnchangedAction->setParameter(projectName);
m_diffAllAction->setEnabled(true);
m_openedAction->setEnabled(true);
m_describeAction->setEnabled(true);
m_annotateAction->setEnabled(true);
m_filelogAction->setEnabled(true);
m_pendingAction->setEnabled(true);
m_updateAllAction->setEnabled(true);
}
bool PerforcePlugin::managesDirectory(const QString &directory, QString *topLevel /* = 0 */)
{
const bool rc = managesDirectoryFstat(directory);
if (topLevel) {
if (rc) {
*topLevel = m_settings.topLevelSymLinkTarget();
} else {
topLevel->clear();
}
}
return rc;
}
bool PerforcePlugin::managesDirectoryFstat(const QString &directory)
{
if (!m_settings.isValid())
return false;
// Cached?
const ManagedDirectoryCache::const_iterator cit = m_managedDirectoryCache.constFind(directory);
if (cit != m_managedDirectoryCache.constEnd())
return cit.value();
// Determine value and insert into cache
bool managed = false;
do {
// Quick check: Must be at or below top level and not "../../other_path"
const QStringList relativeDirArgs = m_settings.relativeToTopLevelArguments(directory);
if (!relativeDirArgs.empty() && relativeDirArgs.front().startsWith(QLatin1String("..")))
break;
// Is it actually managed by perforce?
QStringList args;
args << QLatin1String("fstat") << QLatin1String("-m1") << perforceRelativeFileArguments(relativeDirArgs);
const PerforceResponse result = runP4Cmd(m_settings.topLevel(), args,
RunFullySynchronous);
managed = result.stdOut.contains("depotFile") || result.stdErr.contains("... - no such file(s)");
} while(false);
m_managedDirectoryCache.insert(directory, managed);
return managed;
}
bool PerforcePlugin::vcsOpen(const QString &workingDir, const QString &fileName)
{
if (Perforce::Constants::debug)
qDebug() << "PerforcePlugin::vcsOpen" << workingDir << fileName;
QStringList args;
args << QLatin1String("edit") << QDir::toNativeSeparators(fileName);
const PerforceResponse result = runP4Cmd(workingDir, args,
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
return !result.error;
}
bool PerforcePlugin::vcsAdd(const QString &workingDir, const QString &fileName)
{
QStringList args;
args << QLatin1String("add") << fileName;
const PerforceResponse result = runP4Cmd(workingDir, args,
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
return !result.error;
}
bool PerforcePlugin::vcsDelete(const QString &workingDir, const QString &fileName)
{
QStringList args;
args << QLatin1String("revert") << fileName;
const PerforceResponse revertResult = runP4Cmd(workingDir, args,
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
if (revertResult.error)
return false;
args.clear();
args << QLatin1String("delete") << fileName;
const PerforceResponse deleteResult = runP4Cmd(workingDir, args,
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
// TODO need to carefully parse the actual messages from perforce
// or do a fstat before to decide what to do
// Different states are:
// File is in depot and unopened => p4 delete %
// File is in depot and opened => p4 revert %, p4 delete %
// File is not in depot => p4 revert %
return !deleteResult.error;
}
bool PerforcePlugin::vcsMove(const QString &workingDir, const QString &from, const QString &to)
{
// TODO verify this works
QStringList args;
args << QLatin1String("edit") << from;
const PerforceResponse editResult = runP4Cmd(workingDir, args,
RunFullySynchronous|CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
if (editResult.error)
return false;
args.clear();
args << QLatin1String("move") << from << to;
const PerforceResponse moveResult = runP4Cmd(workingDir, args,
RunFullySynchronous|CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
return !moveResult.error;
}
// Write extra args to temporary file
QSharedPointer<Utils::TempFileSaver>
PerforcePlugin::createTemporaryArgumentFile(const QStringList &extraArgs,
QString *errorString) const
{
if (extraArgs.isEmpty())
return QSharedPointer<Utils::TempFileSaver>();
// create pattern
if (m_tempFilePattern.isEmpty()) {
m_tempFilePattern = QDir::tempPath();
if (!m_tempFilePattern.endsWith(QDir::separator()))
m_tempFilePattern += QDir::separator();
m_tempFilePattern += QLatin1String("qtc_p4_XXXXXX.args");
}
QSharedPointer<Utils::TempFileSaver> rc(new Utils::TempFileSaver(m_tempFilePattern));
rc->setAutoRemove(true);
const int last = extraArgs.size() - 1;
for (int i = 0; i <= last; i++) {
rc->write(extraArgs.at(i).toLocal8Bit());
if (i != last)
rc->write("\n", 1);
}
if (!rc->finalize(errorString))
return QSharedPointer<Utils::TempFileSaver>();
return rc;
}
// Run messages
static inline QString msgNotStarted(const QString &cmd)
{
return PerforcePlugin::tr("Could not start perforce '%1'. Please check your settings in the preferences.").arg(cmd);
}
static inline QString msgTimeout(int timeOut)
{
return PerforcePlugin::tr("Perforce did not respond within timeout limit (%1 ms).").arg(timeOut );
}
static inline QString msgCrash()
{
return PerforcePlugin::tr("The process terminated abnormally.");
}
static inline QString msgExitCode(int ex)
{
return PerforcePlugin::tr("The process terminated with exit code %1.").arg(ex);
}
// Run using a SynchronousProcess, emitting signals to the message window
PerforceResponse PerforcePlugin::synchronousProcess(const QString &workingDir,
const QStringList &args,
unsigned flags,
const QByteArray &stdInput,
QTextCodec *outputCodec) const
{
QTC_ASSERT(stdInput.isEmpty(), return PerforceResponse()) // Not supported here
VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance();
// Run, connect stderr to the output window
Utils::SynchronousProcess process;
const int timeOut = (flags & LongTimeOut) ? m_settings.longTimeOutMS() : m_settings.timeOutMS();
process.setTimeout(timeOut);
process.setStdOutCodec(outputCodec);
if (flags & OverrideDiffEnvironment)
process.setProcessEnvironment(overrideDiffEnvironmentVariable());
if (!workingDir.isEmpty())
process.setWorkingDirectory(workingDir);
// connect stderr to the output window if desired
if (flags & StdErrToWindow) {
process.setStdErrBufferedSignalsEnabled(true);
connect(&process, SIGNAL(stdErrBuffered(QString,bool)), outputWindow, SLOT(append(QString)));
}
// connect stdout to the output window if desired
if (flags & StdOutToWindow) {
process.setStdOutBufferedSignalsEnabled(true);
connect(&process, SIGNAL(stdOutBuffered(QString,bool)), outputWindow, SLOT(append(QString)));
}
if (Perforce::Constants::debug)
qDebug() << "PerforcePlugin::run syncp actual args [" << process.workingDirectory() << ']' << args;
process.setTimeOutMessageBoxEnabled(true);
const Utils::SynchronousProcessResponse sp_resp = process.run(m_settings.p4Command(), args);
if (Perforce::Constants::debug)
qDebug() << sp_resp;
PerforceResponse response;
response.error = true;
response.exitCode = sp_resp.exitCode;
response.stdErr = sp_resp.stdErr;
response.stdOut = sp_resp.stdOut;
switch (sp_resp.result) {
case Utils::SynchronousProcessResponse::Finished:
response.error = false;
break;
case Utils::SynchronousProcessResponse::FinishedError:
response.message = msgExitCode(sp_resp.exitCode);
response.error = !(flags & IgnoreExitCode);
break;
case Utils::SynchronousProcessResponse::TerminatedAbnormally:
response.message = msgCrash();
break;
case Utils::SynchronousProcessResponse::StartFailed:
response.message = msgNotStarted(m_settings.p4Command());
break;
case Utils::SynchronousProcessResponse::Hang:
response.message = msgCrash();
break;
}
return response;
}
// Run using a QProcess, for short queries
PerforceResponse PerforcePlugin::fullySynchronousProcess(const QString &workingDir,
const QStringList &args,
unsigned flags,
const QByteArray &stdInput,
QTextCodec *outputCodec) const
{
QProcess process;
if (flags & OverrideDiffEnvironment)
process.setProcessEnvironment(overrideDiffEnvironmentVariable());
if (!workingDir.isEmpty())
process.setWorkingDirectory(workingDir);
if (Perforce::Constants::debug)
qDebug() << "PerforcePlugin::run fully syncp actual args [" << process.workingDirectory() << ']' << args;
PerforceResponse response;
process.start(m_settings.p4Command(), args);
if (stdInput.isEmpty())
process.closeWriteChannel();
if (!process.waitForStarted(3000)) {
response.error = true;
response.message = msgNotStarted(m_settings.p4Command());
return response;
}
if (!stdInput.isEmpty()) {
if (process.write(stdInput) == -1) {
Utils::SynchronousProcess::stopProcess(process);
response.error = true;
response.message = tr("Unable to write input data to process %1: %2").
arg(QDir::toNativeSeparators(m_settings.p4Command()),
process.errorString());
return response;
}
process.closeWriteChannel();
}
QByteArray stdOut;
QByteArray stdErr;
const int timeOut = (flags & LongTimeOut) ? m_settings.longTimeOutMS() : m_settings.timeOutMS();
if (!Utils::SynchronousProcess::readDataFromProcess(process, timeOut, &stdOut, &stdErr, true)) {
Utils::SynchronousProcess::stopProcess(process);
response.error = true;
response.message = msgTimeout(timeOut);
return response;
}
if (process.exitStatus() != QProcess::NormalExit) {
response.error = true;
response.message = msgCrash();
return response;
}
response.exitCode = process.exitCode();
response.error = response.exitCode ? !(flags & IgnoreExitCode) : false;
response.stdErr = QString::fromLocal8Bit(stdErr);
response.stdOut = outputCodec ? outputCodec->toUnicode(stdOut.constData(), stdOut.size()) :
QString::fromLocal8Bit(stdOut);
const QChar cr = QLatin1Char('\r');
response.stdErr.remove(cr);
response.stdOut.remove(cr);
// Logging
VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance();
if ((flags & StdErrToWindow) && !response.stdErr.isEmpty())
outputWindow->append(response.stdErr);
if ((flags & StdOutToWindow) && !response.stdOut.isEmpty())
outputWindow->append(response.stdOut);
return response;
}
PerforceResponse PerforcePlugin::runP4Cmd(const QString &workingDir,
const QStringList &args,
unsigned flags,
const QStringList &extraArgs,
const QByteArray &stdInput,
QTextCodec *outputCodec) const
{
if (Perforce::Constants::debug)
qDebug() << "PerforcePlugin::runP4Cmd [" << workingDir << ']' << args << extraArgs << stdInput << debugCodec(outputCodec);
VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance();
if (!m_settings.isValid()) {
PerforceResponse invalidConfigResponse;
invalidConfigResponse.error = true;
invalidConfigResponse.message = tr("Perforce is not correctly configured.");
outputWindow->appendError(invalidConfigResponse.message);
return invalidConfigResponse;
}
QStringList actualArgs = m_settings.commonP4Arguments(workingDir);
QString errorMessage;
QSharedPointer<Utils::TempFileSaver> tempFile = createTemporaryArgumentFile(extraArgs, &errorMessage);
if (!tempFile.isNull()) {
actualArgs << QLatin1String("-x") << tempFile->fileName();
} else if (!errorMessage.isEmpty()) {
PerforceResponse tempFailResponse;
tempFailResponse.error = true;
tempFailResponse.message = errorMessage;
return tempFailResponse;
}
actualArgs.append(args);
if (flags & CommandToWindow)
outputWindow->appendCommand(workingDir, m_settings.p4Command(), actualArgs);
if (flags & ShowBusyCursor)
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
const PerforceResponse response = (flags & RunFullySynchronous) ?
fullySynchronousProcess(workingDir, actualArgs, flags, stdInput, outputCodec) :
synchronousProcess(workingDir, actualArgs, flags, stdInput, outputCodec);
if (flags & ShowBusyCursor)
QApplication::restoreOverrideCursor();
if (response.error) {
if (Perforce::Constants::debug)
qDebug() << response.message;
if (flags & ErrorToWindow)
outputWindow->appendError(response.message);
}
return response;
}
Core::IEditor * PerforcePlugin::showOutputInEditor(const QString& title, const QString output,
int editorType,
const QString &source,
QTextCodec *codec)
{
const VCSBase::VCSBaseEditorParameters *params = findType(editorType);
QTC_ASSERT(params, return 0);
const QString id = params->id;
if (Perforce::Constants::debug)
qDebug() << "PerforcePlugin::showOutputInEditor" << title << id << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);
QString s = title;
Core::IEditor *editor = Core::EditorManager::instance()->openEditorWithContents(id, &s, output);
connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,int)),
this, SLOT(vcsAnnotate(QString,QString,int)));
PerforceEditor *e = qobject_cast<PerforceEditor*>(editor->widget());
if (!e)
return 0;
e->setForceReadOnly(true);
e->setSource(source);
s.replace(QLatin1Char(' '), QLatin1Char('_'));
e->setSuggestedFileName(s);
if (codec)
e->setCodec(codec);
Core::IEditor *ie = e->editor();
Core::EditorManager::instance()->activateEditor(ie, Core::EditorManager::ModeSwitch);
return ie;
}
void PerforcePlugin::slotSubmitDiff(const QStringList &files)
{
p4Diff(m_commitWorkingDirectory, files);
}
struct PerforceDiffParameters
{
QString workingDir;
QStringList diffArguments;
QStringList files;
};
// Parameter widget controlling whitespace diff mode, associated with a parameter
class PerforceDiffParameterWidget : public VCSBase::VCSBaseEditorParameterWidget
{
Q_OBJECT
public:
explicit PerforceDiffParameterWidget(const PerforceDiffParameters &p, QWidget *parent = 0);
signals:
void reRunDiff(const Perforce::Internal::PerforceDiffParameters &);
private slots:
void triggerReRun();
private:
const PerforceDiffParameters m_parameters;
};
PerforceDiffParameterWidget::PerforceDiffParameterWidget(const PerforceDiffParameters &p, QWidget *parent) :
VCSBase::VCSBaseEditorParameterWidget(parent), m_parameters(p)
{
setBaseArguments(p.diffArguments);
addIgnoreWhiteSpaceButton(QString(QLatin1Char('w')));
connect(this, SIGNAL(argumentsChanged()), this, SLOT(triggerReRun()));
}
void PerforceDiffParameterWidget::triggerReRun()
{
PerforceDiffParameters effectiveParameters = m_parameters;
effectiveParameters.diffArguments = arguments();
emit reRunDiff(effectiveParameters);
}
void PerforcePlugin::p4Diff(const QString &workingDir, const QStringList &files)
{
PerforceDiffParameters p;
p.workingDir = workingDir;
p.files = files;
p.diffArguments.push_back(QString(QLatin1Char('u')));
p4Diff(p);
}
void PerforcePlugin::p4Diff(const PerforceDiffParameters &p)
{
QTextCodec *codec = VCSBase::VCSBaseEditorWidget::getCodec(p.workingDir, p.files);
const QString id = VCSBase::VCSBaseEditorWidget::getTitleId(p.workingDir, p.files);
// Reuse existing editors for that id
const QString tag = VCSBase::VCSBaseEditorWidget::editorTag(VCSBase::DiffOutput, p.workingDir, p.files);
Core::IEditor *existingEditor = VCSBase::VCSBaseEditorWidget::locateEditorByTag(tag);
// Split arguments according to size
QStringList args;
args << QLatin1String("diff");
if (!p.diffArguments.isEmpty()) // -duw..
args << (QLatin1String("-d") + p.diffArguments.join(QString()));
QStringList extraArgs;
if (p.files.size() > 1) {
extraArgs = p.files;
} else {
args.append(p.files);
}
const unsigned flags = CommandToWindow|StdErrToWindow|ErrorToWindow|OverrideDiffEnvironment;
const PerforceResponse result = runP4Cmd(p.workingDir, args, flags,
extraArgs, QByteArray(), codec);
if (result.error)
return;
if (existingEditor) {
existingEditor->createNew(result.stdOut);
Core::EditorManager::instance()->activateEditor(existingEditor, Core::EditorManager::ModeSwitch);
return;
}
// Create new editor
Core::IEditor *editor = showOutputInEditor(tr("p4 diff %1").arg(id), result.stdOut, VCSBase::DiffOutput,
VCSBase::VCSBaseEditorWidget::getSource(p.workingDir, p.files),
codec);
VCSBase::VCSBaseEditorWidget::tagEditor(editor, tag);
VCSBase::VCSBaseEditorWidget *diffEditorWidget = qobject_cast<VCSBase::VCSBaseEditorWidget *>(editor->widget());
// Wire up the parameter widget to trigger a re-run on
// parameter change and 'revert' from inside the diff editor.
diffEditorWidget->setRevertDiffChunkEnabled(true);
PerforceDiffParameterWidget *pw = new PerforceDiffParameterWidget(p);
connect(pw, SIGNAL(reRunDiff(Perforce::Internal::PerforceDiffParameters)),
this, SLOT(p4Diff(Perforce::Internal::PerforceDiffParameters)));
connect(diffEditorWidget, SIGNAL(diffChunkReverted(VCSBase::DiffChunk)),
pw, SLOT(triggerReRun()));
diffEditorWidget->setConfigurationWidget(pw);
}
void PerforcePlugin::describe(const QString & source, const QString &n)
{
QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(0) : VCSBase::VCSBaseEditorWidget::getCodec(source);
QStringList args;
args << QLatin1String("describe") << QLatin1String("-du") << n;
const PerforceResponse result = runP4Cmd(m_settings.topLevel(), args, CommandToWindow|StdErrToWindow|ErrorToWindow,
QStringList(), QByteArray(), codec);
if (!result.error)
showOutputInEditor(tr("p4 describe %1").arg(n), result.stdOut, VCSBase::DiffOutput, source, codec);
}
void PerforcePlugin::submitCurrentLog()
{
m_submitActionTriggered = true;
Core::EditorManager *em = Core::EditorManager::instance();
em->closeEditors(QList<Core::IEditor*>() << em->currentEditor());
}
void PerforcePlugin::cleanCommitMessageFile()
{
if (!m_commitMessageFileName.isEmpty()) {
QFile::remove(m_commitMessageFileName);
m_commitMessageFileName.clear();
m_commitWorkingDirectory.clear();
}
}
bool PerforcePlugin::isCommitEditorOpen() const
{
return !m_commitMessageFileName.isEmpty();
}
bool PerforcePlugin::submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *submitEditor)
{
if (!isCommitEditorOpen())
return true;
Core::IFile *fileIFace = submitEditor->file();
const PerforceSubmitEditor *perforceEditor = qobject_cast<PerforceSubmitEditor *>(submitEditor);
if (!fileIFace || !perforceEditor)
return true;
// Prompt the user. Force a prompt unless submit was actually invoked (that
// is, the editor was closed or shutdown).
bool wantsPrompt = m_settings.promptToSubmit();
const VCSBase::VCSBaseSubmitEditor::PromptSubmitResult answer =
perforceEditor->promptSubmit(tr("Closing p4 Editor"),
tr("Do you want to submit this change list?"),
tr("The commit message check failed. Do you want to submit this change list"),
&wantsPrompt, !m_submitActionTriggered);
m_submitActionTriggered = false;
if (answer == VCSBase::VCSBaseSubmitEditor::SubmitCanceled)
return false;
// Set without triggering the checking mechanism
if (wantsPrompt != m_settings.promptToSubmit()) {
m_settings.setPromptToSubmit(wantsPrompt);
m_settings.toSettings(Core::ICore::instance()->settings());
}
if (!Core::ICore::instance()->fileManager()->saveFile(fileIFace))
return false;
if (answer == VCSBase::VCSBaseSubmitEditor::SubmitDiscarded) {
cleanCommitMessageFile();
return true;
}
// Pipe file into p4 submit -i
Utils::FileReader reader;
if (!reader.fetch(m_commitMessageFileName, QIODevice::Text)) {
VCSBase::VCSBaseOutputWindow::instance()->appendError(reader.errorString());
return false;
}
QStringList submitArgs;
submitArgs << QLatin1String("submit") << QLatin1String("-i");
const PerforceResponse submitResponse = runP4Cmd(m_settings.topLevelSymLinkTarget(), submitArgs,
LongTimeOut|RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow|ShowBusyCursor,
QStringList(), reader.data());
if (submitResponse.error) {
VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("p4 submit failed: %1").arg(submitResponse.message));
return false;
}
VCSBase::VCSBaseOutputWindow::instance()->append(submitResponse.stdOut);
if (submitResponse.stdOut.contains(QLatin1String("Out of date files must be resolved or reverted)")))
QMessageBox::warning(submitEditor->widget(), tr("Pending change"), tr("Could not submit the change, because your workspace was out of date. Created a pending submit instead."));
cleanCommitMessageFile();
return true;
}
QString PerforcePlugin::clientFilePath(const QString &serverFilePath)
{
QTC_ASSERT(m_settings.isValid(), return QString())
QStringList args;
args << QLatin1String("fstat") << serverFilePath;
const PerforceResponse response = runP4Cmd(m_settings.topLevelSymLinkTarget(), args,
ShowBusyCursor|RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow);
if (response.error)
return QString();
QRegExp r(QLatin1String("\\.\\.\\.\\sclientFile\\s(.+)\n"));
r.setMinimal(true);
const QString path = r.indexIn(response.stdOut) != -1 ? r.cap(1).trimmed() : QString();
if (Perforce::Constants::debug)
qDebug() << "clientFilePath" << serverFilePath << path;
return path;
}
QString PerforcePlugin::pendingChangesData()
{
QTC_ASSERT(m_settings.isValid(), return QString())
QStringList args = QStringList(QLatin1String("info"));
const PerforceResponse userResponse = runP4Cmd(m_settings.topLevelSymLinkTarget(), args,
RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow);
if (userResponse.error)
return QString();
QRegExp r(QLatin1String("User\\sname:\\s(\\S+)\\s*\n"));
QTC_ASSERT(r.isValid(), return QString())
r.setMinimal(true);
const QString user = r.indexIn(userResponse.stdOut) != -1 ? r.cap(1).trimmed() : QString();
if (user.isEmpty())
return QString();
args.clear();
args << QLatin1String("changes") << QLatin1String("-s") << QLatin1String("pending") << QLatin1String("-u") << user;
const PerforceResponse dataResponse = runP4Cmd(m_settings.topLevelSymLinkTarget(), args,
RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow);
return dataResponse.error ? QString() : dataResponse.stdOut;
}
PerforcePlugin::~PerforcePlugin()
{
}
const PerforceSettings& PerforcePlugin::settings() const
{
return m_settings;
}
void PerforcePlugin::setSettings(const Settings &newSettings)
{
if (newSettings != m_settings.settings()) {
m_settings.setSettings(newSettings);
m_managedDirectoryCache.clear();
m_settings.toSettings(Core::ICore::instance()->settings());
getTopLevel();
perforceVersionControl()->emitConfigurationChanged();
}
}
static inline QString msgWhereFailed(const QString & file, const QString &why)
{
//: Failed to run p4 "where" to resolve a Perforce file name to a local
//: file system name.
return PerforcePlugin::tr("Error running \"where\" on %1: %2").
arg(QDir::toNativeSeparators(file), why);
}
// Map a perforce name "//xx" to its real name in the file system
QString PerforcePlugin::fileNameFromPerforceName(const QString& perforceName,
bool quiet,
QString *errorMessage) const
{
// All happy, already mapped
if (!perforceName.startsWith(QLatin1String("//")))
return perforceName;
// "where" remaps the file to client file tree
QStringList args;
args << QLatin1String("where") << perforceName;
unsigned flags = RunFullySynchronous;
if (!quiet)
flags |= CommandToWindow|StdErrToWindow|ErrorToWindow;
const PerforceResponse response = runP4Cmd(m_settings.topLevelSymLinkTarget(), args, flags);
if (response.error) {
*errorMessage = msgWhereFailed(perforceName, response.message);
return QString();
}
QString output = response.stdOut;
if (output.endsWith(QLatin1Char('\r')))
output.chop(1);
if (output.endsWith(QLatin1Char('\n')))
output.chop(1);
if (output.isEmpty()) {
//: File is not managed by Perforce
*errorMessage = msgWhereFailed(perforceName, tr("The file is not mapped"));
return QString();
}
const QString p4fileSpec = output.mid(output.lastIndexOf(QLatin1Char(' ')) + 1);
const QString rc = m_settings.mapToFileSystem(p4fileSpec);
if (Perforce::Constants::debug)
qDebug() << "fileNameFromPerforceName" << perforceName << p4fileSpec << rc;
return rc;
}
PerforcePlugin *PerforcePlugin::perforcePluginInstance()
{
QTC_ASSERT(m_perforcePluginInstance, return 0);
return m_perforcePluginInstance;
}
PerforceVersionControl *PerforcePlugin::perforceVersionControl() const
{
return static_cast<PerforceVersionControl *>(versionControl());
}
void PerforcePlugin::slotTopLevelFound(const QString &t)
{
m_settings.setTopLevel(t);
const QString msg = tr("Perforce repository: %1").
arg(QDir::toNativeSeparators(t));
VCSBase::VCSBaseOutputWindow::instance()->appendSilently(msg);
if (Perforce::Constants::debug)
qDebug() << "P4: " << t;
}
void PerforcePlugin::slotTopLevelFailed(const QString &errorMessage)
{
VCSBase::VCSBaseOutputWindow::instance()->appendSilently(tr("Perforce: Unable to determine the repository: %1").arg(errorMessage));
if (Perforce::Constants::debug)
qDebug() << errorMessage;
}
void PerforcePlugin::getTopLevel()
{
// Run a new checker
if (m_settings.p4Command().isEmpty())
return;
PerforceChecker *checker = new PerforceChecker(this);
connect(checker, SIGNAL(failed(QString)), this, SLOT(slotTopLevelFailed(QString)));
connect(checker, SIGNAL(failed(QString)), checker, SLOT(deleteLater()));
connect(checker, SIGNAL(succeeded(QString)), this, SLOT(slotTopLevelFound(QString)));
connect(checker, SIGNAL(succeeded(QString)),checker, SLOT(deleteLater()));
checker->start(m_settings.p4Command(), m_settings.commonP4Arguments(QString()), 30000);
}
}
}
Q_EXPORT_PLUGIN(Perforce::Internal::PerforcePlugin)
#include "perforceplugin.moc"
|