MCPcopy Create free account
hub / github.com/baldurk/renderdoc / copySelection

Method copySelection

qrenderdoc/Widgets/Extended/RDTreeView.cpp:561–629  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

559}
560
561void RDTreeView::copySelection()
562{
563 QModelIndexList sel = selectionModel()->selectedRows();
564
565 std::sort(sel.begin(), sel.end(), CompareModelIndex);
566
567 QVector<int> widths;
568
569 ICaptureContext *ctx = getCaptureContext(this);
570
571 int minDepth = INT_MAX;
572 int maxDepth = 0;
573
574 // align the copied data so that each column is the same width
575 for(QModelIndex idx : sel)
576 {
577 int colCount = model()->columnCount(idx);
578
579 widths.resize(qMax(widths.size(), colCount));
580
581 for(int i = 0; i < colCount; i++)
582 {
583 QVariant var = model()->data(model()->index(idx.row(), i, idx.parent()));
584 QString text = ctx ? RichResourceTextFormat(*ctx, var) : var.toString();
585 widths[i] = qMax(widths[i], text.count());
586 }
587
588 int depth = GetDepth(model(), idx);
589
590 minDepth = qMin(minDepth, depth);
591 maxDepth = qMax(maxDepth, depth);
592 }
593
594 // add on two characters for every depth, for indent
595 for(int &i : widths)
596 i += 2 * (maxDepth - minDepth - 1);
597
598 // only align up to 50 characters so one really long item doesn't mess up the whole thing
599 for(int &i : widths)
600 i = qMin(50, i);
601
602 QString clipData;
603 for(QModelIndex idx : sel)
604 {
605 int colCount = model()->columnCount(idx);
606
607 int depth = GetDepth(model(), idx);
608
609 QString line;
610
611 for(int i = 0; i < colCount; i++)
612 {
613 QString format = i == 0 ? QFormatStr("%1") : QFormatStr(" %1");
614
615 QVariant var = model()->data(model()->index(idx.row(), i, idx.parent()));
616 QString text = ctx ? RichResourceTextFormat(*ctx, var) : var.toString();
617
618 if(i == 0)

Callers 1

variables_contextMenuMethod · 0.45

Calls 15

getCaptureContextFunction · 0.85
RichResourceTextFormatFunction · 0.85
GetDepthFunction · 0.85
QLatin1CharClass · 0.85
trimmedMethod · 0.80
sortFunction · 0.50
modelFunction · 0.50
QStringFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
columnCountMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected