MCPcopy Create free account
hub / github.com/KDE/kdevelop / TransactionItem

Method TransactionItem

kdevplatform/shell/progresswidget/progressdialog.cpp:108–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106// ----------------------------------------------------------------------------
107
108TransactionItem::TransactionItem( QWidget *parent,
109 ProgressItem *item, bool first )
110 : QWidget( parent ), mCancelButton( nullptr ), mItem( item )
111{
112 auto vbox = new QVBoxLayout(this);
113 vbox->setSpacing( 2 );
114 vbox->setContentsMargins(2, 2, 2, 2);
115 setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
116
117 mFrame = new QFrame( this );
118 mFrame->setFrameShape( QFrame::HLine );
119 mFrame->setFrameShadow( QFrame::Raised );
120 mFrame->show();
121 vbox->setStretchFactor( mFrame, 3 );
122 vbox->addWidget( mFrame );
123
124 auto* h = new QWidget( this );
125 auto hboxLayout = new QHBoxLayout(h);
126 hboxLayout->setContentsMargins(0, 0, 0, 0);
127 hboxLayout->setSpacing( 5 );
128 vbox->addWidget( h );
129
130 mItemLabel =
131 new QLabel( fontMetrics().elidedText( item->label(), Qt::ElideRight, MAX_LABEL_WIDTH ), h );
132 h->layout()->addWidget( mItemLabel );
133 h->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
134
135 mProgress = new QProgressBar( h );
136 hboxLayout->addWidget(mProgress);
137 mProgress->setMaximum( 100 );
138 mProgress->setValue( item->progress() );
139 h->layout()->addWidget( mProgress );
140
141 if ( item->canBeCanceled() ) {
142 mCancelButton = new QPushButton( QIcon::fromTheme( QStringLiteral("dialog-cancel") ), QString(), h );
143 hboxLayout->addWidget(mCancelButton);
144 mCancelButton->setToolTip( i18nc("@info:tooltip", "Cancel this operation" ) );
145 connect ( mCancelButton, &QPushButton::clicked,
146 this, &TransactionItem::slotItemCanceled);
147 h->layout()->addWidget( mCancelButton );
148 }
149
150 h = new QWidget( this );
151 hboxLayout = new QHBoxLayout(h);
152 hboxLayout->setContentsMargins(0, 0, 0, 0);
153 hboxLayout->setSpacing( 5 );
154 h->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
155 vbox->addWidget( h );
156 mItemStatus = new QLabel( h );
157 hboxLayout->addWidget(mItemStatus);
158 mItemStatus->setTextFormat( Qt::RichText );
159 mItemStatus->setText(
160 fontMetrics().elidedText( item->status(), Qt::ElideRight, MAX_LABEL_WIDTH ) );
161 h->layout()->addWidget( mItemStatus );
162 if ( first ) {
163 hideHLine();
164 }
165}

Callers

nothing calls this directly

Calls 9

showMethod · 0.80
canBeCanceledMethod · 0.80
setToolTipMethod · 0.80
QStringClass · 0.50
addWidgetMethod · 0.45
setValueMethod · 0.45
progressMethod · 0.45
setTextMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected