src/mainwindow.cpp

changeset 147
37f936073cac
parent 142
e085f36e4d9f
child 148
e1ced2523cad
equal deleted inserted replaced
146:235941b7322f 147:37f936073cac
207 Document* MainWindow::currentDocument() 207 Document* MainWindow::currentDocument()
208 { 208 {
209 return qobject_cast<Document*>(this->ui->tabs->currentWidget()); 209 return qobject_cast<Document*>(this->ui->tabs->currentWidget());
210 } 210 }
211 211
212 void MainWindow::closeDocument(Document *document)
213 {
214 const int tabIndex = this->ui->tabs->indexOf(document);
215 if (tabIndex != -1)
216 {
217 this->ui->tabs->removeTab(tabIndex);
218 const QString closedDocumentName = pathToName(document->modelPath());
219 delete document;
220 }
221 QSet<QString> openedDocumentNames;
222 for (int i = 0; i < this->ui->tabs->count(); i += 1)
223 {
224 Document* document = qobject_cast<Document*>(this->ui->tabs->widget(i));
225 if (document != nullptr)
226 {
227 openedDocumentNames.insert(pathToName(document->modelPath()));
228 }
229 }
230 }
231
212 void MainWindow::handleDocumentSplitterChange() 232 void MainWindow::handleDocumentSplitterChange()
213 { 233 {
214 Document* currentDocument = this->currentDocument(); 234 Document* currentDocument = this->currentDocument();
215 if (currentDocument != nullptr) 235 if (currentDocument != nullptr)
216 { 236 {

mercurial