void HomeDialog::openProject(){ QString fichier = QFileDialog::getExistingDirectory(this, tr("Open a project"), QDir::homePath()+"/WinSDK/"); if(!fichier.isEmpty()){ emit projectOpened(fichier); close(); } }
///Regarding Projects Project* FileManager::newProject(const QString& name, const QString& rootPath, QString* error) { QString filename = cleanPath(rootPath + "/" + name); QFile file(filename); if(m_documentMap.contains(filename) || m_projectMap.contains(filename)) { if(error) *error = tr("A file with the name <br>\"%0\" <br>is already open.").arg(filename); return 0; } if(!file.open(QIODevice::Truncate|QIODevice::WriteOnly|QIODevice::Text)) { if(error) *error = tr("Unable to open the file <br>\"%0\"").arg(filename); return 0; } Project* project = new Project(name, rootPath); if(!project->isValid()) { delete project; if(error) *error = tr("Invalid project parameters."); } project->setFilename(filename); project->toXml(&file); file.close(); m_projects.append(project); m_projectMap.insert(filename, project); emit projectOpened(project); return project; }
RubySupportPart::RubySupportPart(QObject *parent, const char *name, const QStringList& ) : KDevLanguageSupport (&data, parent, name ? name : "RubySupportPart" ) { setInstance(RubySupportFactory::instance()); setXMLFile("kdevrubysupport.rc"); KAction *action; action = new KAction( i18n("&Run"), "exec", SHIFT + Key_F9, this, SLOT(slotRun()), actionCollection(), "build_execute" ); action->setToolTip(i18n("Run")); action->setWhatsThis(i18n("<b>Run</b><p>Starts an application.")); action->setIcon("ruby_run.png"); action = new KAction( i18n("Run Test Under Cursor"), "exec", ALT + Key_F9, this, SLOT(slotRunTestUnderCursor()), actionCollection(), "build_execute_test_function" ); action->setToolTip(i18n("Run Test Under Cursor")); action->setWhatsThis(i18n("<b>Run Test Under Cursor</b><p>Runs the function under the cursor as test.")); action = new KAction( i18n("Launch Browser"), "network", 0, this, SLOT(slotBrowse()), actionCollection(), "build_launch_browser" ); action->setToolTip(i18n("Launch Browser")); action->setWhatsThis(i18n("<b>Launch Browser</b><p>Opens a web browser pointing to the Ruby Rails server") ); action = new KAction( i18n("Switch To Controller"), 0, CTRL+ALT+Key_1, this, SLOT(slotSwitchToController()), actionCollection(), "switch_to_controller" ); action = new KAction( i18n("Switch To Model"), 0, CTRL+ALT+Key_2, this, SLOT(slotSwitchToModel()), actionCollection(), "switch_to_model" ); action = new KAction( i18n("Switch To View"), 0, CTRL+ALT+Key_3, this, SLOT(slotSwitchToView()), actionCollection(), "switch_to_view" ); action = new KAction( i18n("Switch To Test"), 0, CTRL+ALT+Key_4, this, SLOT(slotSwitchToTest()), actionCollection(), "switch_to_test" ); kdDebug() << "Creating RubySupportPart" << endl; m_shellWidget = new KDevShellWidget( 0, "irb console"); m_shellWidget->setIcon( SmallIcon("ruby_config.png", KIcon::SizeMedium, KIcon::DefaultState, RubySupportPart::instance())); m_shellWidget->setCaption(i18n("Ruby Shell")); mainWindow()->embedOutputView( m_shellWidget, i18n("Ruby Shell"), i18n("Ruby Shell")); mainWindow()->raiseView( m_shellWidget ); connect( core(), SIGNAL(projectOpened()), this, SLOT(projectOpened()) ); connect( core(), SIGNAL(projectClosed()), this, SLOT(projectClosed()) ); connect( core(), SIGNAL(contextMenu(QPopupMenu *, const Context *)), this, SLOT(contextMenu(QPopupMenu *, const Context *)) ); connect( partController(), SIGNAL(savedFile(const KURL&)), this, SLOT(savedFile(const KURL&)) ); connect( core(), SIGNAL(projectConfigWidget(KDialogBase*)), this, SLOT(projectConfigWidget(KDialogBase*)) ); }
PICComponent::PICComponent( ICNDocument *icnDocument, bool newItem, const char *id ) : Component( icnDocument, newItem, id ? id : "pic" ) { m_name = i18n("PIC Micro"); if ( _def_PICComponent_fileName.isEmpty() ) _def_PICComponent_fileName = i18n("<Enter location of PIC Program>"); m_bCreatedInitialPackage = false; m_bLoadingProgram = false; m_pGpsim = 0L; addButton( "run", QRect(), KIcon( "media-playback-start" ) ); addButton( "pause", QRect(), KIcon( "media-playback-pause" ) ); addButton( "reset", QRect(), KIcon( "process-stop" ) ); addButton( "reload", QRect(), KIcon( "view-refresh" ) ); connect( KTechlab::self(), SIGNAL(recentFileAdded(const KUrl &)), this, SLOT(slotUpdateFileList()) ); connect( ProjectManager::self(), SIGNAL(projectOpened()), this, SLOT(slotUpdateFileList()) ); connect( ProjectManager::self(), SIGNAL(projectClosed()), this, SLOT(slotUpdateFileList()) ); connect( ProjectManager::self(), SIGNAL(projectCreated()), this, SLOT(slotUpdateFileList()) ); connect( ProjectManager::self(), SIGNAL(subprojectCreated()), this, SLOT(slotUpdateFileList()) ); connect( ProjectManager::self(), SIGNAL(filesAdded()), this, SLOT(slotUpdateFileList()) ); connect( ProjectManager::self(), SIGNAL(filesRemoved()), this, SLOT(slotUpdateFileList()) ); createProperty( "program", Variant::Type::FileName ); property("program")->setCaption( i18n("Program") ); QString filter; filter = QString("*.flowcode *.cod *.asm *.basic *.c|%1").arg(i18n("All Supported Files")); filter += QString("\n*.flowcode|FlowCode (*.flowcode)"); filter += QString("\n*.cod|%1 (*.cod)").arg(i18n("Symbol File")); filter += QString("\n*.asm|%1 (*.asm)").arg(i18n("Assembly Code")); filter += QString("\n*.basic *.microbe|Microbe (*.basic, *.microbe)"); filter += QString("\n*.c|C (*.c)"); filter += QString("\n*|%1").arg(i18n("All Files")); property("program")->setFilter( filter ); // Used for restoring the pins on file loading before we have had a change // to compile the PIC program createProperty( "lastPackage", Variant::Type::String ); property("lastPackage")->setHidden( true ); // //HACK This is to enable loading with pre-0.3 files (which didn't set a "lastPackage" // // property). This will allow a P16F84 PIC to be initialized (which agrees with pre-0.3 // // behaviour), but it will also load it if // This to allow loading of the PIC component from pre-0.3 files (which didn't set a // "lastPackage" property). if ( !newItem ) property("lastPackage")->setValue("P16F84"); slotUpdateFileList(); slotUpdateBtns(); initPackage( 0 ); }
void ProjectManager::add(Project* project) { int insertRow(rowCount()); beginInsertRows(QModelIndex(), insertRow, insertRow); m_projects.append(project); endInsertRows(); emit projectOpened(index(insertRow)); }
ValgrindPart::ValgrindPart( QObject *parent, const char *name, const QStringList& ) : KDevPlugin( &data, parent, name ? name : "ValgrindPart" ) { setInstance( ValgrindFactory::instance() ); setXMLFile( "kdevpart_valgrind.rc" ); proc = new KShellProcess(); connect( proc, SIGNAL(receivedStdout( KProcess*, char*, int )), this, SLOT(receivedStdout( KProcess*, char*, int )) ); connect( proc, SIGNAL(receivedStderr( KProcess*, char*, int )), this, SLOT(receivedStderr( KProcess*, char*, int )) ); connect( proc, SIGNAL(processExited( KProcess* )), this, SLOT(processExited( KProcess* )) ); connect( core(), SIGNAL(stopButtonClicked(KDevPlugin*)), this, SLOT(slotStopButtonClicked(KDevPlugin*)) ); connect( core(), SIGNAL(projectOpened()), this, SLOT(projectOpened()) ); m_widget = new ValgrindWidget( this ); m_widget->setIcon( SmallIcon("fork") ); m_widget->setCaption(i18n("Valgrind Output")); QWhatsThis::add( m_widget, i18n( "<b>Valgrind</b><p>Shows the output of the valgrind. Valgrind detects<br>" "use of uninitialized memory<br>" "reading/writing memory after it has been free'd<br>" "reading/writing off the end of malloc'd blocks<br>" "reading/writing inappropriate areas on the stack<br>" "memory leaks -- where pointers to malloc'd blocks are lost forever<br>" "passing of uninitialised and/or unaddressable memory to system calls<br>" "mismatched use of malloc/new/new [] vs free/delete/delete []<br>" "some abuses of the POSIX pthread API." ) ); KAction* action = new KAction( i18n("&Valgrind Memory Leak Check"), 0, this, SLOT(slotExecValgrind()), actionCollection(), "tools_valgrind" ); action->setToolTip(i18n("Valgrind memory leak check")); action->setWhatsThis(i18n("<b>Valgrind memory leak check</b><p>Runs Valgrind - a tool to help you find memory-management problems in your programs.")); action = new KAction( i18n("P&rofile with KCachegrind"), 0, this, SLOT(slotExecCalltree()), actionCollection(), "tools_calltree" ); action->setToolTip(i18n("Profile with KCachegrind")); action->setWhatsThis(i18n("<b>Profile with KCachegrind</b><p>Runs your program in calltree and then displays profiler information in KCachegrind.")); mainWindow()->embedOutputView( m_widget, "Valgrind", i18n("Valgrind memory leak check") ); }
PythonSupportPart::PythonSupportPart(QObject *parent, const char *name, const QStringList &) : KDevLanguageSupport(&data, parent, name ? name : "PythonSupportPart") { setInstance(PythonSupportFactory::instance()); setXMLFile("kdevpythonsupport.rc"); connect( core(), SIGNAL(projectOpened()), this, SLOT(projectOpened()) ); connect( core(), SIGNAL(projectClosed()), this, SLOT(projectClosed()) ); connect( partController(), SIGNAL(savedFile(const KURL&)), this, SLOT(savedFile(const KURL&)) ); connect( core(), SIGNAL(projectConfigWidget(KDialogBase*)), this, SLOT(projectConfigWidget(KDialogBase*)) ); connect( core(), SIGNAL(contextMenu(QPopupMenu *, const Context *)), this, SLOT(contextMenu(QPopupMenu *, const Context *)) ); KAction *action; action = new KAction( i18n("Execute Program"), "exec", 0, this, SLOT(slotExecute()), actionCollection(), "build_exec" ); action->setToolTip( i18n("Execute program") ); action->setWhatsThis(i18n("<b>Execute program</b><p>Runs the Python program.")); action = new KAction( i18n("Execute String..."), "exec", 0, this, SLOT(slotExecuteString()), actionCollection(), "build_execstring" ); action->setToolTip( i18n("Execute string") ); action->setWhatsThis(i18n("<b>Execute String</b><p>Executes a string as Python code.")); action = new KAction( i18n("Start Python Interpreter"), "exec", 0, this, SLOT(slotStartInterpreter()), actionCollection(), "build_runinterpreter" ); action->setToolTip( i18n("Start Python interpreter") ); action->setWhatsThis(i18n("<b>Start python interpreter</b><p>Starts the Python interpreter without a program")); action = new KAction( i18n("Python Documentation..."), 0, this, SLOT(slotPydoc()), actionCollection(), "help_pydoc" ); action->setToolTip( i18n("Python documentation") ); action->setWhatsThis(i18n("<b>Python documentation</b><p>Shows a Python documentation page.")); }
BashSupportPart::BashSupportPart(QObject *parent, const char *name, const QStringList& ) : KDevLanguageSupport (&data, parent, name ? name : "BashSupportPart" ) { setInstance(BashSupportFactory::instance()); setXMLFile("kdevbashsupport.rc"); KAction *action; action = new KAction( i18n("&Run"), "exec",Key_F9,this, SLOT(slotRun()),actionCollection(), "build_execute" ); action->setToolTip(i18n("Run")); action->setWhatsThis(i18n("<b>Run</b><p>Starts an application.")); kdDebug() << "Creating BashSupportPart" << endl; connect( core(), SIGNAL(projectConfigWidget(KDialogBase*)), this, SLOT(projectConfigWidget(KDialogBase*)) ); connect( core(), SIGNAL(projectOpened()), this, SLOT(projectOpened()) ); connect( core(), SIGNAL(projectClosed()), this, SLOT(projectClosed()) ); connect( partController(), SIGNAL(savedFile(const KURL&)), this, SLOT(savedFile(const KURL&)) ); connect(partController(), SIGNAL(activePartChanged(KParts::Part*)), this, SLOT(slotActivePartChanged(KParts::Part *))); m_cc = new BashCodeCompletion(); }
// 将项目projectName添加到一打开项目列表中, 如果在所有项目列表中没有该项目, 则返回false, 否则返回true bool ProjectManager::openClosedProject(const QString &projectName) { if (allProjectMap.contains(projectName) && closedProjectList.contains(projectName)) { openedProjectList << projectName; closedProjectList.removeAll(projectName); historySettings->setValue(projectName + "/Status", "On"); historySettings->sync(); emit projectOpened(projectName); ifNoCurrentProject(projectName); return true; } else { return false; } }
Project* FileManager::openProject(QString filename, QString* error) { filename = cleanPath(filename); QFileInfo fi(filename); QFile file(filename); if(!fi.exists()) { if(error) *error = tr("The file \"%0\"<br>does not exist.").arg(filename); return 0; } if(!fi.isFile()) { if(error) *error = tr("\"%0\"<br>is not a file.").arg(filename); return 0; } if(m_documentMap.contains(filename) || m_projectMap.contains(filename)) { if(error) *error = tr("A file with the name <br>\"%0\" <br>is already open.").arg(filename); return 0; } if(!file.open(QIODevice::ReadOnly|QIODevice::Text)) { if(error) *error = tr("Unable to open the file <br>\"%0\".").arg(filename); return 0; } Project* project = Project::fromXml(&file,cleanPath(fi.absolutePath())); file.close(); if(!project) { if(error) *error = tr("Unable to read the project file <br>\"%0\".").arg(filename); return 0; } if(!project->isValid()) { delete project; if(error) *error = tr("Invalid project."); } project->setFilename(filename); m_projects.append(project); m_projectMap.insert(filename, project); emit projectOpened(project); return project; }
FileSelectorPart::FileSelectorPart(QObject *parent, const char *name, const QStringList &) : KDevPlugin(&data, parent, name ? name : "FileSelectorPart") { setInstance(FileSelectorFactory::instance()); m_filetree = new KDevFileSelector( this, mainWindow(), partController(), 0, "fileselectorwidget" ); connect( m_filetree->dirOperator(), SIGNAL(fileSelected(const KFileItem*)), this, SLOT(fileSelected(const KFileItem*))); connect( core(), SIGNAL(projectOpened()), this, SLOT(slotProjectOpened()) ); connect( core(), SIGNAL(configWidget(KDialogBase*)), this, SLOT(slotConfigWidget(KDialogBase*)) ); m_filetree->setCaption( i18n("File Selector") ); m_filetree->setIcon( SmallIcon( info()->icon() ) ); mainWindow()->embedSelectView( m_filetree, i18n("File Selector"), i18n("File selector") ); QWhatsThis::add(m_filetree, i18n("<b>File selector</b><p>This file selector lists directory contents and provides some file management functions.")); m_filetree->readConfig( instance()->config(), "fileselector" ); m_newFileAction = new KAction(i18n("New File..."), CTRL+ALT+SHIFT+Key_N, this, SLOT(newFile()), this); }
void HomeDialog::openRecentProject(QListWidgetItem* i){ emit projectOpened(recentprojectlist.value(ui->RecentProjectList->row(i))); close(); }
// 将projectName添加到所有项目列表以及一打开项目列表中, 如果在所有项目列表中已经有了该项目, // 则检查该项目的path是否相等, 如果相等则添加该项目到一打开项目列表中并返true, 否则什么都不做并返回false. bool ProjectManager::openProject(const QString &rootPath) { QString path = rootPath; path.remove(QRegExp("/\\s*$")); QFileInfo fileInfo(path + "/project.small"); if (!fileInfo.exists() || !fileInfo.isFile()) return false; QSettings *projectSettings = new QSettings(fileInfo.absoluteFilePath(), QSettings::IniFormat); QString name = projectSettings->value("Name").toString(); // 5种情况 // 1. allProjectMap 没有key name, 且path也不为 allProjectMap中的值 // 这种情况属于打开一个不在历史项目中的项目, 正常导入该项目, 发送已导入信号 // 2. allProjectMap 没有key name, 且path = allProjectMap[otherName], otherName != name // 这种情况属于打开一个已经在allProjectMap中的项目, 但是项目配置文件中的项目名称已经与导入时的项目名称不同了, // 应用程序保证了如果修改了项目名称, 则allProjectMap等数也将相应的修改, 所以属于异常 // 处理方式: 将该项目名称改回来, 如果该项目已关闭, 则打开它 // 3. allProjectMap 有了key name, 且path = allProjectMap[name], 且closedProjectList含有name // 这种情况属于打开一个已经关闭的项目 // 4. allProjectMap 有了key name, 且path != allProjectMap[name] // 这种情况属于打开一个不在历史项目中的项目, 但是该项目名称与已有的项目重名了 // 处理方式: 重命名该项目使之不重名, 导入该项目, 发送已导入信号 // 5. allProjectMap 有了key name, 且path = allProjectMap[name], 且openedProjectList含有name // 这种情况属于打开一个已经关闭的项目 if (!allProjectMap.contains(name) && !pathList.contains(path)) { allProjectMap[name] = path; openedProjectList << name; pathList << path; historySettings->setValue(name + "/Status", "On"); historySettings->setValue(name + "/IsCurrent", "False"); historySettings->setValue(name + "/RootPath", path); historySettings->sync(); emit projectOpened(name); ifNoCurrentProject(name); return true; } else if (!allProjectMap.contains(name) && pathList.contains(path)) { QMap<QString, QString>::const_iterator i = allProjectMap.constBegin(); QString projectName = QString(); while (i != allProjectMap.constEnd()) { if (i.value() == path) { projectName = i.key(); projectSettings->setValue("Name", projectName); break; } ++i; } // 如果该项目已关闭, 则打开它 if (closedProjectList.contains(projectName)) openClosedProject(projectName); return true; } else if (allProjectMap.contains(name) && path == allProjectMap[name] && closedProjectList.contains(name)) { return openClosedProject(name); } else if (allProjectMap.contains(name) && path != allProjectMap[name]) { name = validProjectName(name); projectSettings->setValue("Name", name); allProjectMap[name] = path; openedProjectList << name; pathList << path; emit projectOpened(name); ifNoCurrentProject(name); return true; } else { return true; } }