Esempio n. 1
0
/**
 * Saves the edited file.
 */
void EditorPage::save()
{
	if (m_pDoc->isModified()){
		// Avoid warning about modification on disk for this document
		KTextEditor::ModificationInterface *pModificationIf;

		pModificationIf = qobject_cast<KTextEditor::ModificationInterface *>(m_pDoc);
		if (pModificationIf)
			pModificationIf->setModifiedOnDiskWarning(false);

		m_pDoc->save();
	}
}
Esempio n. 2
0
/**
 * Marks a file as modified when the contents of the editor change.
 * This slot is conncted to the textChanged() signal of the Document object.
 * In addition to marking the file, this method also emits the modified()
 * signal.
 */
void EditorPage::slotSetModified(KTextEditor::Document *pDoc)
{
    if (m_pDoc != pDoc) {
        qDebug() << "edieor page documant dose not match"; 
        return;
    }

	// Only perform tasks if the file is not already marked
	if (!m_bModified && pDoc->isModified()) {
		m_bModified = true;
		emit modified(this, m_bModified);
	
		// check whether it was modified on
		// disk as well, and issue a warning if so
        KTextEditor::ModificationInterface *iface =
            qobject_cast<KTextEditor::ModificationInterface *>(pDoc);
		if (iface)
			iface->slotModifiedOnDisk(m_pView);
	}
}
Esempio n. 3
0
/**
 * Marks a file as modified when the contents of the editor change.
 * This slot is connected to the textChanged() signal of the Document object.
 * In addition to marking the file, this method also emits the modified()
 * signal.
 */
void EditorPage::slotSetModified(KTextEditor::Document* pDoc)
{
	// Only perform tasks if the file is not already marked
	if (!m_bModified && m_pDoc->isModified()) {
		m_bModified = true;
		emit modified(this, m_bModified);

#if KDE_IS_VERSION(3,3,0)
		// If the editor is a Kate part, check whether it was modified on
		// disk as well, and issue a warning if so
		KTextEditor::ModificationInterface *pModificationIf;

		pModificationIf = qobject_cast<KTextEditor::ModificationInterface *>(m_pDoc);
		if (pModificationIf){
			pModificationIf->slotModifiedOnDisk(pDoc->activeView());
		}
#endif
	}

	// Start/restart the auto-completion timer
	m_pCompletion->slotAutoComplete();
}
Esempio n. 4
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 *)));
}