File indexing completed on 2024-04-14 03:54:48

0001 /* This file is part of the KDE libraries
0002    SPDX-FileCopyrightText: 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
0003 */
0004 //BEGIN includes
0005 #include "kateview.h"
0006 #include "kateview.moc"
0007 
0008 //#define VIEW_RANGE_DEBUG
0009 
0010 //END includes
0011 
0012 void KateView::blockFix(KTextEditor::Range& range)
0013 {
0014   if (range.start().column() > range.end().column())
0015   {
0016     int tmp = range.start().column();
0017     range.start().setColumn(range.end().column());
0018     range.end().setColumn(tmp);
0019   }
0020 }
0021 
0022 KateView::KateView( KateDocument *doc, QWidget *parent )
0023 {
0024   setComponentData ( KateGlobal::self()->componentData () );
0025 
0026   // selection if for this view only and will invalidate if becoming empty
0027   m_selection.setView (this);
0028 
0029   // use z depth defined in moving ranges interface
0030   m_selection.setZDepth (-100000.0);
0031 
0032   KateGlobal::self()->registerView( this );
0033 
0034   KTextEditor::ViewBarContainer *viewBarContainer=qobject_cast<KTextEditor::ViewBarContainer*>( KateGlobal::self()->container() );
0035   QWidget *bottomBarParent=viewBarContainer?viewBarContainer->getViewBarParent(this,KTextEditor::ViewBarContainer::BottomBar):0;
0036   QWidget *topBarParent=viewBarContainer?viewBarContainer->getViewBarParent(this,KTextEditor::ViewBarContainer::TopBar):0;
0037 
0038   m_bottomViewBar=new KateViewBar (bottomBarParent!=0,KTextEditor::ViewBarContainer::BottomBar,bottomBarParent?bottomBarParent:this,this);
0039   m_topViewBar=new KateViewBar (topBarParent!=0,KTextEditor::ViewBarContainer::TopBar,topBarParent?topBarParent:this,this);
0040 
0041   // ugly workaround:
0042   // Force the layout to be left-to-right even on RTL desktop, as discussed
0043   // on the mailing list. This will cause the lines and icons panel to be on
0044   // the left, even for Arabic/Hebrew/Farsi/whatever users.
0045   setLayoutDirection ( Qt::LeftToRight );
0046 
0047   // layouting ;)
0048   m_vBox = new QVBoxLayout (this);
0049   m_vBox->setContentsMargins(0, 0, 0, 0);
0050   m_vBox->setSpacing (0);
0051 
0052   // add top viewbar...
0053   if (topBarParent)
0054     viewBarContainer->addViewBarToLayout(this,m_topViewBar,KTextEditor::ViewBarContainer::TopBar);
0055   else
0056     m_vBox->addWidget(m_topViewBar);
0057 
0058   m_bottomViewBar->installEventFilter(m_viewInternal);
0059 
0060   // add KateMessageWidget for KTE::MessageInterface immediately above view
0061   m_topMessageWidget = new KateMessageWidget(this);
0062   m_vBox->addWidget(m_topMessageWidget);
0063   m_topMessageWidget->hide();
0064 
0065   // add hbox: KateIconBorder | KateViewInternal | KateScrollBar
0066   QHBoxLayout *hbox = new QHBoxLayout ();
0067   m_vBox->addLayout (hbox, 100);
0068   hbox->setContentsMargins(0, 0, 0, 0);
0069   hbox->setSpacing (0);
0070 
0071   QStyleOption option;
0072   option.initFrom(this);
0073 
0074   if (style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &option, this)) {