| 150 | } |
| 151 | |
| 152 | int 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 | |
| 196 | void GitTabWidget::setInfo(int index, const QStringList &infos) |
| 197 | { |
no test coverage detected