1
2
3 #include "svnlockframerangedialog.h"
4
5 // Tnz6 includes
6 #include "tapp.h"
7
8 // Qt includes
9 #include <QPushButton>
10 #include <QLabel>
11 #include <QMovie>
12 #include <QBoxLayout>
13 #include <QHostInfo>
14 #include <QPlainTextEdit>
15 #include <QMainWindow>
16
17 //=============================================================================
18 // SVNLockFrameRangeDialog
19 //-----------------------------------------------------------------------------
20
SVNLockFrameRangeDialog(QWidget * parent,const QString & workingDir,const QString & file,int frameCount)21 SVNLockFrameRangeDialog::SVNLockFrameRangeDialog(QWidget *parent,
22 const QString &workingDir,
23 const QString &file,
24 int frameCount)
25 : Dialog(TApp::instance()->getMainWindow(), true, false)
26 , m_workingDir(workingDir)
27 , m_file(file)
28 , m_hasError(false)
29 , m_fromIsValid(true)
30 , m_toIsValid(true) {
31 setModal(false);
32 setAttribute(Qt::WA_DeleteOnClose, true);
33
34 setWindowTitle(tr("Version Control: Edit Frame Range"));
35
36 setMinimumSize(300, 220);
37 QWidget *container = new QWidget;
38
39 QVBoxLayout *mainLayout = new QVBoxLayout;
40 mainLayout->setAlignment(Qt::AlignHCenter);
41 mainLayout->setMargin(0);
42
43 QHBoxLayout *hLayout = new QHBoxLayout;
44
45 m_waitingLabel = new QLabel;
46 QMovie *waitingMove = new QMovie(":Resources/waiting.gif");
47 waitingMove->setParent(this);
48
49 m_waitingLabel->setMovie(waitingMove);
50 waitingMove->setCacheMode(QMovie::CacheAll);
51 waitingMove->start();
52
53 m_textLabel = new QLabel;
54
55 m_textLabel->setText(tr("Temporary Lock file..."));
56
57 hLayout->addStretch();
58 hLayout->addWidget(m_waitingLabel);
59 hLayout->addWidget(m_textLabel);
60 hLayout->addStretch();
61
62 mainLayout->addLayout(hLayout);
63 mainLayout->addSpacing(10);
64
65 QHBoxLayout *fromToLayout = new QHBoxLayout;
66
67 m_fromLabel = new QLabel(tr("From:"));
68 m_fromLabel->setMaximumWidth(60);
69 m_fromLabel->hide();
70
71 m_toLabel = new QLabel(tr("To:"));
72 m_toLabel->setMaximumWidth(60);
73 m_toLabel->hide();
74
75 m_fromLineEdit = new DVGui::IntLineEdit;
76 m_fromLineEdit->setRange(1, frameCount);
77 m_fromLineEdit->hide();
78 connect(m_fromLineEdit, SIGNAL(textChanged(const QString &)), this,
79 SLOT(onFromLineEditTextChanged()));
80
81 m_toLineEdit = new DVGui::IntLineEdit;
82 m_toLineEdit->setRange(1, frameCount);
83 m_toLineEdit->hide();
84 m_toLineEdit->setValue(frameCount);
85 connect(m_toLineEdit, SIGNAL(textChanged(const QString &)), this,
86 SLOT(onToLineEditTextChanged()));
87
88 fromToLayout->addStretch();
89 fromToLayout->addWidget(m_fromLabel);
90 fromToLayout->addWidget(m_fromLineEdit);
91 fromToLayout->addWidget(m_toLabel);
92 fromToLayout->addWidget(m_toLineEdit);
93 fromToLayout->addStretch();
94
95 mainLayout->addLayout(fromToLayout);
96
97 QHBoxLayout *commentLayout = new QHBoxLayout;
98
99 m_commentTextEdit = new QPlainTextEdit;
100 m_commentTextEdit->setMaximumHeight(50);
101 m_commentTextEdit->hide();
102
103 m_commentLabel = new QLabel(tr("Comment:"));
104 m_commentLabel->setFixedWidth(55);
105 m_commentLabel->hide();
106
107 commentLayout->addWidget(m_commentLabel);
108 commentLayout->addWidget(m_commentTextEdit);
109
110 mainLayout->addLayout(commentLayout);
111
112 container->setLayout(mainLayout);
113
114 beginHLayout();
115 addWidget(container, false);
116 endHLayout();
117
118 m_lockButton = new QPushButton(tr("Edit"));
119 connect(m_lockButton, SIGNAL(clicked()), this, SLOT(onLockButtonClicked()));
120
121 m_cancelButton = new QPushButton(tr("Cancel"));
122 connect(m_cancelButton, SIGNAL(clicked()), this,
123 SLOT(onCancelButtonClicked()));
124
125 addButtonBarWidget(m_lockButton, m_cancelButton);
126
127 // 0. Connect for svn errors (that may occurs)
128 connect(&m_thread, SIGNAL(error(const QString &)), this,
129 SLOT(onError(const QString &)));
130
131 // Step 1: Lock
132 QStringList args;
133 args << "lock";
134 args << m_file;
135
136 connect(&m_thread, SIGNAL(done(const QString &)), this, SLOT(onLockDone()));
137 m_thread.executeCommand(m_workingDir, "svn", args, false);
138 }
139
140 //-----------------------------------------------------------------------------
141
switchToCloseButton()142 void SVNLockFrameRangeDialog::switchToCloseButton() {
143 m_waitingLabel->hide();
144 m_commentTextEdit->hide();
145 m_commentLabel->hide();
146 m_lockButton->disconnect();
147 m_lockButton->setText("Close");
148 m_lockButton->setEnabled(true);
149 m_cancelButton->hide();
150 connect(m_lockButton, SIGNAL(clicked()), this, SLOT(close()));
151 }
152
153 //-----------------------------------------------------------------------------
154
onError(const QString & errorString)155 void SVNLockFrameRangeDialog::onError(const QString &errorString) {
156 m_textLabel->setText(errorString);
157 switchToCloseButton();
158 update();
159 m_hasError = true;
160 }
161
162 //-----------------------------------------------------------------------------
163
onPropGetDone(const QString & xmlResponse)164 void SVNLockFrameRangeDialog::onPropGetDone(const QString &xmlResponse) {
165 SVNPartialLockReader reader(xmlResponse);
166 QList<SVNPartialLock> lockList = reader.getPartialLock();
167 if (lockList.isEmpty())
168 m_textLabel->setText(tr("No frame range edited."));
169 else {
170 m_lockInfos = lockList.at(0).m_partialLockList;
171 if (m_lockInfos.isEmpty())
172 m_textLabel->setText(tr("No frame range edited."));
173 else {
174 QString temp;
175 for (int i = 0; i < m_lockInfos.size(); i++) {
176 if (i != 0) temp.append("\n\n");
177 SVNPartialLockInfo lock = m_lockInfos.at(i);
178 temp.append(tr("%1 on %2 is editing frames from %3 to %4.")
179 .arg(lock.m_userName)
180 .arg(lock.m_hostName)
181 .arg(lock.m_from)
182 .arg(lock.m_to));
183 }
184 m_textLabel->setText(temp);
185 }
186 }
187
188 int height =
189 180 + (m_lockInfos.isEmpty() ? 0 : ((m_lockInfos.size() - 1) * 25));
190 setMinimumSize(300, height);
191
192 m_lockButton->show();
193
194 m_cancelButton->show();
195
196 // Update from and to lineedit valid status
197 onFromLineEditTextChanged();
198 onToLineEditTextChanged();
199
200 m_waitingLabel->hide();
201
202 m_fromLabel->show();
203 m_toLabel->show();
204 m_fromLineEdit->show();
205 m_toLineEdit->show();
206
207 m_commentLabel->show();
208 m_commentTextEdit->show();
209 }
210
211 //-----------------------------------------------------------------------------
212
onLockButtonClicked()213 void SVNLockFrameRangeDialog::onLockButtonClicked() {
214 // Build the old partial Lock string
215 QString partialLockString;
216
217 int count = m_lockInfos.size();
218 for (int i = 0; i < count; i++) {
219 if (i != 0) partialLockString.append(";");
220 SVNPartialLockInfo lockInfo = m_lockInfos.at(i);
221 partialLockString.append(lockInfo.m_userName + "@" + lockInfo.m_hostName +
222 ":" + QString::number(lockInfo.m_from) + ":" +
223 QString::number(lockInfo.m_to));
224 }
225
226 // Add the new value
227 QString userName = VersionControl::instance()->getUserName();
228 QString hostName = QHostInfo::localHostName();
229 QString from = QString::number(m_fromLineEdit->getValue());
230 QString to = QString::number(m_toLineEdit->getValue());
231
232 if (count != 0) partialLockString.append(";");
233 partialLockString.append(userName + "@" + hostName + ":" + from + ":" + to);
234
235 // Step 3: propset
236 QStringList args;
237 args << "propset";
238 args << "partial-lock";
239 args << partialLockString;
240 args << m_file;
241
242 m_thread.disconnect(SIGNAL(done(const QString &)));
243 connect(&m_thread, SIGNAL(done(const QString &)), this,
244 SLOT(onPropSetDone()));
245 m_thread.executeCommand(m_workingDir, "svn", args, true);
246 }
247
248 //-----------------------------------------------------------------------------
249
onCancelButtonClicked()250 void SVNLockFrameRangeDialog::onCancelButtonClicked() {
251 QStringList args;
252 args << "unlock";
253 args << m_file;
254
255 m_thread.disconnect(SIGNAL(done(const QString &)));
256 connect(&m_thread, SIGNAL(done(const QString &)), this, SLOT(close()));
257 m_thread.executeCommand(m_workingDir, "svn", args, true);
258 }
259
260 //-----------------------------------------------------------------------------
261
onFromLineEditTextChanged()262 void SVNLockFrameRangeDialog::onFromLineEditTextChanged() {
263 int value = m_fromLineEdit->getValue();
264
265 // Check if from is inside one range
266 int count = m_lockInfos.size();
267
268 m_fromIsValid = true;
269 for (int i = 0; i < count; i++) {
270 SVNPartialLockInfo lockInfo = m_lockInfos.at(i);
271 if (value >= lockInfo.m_from && value <= lockInfo.m_to) {
272 m_fromIsValid = false;
273 break;
274 }
275 }
276
277 m_fromLineEdit->setStyleSheet(
278 m_fromIsValid ? "" : "color: red; background-color: red;");
279 m_lockButton->setEnabled(m_fromIsValid && m_toIsValid);
280 }
281
282 //-----------------------------------------------------------------------------
283
onToLineEditTextChanged()284 void SVNLockFrameRangeDialog::onToLineEditTextChanged() {
285 int value = m_toLineEdit->getValue();
286
287 // Check if from is inside one range
288 int count = m_lockInfos.size();
289 m_toIsValid = true;
290 for (int i = 0; i < count; i++) {
291 SVNPartialLockInfo lockInfo = m_lockInfos.at(i);
292 if (value >= lockInfo.m_from && value <= lockInfo.m_to) {
293 m_toIsValid = false;
294 break;
295 }
296 }
297
298 m_toLineEdit->setStyleSheet(
299 m_toIsValid ? "" : "color: red; background-color: red;");
300 m_lockButton->setEnabled(m_fromIsValid && m_toIsValid);
301 }
302
303 //-----------------------------------------------------------------------------
304
onLockDone()305 void SVNLockFrameRangeDialog::onLockDone() {
306 if (!m_hasError) {
307 m_textLabel->setText(tr("Getting frame range edit information..."));
308
309 // Step 2: propget
310 QStringList args;
311 args << "proplist";
312 args << m_file;
313 args << "--xml";
314 args << "-v";
315
316 m_thread.disconnect(SIGNAL(done(const QString &)));
317 connect(&m_thread, SIGNAL(done(const QString &)), this,
318 SLOT(onPropGetDone(const QString &)));
319 m_thread.executeCommand(m_workingDir, "svn", args, true);
320 }
321 }
322
323 //-----------------------------------------------------------------------------
324
onPropSetDone()325 void SVNLockFrameRangeDialog::onPropSetDone() {
326 // Step 4: Commit
327 QStringList args;
328 args << "commit";
329 args << m_file;
330 if (!m_commentTextEdit->toPlainText().isEmpty())
331 args << QString("-m").append(m_commentTextEdit->toPlainText());
332 else
333 args << QString("-m").append(VersionControl::instance()->getUserName() +
334 " edit frame range.");
335 m_thread.disconnect(SIGNAL(done(const QString &)));
336 connect(&m_thread, SIGNAL(done(const QString &)), this, SLOT(finish()));
337 m_thread.executeCommand(m_workingDir, "svn", args, true);
338 }
339
340 //-----------------------------------------------------------------------------
341
finish()342 void SVNLockFrameRangeDialog::finish() {
343 if (!m_hasError) {
344 emit done(QStringList(m_file));
345 close();
346 }
347 }
348
349 //=============================================================================
350 // SVNLockMultiFrameRangeDialog
351 //-----------------------------------------------------------------------------
352
SVNLockMultiFrameRangeDialog(QWidget * parent,const QString & workingDir,const QStringList & files)353 SVNLockMultiFrameRangeDialog::SVNLockMultiFrameRangeDialog(
354 QWidget *parent, const QString &workingDir, const QStringList &files)
355 : Dialog(TApp::instance()->getMainWindow(), true, false)
356 , m_workingDir(workingDir)
357 , m_files(files)
358 , m_hasError(false)
359 , m_fromIsValid(true)
360 , m_toIsValid(true) {
361 setModal(false);
362 setAttribute(Qt::WA_DeleteOnClose, true);
363
364 setWindowTitle(tr("Version Control: Edit Frame Range"));
365
366 setMinimumSize(300, 220);
367 QWidget *container = new QWidget;
368
369 QVBoxLayout *mainLayout = new QVBoxLayout;
370 mainLayout->setAlignment(Qt::AlignHCenter);
371 mainLayout->setMargin(0);
372
373 QHBoxLayout *hLayout = new QHBoxLayout;
374
375 m_waitingLabel = new QLabel;
376 QMovie *waitingMove = new QMovie(":Resources/waiting.gif");
377 waitingMove->setParent(this);
378
379 m_waitingLabel->setMovie(waitingMove);
380 waitingMove->setCacheMode(QMovie::CacheAll);
381 waitingMove->start();
382
383 m_textLabel = new QLabel;
384
385 m_textLabel->setText(tr("Getting repository status..."));
386
387 hLayout->addStretch();
388 hLayout->addWidget(m_waitingLabel);
389 hLayout->addWidget(m_textLabel);
390 hLayout->addStretch();
391
392 mainLayout->addLayout(hLayout);
393 mainLayout->addSpacing(10);
394
395 QHBoxLayout *fromToLayout = new QHBoxLayout;
396
397 m_fromLabel = new QLabel(tr("From:"));
398 m_fromLabel->setMaximumWidth(60);
399 m_fromLabel->hide();
400
401 m_toLabel = new QLabel(tr("To:"));
402 m_toLabel->setMaximumWidth(60);
403 m_toLabel->hide();
404
405 int frameCount = m_files.size();
406
407 m_fromLineEdit = new DVGui::IntLineEdit;
408 m_fromLineEdit->setRange(1, frameCount);
409 m_fromLineEdit->hide();
410 connect(m_fromLineEdit, SIGNAL(textChanged(const QString &)), this,
411 SLOT(onFromLineEditTextChanged()));
412
413 m_toLineEdit = new DVGui::IntLineEdit;
414 m_toLineEdit->setRange(1, frameCount);
415 m_toLineEdit->hide();
416 m_toLineEdit->setValue(frameCount);
417 connect(m_toLineEdit, SIGNAL(textChanged(const QString &)), this,
418 SLOT(onToLineEditTextChanged()));
419
420 fromToLayout->addStretch();
421 fromToLayout->addWidget(m_fromLabel);
422 fromToLayout->addWidget(m_fromLineEdit);
423 fromToLayout->addWidget(m_toLabel);
424 fromToLayout->addWidget(m_toLineEdit);
425 fromToLayout->addStretch();
426
427 mainLayout->addLayout(fromToLayout);
428
429 QHBoxLayout *commentLayout = new QHBoxLayout;
430
431 m_commentTextEdit = new QPlainTextEdit;
432 m_commentTextEdit->setMaximumHeight(50);
433 m_commentTextEdit->hide();
434
435 m_commentLabel = new QLabel(tr("Comment:"));
436 m_commentLabel->setFixedWidth(55);
437 m_commentLabel->hide();
438
439 commentLayout->addWidget(m_commentLabel);
440 commentLayout->addWidget(m_commentTextEdit);
441
442 mainLayout->addLayout(commentLayout);
443
444 container->setLayout(mainLayout);
445
446 beginHLayout();
447 addWidget(container, false);
448 endHLayout();
449
450 m_lockButton = new QPushButton(tr("Edit"));
451 connect(m_lockButton, SIGNAL(clicked()), this, SLOT(onLockButtonClicked()));
452
453 m_cancelButton = new QPushButton(tr("Cancel"));
454 connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
455
456 m_lockButton->hide();
457 m_cancelButton->hide();
458
459 addButtonBarWidget(m_lockButton, m_cancelButton);
460
461 // 0. Connect for svn errors (that may occurs)
462 connect(&m_thread, SIGNAL(error(const QString &)), this,
463 SLOT(onError(const QString &)));
464
465 // 1. Getting status
466 connect(&m_thread, SIGNAL(statusRetrieved(const QString &)), this,
467 SLOT(onStatusRetrieved(const QString &)));
468 m_thread.getSVNStatus(m_workingDir, m_files, true);
469 }
470
471 //-----------------------------------------------------------------------------
472
switchToCloseButton()473 void SVNLockMultiFrameRangeDialog::switchToCloseButton() {
474 m_waitingLabel->hide();
475 m_commentTextEdit->hide();
476 m_commentLabel->hide();
477 m_lockButton->disconnect();
478 m_lockButton->setText("Close");
479 m_lockButton->setEnabled(true);
480 m_cancelButton->hide();
481 connect(m_lockButton, SIGNAL(clicked()), this, SLOT(close()));
482 }
483
484 //-----------------------------------------------------------------------------
485
onError(const QString & errorString)486 void SVNLockMultiFrameRangeDialog::onError(const QString &errorString) {
487 m_textLabel->setText(errorString);
488 switchToCloseButton();
489 update();
490 m_hasError = true;
491 }
492
493 //-----------------------------------------------------------------------------
494
onStatusRetrieved(const QString & xmlResponse)495 void SVNLockMultiFrameRangeDialog::onStatusRetrieved(
496 const QString &xmlResponse) {
497 m_waitingLabel->hide();
498
499 SVNStatusReader sr(xmlResponse);
500 m_status = sr.getStatus();
501
502 // Fill m_lockInfos list
503 SVNPartialLockInfo info;
504 info.m_from = 0;
505 int count = m_status.size();
506 for (int i = 0; i < count; i++) {
507 SVNStatus s = m_status.at(i);
508 if (s.m_isLocked) {
509 if (info.m_userName != s.m_lockOwner && info.m_userName != "") {
510 m_lockInfos.append(info);
511 info.m_from = 0;
512 }
513 info.m_userName = s.m_lockOwner;
514 if (info.m_from == 0)
515 info.m_from = i + 1;
516 else
517 info.m_to = i + 1;
518 }
519 }
520
521 if (info.m_userName != "" && info.m_from != 0) m_lockInfos.append(info);
522
523 if (m_lockInfos.isEmpty())
524 m_textLabel->setText(tr("No frame range edited."));
525 else {
526 QString temp;
527 for (int i = 0; i < m_lockInfos.size(); i++) {
528 if (i != 0) temp.append("\n\n");
529 SVNPartialLockInfo lock = m_lockInfos.at(i);
530 temp.append(tr("%1 is editing frames from %2 to %3")
531 .arg(lock.m_userName)
532 .arg(lock.m_from)
533 .arg(lock.m_to));
534 }
535 m_textLabel->setText(temp);
536 }
537
538 int height =
539 180 + (m_lockInfos.isEmpty() ? 0 : ((m_lockInfos.size() - 1) * 25));
540 setMinimumSize(300, height);
541
542 m_lockButton->show();
543
544 m_cancelButton->show();
545
546 // Update from and to lineedit valid status
547 onFromLineEditTextChanged();
548 onToLineEditTextChanged();
549
550 m_waitingLabel->hide();
551
552 m_fromLabel->show();
553 m_toLabel->show();
554 m_fromLineEdit->show();
555 m_toLineEdit->show();
556
557 m_commentLabel->show();
558 m_commentTextEdit->show();
559 }
560 //-----------------------------------------------------------------------------
561
onFromLineEditTextChanged()562 void SVNLockMultiFrameRangeDialog::onFromLineEditTextChanged() {
563 int value = m_fromLineEdit->getValue();
564
565 // Check if from is inside one range
566 int count = m_lockInfos.size();
567
568 m_fromIsValid = true;
569 for (int i = 0; i < count; i++) {
570 SVNPartialLockInfo lockInfo = m_lockInfos.at(i);
571 if (value >= lockInfo.m_from && value <= lockInfo.m_to) {
572 m_fromIsValid = false;
573 break;
574 }
575 }
576
577 m_fromLineEdit->setStyleSheet(
578 m_fromIsValid ? "" : "color: red; background-color: red;");
579 m_lockButton->setEnabled(m_fromIsValid && m_toIsValid);
580 }
581
582 //-----------------------------------------------------------------------------
583
onToLineEditTextChanged()584 void SVNLockMultiFrameRangeDialog::onToLineEditTextChanged() {
585 int value = m_toLineEdit->getValue();
586
587 // Check if from is inside one range
588 int count = m_lockInfos.size();
589 m_toIsValid = true;
590 for (int i = 0; i < count; i++) {
591 SVNPartialLockInfo lockInfo = m_lockInfos.at(i);
592 if (value >= lockInfo.m_from && value <= lockInfo.m_to) {
593 m_toIsValid = false;
594 break;
595 }
596 }
597
598 m_toLineEdit->setStyleSheet(
599 m_toIsValid ? "" : "color: red; background-color: red;");
600 m_lockButton->setEnabled(m_fromIsValid && m_toIsValid);
601 }
602
603 //-----------------------------------------------------------------------------
604
onLockButtonClicked()605 void SVNLockMultiFrameRangeDialog::onLockButtonClicked() {
606 for (int i = m_fromLineEdit->getValue() - 1; i < m_toLineEdit->getValue();
607 i++)
608 m_filesToLock.append(m_files.at(i));
609
610 m_waitingLabel->show();
611 m_fromLabel->hide();
612 m_toLabel->hide();
613 m_fromLineEdit->hide();
614 m_toLineEdit->hide();
615 m_commentLabel->hide();
616 m_commentTextEdit->hide();
617
618 m_textLabel->setText(tr("Editing %1 items...").arg(m_filesToLock.size()));
619
620 QStringList args;
621 args << "lock";
622
623 int fileCount = m_filesToLock.size();
624 for (int i = 0; i < fileCount; i++) args << m_filesToLock.at(i);
625
626 if (!m_commentTextEdit->toPlainText().isEmpty())
627 args << QString("-m").append(m_commentTextEdit->toPlainText());
628 else
629 args << QString("-m").append(VersionControl::instance()->getUserName() +
630 " edit frame range.");
631 m_thread.disconnect(SIGNAL(done(const QString &)));
632 connect(&m_thread, SIGNAL(done(const QString &)), SLOT(onLockDone()));
633 m_thread.executeCommand(m_workingDir, "svn", args);
634 }
635
636 //-----------------------------------------------------------------------------
637
onLockDone()638 void SVNLockMultiFrameRangeDialog::onLockDone() {
639 if (!m_hasError) {
640 QStringList files;
641 int fileCount = m_files.size();
642 for (int i = 0; i < fileCount; i++) files.append(m_files.at(i));
643 emit done(files);
644 close();
645 }
646 }
647
648 //=============================================================================
649 // SVNUnlockFrameRangeDialog
650 //-----------------------------------------------------------------------------
651
SVNUnlockFrameRangeDialog(QWidget * parent,const QString & workingDir,const QString & file)652 SVNUnlockFrameRangeDialog::SVNUnlockFrameRangeDialog(QWidget *parent,
653 const QString &workingDir,
654 const QString &file)
655 : Dialog(TApp::instance()->getMainWindow(), true, false)
656 , m_workingDir(workingDir)
657 , m_file(file)
658 , m_hasError(false) {
659 setModal(false);
660 setAttribute(Qt::WA_DeleteOnClose, true);
661
662 setWindowTitle(tr("Version Control: Unlock Frame Range"));
663
664 setMinimumSize(300, 150);
665 QWidget *container = new QWidget;
666
667 QVBoxLayout *mainLayout = new QVBoxLayout;
668 mainLayout->setAlignment(Qt::AlignHCenter);
669 mainLayout->setMargin(0);
670
671 QHBoxLayout *hLayout = new QHBoxLayout;
672
673 m_waitingLabel = new QLabel;
674 QMovie *waitingMove = new QMovie(":Resources/waiting.gif");
675 waitingMove->setParent(this);
676
677 m_waitingLabel->hide();
678
679 m_waitingLabel->setMovie(waitingMove);
680 waitingMove->setCacheMode(QMovie::CacheAll);
681 waitingMove->start();
682
683 m_textLabel = new QLabel;
684
685 m_textLabel->setText(
686 tr("Note: the file will be updated too. Are you sure ?"));
687
688 hLayout->addStretch();
689 hLayout->addWidget(m_waitingLabel);
690 hLayout->addWidget(m_textLabel);
691 hLayout->addStretch();
692
693 mainLayout->addLayout(hLayout);
694 container->setLayout(mainLayout);
695
696 beginHLayout();
697 addWidget(container, false);
698 endHLayout();
699
700 m_unlockButton = new QPushButton(tr("Unlock"));
701 connect(m_unlockButton, SIGNAL(clicked()), this,
702 SLOT(onUnlockButtonClicked()));
703
704 m_cancelButton = new QPushButton(tr("Cancel"));
705 connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
706
707 addButtonBarWidget(m_unlockButton, m_cancelButton);
708
709 // 0. Connect for svn errors (that may occurs)
710 connect(&m_thread, SIGNAL(error(const QString &)), this,
711 SLOT(onError(const QString &)));
712 }
713
714 //-----------------------------------------------------------------------------
715
onCommitDone()716 void SVNUnlockFrameRangeDialog::onCommitDone() {
717 m_textLabel->setText(tr("Unlock done successfully."));
718
719 QStringList files;
720 files.append(m_file);
721 emit done(files);
722 switchToCloseButton();
723 }
724
725 //-----------------------------------------------------------------------------
726
onUpdateDone()727 void SVNUnlockFrameRangeDialog::onUpdateDone() {
728 m_textLabel->setText(tr("Locking file..."));
729
730 // Step 2: Lock
731 QStringList args;
732 args << "lock";
733 args << m_file;
734
735 m_thread.disconnect(SIGNAL(done(const QString &)));
736 connect(&m_thread, SIGNAL(done(const QString &)), this, SLOT(onLockDone()));
737 m_thread.executeCommand(m_workingDir, "svn", args, false);
738 }
739
740 //-----------------------------------------------------------------------------
741
onLockDone()742 void SVNUnlockFrameRangeDialog::onLockDone() {
743 m_textLabel->setText(tr("Getting frame range edit information..."));
744
745 // Step 3: propget
746 QStringList args;
747 args << "proplist";
748 args << m_file;
749 args << "--xml";
750 args << "-v";
751
752 m_thread.disconnect(SIGNAL(done(const QString &)));
753 connect(&m_thread, SIGNAL(done(const QString &)), this,
754 SLOT(onPropGetDone(const QString &)));
755 m_thread.executeCommand(m_workingDir, "svn", args, true);
756 }
757
758 //-----------------------------------------------------------------------------
759
onError(const QString & text)760 void SVNUnlockFrameRangeDialog::onError(const QString &text) {
761 m_textLabel->setText(text);
762 switchToCloseButton();
763 update();
764 m_hasError = true;
765 }
766
767 //-----------------------------------------------------------------------------
768
onPropGetDone(const QString & xmlResponse)769 void SVNUnlockFrameRangeDialog::onPropGetDone(const QString &xmlResponse) {
770 SVNPartialLockReader reader(xmlResponse);
771 QList<SVNPartialLock> lockList = reader.getPartialLock();
772 if (lockList.isEmpty()) {
773 m_textLabel->setText(tr("No frame range edited."));
774 switchToCloseButton();
775 return;
776 } else {
777 m_lockInfos = lockList.at(0).m_partialLockList;
778 if (m_lockInfos.isEmpty()) {
779 m_textLabel->setText(tr("No frame range edited."));
780 switchToCloseButton();
781 return;
782 }
783 }
784
785 QString partialLockString;
786
787 QString userName = VersionControl::instance()->getUserName();
788 QString hostName = QHostInfo::localHostName();
789
790 int count = m_lockInfos.size();
791
792 int entryAdded = 0;
793 for (int i = 0; i < count; i++) {
794 SVNPartialLockInfo lockInfo = m_lockInfos.at(i);
795 bool isMe =
796 lockInfo.m_userName == userName && lockInfo.m_hostName == hostName;
797 if (!isMe) {
798 if (i != 0) partialLockString.append(";");
799 partialLockString.append(lockInfo.m_userName + "@" + lockInfo.m_hostName +
800 ":" + QString::number(lockInfo.m_from) + ":" +
801 QString::number(lockInfo.m_to));
802 entryAdded++;
803 } else
804 m_myInfo = lockInfo;
805 }
806
807 m_textLabel->setText(tr("Updating frame range edit information..."));
808
809 // There is no more partial-lock > propdel
810 if (entryAdded == 0) {
811 // Step 4: propdel
812 QStringList args;
813 args << "propdel";
814 args << "partial-lock";
815 args << m_file;
816
817 m_thread.disconnect(SIGNAL(done(const QString &)));
818 connect(&m_thread, SIGNAL(done(const QString &)), this,
819 SLOT(onPropSetDone()));
820 m_thread.executeCommand(m_workingDir, "svn", args, true);
821 }
822 // Set the partial-lock property
823 else {
824 // Step 4: propset
825 QStringList args;
826 args << "propset";
827 args << "partial-lock";
828 args << partialLockString;
829 args << m_file;
830
831 m_thread.disconnect(SIGNAL(done(const QString &)));
832 connect(&m_thread, SIGNAL(done(const QString &)), this,
833 SLOT(onPropSetDone()));
834 m_thread.executeCommand(m_workingDir, "svn", args, true);
835 }
836 }
837
838 //-----------------------------------------------------------------------------
839
onPropSetDone()840 void SVNUnlockFrameRangeDialog::onPropSetDone() {
841 m_textLabel->setText(tr("Putting changes..."));
842
843 // Step 5: commit
844 QStringList args;
845 args << "commit";
846 args << m_file;
847 args << QString("-m").append(m_myInfo.m_userName + " on " +
848 m_myInfo.m_hostName + " unlock frames from " +
849 QString::number(m_myInfo.m_from) + " to " +
850 QString::number(m_myInfo.m_to) + ".");
851
852 m_thread.disconnect(SIGNAL(done(const QString &)));
853 connect(&m_thread, SIGNAL(done(const QString &)), this, SLOT(onCommitDone()));
854 m_thread.executeCommand(m_workingDir, "svn", args, true);
855 }
856
857 //-----------------------------------------------------------------------------
858
onUnlockButtonClicked()859 void SVNUnlockFrameRangeDialog::onUnlockButtonClicked() {
860 m_waitingLabel->show();
861 m_textLabel->setText(tr("Updating file..."));
862
863 // Step 1: Update
864 QStringList args;
865 args << "update";
866 args << m_file;
867
868 connect(&m_thread, SIGNAL(done(const QString &)), this, SLOT(onUpdateDone()));
869 m_thread.executeCommand(m_workingDir, "svn", args, false);
870 }
871
872 //-----------------------------------------------------------------------------
873
switchToCloseButton()874 void SVNUnlockFrameRangeDialog::switchToCloseButton() {
875 m_waitingLabel->hide();
876 m_unlockButton->disconnect();
877 m_unlockButton->setText(tr("Close"));
878 m_unlockButton->setEnabled(true);
879 m_unlockButton->show();
880 m_cancelButton->hide();
881 connect(m_unlockButton, SIGNAL(clicked()), this, SLOT(close()));
882 }
883
884 //=============================================================================
885 // SVNUnlockMultiFrameRangeDialog
886 //-----------------------------------------------------------------------------
887
SVNUnlockMultiFrameRangeDialog(QWidget * parent,const QString & workingDir,const QStringList & files)888 SVNUnlockMultiFrameRangeDialog::SVNUnlockMultiFrameRangeDialog(
889 QWidget *parent, const QString &workingDir, const QStringList &files)
890 : Dialog(TApp::instance()->getMainWindow(), true, false)
891 , m_workingDir(workingDir)
892 , m_files(files)
893 , m_hasError(false) {
894 setModal(false);
895 setAttribute(Qt::WA_DeleteOnClose, true);
896
897 setWindowTitle(tr("Version Control: Unlock Frame Range"));
898
899 setMinimumSize(300, 150);
900 QWidget *container = new QWidget;
901
902 QVBoxLayout *mainLayout = new QVBoxLayout;
903 mainLayout->setAlignment(Qt::AlignHCenter);
904 mainLayout->setMargin(0);
905
906 QHBoxLayout *hLayout = new QHBoxLayout;
907
908 m_waitingLabel = new QLabel;
909 QMovie *waitingMove = new QMovie(":Resources/waiting.gif");
910 waitingMove->setParent(this);
911
912 m_waitingLabel->hide();
913
914 m_waitingLabel->setMovie(waitingMove);
915 waitingMove->setCacheMode(QMovie::CacheAll);
916 waitingMove->start();
917
918 m_textLabel = new QLabel;
919
920 m_textLabel->setText(tr("Getting repository status..."));
921
922 hLayout->addStretch();
923 hLayout->addWidget(m_waitingLabel);
924 hLayout->addWidget(m_textLabel);
925 hLayout->addStretch();
926
927 mainLayout->addLayout(hLayout);
928 container->setLayout(mainLayout);
929
930 beginHLayout();
931 addWidget(container, false);
932 endHLayout();
933
934 m_unlockButton = new QPushButton(tr("Unlock"));
935 connect(m_unlockButton, SIGNAL(clicked()), this,
936 SLOT(onUnlockButtonClicked()));
937
938 m_cancelButton = new QPushButton(tr("Cancel"));
939 connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
940
941 m_unlockButton->hide();
942
943 addButtonBarWidget(m_unlockButton, m_cancelButton);
944
945 // 0. Connect for svn errors (that may occurs)
946 connect(&m_thread, SIGNAL(error(const QString &)), this,
947 SLOT(onError(const QString &)));
948
949 // 1. Getting status
950 connect(&m_thread, SIGNAL(statusRetrieved(const QString &)), this,
951 SLOT(onStatusRetrieved(const QString &)));
952 m_thread.getSVNStatus(m_workingDir, m_files, true);
953 }
954 //-----------------------------------------------------------------------------
955
onUnlockButtonClicked()956 void SVNUnlockMultiFrameRangeDialog::onUnlockButtonClicked() {
957 m_waitingLabel->show();
958
959 int fileCount = m_filesToUnlock.size();
960
961 m_textLabel->setText(tr("Unlocking %1 items...").arg(fileCount));
962
963 QStringList args;
964 args << "unlock";
965
966 for (int i = 0; i < fileCount; i++) args << m_filesToUnlock.at(i);
967
968 m_thread.disconnect(SIGNAL(done(const QString &)));
969 connect(&m_thread, SIGNAL(done(const QString &)), SLOT(onUnlockDone()));
970 m_thread.executeCommand(m_workingDir, "svn", args);
971 }
972
973 //-----------------------------------------------------------------------------
974
onStatusRetrieved(const QString & xmlResponse)975 void SVNUnlockMultiFrameRangeDialog::onStatusRetrieved(
976 const QString &xmlResponse) {
977 m_waitingLabel->hide();
978
979 SVNStatusReader sr(xmlResponse);
980 m_status = sr.getStatus();
981
982 QString userName = VersionControl::instance()->getUserName();
983
984 int count = m_status.size();
985 for (int i = 0; i < count; i++) {
986 SVNStatus s = m_status.at(i);
987 if (s.m_isLocked && s.m_lockOwner == userName)
988 m_filesToUnlock.append(m_files.at(i));
989 }
990
991 int filesToUnlockCount = m_filesToUnlock.size();
992
993 if (filesToUnlockCount == 0) {
994 m_textLabel->setText(tr("No items to unlock."));
995 switchToCloseButton();
996 } else {
997 m_waitingLabel->hide();
998 m_textLabel->setText(tr("%1 items to unlock.").arg(filesToUnlockCount));
999 m_unlockButton->show();
1000 }
1001 }
1002
1003 //-----------------------------------------------------------------------------
1004
onError(const QString & text)1005 void SVNUnlockMultiFrameRangeDialog::onError(const QString &text) {
1006 m_textLabel->setText(text);
1007 switchToCloseButton();
1008 update();
1009 m_hasError = true;
1010 }
1011
1012 //-----------------------------------------------------------------------------
1013
switchToCloseButton()1014 void SVNUnlockMultiFrameRangeDialog::switchToCloseButton() {
1015 m_waitingLabel->hide();
1016 m_unlockButton->disconnect();
1017 m_unlockButton->setText("Close");
1018 m_unlockButton->setEnabled(true);
1019 m_unlockButton->show();
1020 m_cancelButton->hide();
1021 connect(m_unlockButton, SIGNAL(clicked()), this, SLOT(close()));
1022 }
1023
1024 //-----------------------------------------------------------------------------
1025
onUnlockDone()1026 void SVNUnlockMultiFrameRangeDialog::onUnlockDone() {
1027 if (!m_hasError) {
1028 QStringList files;
1029 int fileCount = m_filesToUnlock.size();
1030 for (int i = 0; i < fileCount; i++) files.append(m_filesToUnlock.at(i));
1031 emit done(files);
1032 close();
1033 }
1034 }
1035
1036 //=============================================================================
1037 // SVNFrameRangeLockInfoDialog
1038 //-----------------------------------------------------------------------------
1039
SVNFrameRangeLockInfoDialog(QWidget * parent,const QString & workingDir,const QString & file)1040 SVNFrameRangeLockInfoDialog::SVNFrameRangeLockInfoDialog(
1041 QWidget *parent, const QString &workingDir, const QString &file)
1042 : Dialog(TApp::instance()->getMainWindow(), true, false)
1043 , m_workingDir(workingDir)
1044 , m_file(file) {
1045 setModal(false);
1046 setAttribute(Qt::WA_DeleteOnClose, true);
1047
1048 setWindowTitle(tr("Version Control: Edit Info"));
1049
1050 setMinimumSize(300, 150);
1051
1052 m_waitingLabel = new QLabel;
1053 QMovie *waitingMove = new QMovie(":Resources/waiting.gif");
1054 waitingMove->setParent(this);
1055
1056 m_waitingLabel->setMovie(waitingMove);
1057 waitingMove->setCacheMode(QMovie::CacheAll);
1058 waitingMove->start();
1059
1060 m_textLabel = new QLabel;
1061
1062 m_textLabel->setText(tr("Getting repository status..."));
1063
1064 QHBoxLayout *mainLayout = new QHBoxLayout;
1065 mainLayout->addStretch();
1066 mainLayout->addWidget(m_waitingLabel);
1067 mainLayout->addWidget(m_textLabel);
1068 mainLayout->addStretch();
1069
1070 beginHLayout();
1071 addLayout(mainLayout, false);
1072 endHLayout();
1073
1074 QPushButton *closeButton = new QPushButton(tr("Close"));
1075 connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
1076
1077 addButtonBarWidget(closeButton);
1078
1079 // 0. Connect for svn errors (that may occurs)
1080 connect(&m_thread, SIGNAL(error(const QString &)), this,
1081 SLOT(onError(const QString &)));
1082
1083 // 1. propget
1084 QStringList args;
1085 args << "proplist";
1086 args << m_file;
1087 args << "--xml";
1088 args << "-v";
1089
1090 connect(&m_thread, SIGNAL(done(const QString &)), this,
1091 SLOT(onPropGetDone(const QString &)));
1092 m_thread.executeCommand(m_workingDir, "svn", args, true);
1093 }
1094
1095 //-----------------------------------------------------------------------------
1096
onError(const QString & errorString)1097 void SVNFrameRangeLockInfoDialog::onError(const QString &errorString) {
1098 m_waitingLabel->hide();
1099 m_textLabel->setText(errorString);
1100 }
1101
1102 //-----------------------------------------------------------------------------
1103
onPropGetDone(const QString & xmlResponse)1104 void SVNFrameRangeLockInfoDialog::onPropGetDone(const QString &xmlResponse) {
1105 m_waitingLabel->hide();
1106
1107 SVNPartialLockReader reader(xmlResponse);
1108 QList<SVNPartialLock> lockList = reader.getPartialLock();
1109 if (lockList.isEmpty())
1110 m_textLabel->setText(tr("No frame range edited."));
1111 else {
1112 QList<SVNPartialLockInfo> lockInfos = lockList.at(0).m_partialLockList;
1113 if (lockInfos.isEmpty())
1114 m_textLabel->setText(tr("No frame range edited."));
1115 else {
1116 QString temp;
1117 for (int i = 0; i < lockInfos.size(); i++) {
1118 if (i != 0) temp.append("\n\n");
1119 SVNPartialLockInfo lock = lockInfos.at(i);
1120 temp.append(tr("%1 on %2 is editing frames from %3 to %4.")
1121 .arg(lock.m_userName)
1122 .arg(lock.m_hostName)
1123 .arg(lock.m_from)
1124 .arg(lock.m_to));
1125 }
1126 int height = 100 + ((lockInfos.size() - 1) * 25);
1127 setMinimumSize(300, height);
1128
1129 m_textLabel->setText(temp);
1130 }
1131 }
1132 }
1133
1134 //=============================================================================
1135 // SVNMultiFrameRangeLockInfoDialog
1136 //-----------------------------------------------------------------------------
1137
SVNMultiFrameRangeLockInfoDialog(QWidget * parent,const QString & workingDir,const QStringList & files)1138 SVNMultiFrameRangeLockInfoDialog::SVNMultiFrameRangeLockInfoDialog(
1139 QWidget *parent, const QString &workingDir, const QStringList &files)
1140 : Dialog(TApp::instance()->getMainWindow(), true, false)
1141 , m_workingDir(workingDir)
1142 , m_files(files) {
1143 setModal(false);
1144 setAttribute(Qt::WA_DeleteOnClose, true);
1145
1146 setWindowTitle(tr("Version Control: Edit Info"));
1147
1148 setMinimumSize(300, 150);
1149
1150 m_waitingLabel = new QLabel;
1151 QMovie *waitingMove = new QMovie(":Resources/waiting.gif");
1152 waitingMove->setParent(this);
1153
1154 m_waitingLabel->setMovie(waitingMove);
1155 waitingMove->setCacheMode(QMovie::CacheAll);
1156 waitingMove->start();
1157
1158 m_textLabel = new QLabel;
1159
1160 m_textLabel->setText(tr("Getting repository status..."));
1161
1162 QHBoxLayout *mainLayout = new QHBoxLayout;
1163 mainLayout->addStretch();
1164 mainLayout->addWidget(m_waitingLabel);
1165 mainLayout->addWidget(m_textLabel);
1166 mainLayout->addStretch();
1167
1168 beginHLayout();
1169 addLayout(mainLayout, false);
1170 endHLayout();
1171
1172 QPushButton *closeButton = new QPushButton(tr("Close"));
1173 connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
1174
1175 addButtonBarWidget(closeButton);
1176
1177 // 0. Connect for svn errors (that may occurs)
1178 connect(&m_thread, SIGNAL(error(const QString &)), this,
1179 SLOT(onError(const QString &)));
1180
1181 // 1. Getting status
1182 connect(&m_thread, SIGNAL(statusRetrieved(const QString &)), this,
1183 SLOT(onStatusRetrieved(const QString &)));
1184 m_thread.getSVNStatus(m_workingDir, m_files, true);
1185 }
1186
1187 //-----------------------------------------------------------------------------
1188
onError(const QString & errorString)1189 void SVNMultiFrameRangeLockInfoDialog::onError(const QString &errorString) {
1190 m_waitingLabel->hide();
1191 m_textLabel->setText(errorString);
1192 }
1193
1194 //-----------------------------------------------------------------------------
1195
onStatusRetrieved(const QString & xmlResponse)1196 void SVNMultiFrameRangeLockInfoDialog::onStatusRetrieved(
1197 const QString &xmlResponse) {
1198 m_waitingLabel->hide();
1199
1200 SVNStatusReader sr(xmlResponse);
1201 QList<SVNStatus> status = sr.getStatus();
1202
1203 // Fill_lockInfos list
1204 QList<SVNPartialLockInfo> lockInfos;
1205 SVNPartialLockInfo info;
1206 info.m_from = 0;
1207 int count = status.size();
1208 for (int i = 0; i < count; i++) {
1209 SVNStatus s = status.at(i);
1210 if (s.m_isLocked) {
1211 if (info.m_userName != s.m_lockOwner && info.m_userName != "") {
1212 lockInfos.append(info);
1213 info.m_from = 0;
1214 }
1215 info.m_userName = s.m_lockOwner;
1216 if (info.m_from == 0) {
1217 info.m_from = i + 1;
1218 info.m_to = i + 1;
1219 } else
1220 info.m_to = i + 1;
1221 }
1222 }
1223
1224 if (info.m_userName != "" && info.m_from != 0) lockInfos.append(info);
1225
1226 if (lockInfos.isEmpty())
1227 m_textLabel->setText(tr("No frame range edited."));
1228 else {
1229 QString temp;
1230 for (int i = 0; i < lockInfos.size(); i++) {
1231 if (i != 0) temp.append("\n\n");
1232 SVNPartialLockInfo lock = lockInfos.at(i);
1233 temp.append(tr("%1 is editing frames from %2 to %3")
1234 .arg(lock.m_userName)
1235 .arg(lock.m_from)
1236 .arg(lock.m_to));
1237 }
1238 int height = 100 + ((lockInfos.size() - 1) * 25);
1239 setMinimumSize(300, height);
1240
1241 m_textLabel->setText(temp);
1242 }
1243 }
1244