Beispiel #1
0
/**
 * Class constructor.
 * @param	pDoc	The document object associated with this page
 * @param	pMenu	A Cscope queries popup menu to use with the editor
 * @param	pParent	The parent widget
 * @param	szName	The widget's name
 */
EditorPage::EditorPage(KTextEditor::Document* pDoc, QMenu* pMenu,
	QTabWidget* pParent, const char* szName) : QWidget(pParent),
	m_pParentTab(pParent),
	m_pDoc(pDoc),
	m_bOpen(false),
	m_bNewFile(false),
	m_sName(""),
	m_bWritable(true), /* new documents are writable by default */
	m_bModified(false),
	m_nLine(0),
	m_bSaveNewSizes(false)
{
	Q_UNUSED(pMenu);
	setObjectName(szName);

	// Create code-completion objects (will be deleted by QObject destructor)
	m_pCompletion = new SymbolCompletion(this, this);

	// Set read-only mode, if required
	if (Config().getReadOnlyMode())
		m_pDoc->setReadWrite(false);

	// Turn on modifiedOnHdWarning on a per document base; this must be done BEFORE
	// creating the view ( see KateDocument::KateDocument )
	KTextEditor::ModificationInterface *pModificationIf;
	pModificationIf = qobject_cast<KTextEditor::ModificationInterface *>(m_pDoc);
	if (pModificationIf)
		pModificationIf->setModifiedOnDiskWarning(Config().getWarnModifiedOnDisk());

	// Create the child widgets
	m_pSplit = new QSplitter(this);
	m_pCtagsList = new CtagsList(m_pSplit);
	m_pView = m_pDoc->createView(m_pSplit);

	QHBoxLayout* pLayout = new QHBoxLayout;
	pLayout->addWidget(m_pSplit);
	QWidget::setLayout(pLayout);

	// Perform tasks only when the document has been loaded completely
	connect(m_pDoc, SIGNAL(completed()), this, SLOT(slotFileOpened()));

	// Be notified when the text in the editor changes
	connect(m_pDoc, SIGNAL(textChanged(KTextEditor::Document*)), this, SLOT(slotSetModified(KTextEditor::Document*)));
	connect(m_pDoc, SIGNAL(undoChanged()), this, SLOT(slotUndoChanged()));

	// Store the sizes of the child windows when the tag list is resized
	// (since it may imply a move of the splitter divider)
	connect(m_pCtagsList, SIGNAL(resized()), this, SLOT(slotChildResized()));

	// Go to a symbol's line if it is selected in the tag list
	connect(m_pCtagsList, SIGNAL(lineRequested(uint)), this,
		SLOT(slotGotoLine(uint)));

	// Add Ctag records to the tag list
	connect(&m_ctags, SIGNAL(dataReady(FrontendToken*)), m_pCtagsList,
		SLOT(slotDataReady(FrontendToken*)));

	// Monitor Ctags' operation
	connect(&m_ctags, SIGNAL(finished(uint)), m_pCtagsList, 
		SLOT(slotCtagsFinished(uint)));

	// Set the context menu
	m_pView->setContextMenu(pMenu);
	connect(m_pView, SIGNAL(cursorPositionChanged(KTextEditor::View *, const KTextEditor::Cursor&)),
		this, SLOT(slotCursorPosChange(KTextEditor::View *)));
}
Beispiel #2
0
/**
 * Class constructor.
 * @param	pDoc	The document object associated with this page
 * @param	pMenu	A Cscope queries popup menu to use with the editor
 * @param	pParent	The parent widget
 * @param	szName	The widget's name
 */
EditorPage::EditorPage(KTextEditor::Document* pDoc, QPopupMenu* pMenu,
	QTabWidget* pParent, const char* szName) : QHBox(pParent, szName),
	m_pParentTab(pParent),
	m_pDoc(pDoc),
	m_bOpen(false),
	m_bNewFile(false),
	m_sName(""),
	m_bWritable(true), /* new documents are writable by default */
	m_bModified(false),
	m_nLine(0),
	m_bSaveNewSizes(false)
{
	KTextEditor::PopupMenuInterface* pMenuIf;
	KTextEditor::ViewCursorInterface* pCursorIf;
	
	// Create code-completion objects (will be deleted by QObject destructor)
	m_pCompletion = new SymbolCompletion(this, this);
	
	// Set read-only mode, if required
	if (Config().getReadOnlyMode())
		m_pDoc->setReadWrite(false);
	
	// Create the child widgets
	m_pSplit = new QSplitter(this);
	m_pCtagsList = new CtagsList(m_pSplit);
	m_pView = m_pDoc->createView(m_pSplit);
	m_pSplit->setResizeMode(m_pCtagsList, QSplitter::KeepSize);
	
	// Perform tasks only when the document has been loaded completely
	connect(m_pDoc, SIGNAL(completed()), this, SLOT(slotFileOpened()));
	
	// Be notified when the text in the editor changes
	connect(m_pDoc, SIGNAL(textChanged()), this, SLOT(slotSetModified()));
	connect(m_pDoc, SIGNAL(undoChanged()), this, SLOT(slotUndoChanged()));
	
	// Store the sizes of the child windows when the tag list is resized
	// (since it may imply a move of the splitter divider)
	connect(m_pCtagsList, SIGNAL(resized()), this, SLOT(slotChildResized()));

	// Go to a symbol's line if it is selected in the tag list
	connect(m_pCtagsList, SIGNAL(lineRequested(uint)), this,
		SLOT(slotGotoLine(uint)));

	// Add Ctag records to the tag list
	connect(&m_ctags, SIGNAL(dataReady(FrontendToken*)), m_pCtagsList,
		SLOT(slotDataReady(FrontendToken*)));
		
	// Monitor Ctags' operation
	connect(&m_ctags, SIGNAL(finished(uint)), m_pCtagsList, 
		SLOT(slotCtagsFinished(uint)));
		
	// Set the context menu
	pMenuIf = dynamic_cast<KTextEditor::PopupMenuInterface*>(m_pView);
	if (pMenuIf)
		pMenuIf->installPopup(pMenu);

	// Emit a signal whenever the cursor's position changes
	pCursorIf = dynamic_cast<KTextEditor::ViewCursorInterface*>(m_pView);
	if (pCursorIf) {
		connect(m_pView, SIGNAL(cursorPositionChanged()), this,
			SLOT(slotCursorPosChange()));
	}
}
Beispiel #3
0
/**
 * Class constructor.
 * @param	pDoc	The document object associated with this page
 * @param	pMenu	A Cscope queries popup menu to use with the editor
 * @param	pParent	The parent widget
 * @param	szName	The widget's name
 */
EditorPage::EditorPage(KTextEditor::Document* pDoc, QMenu* pMenu, QTabWidget* pParent) : 
    m_pParentTab(pParent),
	m_pDoc(pDoc),
	m_bOpen(false),
	m_bNewFile(false),
	m_sName(""),
	m_bWritable(true), /* new documents are writable by default */
	m_bModified(false),
	m_nLine(0),
	m_bSaveNewSizes(false)
{
    QHBoxLayout *layout = new QHBoxLayout(this);
	
	// Set read-only mode, if required
	if (Config().getReadOnlyMode())
		m_pDoc->setReadWrite(false);

	// Create the child widgets
	m_pSplit = new QSplitter(Qt::Horizontal, this);
	m_pCtagsListWidget = new CtagsListWidget(m_pSplit);
	m_pView = m_pDoc->createView(m_pSplit);

    m_pSplit->addWidget(m_pCtagsListWidget);
    m_pSplit->addWidget(m_pView);
	//m_pSplit->setResizeMode(m_pCtagsListWidget, QSplitter::KeepSize);

    layout->addWidget(m_pSplit);
	
	// Perform tasks only when the document has been loaded completely
	connect(m_pDoc, SIGNAL(completed()), this, SLOT(slotFileOpened()));
	
	// Be notified when the text in the editor changes
	connect(m_pDoc, SIGNAL(textChanged(KTextEditor::Document *)),
            this, SLOT(slotSetModified(KTextEditor::Document *)));
	connect(m_pDoc, SIGNAL(undoChanged()), this, SLOT(slotUndoChanged()));
	
	// Store the sizes of the child windows when the tag list is resized
	// (since it may imply a move of the splitter divider)
	connect(m_pCtagsListWidget, SIGNAL(resized()), this, SLOT(slotChildResized()));

	// Go to a symbol's line if it is selected in the tag list
	connect(m_pCtagsListWidget, SIGNAL(lineRequested(uint)), this,
		SLOT(slotGotoLine(uint)));

	// Add Ctag records to the tag list
	connect(&m_ctags, SIGNAL(dataReady(FrontendToken*)), m_pCtagsListWidget,
		SLOT(slotDataReady(FrontendToken*)));
		
	// Monitor Ctags' operation
	connect(&m_ctags, SIGNAL(finished(uint)), m_pCtagsListWidget, 
		SLOT(slotCtagsFinished(uint)));
		
	// Set the context menu
    m_pView->setContextMenu(pMenu);

	// Emit a signal whenever the cursor's position changes
    connect(m_pView, SIGNAL(cursorPositionChanged(KTextEditor::View *, 
                    const KTextEditor::Cursor &)), 
                this, SLOT(slotCursorPosChange(KTextEditor::View *, 
                        const KTextEditor::Cursor &)));

    setShowLinenum(Config().getShowLinenum());
}