/* * Constructs a Mainwindow as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * */ Mainwindow::Mainwindow(QWidget* parent, const char* name, Qt::WindowFlags fl) : QMainWindow(parent, fl) { setObjectName(name); _progress = 0; _label = 0; setupUi(this); init(); _welcome_shown = false; _desktop = _main->getDesktop (); QSettings qs; setWindowState(windowState() ^ Qt::WindowFullScreen); setWindowState(windowState() ^ Qt::WindowMaximized); restoreGeometry(qs.value("mainwindow/geometry").toByteArray()); restoreState(qs.value("mainwindow/state").toByteArray()); // to stop the status bar rising all the time, set its maximum size QSize size = QSize (5000, 20); statusBar ()->setMaximumSize (size); connect (_main->getDesktop (), SIGNAL (updateDone ()), this, SLOT (welcome ())); connect (_main->getDesktop (), SIGNAL (undoChanged ()), this, SLOT (undoChanged ())); undoChanged (); addAction(actionExit); addAction(actionFind); }
void KateUndoManager::editEnd() { if (!m_isActive) return; // editStart() and editEnd() must be called in alternating fashion Q_ASSERT(m_editCurrentUndo != 0); // an undo group must have been created by editStart() const KTextEditor::Cursor cursorPosition = activeView() ? activeView()->cursorPosition() : KTextEditor::Cursor::invalid(); const KTextEditor::Range selectionRange = activeView() ? activeView()->selectionRange() : KTextEditor::Range::invalid(); m_editCurrentUndo->editEnd(cursorPosition, selectionRange); bool changedUndo = false; if (m_editCurrentUndo->isEmpty()) { delete m_editCurrentUndo; } else if (!undoItems.isEmpty() && undoItems.last()->merge(m_editCurrentUndo, m_undoComplexMerge)) { delete m_editCurrentUndo; } else { undoItems.append(m_editCurrentUndo); changedUndo = true; } m_editCurrentUndo = 0L; if (changedUndo) emit undoChanged(); Q_ASSERT(m_editCurrentUndo == 0); // must be 0 after calling this method }
void KateUndoManager::clearRedo() { qDeleteAll(redoItems); redoItems.clear (); lastRedoGroupWhenSaved = 0; docWasSavedWhenRedoWasEmpty = false; emit undoChanged (); }
bool Recorder::redo() { bool couldUndo = canUndo(); bool couldRedo = canRedo(); if(canRedo()) { actions_.at(nextUndo_ + 1)->redo(model_); ++nextUndo_; if(couldUndo != canUndo()) { emit undoChanged(canUndo()); } if(couldRedo != canRedo()) { emit redoChanged(canRedo()); } return true; } return false; }
/** * 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())); } }
void KateUndoManager::updateConfig () { emit undoChanged (); }
Desktopwidget::Desktopwidget (QWidget *parent) : QSplitter (parent) { _model = new Dirmodel (); // _model->setLazyChildCount (true); _dir = new Dirview (this); _dir->setModel (_model); _contents = new Desktopmodel (this); QWidget *group = createToolbar(); _view = new Desktopview (group); QVBoxLayout *lay = new QVBoxLayout (group); lay->setContentsMargins (0, 0, 0, 0); lay->setSpacing (2); lay->addWidget (_toolbar); lay->addWidget (_view); connect (_view, SIGNAL (itemPreview (const QModelIndex &, int, bool)), this, SLOT (slotItemPreview (const QModelIndex &, int, bool))); #ifdef USE_PROXY _proxy = new Desktopproxy (this); _proxy->setSourceModel (_contents); _view->setModel (_proxy); // printf ("contents=%p, proxy=%p\n", _contents, _proxy); // set up the model converter _modelconv = new Desktopmodelconv (_contents, _proxy); // setup another one for Desktopmodel, which only allows assertions _modelconv_assert = new Desktopmodelconv (_contents, _proxy, false); #else _proxy = 0; _view->setModel (_contents); _modelconv = new Desktopmodelconv (_contents); // setup another one for Desktopmodel, which only allows assertions _modelconv_assert = new Desktopmodelconv (_contents, false); #endif _view->setModelConv (_modelconv); _contents->setModelConv (_modelconv_assert); _delegate = new Desktopdelegate (_modelconv, this); _view->setItemDelegate (_delegate); connect (_delegate, SIGNAL (itemClicked (const QModelIndex &, int)), this, SLOT (slotItemClicked (const QModelIndex &, int))); connect (_delegate, SIGNAL (itemPreview (const QModelIndex &, int, bool)), this, SLOT (slotItemPreview (const QModelIndex &, int, bool))); connect (_delegate, SIGNAL (itemDoubleClicked (const QModelIndex &)), this, SLOT (openStack (const QModelIndex &))); connect (_contents, SIGNAL (undoChanged ()), this, SIGNAL (undoChanged ())); connect (_contents, SIGNAL (dirChanged (QString&, QModelIndex&)), this, SLOT (slotDirChanged (QString&, QModelIndex&))); connect (_contents, SIGNAL (beginningScan (const QModelIndex &)), this, SLOT (slotBeginningScan (const QModelIndex &))); connect (_contents, SIGNAL (endingScan (bool)), this, SLOT (slotEndingScan (bool))); connect (_contents, SIGNAL(updateRepositoryList (QString &, bool)), this, SLOT(slotUpdateRepositoryList (QString &, bool))); // position the items when the model is reset, otherwise things // move and look ugly for a while connect (_contents, SIGNAL (modelReset ()), _view, SLOT (setPositions ())); createPage(); // and when there are no selected items connect (_view, SIGNAL (pageLost()), _page, SLOT (slotReset ())); _parent = parent; _pendingMatch = QString::null; _updating = false; // setup the preview timer _timer = new QTimer (); _timer->setSingleShot (true); connect (_timer, SIGNAL(timeout()), this, SLOT(updatePreview())); connect (_dir, SIGNAL (clicked (const QModelIndex&)), this, SLOT (dirSelected (const QModelIndex&))); connect (_dir, SIGNAL (activated (const QModelIndex&)), this, SLOT (dirSelected (const QModelIndex&))); connect (_model, SIGNAL(droppedOnFolder(const QMimeData *, QString &)), this, SLOT(slotDroppedOnFolder(const QMimeData *, QString &))); /* notice when the current directory is fully displayed so we can handle any pending action */ connect (_contents, SIGNAL (updateDone()), this, SLOT (slotUpdateDone())); // connect signals from the directory tree connect (_dir->_new, SIGNAL (triggered ()), this, SLOT (newDir ())); connect (_dir->_rename, SIGNAL (triggered ()), this, SLOT (renameDir ())); connect (_dir->_delete, SIGNAL (triggered ()), this, SLOT (deleteDir ())); connect (_dir->_refresh, SIGNAL (triggered ()), this, SLOT (refreshDir ())); connect (_dir->_add_recent, SIGNAL (triggered ()), this, SLOT (addToRecent ())); connect (_dir->_add_repository, SIGNAL (triggered ()), this, SLOT (slotAddRepository ())); connect (_dir->_remove_repository, SIGNAL (triggered ()), this, SLOT (slotRemoveRepository ())); setStretchFactor(indexOf(_dir), 0); QList<int> size; if (!getSettingsSizes ("desktopwidget/", size)) { size.append (200); size.append (1000); size.append (400); } setSizes (size); connect (_view, SIGNAL (popupMenu (QModelIndex &)), this, SLOT (slotPopupMenu (QModelIndex &))); // allow top level to see our view messages connect (_view, SIGNAL (newContents (QString)), this, SIGNAL (newContents (QString))); addActions(); /* unfortunately when we first run maxview it starts with the main window un-maximised. This means that scrollToLast() doesn't quite scroll far enough for the maximised view which appears soon afterwards. As a hack for the moment, we do another scroll 1 second after starting up */ QTimer::singleShot(1000, _view, SLOT (scrollToLast())); }
/** * 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 *))); }
/** * 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()); }
void EditorTabWidget::createDocument(KURL url/*, const QString& text*/) { /* KTextEditor::PopupMenuInterface* popupIf = dynamic_cast<KTextEditor::PopupMenuInterface*>(w->view()); if (popupIf) popupIf->installPopup((QPopupMenu *)quantaApp->factory()->container("popup_editor", quantaApp)); */ KTextEditor::View *view; if((view = openKDocument(url)) == NULL) return; KTextEditor::MarkInterfaceExtension* imarkex = dynamic_cast<KTextEditor::MarkInterfaceExtension*>(view->document()); if(imarkex) { KIconLoader *loader = KGlobal::iconLoader(); #if (KDE_VERSION_MAJOR >= 3) && (KDE_VERSION_MINOR >= 3) imarkex->setPixmap(KTextEditor::MarkInterface::Execution, loader->loadIcon( "executionpoint", KIcon::Small)); #else imarkex->setPixmap(KTextEditor::MarkInterface::markType05, loader->loadIcon( "executionpoint", KIcon::Small)); #endif imarkex->setPixmap(KTextEditor::MarkInterface::markType08, loader->loadIcon( "preexecutionpoint", KIcon::Small)); #if (KDE_VERSION_MAJOR >= 3) && (KDE_VERSION_MINOR >= 3) imarkex->setPixmap(KTextEditor::MarkInterface::BreakpointActive, loader->loadIcon( "activebreakpoint",KIcon::Small)); #else imarkex->setPixmap(KTextEditor::MarkInterface::markType02, loader->loadIcon( "activebreakpoint", KIcon::Small)); #endif #if (KDE_VERSION_MAJOR >= 3) && (KDE_VERSION_MINOR >= 3) imarkex->setPixmap(KTextEditor::MarkInterface::BreakpointDisabled, loader->loadIcon( "disabledbreakpoint",KIcon::Small)); #else imarkex->setPixmap(KTextEditor::MarkInterface::markType04, loader->loadIcon( "disabledbreakpoint", KIcon::Small)); #endif #if (KDE_VERSION_MAJOR >= 3) && (KDE_VERSION_MINOR >= 3) imarkex->setDescription(KTextEditor::MarkInterface::BreakpointActive, "Breakpoint"); #else imarkex->setDescription(KTextEditor::MarkInterface::markType02, "Breakpoint"); #endif #if (KDE_VERSION_MAJOR >= 3) && (KDE_VERSION_MINOR >= 3) imarkex->setMarksUserChangable(KTextEditor::MarkInterface::Bookmark + KTextEditor::MarkInterface::BreakpointActive); #else imarkex->setMarksUserChangable(KTextEditor::MarkInterface::markType01 + KTextEditor::MarkInterface::markType02); #endif } connect(view->document(), SIGNAL(marksChanged()), this, SLOT(slotMarkChanged())); connect(view->document(), SIGNAL(undoChanged()), this, SLOT(slotUndoChanged())); Document_t d; d.path = url.path(); d.view = view; d.hasUndo = false; d.hasRedo = false; //d.marks = imark->marks(); m_docList.append(d); disableUndoAction(); disableRedoAction(); }