• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • app
kateviewspacecontainer.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
3  Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
4  Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 //BEGIN Includes
22 #include "kateviewspacecontainer.h"
23 #include "kateviewspacecontainer.moc"
24 
25 #include "katetabwidget.h"
26 #include "katemainwindow.h"
27 #include "katedocmanager.h"
28 #include "kateviewmanager.h"
29 #include "kateviewspace.h"
30 
31 #include <dcopclient.h>
32 #include <tdeaction.h>
33 #include <tdecmdlineargs.h>
34 #include <kdebug.h>
35 #include <tdediroperator.h>
36 #include <kdockwidget.h>
37 #include <kencodingfiledialog.h>
38 #include <kiconloader.h>
39 #include <tdeglobal.h>
40 #include <tdelocale.h>
41 #include <tdetoolbar.h>
42 #include <tdemessagebox.h>
43 #include <ksimpleconfig.h>
44 #include <kstdaction.h>
45 #include <tdestandarddirs.h>
46 #include <tdeglobalsettings.h>
47 #include <kstringhandler.h>
48 
49 #include <tdetexteditor/encodinginterface.h>
50 
51 #include <tqlayout.h>
52 #include <tqobjectlist.h>
53 #include <tqstringlist.h>
54 #include <tqvbox.h>
55 #include <tqtimer.h>
56 #include <tqfileinfo.h>
57 
58 //END Includes
59 
60 KateViewSpaceContainer::KateViewSpaceContainer (TQWidget *parent, KateViewManager *viewManager)
61  : TQVBox (parent)
62  , m_viewManager(viewManager)
63  , m_blockViewCreationAndActivation (false)
64  , m_activeViewRunning (false)
65  , m_pendingViewCreation(false)
66 {
67  // no memleaks
68  m_viewList.setAutoDelete(true);
69  m_viewSpaceList.setAutoDelete(true);
70 
71  KateViewSpace* vs = new KateViewSpace( this, this );
72  connect(this, TQ_SIGNAL(statusChanged(Kate::View *, int, int, int, bool, int, const TQString&)), vs, TQ_SLOT(slotStatusChanged(Kate::View *, int, int, int, bool, int, const TQString&)));
73  vs->setActive( true );
74  m_viewSpaceList.append(vs);
75  connect( this, TQ_SIGNAL(viewChanged()), this, TQ_SLOT(slotViewChanged()) );
76  connect(KateDocManager::self(), TQ_SIGNAL(initialDocumentReplaced()), this, TQ_SIGNAL(viewChanged()));
77 
78  connect(KateDocManager::self(),TQ_SIGNAL(documentCreated(Kate::Document *)),this,TQ_SLOT(documentCreated(Kate::Document *)));
79  connect(KateDocManager::self(),TQ_SIGNAL(documentDeleted(uint)),this,TQ_SLOT(documentDeleted(uint)));
80 }
81 
82 KateViewSpaceContainer::~KateViewSpaceContainer ()
83 {
84  m_viewList.setAutoDelete(false);
85  m_viewSpaceList.setAutoDelete(false);
86 }
87 
88 void KateViewSpaceContainer::documentCreated (Kate::Document *doc)
89 {
90  if (m_blockViewCreationAndActivation) return;
91 
92  if (!activeView())
93  activateView (doc->documentNumber());
94 }
95 
96 void KateViewSpaceContainer::documentDeleted (uint)
97 {
98  if (m_blockViewCreationAndActivation) return;
99 
100  // just for the case we close a document out of many and this was the active one
101  // if all docs are closed, this will be handled by the documentCreated
102  if (!activeView() && (KateDocManager::self()->documents() > 0))
103  createView (KateDocManager::self()->document(KateDocManager::self()->documents()-1));
104 }
105 
106 bool KateViewSpaceContainer::createView ( Kate::Document *doc )
107 {
108  if (m_blockViewCreationAndActivation) return false;
109 
110  // create doc
111  if (!doc)
112  doc = KateDocManager::self()->createDoc ();
113 
114  // create view
115  Kate::View *view = (Kate::View *) doc->createView (this, 0L);
116 
117  m_viewList.append (view);
118 
119  // disable settings dialog action
120  view->actionCollection()->remove (view->actionCollection()->action( "set_confdlg" ));
121 
122  // popup menu
123  view->installPopup ((TQPopupMenu*)(mainWindow()->factory()->container("tdetexteditor_popup", mainWindow())) );
124 
125  connect(view->getDoc(),TQ_SIGNAL(nameChanged(Kate::Document *)),this,TQ_SLOT(statusMsg()));
126  connect(view,TQ_SIGNAL(cursorPositionChanged()),this,TQ_SLOT(statusMsg()));
127  connect(view,TQ_SIGNAL(newStatus()),this,TQ_SLOT(statusMsg()));
128  connect(view->getDoc(), TQ_SIGNAL(undoChanged()), this, TQ_SLOT(statusMsg()));
129  connect(view,TQ_SIGNAL(dropEventPass(TQDropEvent *)), mainWindow(),TQ_SLOT(slotDropEvent(TQDropEvent *)));
130  connect(view,TQ_SIGNAL(gotFocus(Kate::View *)),this,TQ_SLOT(activateSpace(Kate::View *)));
131 
132  activeViewSpace()->addView( view );
133  activateView( view );
134  connect( doc, TQ_SIGNAL(modifiedOnDisc(Kate::Document *, bool, unsigned char)),
135  activeViewSpace(), TQ_SLOT(modifiedOnDisc(Kate::Document *, bool, unsigned char)) );
136 
137  return true;
138 }
139 
140 bool KateViewSpaceContainer::deleteView (Kate::View *view, bool delViewSpace)
141 {
142  if (!view) return true;
143 
144  KateViewSpace *viewspace = (KateViewSpace *)view->parentWidget()->parentWidget();
145 
146  viewspace->removeView (view);
147 
148  mainWindow()->guiFactory ()->removeClient (view);
149 
150  // remove view from list and memory !!
151  m_viewList.remove (view);
152 
153  if (delViewSpace)
154  if ( viewspace->viewCount() == 0 )
155  removeViewSpace( viewspace );
156 
157  return true;
158 }
159 
160 KateViewSpace* KateViewSpaceContainer::activeViewSpace ()
161 {
162  TQPtrListIterator<KateViewSpace> it(m_viewSpaceList);
163 
164  for (; it.current(); ++it)
165  {
166  if ( it.current()->isActiveSpace() )
167  return it.current();
168  }
169 
170  if (m_viewSpaceList.count() > 0)
171  {
172  m_viewSpaceList.first()->setActive( true );
173  return m_viewSpaceList.first();
174  }
175 
176  return 0L;
177 }
178 
179 Kate::View* KateViewSpaceContainer::activeView ()
180 {
181  if (m_activeViewRunning)
182  return 0L;
183 
184  m_activeViewRunning = true;
185 
186  for (TQPtrListIterator<Kate::View> it(m_viewList); it.current(); ++it)
187  {
188  if ( it.current()->isActive() )
189  {
190  m_activeViewRunning = false;
191  return it.current();
192  }
193  }
194 
195  // if we get to here, no view isActive()
196  // first, try to get one from activeViewSpace()
197  KateViewSpace* vs;
198  if ( (vs = activeViewSpace()) )
199  {
200  if ( vs->currentView() )
201  {
202  activateView (vs->currentView());
203 
204  m_activeViewRunning = false;
205  return vs->currentView();
206  }
207  }
208 
209  // last attempt: just pick first
210  if (m_viewList.count() > 0)
211  {
212  activateView (m_viewList.first());
213 
214  m_activeViewRunning = false;
215  return m_viewList.first();
216  }
217 
218  m_activeViewRunning = false;
219 
220  // no views exists!
221  return 0L;
222 }
223 
224 void KateViewSpaceContainer::setActiveSpace ( KateViewSpace* vs )
225 {
226  if (activeViewSpace())
227  activeViewSpace()->setActive( false );
228 
229  vs->setActive( true, viewSpaceCount() > 1 );
230 }
231 
232 void KateViewSpaceContainer::setActiveView ( Kate::View* view )
233 {
234  if (activeView())
235  activeView()->setActive( false );
236 
237  view->setActive( true );
238 }
239 
240 void KateViewSpaceContainer::activateSpace (Kate::View* v)
241 {
242  if (!v) return;
243 
244  KateViewSpace* vs = (KateViewSpace*)v->parentWidget()->parentWidget();
245 
246  if (!vs->isActiveSpace()) {
247  setActiveSpace (vs);
248  activateView(v);
249  }
250 }
251 
252 void KateViewSpaceContainer::reactivateActiveView() {
253  Kate::View *view=activeView();
254  if (view) {
255  view->setActive(false);
256  activateView(view);
257  } else if (m_pendingViewCreation) {
258  m_pendingViewCreation=false;
259  disconnect(m_pendingDocument,TQ_SIGNAL(nameChanged(Kate::Document *)),this,TQ_SLOT(slotPendingDocumentNameChanged()));
260  createView(m_pendingDocument);
261  }
262 }
263 
264 void KateViewSpaceContainer::activateView ( Kate::View *view )
265 {
266  if (!view) return;
267 
268  if (!view->isActive())
269  {
270  if ( !activeViewSpace()->showView (view) )
271  {
272  // since it wasn't found, give'em a new one
273  createView ( view->getDoc() );
274  return;
275  }
276 
277  setActiveView (view);
278  m_viewList.findRef (view);
279 
280  mainWindow()->toolBar ()->setUpdatesEnabled (false);
281 
282  if (m_viewManager->guiMergedView)
283  mainWindow()->guiFactory()->removeClient (m_viewManager->guiMergedView );
284 
285  m_viewManager->guiMergedView = view;
286 
287  if (!m_blockViewCreationAndActivation)
288  mainWindow()->guiFactory ()->addClient( view );
289 
290  mainWindow()->toolBar ()->setUpdatesEnabled (true);
291 
292  statusMsg();
293 
294  emit viewChanged ();
295  }
296 
297  KateDocManager::self()->setActiveDocument(view->getDoc());
298 }
299 
300 void KateViewSpaceContainer::activateView( uint documentNumber )
301 {
302  if ( activeViewSpace()->showView(documentNumber) ) {
303  activateView( activeViewSpace()->currentView() );
304  }
305  else
306  {
307  TQPtrListIterator<Kate::View> it(m_viewList);
308  for ( ;it.current(); ++it)
309  {
310  if ( it.current()->getDoc()->documentNumber() == documentNumber )
311  {
312  createView( it.current()->getDoc() );
313  return;
314  }
315  }
316 
317  Kate::Document *d = (Kate::Document *)KateDocManager::self()->documentWithID(documentNumber);
318  createView (d);
319  }
320 }
321 
322 uint KateViewSpaceContainer::viewCount ()
323 {
324  return m_viewList.count();
325 }
326 
327 uint KateViewSpaceContainer::viewSpaceCount ()
328 {
329  return m_viewSpaceList.count();
330 }
331 
332 void KateViewSpaceContainer::slotViewChanged()
333 {
334  if ( activeView() && !activeView()->hasFocus())
335  activeView()->setFocus();
336 }
337 
338 void KateViewSpaceContainer::activateNextView()
339 {
340  uint i = m_viewSpaceList.find (activeViewSpace())+1;
341 
342  if (i >= m_viewSpaceList.count())
343  i=0;
344 
345  setActiveSpace (m_viewSpaceList.at(i));
346  activateView(m_viewSpaceList.at(i)->currentView());
347 }
348 
349 void KateViewSpaceContainer::activatePrevView()
350 {
351  int i = m_viewSpaceList.find (activeViewSpace())-1;
352 
353  if (i < 0)
354  i=m_viewSpaceList.count()-1;
355 
356  setActiveSpace (m_viewSpaceList.at(i));
357  activateView(m_viewSpaceList.at(i)->currentView());
358 }
359 
360 void KateViewSpaceContainer::closeViews(uint documentNumber)
361 {
362  TQPtrList<Kate::View> closeList;
363 
364  for (uint z=0 ; z < m_viewList.count(); z++)
365  {
366  Kate::View* current = m_viewList.at(z);
367  if ( current->getDoc()->documentNumber() == documentNumber )
368  {
369  closeList.append (current);
370  }
371  }
372 
373  while ( !closeList.isEmpty() )
374  {
375  Kate::View *view = closeList.first();
376  deleteView (view, true);
377  closeList.removeFirst();
378  }
379 
380  if (m_blockViewCreationAndActivation) return;
381  TQTimer::singleShot(0,this,TQ_SIGNAL(viewChanged()));
382  //emit m_viewManager->viewChanged ();
383 }
384 
385 void KateViewSpaceContainer::slotPendingDocumentNameChanged() {
386  TQString c;
387  if (m_pendingDocument->url().isEmpty() || (!showFullPath))
388  {
389  c = m_pendingDocument->docName();
390  }
391  else
392  {
393  c = m_pendingDocument->url().prettyURL();
394  }
395  setCaption(KStringHandler::lsqueeze(c,32));
396 }
397 
398 void KateViewSpaceContainer::statusMsg ()
399 {
400  if (!activeView()) return;
401 
402  Kate::View* v = activeView();
403 
404  bool readOnly = !v->getDoc()->isReadWrite();
405  uint config = v->getDoc()->configFlags();
406 
407  int ovr = 0;
408  if (readOnly)
409  ovr = 0;
410  else
411  {
412  if (config & Kate::Document::cfOvr)
413  {
414  ovr=1;
415  }
416  else
417  {
418  ovr=2;
419  }
420  }
421 
422  int mod = (int)v->getDoc()->isModified();
423  bool block=v->getDoc()->blockSelectionMode();
424 
425  TQString c;
426  if (v->getDoc()->url().isEmpty() || (!showFullPath))
427  {
428  c = v->getDoc()->docName();
429  }
430  else
431  {
432  c = v->getDoc()->url().pathOrURL();
433  }
434 
435  m_viewManager->mainWindow()->tabWidget()->changeTab (this, KStringHandler::lsqueeze(c,32));
436  emit statusChanged (v, v->cursorLine(), v->cursorColumn(), ovr,block, mod, KStringHandler::lsqueeze(c,64));
437  emit statChanged ();
438 }
439 
440 void KateViewSpaceContainer::splitViewSpace( KateViewSpace* vs,
441  bool isHoriz,
442  bool atTop)
443 {
444 // kdDebug(13001)<<"splitViewSpace()"<<endl;
445 
446  if (!activeView()) return;
447  if (!vs) vs = activeViewSpace();
448 
449  bool isFirstTime = vs->parentWidget() == this;
450 
451  TQValueList<int> psizes;
452  if ( ! isFirstTime )
453  if ( TQSplitter *ps = static_cast<TQSplitter*>(vs->parentWidget()->tqt_cast("TQSplitter")) )
454  psizes = ps->sizes();
455 
456  TQt::Orientation o = isHoriz ? TQt::Vertical : TQt::Horizontal;
457  KateMDI::Splitter* s = new KateMDI::Splitter(o, vs->parentWidget());
458  s->setOpaqueResize( TDEGlobalSettings::opaqueResize() );
459 
460  if (! isFirstTime) {
461  // anders: make sure the split' viewspace is always
462  // correctly positioned.
463  // If viewSpace is the first child, the new splitter must be moveToFirst'd
464  if ( !((KateMDI::Splitter*)vs->parentWidget())->isLastChild( vs ) )
465  ((KateMDI::Splitter*)s->parentWidget())->moveToFirst( s );
466  }
467  vs->reparent( s, 0, TQPoint(), true );
468  KateViewSpace* vsNew = new KateViewSpace( this, s );
469 
470  if (atTop)
471  s->moveToFirst( vsNew );
472 
473  if (!isFirstTime)
474  if (TQSplitter *ps = static_cast<TQSplitter*>(s->parentWidget()->tqt_cast("TQSplitter")) )
475  ps->setSizes( psizes );
476 
477  s->show();
478 
479  TQValueList<int> sizes;
480  int space = 50;//isHoriz ? s->parentWidget()->height()/2 : s->parentWidget()->width()/2;
481  sizes << space << space;
482  s->setSizes( sizes );
483 
484  connect(this, TQ_SIGNAL(statusChanged(Kate::View *, int, int, int, bool, int, const TQString &)), vsNew, TQ_SLOT(slotStatusChanged(Kate::View *, int, int,int, bool, int, const TQString &)));
485  m_viewSpaceList.append( vsNew );
486  activeViewSpace()->setActive( false );
487  vsNew->setActive( true, true );
488  vsNew->show();
489 
490  createView (activeView()->getDoc());
491 
492  if (this == m_viewManager->activeContainer())
493  m_viewManager->updateViewSpaceActions ();
494 
495 // kdDebug(13001)<<"splitViewSpace() - DONE!"<<endl;
496 }
497 
498 void KateViewSpaceContainer::removeViewSpace (KateViewSpace *viewspace)
499 {
500  // abort if viewspace is 0
501  if (!viewspace) return;
502 
503  // abort if this is the last viewspace
504  if (m_viewSpaceList.count() < 2) return;
505 
506  KateMDI::Splitter* p = (KateMDI::Splitter*)viewspace->parentWidget();
507 
508  // find out if it is the first child for repositioning
509  // see below
510  bool pIsFirst = false;
511 
512  // save some size information
513  KateMDI::Splitter* pp=0L;
514  TQValueList<int> ppsizes;
515  if (m_viewSpaceList.count() > 2 && p->parentWidget() != this)
516  {
517  pp = (KateMDI::Splitter*)p->parentWidget();
518  ppsizes = pp->sizes();
519  pIsFirst = !pp->isLastChild( p ); // simple logic, right-
520  }
521 
522  // Figure out where to put views that are still needed
523  KateViewSpace* next;
524  if (m_viewSpaceList.find(viewspace) == 0)
525  next = m_viewSpaceList.next();
526  else
527  next = m_viewSpaceList.prev();
528 
529  // Reparent views in viewspace that are last views, delete the rest.
530  int vsvc = viewspace->viewCount();
531  while (vsvc > 0)
532  {
533  if (viewspace->currentView())
534  {
535  Kate::View* v = viewspace->currentView();
536 
537  if (v->isLastView())
538  {
539  viewspace->removeView(v);
540  next->addView( v, false );
541  }
542  else
543  {
544  deleteView( v, false );
545  }
546  }
547  vsvc = viewspace->viewCount();
548  }
549 
550  m_viewSpaceList.remove( viewspace );
551 
552  // reparent the other sibling of the parent.
553  while (!p->childrenListObject().isEmpty())
554  {
555  TQWidget* other = ((TQWidget *)(( TQPtrList<TQObject>)p->childrenListObject()).first());
556 
557  other->reparent( p->parentWidget(), 0, TQPoint(), true );
558  // We also need to find the right viewspace to become active
559  if (pIsFirst)
560  ((KateMDI::Splitter*)p->parentWidget())->moveToFirst( other );
561  if ( other->isA("KateViewSpace") ) {
562  setActiveSpace( (KateViewSpace*)other );
563  }
564  else {
565  TQObjectList* l = other->queryList( "KateViewSpace" );
566  if ( l->first() != 0 ) { // I REALLY hope so!
567  setActiveSpace( (KateViewSpace*)l->first() );
568  }
569  delete l;
570  }
571  }
572 
573  delete p;
574 
575  if (!ppsizes.isEmpty())
576  pp->setSizes( ppsizes );
577 
578  // find the view that is now active.
579  Kate::View* v = activeViewSpace()->currentView();
580  if ( v )
581  activateView( v );
582 
583  if (this == m_viewManager->activeContainer())
584  m_viewManager->updateViewSpaceActions ();
585 
586  emit viewChanged();
587 }
588 
589 void KateViewSpaceContainer::slotCloseCurrentViewSpace()
590 {
591  removeViewSpace(activeViewSpace());
592 }
593 
594 void KateViewSpaceContainer::setShowFullPath( bool enable )
595 {
596  showFullPath = enable;
597  statusMsg ();
598  //m_mainWindow->slotWindowActivated ();
599 }
600 
605 void KateViewSpaceContainer::saveViewConfiguration(TDEConfig *config,const TQString& group)
606 {
607  bool weHaveSplittersAlive (viewSpaceCount() > 1);
608 
609  config->setGroup (group); //"View Configuration");
610  config->writeEntry ("Splitters", weHaveSplittersAlive);
611 
612  // no splitters around
613  if (!weHaveSplittersAlive)
614  {
615  config->writeEntry("Active Viewspace", 0);
616  m_viewSpaceList.first()->saveConfig ( config, 0,group );
617 
618  return;
619  }
620 
621  // I need the first splitter, the one which has this as parent.
622  KateMDI::Splitter* s;
623  TQObjectList *l = queryList("KateMDI::Splitter", 0, false, false);
624  TQObjectListIt it( *l );
625 
626  if ( (s = (KateMDI::Splitter*)it.current()) != 0 )
627  saveSplitterConfig( s, 0, config , group);
628 
629  delete l;
630 }
631 
632 void KateViewSpaceContainer::restoreViewConfiguration (TDEConfig *config, const TQString& group)
633 {
634  config->setGroup(group);
635  //config->setGroup ("View Configuration");
636 
637  // no splitters around, ohhh :()
638  if (!config->readBoolEntry ("Splitters"))
639  {
640  // only add the new views needed, let the old stay, won't hurt if one around
641  m_viewSpaceList.first ()->restoreConfig (this, config, TQString(group+"-ViewSpace 0"));
642  }
643  else
644  {
645  // send all views + their gui to **** ;)
646  for (uint i=0; i < m_viewList.count(); i++)
647  mainWindow()->guiFactory ()->removeClient (m_viewList.at(i));
648 
649  m_viewList.clear ();
650 
651  // cu viewspaces
652  m_viewSpaceList.clear();
653 
654  // call restoreSplitter for Splitter 0
655  restoreSplitter( config, TQString(group+"-Splitter 0"), this,group );
656  }
657 
658  // finally, make the correct view active.
659  config->setGroup (group);
660 /*
661  KateViewSpace *vs = m_viewSpaceList.at( config->readNumEntry("Active ViewSpace") );
662  if ( vs )
663  activateSpace( vs->currentView() );
664  */
665 }
666 
667 
668 void KateViewSpaceContainer::saveSplitterConfig( KateMDI::Splitter* s, int idx, TDEConfig* config, const TQString& viewConfGrp )
669 {
670  TQString grp = TQString(viewConfGrp+"-Splitter %1").arg(idx);
671  config->setGroup(grp);
672 
673  // Save sizes, orient, children for this splitter
674  config->writeEntry( "Sizes", s->sizes() );
675  config->writeEntry( "Orientation", s->orientation() );
676 
677  TQStringList childList;
678  // a katesplitter has two children, of which one may be a KateSplitter.
679  const TQObjectList l = s->childrenListObject();
680  TQObjectListIt it( l );
681  TQObject* obj;
682  for (; it.current(); ++it) {
683  obj = it.current();
684  TQString n; // name for child list, see below
685  // For KateViewSpaces, ask them to save the file list.
686  if ( obj->isA("KateViewSpace") ) {
687  n = TQString(viewConfGrp+"-ViewSpace %1").arg( m_viewSpaceList.find((KateViewSpace*)obj) );
688  ((KateViewSpace*)obj)->saveConfig ( config, m_viewSpaceList.find((KateViewSpace*)obj), viewConfGrp);
689  // save active viewspace
690  if ( ((KateViewSpace*)obj)->isActiveSpace() ) {
691  config->setGroup(viewConfGrp);
692  config->writeEntry("Active Viewspace", m_viewSpaceList.find((KateViewSpace*)obj) );
693  }
694  }
695  // For KateSplitters, recurse
696  else if ( obj->isA("KateMDI::Splitter") ) {
697  idx++;
698  saveSplitterConfig( (KateMDI::Splitter*)obj, idx, config,viewConfGrp);
699  n = TQString(viewConfGrp+"-Splitter %1").arg( idx );
700  }
701  // make sure list goes in right place!
702  if (!n.isEmpty()) {
703  if ( childList.count() > 0 && ! s->isLastChild( (TQWidget*)obj ) )
704  childList.prepend( n );
705  else
706  childList.append( n );
707  }
708  }
709 
710  // reset config group.
711  config->setGroup(grp);
712  config->writeEntry("Children", childList);
713 }
714 
715 void KateViewSpaceContainer::restoreSplitter( TDEConfig* config, const TQString &group, TQWidget* parent, const TQString& viewConfGrp)
716 {
717  config->setGroup( group );
718 
719  KateMDI::Splitter* s = new KateMDI::Splitter((TQt::Orientation)config->readNumEntry("Orientation"), parent);
720 
721  TQStringList children = config->readListEntry( "Children" );
722  for (TQStringList::Iterator it=children.begin(); it!=children.end(); ++it)
723  {
724  // for a viewspace, create it and open all documents therein.
725  if ( (*it).startsWith(viewConfGrp+"-ViewSpace") )
726  {
727  KateViewSpace* vs = new KateViewSpace( this, s );
728 
729  connect(this, TQ_SIGNAL(statusChanged(Kate::View *, int, int, int, bool, int, const TQString &)), vs, TQ_SLOT(slotStatusChanged(Kate::View *, int, int, int, bool, int, const TQString &)));
730 
731  if (m_viewSpaceList.isEmpty())
732  vs->setActive (true);
733 
734  m_viewSpaceList.append( vs );
735 
736  vs->show();
737  setActiveSpace( vs );
738 
739  vs->restoreConfig (this, config, *it);
740  }
741  else
742  {
743  // for a splitter, recurse.
744  restoreSplitter( config, TQString(*it), s, viewConfGrp );
745  }
746  }
747 
748  // set sizes
749  config->setGroup( group );
750  s->setSizes( config->readIntListEntry("Sizes") );
751  s->show();
752 }
753 
754 KateMainWindow *KateViewSpaceContainer::mainWindow() {
755  return m_viewManager->mainWindow();
756 }
KateMDI::Splitter
This class is needed because TQSplitter cant return an index for a widget.
Definition: katemdi.h:41
KateMDI::Splitter::isLastChild
bool isLastChild(TQWidget *w) const
Since there is supposed to be only 2 childs of a katesplitter, any child other than the last is the f...
Definition: katemdi.cpp:54

kate

Skip menu "kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kate

Skip menu "kate"
  • kate
  • libkonq
  • twin
  •   lib
Generated for kate by doxygen 1.8.13
This website is maintained by Timothy Pearson.