| 153 | } |
| 154 | |
| 155 | void TabBar::setFileName(const QString &fileName) |
| 156 | { |
| 157 | if (fileName.isEmpty() || !QFile::exists(fileName)) |
| 158 | return; |
| 159 | |
| 160 | int index = indexOf(fileName); |
| 161 | if (-1 != index) { |
| 162 | d->tabBar->setCurrentIndex(index); |
| 163 | return; |
| 164 | } |
| 165 | |
| 166 | QSignalBlocker block(d->tabBar); |
| 167 | QFileInfo info(fileName); |
| 168 | index = d->tabBar->addTab(info.fileName()); |
| 169 | d->tabBar->setTabToolTip(index, fileName); |
| 170 | d->tabBar->setCurrentIndex(index); |
| 171 | |
| 172 | emit tabSwitched(fileName); |
| 173 | editor.switchedFile(fileName); |
| 174 | } |
| 175 | |
| 176 | int TabBar::indexOf(const QString &fileName) |
| 177 | { |
no test coverage detected