bool SessionManager::restoreYourSession(int index) { const QString & sessionPath = KStandardDirs::locateLocal("appdata" , QL1S("usersessions/")); const QString & sessionName = QL1S("ses") + QString::number(index); QDomDocument document("session"); if (!readSessionDocument(document,sessionPath + sessionName)) return false; // trace the windows to delete RekonqWindowList wList = rApp->rekonqWindowList(); for (unsigned int winNo = 0; winNo < document.elementsByTagName("window").length(); winNo++) { QDomElement window = document.elementsByTagName("window").at(winNo).toElement(); RekonqWindow *tw = rApp->newWindow(); int currentTab = loadTabs(tw, window, true, false); tw->tabWidget()->setCurrentIndex(currentTab); } Q_FOREACH(const QWeakPointer<RekonqWindow> &w, wList) { if (!w.isNull()) w.data()->close(); } return true; }
bool SessionManager::restoreWindow(RekonqWindow* window) { QDomDocument document("session"); if (!readSessionDocument(document, m_sessionFilePath)) return false; unsigned int winNo; for (winNo = 0; winNo < document.elementsByTagName("window").length(); winNo++) { QDomElement savedWindowElement = document.elementsByTagName("window").at(winNo).toElement(); if (window->objectName() != savedWindowElement.attribute("name", "")) continue; int currentTab = loadTabs(window, savedWindowElement, false); window->tabWidget()->setCurrentIndex(currentTab); return true; } return false; }
bool SessionManager::restoreJustThePinnedTabs() { QDomDocument document("session"); if (!readSessionDocument(document, m_sessionFilePath)) return false; bool done = false; for (unsigned int winNo = 0; winNo < document.elementsByTagName("window").length(); winNo++) { QDomElement window = document.elementsByTagName("window").at(winNo).toElement(); if (!areTherePinnedTabs(window)) continue; done = true; RekonqWindow *tw = rApp->newWindow(false); int currentTab = loadTabs(tw, window, false, true); tw->tabWidget()->setCurrentIndex(currentTab); } return done; }
void MainFrm::openRecentFile() { QAction *action = qobject_cast<QAction *>(sender()); if (action){ if (!readXMLFile(action->data().toString())) this->displayError(tr("Could not parse XML file! Are you sure it exists and is a valid project file?"),true); else loadTabs(); } }
EditInspectionDialogueCompressors::EditInspectionDialogueCompressors(const QString &customer_id, const QString &circuit_id, const QString &inspection_date, QWidget *parent) : QWidget(parent), customer_id(customer_id), circuit_id(circuit_id), original_inspection_date(inspection_date) { QVBoxLayout *layout = new QVBoxLayout(this); tab_w = new QTabWidget(this); layout->addWidget(tab_w); loadTabs(inspection_date); }
void MainFrm::loadFile() { if (pFrmReports->isVisible()) closeSecondaryFrm(pFrmReports); QString fileName = QFileDialog::getOpenFileName(this, tr("Open Project"), tr(""), tr("Project Files (*.xml)")); if (!fileName.isEmpty()){ if (!readXMLFile(fileName)) this->displayError(tr("Could not parse XML file! Are you sure this is a valid project file?"),true); else loadTabs(); setCurrentFile(fileName); statusShow(tr("File loaded")); } }
bool SessionManager::restoreSessionFromScratch() { QDomDocument document("session"); if (!readSessionDocument(document, m_sessionFilePath)) return false; for (unsigned int winNo = 0; winNo < document.elementsByTagName("window").length(); winNo++) { QDomElement window = document.elementsByTagName("window").at(winNo).toElement(); RekonqWindow *tw = rApp->newWindow(); int currentTab = loadTabs(tw, window, true, false); tw->tabWidget()->setCurrentIndex(currentTab); } return true; }
void SessionManager::restoreCrashedSession() { QDomDocument document("session"); if (!readSessionDocument(document, m_sessionFilePath)) return; for (unsigned int winNo = 0; winNo < document.elementsByTagName("window").length(); winNo++) { QDomElement window = document.elementsByTagName("window").at(winNo).toElement(); RekonqWindow *tw = (winNo == 0) ? rApp->rekonqWindow() : rApp->newWindow(); KUrl u = tw->currentWebWindow()->url(); bool useCurrentTab = (u.isEmpty() || u.protocol() == QL1S("rekonq")); int currentTab = loadTabs(tw, window, useCurrentTab); tw->tabWidget()->setCurrentIndex(currentTab); } setSessionManagementEnabled(true); }