⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kscope.cpp

📁 This a source insight software in Linux. It s is similar to the source insight software for windows.
💻 CPP
📖 第 1 页 / 共 3 页
字号:
 */void KScope::slotProjectCscopeOut(){	QString sFilePath;		// Prompt for a Cscope.out file	sFilePath = KFileDialog::getOpenFileName();	if (sFilePath.isEmpty())		return;	// Open a temporary project	openCscopeOut(sFilePath);	}/** * Handles the "Cscope->References..." menu command. * Prompts the user for a symbol name, and initiates a query to find all  * references to that symbol. */void KScope::slotQueryReference(){	slotQuery(SymbolDlg::Reference, true);}/** * Handles the "Cscope->Definition..." menu command. * Prompts the user for a symbol name, and initiates a query to find the  * global definition of that symbol. */void KScope::slotQueryDefinition(){	slotQuery(SymbolDlg::Definition, true);}/** * Handles the "Cscope->Called Functions..." menu command. * Prompts the user for a function name, and initiates a query to find all  * function calls from that function. */void KScope::slotQueryCalled(){	slotQuery(SymbolDlg::Called, true);}/** * Handles the "Cscope->Calling Functions..." menu command. * Prompts the user for a function name, and initiates a query to find all  * functions calling that function. */void KScope::slotQueryCalling(){	slotQuery(SymbolDlg::Calling, true);}/** * Handles the "Cscope->Find Text..." menu command. * Prompts the user for a string, and initiates a query to find alloccurances  * of that string. */void KScope::slotQueryText(){	slotQuery(SymbolDlg::Text, true);}/** * Handles the "Cscope->Find EGrep Pattern..." menu command. * Prompts the user for a regular expression, and initiates a query to find  * all strings matching that pattern. */void KScope::slotQueryPattern(){	slotQuery(SymbolDlg::Pattern, true);}/** * Handles the "Cscope->Find File..." menu command. * Prompts the user for a file name, and initiates a query to find all files * having that name. */void KScope::slotQueryFile(){	slotQuery(SymbolDlg::FileName, true);}/** * Handles the "Cscope->Find Including Files..." menu command. * Prompts the user for a file name, and initiates a query to find all files * having an #include directive to that file. */void KScope::slotQueryIncluding(){	slotQuery(SymbolDlg::Including, true);}/** * Handles the "Cscope->Quick Definition" menu command. * Initiates a query to find the global definition of the symbol currently * selected or under the cursor. The user is prompted only if no symbol can * be found. */void KScope::slotQueryQuickDef(){	QString sSymbol;	QueryViewDlg* pDlg;	uint nType;		// Get the requested symbol and query type	nType = SymbolDlg::Definition;	if (!getSymbol(nType, sSymbol, false))		return;			// Create a modeless query view dialogue	pDlg = new QueryViewDlg(QueryViewDlg::DestroyOnSelect, this);		// Display a line when it is selected in the dialogue	connect(pDlg, SIGNAL(lineRequested(const QString&, uint)), this,		SLOT(slotShowEditor(const QString&, uint)));			// Start the query	pDlg->query(nType, sSymbol);}/** * Handles the "Cscope->Call Tree..." menu command. * Displays a tree of functions calling the requested function. */void KScope::slotCallTree(){	slotQuery(SymbolDlg::CallTree, true);}/** * Handles the "Cscope->Rebuild Database..." command. * Rebuilds Cscope's database for the current project. */void KScope::slotRebuildDB(){	if (!m_pProjMgr->dbExists()) {		m_pProgressDlg = new ProgressDlg(i18n("KScope"), i18n("Please wait "			"while the database is built for the first time"), this);		m_pProgressDlg->setAllowCancel(false);		m_pProgressDlg->setValue(0);	}		m_pCscopeBuild->rebuild();}/** * Handles the "Settings->Configure Shortcuts..." command. * Displays the prferences dialog, which allows the user  * to change the shortcuts for KScope. */void KScope::slotShortcuts(){	KKeyDialog::configure(actionCollection(), this);}/** * Handles the "Settings->Configure KScope..." command. * Displays the prferences dialog, which allows the user to set different * configuration parameters for KScope. */void KScope::slotConfigure(){	PreferencesDlg dlg;	// Apply the preferences if either the "Apply" or the "OK" buttons are	// clicked	connect(&dlg, SIGNAL(applyPref()), this, SLOT(slotApplyPref()));	// Show the dialog	dlg.exec();}/** * Refreshes the file list when files are added to or removed from a project, * and rebuilds the Cscope database. * This slot is attached to the fileListChanged() signal emitted by  * the ProjectManager object. */void KScope::slotProjectFilesChanged(){	QStringList slArgs;		// Refresh the file list	m_pFileList->clear();	m_pProjMgr->fillList(m_pFileList);		// Rebuild the symbol database	if (isAutoRebuildEnabled())		slotRebuildDB();}/** * Adds a list of files to the current project. * This slot is connected to the filesAdded() signal of the ProjectManager * object. Once files are added to the project, they are also added to the * file list, and the project's database is rebuilt. * @param	slFiles	The list of file paths added to the project */void KScope::slotFilesAdded(const QStringList& slFiles){	QStringList::const_iterator itr;	// Add the file paths to the project's file list	for (itr = slFiles.begin(); itr != slFiles.end(); ++itr)		m_pFileList->addItem(*itr);		// Rebuild the database	if (isAutoRebuildEnabled())		slotRebuildDB();}/** * Promts the user for a symbol, an starts a new Cscope query. * @param	nType	The numeric query type code * @param	bPrompt	true to always prompt for a symbol, false to try to * 					obtain the symbol automatically */void KScope::slotQuery(uint nType, bool bPrompt){	QString sSymbol;	CallTreeDlg* pCallTreeDlg;		// Get the requested symbol and query type	if (!getSymbol(nType, sSymbol, bPrompt))		return;			if (nType == SymbolDlg::CallTree) {		// Create and display a call tree dialogue		pCallTreeDlg = m_pCallTreeMgr->addDialog();		pCallTreeDlg->setRoot(sSymbol);		pCallTreeDlg->show();	}	else {		// Run the requested query		nType = SymbolDlg::getQueryType(nType);		m_pQueryWidget->initQuery(nType, sSymbol);				// Ensure Query Window is visible		toggleQueryWindow(true);		}}/** * Opens a project. * If another project is currently active, it is cosed first. * @param	sDir	The directory of the project to open. */void KScope::openProject(const QString& sDir){	QStringList slQueryFiles;	QStringList slCallTreeFiles;	QStringList slArgs;	ProjectManager::Options opt;		// Close the current project (may return false if the user clicks on the	// "Cancel" button while prompted to save a file)	if (!slotCloseProject())		return;	// Open the project in the project manager	if (!m_pProjMgr->open(sDir))		return;		// Change main window title	setCaption(m_pProjMgr->getName());	// Set the root of the file tree	m_pFileView->setRoot(m_pProjMgr->getRoot());		// Initialise Cscope and create a builder object	initCscope();		// Set auto-completion parameters	m_pProjMgr->getOptions(opt);	SymbolCompletion::initAutoCompletion(opt.bACEnabled, opt.nACMinChars,		opt.nACDelay, opt.nACMaxEntries);		// Create an initial query page	m_pQueryWidget->addQueryPage();		// If this is a new project (i.e., no source files are yet included), 	// display the project files dialogue	if (m_pProjMgr->isEmpty()) {		slotProjectFiles();		return;	}		// Fill the file list with all files in the project. 	m_pProjMgr->fillList(m_pFileList);		// Reload previously-open files	loadOpenFiles();			// Load previously stored queries	m_pProjMgr->getQueryFiles(slQueryFiles);	m_pQueryWidget->loadLockedQueries(m_pProjMgr->getPath(), slQueryFiles);		// Load previously stored call trees	m_pProjMgr->getCallTreeFiles(slCallTreeFiles);	m_pCallTreeMgr->loadOpenDialogs(m_pProjMgr->getPath(), slCallTreeFiles);		// Rebuild the cross-reference database	if (isAutoRebuildEnabled())		slotRebuildDB();}/** * Reopens all files which were open when the project was last closed. * In order to reduce the time required by this operation, the GUI of all * but the last editor part is not merged with that of the main window. */void KScope::loadOpenFiles(){	OpenFileList list;	FileLocation* pLoc;	EditorPage* pPage;		// Get the list of open files	m_pProjMgr->getOpenFiles(list);	if (list.isEmpty())		return;		// Do not update the GUI when loading the editor parts of the initially	// hidden windows	m_bUpdateGUI = false;		for (pLoc = list.first(); pLoc != NULL; pLoc = list.next()) {		if (QFile::exists(pLoc->m_sPath)) {			pPage = addEditor(pLoc->m_sPath);			pPage->setCursorPos(pLoc->m_nLine, pLoc->m_nCol);		}	}		// Merge the GUI of the visible editor part	m_bUpdateGUI = true;	// Set the active editor (or choose a default one)	if (m_pEditTabs->findEditorPage(m_pProjMgr->getLastOpenFile(), true) ==		NULL) {		m_pEditTabs->findEditorPage(list.last()->m_sPath, true);	}}/** * Shows or hides the query dock window. * This function is only called internally, not as a result of a user's * workspace action (e.g., clicking the "Show/Hide Query Window" toolbar * button). Therefore it does not reflect the user's preference, which is * kept through the m_bHideQueryOnSelection variable. * @param	bShow	true to show the window, false to hide it */void KScope::toggleQueryWindow(bool bShow){	// Remember the user's preferences	if (bShow)		m_bHideQueryOnSelection = m_pQueryDock->isHidden();	else		m_bHideQueryOnSelection = false;		// Change the visibility state of the widget, if required	if (m_pQueryDock->isShown() != bShow)		m_pQueryDock->changeHideShowState();			// Make sure the action's state matches the widget's	m_pToggleQueryWindowAction->setChecked(bShow);}/** * Opens a temporary project for a Cscope.out file. * @param	sFilePath	The full path of the Cscope.out file * @return	true if successful, false otherwise */bool KScope::openCscopeOut(const QString& sFilePath){		// Close the current project (may return false if the user clicks on the	// "Cancel" button while prompted to save a file)	if (!slotCloseProject())		return false;	// Open a temporary project for this cscope.out file	if (!m_pProjMgr->openCscopeOut(sFilePath))		return false;		// Change main window title	setCaption(m_pProjMgr->getName());		// Initialise Cscope and create a builder object	initCscope();		// Create an initial query page	m_pQueryWidget->addQueryPage();	return true;}/** * Parses the command line, after it was stripped of its KDE options. * The command line may contain one of the following options: * 1. A project file (named cscope.proj) * 2. A Cscope cross-reference database * 3. A list of source files * @param	pArgs	Command line arguments */void KScope::parseCmdLine(KCmdLineArgs* pArgs){	QString sArg;	QFileInfo fi;	int i;	// Loop over all arguments	for (i = 0; i < pArgs->count(); i++) {		// Verify the argument is a file or directory name		sArg = pArgs->arg(i);		fi.setFile(sArg);		if (!fi.exists())			continue;					// Handle the current argument		if (fi.isFile()) {			if (fi.fileName() == "cscope.proj") {				// Open a project file				openProject(fi.dirPath(true));				return;			} else if (openCscopeOut(sArg)) {				// Opened the file as a cross-reference database				return;			} else {				// Assume this is a source file				slotShowEditor(sArg, 0);			}		} else if (fi.isDir()) {			// Treat the given path as a project directory			openProject(fi.absFilePath());			return;		}	}}/** * Initialises the CscopeFrontend class with the current project arguments, * and creates an object used for rebuilding the symbol database. */void KScope::initCscope(){	// Delete the current object, if one exists	if (m_pCscopeBuild)		delete m_pCscopeBuild;	// Initialise CscopeFrontend	CscopeFrontend::init(m_pProjMgr->getPath(), m_pProjMgr->getArgList());	// Create a persistent Cscope process	m_pCscopeBuild = new CscopeFrontend();	// Show build progress information in the main status bar	connect(m_pCscopeBuild, SIGNAL(progress(int, int)), this,		SLOT(slotBuildProgress(int, int)));	connect(m_pCscopeBuild, SIGNAL(finished(uint)), this,		SLOT(slotBuildFinished(uint)));	// Show errors in a modeless dialogue	connect(m_pCscopeBuild, SIGNAL(error(const QString&)), this,		SLOT(slotCscopeError(const QString&)));}/** * Closes the active project. * Closing a project involves closing all of the editor windows (prompting * the user for unsaved changes); terminating the Cscope process; and further * clean-up of the project's data. */bool KScope::slotCloseProject(){	QString sLastOpenFile;	OpenFileList lstOpenFiles;	QStringList slQueryFiles;	QStringList slCallTreeFiles;		// Do nothing if no project is open	if (!m_pProjMgr->isOpen())		return true;		// Close all open editor pages	if (m_pEditTabs->count() > 0) {		sLastOpenFile = m_pEditTabs->getCurrentPage()->getFilePath();		m_pEditTabs->getOpenFiles(lstOpenFiles);		if (!m_pEditTabs->removeAllPages())			return false;	}		// Store locked queries, and close all query pages	m_pQueryWidget->saveLockedQueries(m_pProjMgr->getPath(), slQueryFiles);	m_pQueryWidget->slotCloseAll();	// Store opened call trees	m_pCallTreeMgr->saveOpenDialogs(m_pProjMgr->getPath(), slCallTreeFiles);	m_pCallTreeMgr->closeAll();		// Save current session	m_pProjMgr->setLastOpenFile(sLastOpenFile);	m_pProjMgr->setOpenFiles(lstOpenFiles);	m_pProjMgr->setQueryFiles(slQueryFiles);	m_pProjMgr->setCallTreeFiles(slCallTreeFiles);		// Close the project in the project manager, and terminate the Cscope	// process	m_pProjMgr->close();	delete m_pCscopeBuild;	m_pCscopeBuild = NULL;	setCaption(QString::null);	// Clear the contents of the file list	m_pFileView->clear();	return true;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -