MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / addWidget

Method addWidget

src/plugins/git/gui/gittabwidget.cpp:152–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152int GitTabWidget::addWidget(GitType type, const QString &name)
153{
154 QFileInfo info(name);
155 QString indexStr, title;
156 switch (type) {
157 case GitLog:
158 indexStr = tr("Git Log \"%1\"").arg(name);
159 title = tr("Git Log \"%1\"").arg(info.fileName());
160 break;
161 case GitBlame:
162 indexStr = tr("Git Blame \"%1\"").arg(name);
163 title = tr("Git Blame \"%1\"").arg(info.fileName());
164 break;
165 case GitDiff:
166 indexStr = tr("Git Diff \"%1\"").arg(name);
167 title = tr("Git Diff \"%1\"").arg(info.fileName());
168 break;
169 case GitShow:
170 indexStr = tr("Git Show \"%1\"").arg(name);
171 title = indexStr;
172 break;
173 }
174
175 int index = d->indexOf(indexStr);
176 if (index == -1) {
177 auto widget = d->createWidget(type);
178 if (!widget)
179 return -1;
180
181 widget->setSourceFile(name);
182 widget->setReadyMessage(tr("Working..."));
183 d->stackedWidget->addWidget(widget);
184 index = d->tabBar->addTab(title);
185 d->tabBar->setTabToolTip(index, indexStr);
186 } else {
187 auto widget = qobject_cast<GitBaseWidget *>(d->stackedWidget->widget(index));
188 if (widget)
189 widget->setReadyMessage(tr("Working..."));
190 }
191
192 d->tabBar->setCurrentIndex(index);
193 return index;
194}
195
196void GitTabWidget::setInfo(int index, const QStringList &infos)
197{

Callers 7

readyWorkMethod · 0.45
initUIMethod · 0.45
initUIMethod · 0.45
initUIMethod · 0.45
initUIMethod · 0.45
initUIMethod · 0.45
initUIMethod · 0.45

Calls 8

fileNameMethod · 0.80
addTabMethod · 0.80
indexOfMethod · 0.45
createWidgetMethod · 0.45
setSourceFileMethod · 0.45
setReadyMessageMethod · 0.45
widgetMethod · 0.45
setCurrentIndexMethod · 0.45

Tested by

no test coverage detected