MCPcopy Create free account
hub / github.com/KDE/kdevelop / openProject

Method openProject

kdevplatform/shell/projectcontroller.cpp:808–898  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

806}
807
808void ProjectController::openProject( const QUrl &projectFile )
809{
810 Q_D(ProjectController);
811
812 QUrl url = projectFile;
813
814 if ( url.isEmpty() ) {
815 url = d->dialog->askProjectConfigLocation(false);
816 if ( url.isEmpty() ) {
817 return;
818 }
819 }
820
821 Q_ASSERT(!url.isRelative());
822
823 QList<const Session*> existingSessions;
824 if(!Core::self()->sessionController()->activeSession()->containedProjects().contains(url))
825 {
826 const auto sessions = Core::self()->sessionController()->sessions();
827 for (const Session* session : sessions) {
828 if(session->containedProjects().contains(url))
829 {
830 existingSessions << session;
831#if 0
832 ///@todo Think about this! Problem: The session might already contain files, the debugger might be active, etc.
833 //If this session is empty, close it
834 if(Core::self()->sessionController()->activeSession()->description().isEmpty())
835 {
836 //Terminate this instance of kdevelop if the user agrees
837 const auto windows = Core::self()->uiController()->controller()->mainWindows();
838 for (Sublime::MainWindow* window : windows) {
839 window->close();
840 }
841 }
842#endif
843 }
844 }
845 }
846
847 if ( ! existingSessions.isEmpty() ) {
848 ScopedDialog<QDialog> dialog(Core::self()->uiControllerInternal()->activeMainWindow());
849 dialog->setWindowTitle(i18nc("@title:window", "Project Already Open"));
850
851 auto mainLayout = new QVBoxLayout(dialog);
852 mainLayout->addWidget(new QLabel(i18n("The project you're trying to open is already open in at least one "
853 "other session.<br>What do you want to do?")));
854 QGroupBox sessions;
855 sessions.setLayout(new QVBoxLayout);
856 auto* newSession = new QRadioButton(i18nc("@option:radio", "Add project to current session"));
857 sessions.layout()->addWidget(newSession);
858 newSession->setChecked(true);
859 for (const Session* session : std::as_const(existingSessions)) {
860 auto* button = new QRadioButton(i18nc("@option:radio", "Open session %1", session->description()));
861 button->setProperty("sessionid", session->id().toString());
862 sessions.layout()->addWidget(button);
863 }
864 sessions.layout()->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding));
865 mainLayout->addWidget(&sessions);

Callers 1

loadProjectFunction · 0.45

Calls 15

containedProjectsMethod · 0.80
sessionControllerMethod · 0.80
sessionsMethod · 0.80
mainWindowsMethod · 0.80
uiControllerMethod · 0.80
uiControllerInternalMethod · 0.80
setPropertyMethod · 0.80
buttonMethod · 0.80
execMethod · 0.80
propertyMethod · 0.80
loadSessionMethod · 0.80
importProjectMethod · 0.80

Tested by 1

loadProjectFunction · 0.36