void EditorTabWidget::slotUndoChanged() { if(m_terminating) return; KTextEditor::Document *doc = (*(m_docList.at(currentPageIndex()))).view->document(); KTextEditor::UndoInterface* undoif = dynamic_cast<KTextEditor::UndoInterface*>(doc); if(undoif) { if(undoif->undoCount() == 0) { (*(m_docList.at(currentPageIndex()))).hasUndo = false; disableUndoAction(); } else if(undoif->undoCount() == 1) { (*(m_docList.at(currentPageIndex()))).hasUndo = true; enableUndoAction(); } if(undoif->redoCount() == 0) { (*(m_docList.at(currentPageIndex()))).hasRedo = false; disableRedoAction(); } else if(undoif->redoCount() == 1) { (*(m_docList.at(currentPageIndex()))).hasRedo = true; enableRedoAction(); } } }
void EditorTabWidget::slotRedo() { KTextEditor::Document *doc = (*(m_docList.at(currentPageIndex()))).view->document(); KTextEditor::UndoInterface* undoif = dynamic_cast<KTextEditor::UndoInterface*>(doc); if(undoif) { (*(m_docList.at(currentPageIndex()))).hasRedo = false; undoif->redo(); } }
void EditorTabWidget::closeCurrentDocument() { if(count() == 0) return; m_closeGuard = true; int index = currentPageIndex(); QValueList<Document_t>::iterator it = m_docList.at(index); KTextEditor::Document* doc = (*it).view->document(); doc->closeURL(); KTextEditor::View* view = (*it).view; delete view; delete doc; QWidget* w = page(index); removePage(w); m_docList.remove(it); if(count() == 0) { disableEditorActions(); } m_closeGuard = false; }
bool EditorTabWidget::saveCurrentFile() { if(count() == 0) return false; KTextEditor::Document *doc = (*(m_docList.at(currentPageIndex()))).view->document(); return doc->save(); }
void EditorTabWidget::slotConfigEditor() { if(count() == 0) return; KTextEditor::Document *doc = (*m_docList.at(currentPageIndex())).view->document(); if(!doc) return; KTextEditor::ConfigInterface* configIf = dynamic_cast<KTextEditor::ConfigInterface*>(doc); configIf->configDialog(); }
void EditorTabWidget::slotSelectAll() { KTextEditor::Document *doc = (*(m_docList.at(currentPageIndex()))).view->document(); KTextEditor::SelectionInterface* selif = dynamic_cast<KTextEditor::SelectionInterface*>(doc); if(selif) { selif->selectAll(); } }
void EditorTabWidget::slotPaste() { KTextEditor::View *v = (*(m_docList.at(currentPageIndex()))).view; KTextEditor::ClipboardInterface* clipif = dynamic_cast<KTextEditor::ClipboardInterface*>(v); if(clipif) { clipif->paste(); } }
QString TabWidget::handleDCOP(int function, const QStringList& args) { switch (function) { case DCOP::currentItem: return QString::number(currentPageIndex()); case DCOP::setCurrentItem: setCurrentPage(args[0].toUInt()); break; case DCOP::insertTab: insertTab(0L, args[0], args[1].toUInt()); break; default: return KommanderWidget::handleDCOP(function, args); } return QString(); }
int EditorTabWidget::currentDocumentLine() { int index; uint line, col; KTextEditor::View* view; KTextEditor::ViewCursorInterface *vci; if((index = currentPageIndex()) == -1) return 0; Document_t d; d = *(m_docList.at(index)); view = d.view; vci = dynamic_cast<KTextEditor::ViewCursorInterface*>(view); vci->cursorPosition(&line, &col); return line+1; }
void EditorTabWidget::gotoLineAtFile(const QString& filePath, int line) { int index; KTextEditor::View* view; KTextEditor::ViewCursorInterface *vci; setCurrentDocument(filePath, true); if((index = currentPageIndex()) == -1) return; Document_t d; d = *(m_docList.at(index)); view = d.view; vci = dynamic_cast<KTextEditor::ViewCursorInterface*>(view); vci->setCursorPosition(line, 0); }
/*! \reimp */ bool QTabWidget::eventFilter( QObject *o, QEvent * e) { if ( o == this ) { if ( e->type() == QEvent::LanguageChange || e->type() == QEvent::LayoutHint ) { d->dirty = TRUE; setUpLayout(); updateGeometry(); } else if ( e->type() == QEvent::KeyPress ) { QKeyEvent *ke = (QKeyEvent*) e; if ( ( ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab ) && count() > 1 && ke->state() & Qt::ControlButton ) { int page = currentPageIndex(); if ( ke->key() == Qt::Key_Backtab || ke->state() & Qt::ShiftButton ) { page--; if ( page < 0 ) page = count() - 1; } else { page++; if ( page >= count() ) page = 0; } setCurrentPage( page ); if ( !qApp->focusWidget() ) d->tabs->setFocus(); return TRUE; } } } else if ( o == d->stack ) { if ( e->type() == QEvent::ChildRemoved && ( (QChildEvent*)e )->child()->isWidgetType() ) { removePage( (QWidget*) ( (QChildEvent*)e )->child() ); return TRUE; } else if ( e->type() == QEvent::LayoutHint ) { updateGeometry(); } } return FALSE; }
/** * Returns the widget of the current page */ QWidget *PsiTabWidget::currentPage() { if (currentPageIndex() == -1) return 0; return widgets_[currentPageIndex()]; }
void EditorTabWidget::slotMarkChanged() { //I get sick looking at this code... //terminating: prevent from crash if(m_terminating) return; QValueList<Document_t>::iterator it = m_docList.at(currentPageIndex()); QPtrList<KTextEditor::Mark> currentMarks = documentMarkIf((*it).path)->marks(); QValueList<KTextEditor::Mark> & oldMarks = (*it).marks; KTextEditor::Mark *cur; QValueList<KTextEditor::Mark>::iterator old; //closeGuard: prevent from emit signals to remove bp marks(we want them persistent) //m_markGuard: prevent from processing marks twice if(m_closeGuard || m_markGuard) goto end; if(oldMarks.count() == currentMarks.count()) { //--2+ marks on the same line | mark changed position KTextEditor::Mark mark; for(cur = currentMarks.first(), old = oldMarks.begin(); cur; cur = currentMarks.next(), ++old) { if((cur->line == (*old).line) && (cur->type != (*old).type)) { //--2+ marks on the same line mark.line = cur->line; if(cur->type > (*old).type) { mark.type = cur->type - (*old).type; //add dispatchMark(mark, true); } else { //remove mark.type = (*old).type - cur->type; dispatchMark(mark, false); } //break; } else if((*old).line != cur->line) { //mark changed position //remove old dispatchMark((*old), false); //add new dispatchMark(*cur, true); } } } else if(oldMarks.count() > currentMarks.count()) { //a mark was removed if(currentMarks.count() == 0) { dispatchMark(*(oldMarks.begin()), false); } else { bool found; for(old = oldMarks.begin(); old != oldMarks.end(); ++old) { found = false; for(cur = currentMarks.first(); cur; cur = currentMarks.next()) { if(((*old).line == cur->line) && ((*old).type |= cur->type)) { found = true; break; } } if(found == false) { dispatchMark(*old, false); break; } } } } else { //a mark was added if(oldMarks.count() == 0) { dispatchMark(*(currentMarks.first()), true); } else { bool found; for(cur = currentMarks.first(); cur; cur = currentMarks.next()) { found = false; for(old = oldMarks.begin(); old != oldMarks.end(); ++old) { if(((*old).line == cur->line) && ((*old).type |= cur->type)) { found = true; break; } } if(found == false) { dispatchMark(*cur, true); break; } } } } end: loadMarks((*it), (*it).view->document()); }
const QString& EditorTabWidget::currentDocumentPath() { return documentPath(currentPageIndex()); }
QWidget * QTabWidget::currentPage() const { return page( currentPageIndex() ); }