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

kate

  • kate
  • app
katefilelist.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 "katefilelist.h"
23 #include "katefilelist.moc"
24 
25 #include "katedocmanager.h"
26 #include "kateviewmanager.h"
27 #include "katemainwindow.h"
28 
29 #include <tqapplication.h>
30 #include <tqpainter.h>
31 #include <tqpopupmenu.h>
32 #include <tqheader.h>
33 #include <tqcolor.h>
34 #include <tqcheckbox.h>
35 #include <tqhbox.h>
36 #include <tqlayout.h>
37 #include <tqgroupbox.h>
38 #include <tqlabel.h>
39 #include <tqwhatsthis.h>
40 
41 #include <kiconloader.h>
42 #include <tdeconfig.h>
43 #include <tdelocale.h>
44 #include <tdeglobalsettings.h>
45 #include <kpassivepopup.h>
46 #include <kdebug.h>
47 #include <tdeapplication.h>
48 #include <kstringhandler.h>
49 #include <kcolorbutton.h>
50 #include <kdialog.h>
51 //END Includes
52 
53 //BEGIN ToolTip
54 class ToolTip : public TQToolTip
55 {
56  public:
57  ToolTip( TQWidget *parent, KateFileList *lv )
58  : TQToolTip( parent ),
59  m_listView( lv )
60  {
61  }
62  virtual ~ToolTip() {};
63 
64  void maybeTip( const TQPoint &pos )
65  {
66  TQListViewItem *i = m_listView->itemAt( pos );
67  if ( ! i ) return;
68 
69  KateFileListItem *item = ((KateFileListItem*)i);
70  if ( ! item ) return;
71 
72  tip( m_listView->itemRect( i ), m_listView->tooltip( item, 0 ) );
73 
74  }
75 
76  private:
77  KateFileList *m_listView;
78 };
79 
80 //END ToolTip
81 
82 //BEGIN KateFileList
83 KateFileList::KateFileList (KateMainWindow *main,
84  KateViewManager *_viewManager,
85  TQWidget * parent, const char * name )
86  : TDEListView (parent, name)
87  , m_sort( KateFileList::sortByID )
88 {
89  m_main = main;
90  m_tooltip = new ToolTip( viewport(), this );
91 
92  // default colors
93  m_viewShade = TQColor( 51, 204, 255 );
94  m_editShade = TQColor( 255, 102, 153 );
95  m_enableBgShading = false;
96 
97  setFocusPolicy ( TQWidget::NoFocus );
98 
99  viewManager = _viewManager;
100 
101  header()->hide();
102  addColumn("Document Name");
103 
104  setSelectionMode( TQListView::Single );
105  setSortType(KateFileList::sortByID);
106  setShowToolTips( false );
107 
108  setupActions ();
109 
110  connect(this,TQ_SIGNAL(moved()),this,TQ_SLOT(updateFileListLocations()));
111 
112  for (uint i = 0; i < KateDocManager::self()->documents(); i++)
113  {
114  slotDocumentCreated (KateDocManager::self()->document(i));
115  slotModChanged (KateDocManager::self()->document(i));
116  }
117 
118  connect(KateDocManager::self(),TQ_SIGNAL(documentCreated(Kate::Document *)),
119  this,TQ_SLOT(slotDocumentCreated(Kate::Document *)));
120  connect(KateDocManager::self(),TQ_SIGNAL(documentDeleted(uint)),
121  this,TQ_SLOT(slotDocumentDeleted(uint)));
122 
123  // don't Honour KDE single/double click setting, this files are already open,
124  // no need for hassle of considering double-click
125  connect(this,TQ_SIGNAL(selectionChanged(TQListViewItem *)),
126  this,TQ_SLOT(slotActivateView(TQListViewItem *)));
127  connect(viewManager,TQ_SIGNAL(viewChanged()), this,TQ_SLOT(slotViewChanged()));
128  connect(this,TQ_SIGNAL(contextMenuRequested( TQListViewItem *, const TQPoint &, int )),
129  this,TQ_SLOT(slotMenu ( TQListViewItem *, const TQPoint &, int )));
130 }
131 
132 KateFileList::~KateFileList ()
133 {
134  delete m_tooltip;
135 }
136 
137 void KateFileList::setupActions ()
138 {
139  windowNext = KStdAction::back(this, TQ_SLOT(slotPrevDocument()), m_main->actionCollection());
140  windowPrev = KStdAction::forward(this, TQ_SLOT(slotNextDocument()), m_main->actionCollection());
141  sortAction = new TDESelectAction( i18n("Sort &By"), 0,
142  m_main->actionCollection(), "filelist_sortby" );
143  listMoveFileUp = new TDEAction( i18n("Move File Up"), 0, m_main->actionCollection(), "filelist_move_up" );
144  //listMoveFileUp->setShortcut(TDEShortcut(CTRL + SHIFT + Key_Comma));
145  listMoveFileDown = new TDEAction( i18n("Move File Down"), 0, m_main->actionCollection(), "filelist_move_down" );
146  //listMoveFileDown->setShortcut(TDEShortcut(CTRL + SHIFT + Key_Period));
147  connect( listMoveFileUp, TQ_SIGNAL(activated()), this, TQ_SLOT(moveFileUp()) );
148  connect( listMoveFileDown, TQ_SIGNAL(activated()), this, TQ_SLOT(moveFileDown()) );
149  TQStringList l;
150  l << i18n("Opening Order") << i18n("Document Name") << i18n("URL") << i18n("Manual Placement");
151  sortAction->setItems( l );
152  connect( sortAction, TQ_SIGNAL(activated(int)), this, TQ_SLOT(setSortType(int)) );
153 }
154 
155 void KateFileList::updateActions ()
156 {
157  windowNext->setEnabled(KateDocManager::self()->documents() > 1);
158  windowPrev->setEnabled(KateDocManager::self()->documents() > 1);
159 }
160 
161 void KateFileList::keyPressEvent(TQKeyEvent *e) {
162  if ( ( e->key() == Key_Return ) || ( e->key() == Key_Enter ) )
163  {
164  e->accept();
165  slotActivateView( currentItem() );
166  }
167  else
168  {
169  TDEListView::keyPressEvent(e);
170  }
171 }
172 
173 // Protect single mode selection: don't let them
174 // leftclick outside items.
175 // ### if we get to accept keyboard navigation, set focus before
176 // returning
177 void KateFileList::contentsMousePressEvent( TQMouseEvent *e )
178 {
179  m_lastMouseDownPos = e->pos();
180 
181  if ( ! itemAt( contentsToViewport( e->pos() ) ) )
182  return;
183 
184  TDEListView::contentsMousePressEvent( e );
185 }
186 
187 void KateFileList::resizeEvent( TQResizeEvent *e )
188 {
189  TDEListView::resizeEvent( e );
190 
191  // ### We may want to actually calculate the widest field,
192  // since it's not automatically scrinked. If I add support for
193  // tree or marks, the changes of the required width will vary
194  // a lot with opening/closing of files and display changes for
195  // the mark branches.
196  int w = viewport()->width();
197  if ( columnWidth( 0 ) < w )
198  setColumnWidth( 0, w );
199 }
200 
201 void KateFileList::slotNextDocument()
202 {
203  if ( ! currentItem() || childCount() == 0 )
204  return;
205 
206  // ### more checking once more item types are added
207 
208  if ( currentItem()->nextSibling() )
209  viewManager->activateView( ((KateFileListItem*)currentItem()->nextSibling())->documentNumber() );
210  else
211  viewManager->activateView( ((KateFileListItem *)firstChild())->documentNumber() );
212 }
213 
214 void KateFileList::slotPrevDocument()
215 {
216  if ( ! currentItem() || childCount() == 0 )
217  return;
218 
219  // ### more checking once more item types are added
220 
221  if ( currentItem()->itemAbove() )
222  viewManager->activateView( ((KateFileListItem*)currentItem()->itemAbove())->documentNumber() );
223  else
224  viewManager->activateView( ((KateFileListItem *)lastItem())->documentNumber() );
225 }
226 
227 void KateFileList::slotDocumentCreated (Kate::Document *doc)
228 {
229  new KateFileListItem( this, doc/*, doc->documentNumber()*/ );
230  connect(doc,TQ_SIGNAL(modStateChanged(Kate::Document *)),this,TQ_SLOT(slotModChanged(Kate::Document *)));
231  connect(doc,TQ_SIGNAL(nameChanged(Kate::Document *)),this,TQ_SLOT(slotNameChanged(Kate::Document *)));
232  connect(doc,TQ_SIGNAL(modifiedOnDisc(Kate::Document *, bool, unsigned char)),this,TQ_SLOT(slotModifiedOnDisc(Kate::Document *, bool, unsigned char)));
233 
234  sort();
235  updateFileListLocations();
236  updateActions ();
237 }
238 
239 void KateFileList::slotDocumentDeleted (uint documentNumber)
240 {
241  TQListViewItem * item = firstChild();
242  while( item ) {
243  if ( ((KateFileListItem *)item)->documentNumber() == documentNumber )
244  {
245 // m_viewHistory.removeRef( (KateFileListItem *)item );
246 // m_editHistory.removeRef( (KateFileListItem *)item );
247 
248  removeItem( item );
249 
250  break;
251  }
252  item = item->nextSibling();
253  }
254 
255  updateFileListLocations();
256  updateActions ();
257 }
258 
259 void KateFileList::slotActivateView( TQListViewItem *item )
260 {
261  if ( ! item || item->rtti() != RTTI_KateFileListItem )
262  return;
263 
264  KateFileListItem *i = ((KateFileListItem*)item);
265  const KateDocumentInfo *info = KateDocManager::self()->documentInfo(i->document());
266 
267  if (info && info->modifiedOnDisc) {
268  // Simulate mouse button release, otherwise the paused DND operation
269  // will reactivate as soon as the mouse re-enters the list view!
270  TQMouseEvent e(TQEvent::MouseButtonRelease, m_lastMouseDownPos, TQt::LeftButton, 0);
271  contentsMouseReleaseEvent(&e);
272  }
273 
274  viewManager->activateView( i->documentNumber() );
275 }
276 
277 void KateFileList::slotModChanged (Kate::Document *doc)
278 {
279  if (!doc) return;
280 
281  TQListViewItem * item = firstChild();
282  while( item )
283  {
284  if ( ((KateFileListItem *)item)->documentNumber() == doc->documentNumber() )
285  break;
286 
287  item = item->nextSibling();
288  }
289 
290  if ( ((KateFileListItem *)item)->document()->isModified() )
291  {
292  m_editHistory.removeRef( (KateFileListItem *)item );
293  m_editHistory.prepend( (KateFileListItem *)item );
294 
295  for ( uint i=0; i < m_editHistory.count(); i++ )
296  {
297  m_editHistory.at( i )->setEditHistPos( i+1 );
298  repaintItem( m_editHistory.at( i ) );
299  }
300  }
301  else
302  repaintItem( item );
303 }
304 
305 void KateFileList::slotModifiedOnDisc (Kate::Document *doc, bool, unsigned char)
306 {
307  slotModChanged( doc );
308 }
309 
310 void KateFileList::slotNameChanged (Kate::Document *doc)
311 {
312  if (!doc) return;
313 
314  // ### using nextSibling to *only* look at toplevel items.
315  // child items could be marks for example
316  TQListViewItem * item = firstChild();
317  while( item ) {
318  if ( ((KateFileListItem*)item)->document() == doc )
319  {
320  item->setText( 0, doc->docName() );
321  repaintItem( item );
322  break;
323  }
324  item = item->nextSibling();
325  }
326  updateSort();
327 }
328 
329 void KateFileList::slotViewChanged ()
330 {
331  if (!viewManager->activeView()) return;
332 
333  Kate::View *view = viewManager->activeView();
334  uint dn = view->getDoc()->documentNumber();
335 
336  TQListViewItem * i = firstChild();
337  while( i ) {
338  if ( ((KateFileListItem *)i)->documentNumber() == dn )
339  {
340  break;
341  }
342  i = i->nextSibling();
343  }
344 
345  if ( ! i )
346  return;
347 
348  KateFileListItem *item = (KateFileListItem*)i;
349  setCurrentItem( item );
350 
351  // ### During load of file lists, all the loaded views gets active.
352  // Do something to avoid shading them -- maybe not creating views, just
353  // open the documents???
354 
355 
356 // int p = 0;
357 // if ( m_viewHistory.count() )
358 // {
359 // int p = m_viewHistory.findRef( item ); // only repaint items that needs it
360 // }
361 
362  m_viewHistory.removeRef( item );
363  m_viewHistory.prepend( item );
364 
365  for ( uint i=0; i < m_viewHistory.count(); i++ )
366  {
367  m_viewHistory.at( i )->setViewHistPos( i+1 );
368  repaintItem( m_viewHistory.at( i ) );
369  }
370 
371  updateFileListLocations();
372 }
373 
374 void KateFileList::updateFileListLocations()
375 {
376  TQListViewItem* item = firstChild();
377  int i=0;
378  while (item) {
379  Kate::Document* itemDocument = ((KateFileListItem *)item)->document();
380  if (m_sort == KateFileList::sortManual) {
381  if (KateDocManager::self()->findDocument(itemDocument) >= 0) {
382  itemDocument->setDocumentListPosition(i);
383  }
384  }
385  else {
386  if (KateDocManager::self()->findDocument(itemDocument) >= 0) {
387  itemDocument->setDocumentListPosition(-1);
388  }
389  }
390  item = item->itemBelow();
391  i++;
392  }
393 }
394 
395 void KateFileList::slotMenu ( TQListViewItem *item, const TQPoint &p, int /*col*/ )
396 {
397  if (!item)
398  return;
399 
400  m_clickedMenuItem = item;
401  if (m_clickedMenuItem->itemAbove()) {
402  listMoveFileUp->setEnabled(true);
403  }
404  else {
405  listMoveFileUp->setEnabled(false);
406  }
407  if (m_clickedMenuItem->itemBelow()) {
408  listMoveFileDown->setEnabled(true);
409  }
410  else {
411  listMoveFileDown->setEnabled(false);
412  }
413 
414  TQPopupMenu *menu = (TQPopupMenu*) ((viewManager->mainWindow())->factory()->container("filelist_popup", viewManager->mainWindow()));
415 
416  if (menu) {
417  menu->exec(p);
418  }
419 }
420 
421 TQString KateFileList::tooltip( TQListViewItem *item, int )
422 {
423  KateFileListItem *i = ((KateFileListItem*)item);
424  if ( ! i ) return TQString::null;
425 
426  TQString str;
427  const KateDocumentInfo *info = KateDocManager::self()->documentInfo(i->document());
428 
429  if (info && info->modifiedOnDisc)
430  {
431  if (info->modifiedOnDiscReason == 1)
432  str += i18n("<b>This file was changed (modified) on disk by another program.</b><br />");
433  else if (info->modifiedOnDiscReason == 2)
434  str += i18n("<b>This file was changed (created) on disk by another program.</b><br />");
435  else if (info->modifiedOnDiscReason == 3)
436  str += i18n("<b>This file was changed (deleted) on disk by another program.</b><br />");
437  }
438 
439  str += i->document()->url().prettyURL();
440  return str;
441 }
442 
443 
444 void KateFileList::setSortType (int s)
445 {
446  m_sort = s;
447  if (m_sort == KateFileList::sortManual) {
448  setSorting( -1, true );
449  setDragEnabled(true);
450  setAcceptDrops(true);
451  }
452  else {
453  setSorting( 0, true );
454  setDragEnabled(false);
455  setAcceptDrops(false);
456  updateSort ();
457  }
458 }
459 
460 void KateFileList::moveFileUp()
461 {
462  if (m_clickedMenuItem) {
463  sortAction->setCurrentItem(KateFileList::sortManual);
464  setSortType(KateFileList::sortManual);
465  TQListViewItem* nitemabove = m_clickedMenuItem->itemAbove();
466  if (nitemabove) {
467  nitemabove = nitemabove->itemAbove();
468  if (nitemabove) {
469  m_clickedMenuItem->moveItem(nitemabove);
470  }
471  else {
472  // Qt made this hard
473  nitemabove = m_clickedMenuItem->itemAbove();
474  nitemabove->moveItem(m_clickedMenuItem);
475  }
476  }
477  }
478  updateFileListLocations();
479 }
480 
481 void KateFileList::moveFileDown()
482 {
483  if (m_clickedMenuItem) {
484  sortAction->setCurrentItem(KateFileList::sortManual);
485  setSortType(KateFileList::sortManual);
486  TQListViewItem* nitemabove = m_clickedMenuItem->itemBelow();
487  if (nitemabove) {
488  m_clickedMenuItem->moveItem(nitemabove);
489  }
490  }
491  updateFileListLocations();
492 }
493 
494 void KateFileList::updateSort ()
495 {
496  sort ();
497  updateFileListLocations();
498 }
499 
500 void KateFileList::readConfig( TDEConfig *config, const TQString &group )
501 {
502  TQString oldgroup = config->group();
503  config->setGroup( group );
504 
505  setSortType( config->readNumEntry( "Sort Type", sortByID ) );
506  m_viewShade = config->readColorEntry( "View Shade", &m_viewShade );
507  m_editShade = config->readColorEntry( "Edit Shade", &m_editShade );
508  m_enableBgShading = config->readBoolEntry( "Shading Enabled", &m_enableBgShading );
509 
510  sortAction->setCurrentItem( sortType() );
511 
512  config->setGroup( oldgroup );
513 }
514 
515 void KateFileList::writeConfig( TDEConfig *config, const TQString &group )
516 {
517  TQString oldgroup = config->group();
518  config->setGroup( group );
519 
520  config->writeEntry( "Sort Type", m_sort );
521  config->writeEntry( "View Shade", m_viewShade );
522  config->writeEntry( "Edit Shade", m_editShade );
523  config->writeEntry( "Shading Enabled", m_enableBgShading );
524 
525  config->setGroup( oldgroup );
526 }
527 
528 void KateFileList::takeItem( TQListViewItem *item )
529 {
530  if ( item->rtti() == RTTI_KateFileListItem )
531  {
532  m_editHistory.removeRef( (KateFileListItem*)item );
533  m_viewHistory.removeRef( (KateFileListItem*)item );
534  }
535  TQListView::takeItem( item );
536 }
537 //END KateFileList
538 
539 //BEGIN KateFileListItem
540 KateFileListItem::KateFileListItem( TQListView* lv,
541  Kate::Document *_doc )
542  : TQListViewItem( lv, _doc->docName() ),
543  doc( _doc ),
544  m_viewhistpos( 0 ),
545  m_edithistpos( 0 ),
546  m_docNumber( _doc->documentNumber() )
547 {
548  // Move this document to the end of the list where it belongs
549  TQListViewItem* lastitem = lv->lastItem();
550  if (lastitem) {
551  moveItem(lastitem);
552  }
553 }
554 
555 KateFileListItem::~KateFileListItem()
556 {
557 }
558 
559 const TQPixmap *KateFileListItem::pixmap ( int column ) const
560 {
561  if ( column == 0) {
562  static TQPixmap noPm = SmallIcon ("null");
563  static TQPixmap modPm = SmallIcon("modified");
564  static TQPixmap discPm = SmallIcon("modonhd");
565  static TQPixmap modmodPm = SmallIcon("modmod");
566 
567  const KateDocumentInfo *info = KateDocManager::self()->documentInfo(doc);
568 
569  if (info && info->modifiedOnDisc)
570  return doc->isModified() ? &modmodPm : &discPm;
571  else
572  return doc->isModified() ? &modPm : &noPm;
573  }
574 
575  return 0;
576 }
577 
578 void KateFileListItem::paintCell( TQPainter *painter, const TQColorGroup & cg, int column, int width, int align )
579 {
580  KateFileList *fl = (KateFileList*)listView();
581  if ( ! fl ) return;
582 
583  if ( column == 0 )
584  {
585  TQColorGroup cgNew = cg;
586 
587  // replace the base color with a different shading if necessary...
588  if ( fl->shadingEnabled() && m_viewhistpos > 1 )
589  {
590  TQColor b( cg.base() );
591 
592  TQColor shade = fl->viewShade();
593  TQColor eshade = fl->editShade();
594  int hc = fl->histCount();
595  // If this file is in the edit history, blend in the eshade
596  // color. The blend is weighted by the position in the editing history
597  if ( fl->shadingEnabled() && m_edithistpos > 0 )
598  {
599  int ec = fl->editHistCount();
600  int v = hc-m_viewhistpos;
601  int e = ec-m_edithistpos+1;
602  e = e*e;
603  int n = TQMAX(v + e, 1);
604  shade.setRgb(
605  ((shade.red()*v) + (eshade.red()*e))/n,
606  ((shade.green()*v) + (eshade.green()*e))/n,
607  ((shade.blue()*v) + (eshade.blue()*e))/n
608  );
609  }
610  // blend in the shade color.
611  // max transperancy < .5, latest is most colored.
612  float t = (0.5/hc)*(hc-m_viewhistpos+1);
613  b.setRgb(
614  (int)((b.red()*(1-t)) + (shade.red()*t)),
615  (int)((b.green()*(1-t)) + (shade.green()*t)),
616  (int)((b.blue()*(1-t)) + (shade.blue()*t))
617  );
618 
619  cgNew.setColor(TQColorGroup::Base, b);
620  }
621 
622  TQListViewItem::paintCell( painter, cgNew, column, width, align );
623  }
624  else
625  TQListViewItem::paintCell( painter, cg, column, width, align );
626 }
627 
628 int KateFileListItem::compare ( TQListViewItem * i, int col, bool ascending ) const
629 {
630  if ( i->rtti() == RTTI_KateFileListItem )
631  {
632  switch( ((KateFileList*)listView())->sortType() )
633  {
634  case KateFileList::sortByID:
635  {
636 
637  int d = (int)doc->documentNumber() - ((KateFileListItem*)i)->documentNumber();
638  return ascending ? d : -d;
639  break;
640  }
641  case KateFileList::sortByURL:
642  return doc->url().prettyURL().compare( ((KateFileListItem*)i)->document()->url().prettyURL() );
643  break;
644  default:
645  return TQListViewItem::compare( i, col, ascending );
646  }
647  }
648  return 0;
649 }
650 //END KateFileListItem
651 
652 //BEGIN KFLConfigPage
653 KFLConfigPage::KFLConfigPage( TQWidget* parent, const char *name, KateFileList *fl )
654  : Kate::ConfigPage( parent, name ),
655  m_filelist( fl ),
656  m_changed( false )
657 {
658  TQVBoxLayout *lo1 = new TQVBoxLayout( this );
659  int spacing = KDialog::spacingHint();
660  lo1->setSpacing( spacing );
661 
662  TQGroupBox *gb = new TQGroupBox( 1, TQt::Horizontal, i18n("Background Shading"), this );
663  lo1->addWidget( gb );
664 
665  TQWidget *g = new TQWidget( gb );
666  TQGridLayout *lo = new TQGridLayout( g, 2, 2 );
667  lo->setSpacing( KDialog::spacingHint() );
668  cbEnableShading = new TQCheckBox( i18n("&Enable background shading"), g );
669  lo->addMultiCellWidget( cbEnableShading, 1, 1, 0, 1 );
670 
671  kcbViewShade = new KColorButton( g );
672  lViewShade = new TQLabel( kcbViewShade, i18n("&Viewed documents' shade:"), g );
673  lo->addWidget( lViewShade, 2, 0 );
674  lo->addWidget( kcbViewShade, 2, 1 );
675 
676  kcbEditShade = new KColorButton( g );
677  lEditShade = new TQLabel( kcbEditShade, i18n("&Modified documents' shade:"), g );
678  lo->addWidget( lEditShade, 3, 0 );
679  lo->addWidget( kcbEditShade, 3, 1 );
680 
681  // sorting
682  TQHBox *hbSorting = new TQHBox( this );
683  lo1->addWidget( hbSorting );
684  lSort = new TQLabel( i18n("&Sort by:"), hbSorting );
685  cmbSort = new TQComboBox( hbSorting );
686  lSort->setBuddy( cmbSort );
687  TQStringList l;
688  l << i18n("Opening Order") << i18n("Document Name") << i18n("URL");
689  cmbSort->insertStringList( l );
690 
691  lo1->insertStretch( -1, 10 );
692 
693  TQWhatsThis::add( cbEnableShading, i18n(
694  "When background shading is enabled, documents that have been viewed "
695  "or edited within the current session will have a shaded background. "
696  "The most recent documents have the strongest shade.") );
697  TQWhatsThis::add( kcbViewShade, i18n(
698  "Set the color for shading viewed documents.") );
699  TQWhatsThis::add( kcbEditShade, i18n(
700  "Set the color for modified documents. This color is blended into "
701  "the color for viewed files. The most recently edited documents get "
702  "most of this color.") );
703 
704  TQWhatsThis::add( cmbSort, i18n(
705  "Set the sorting method for the documents.") );
706 
707  reload();
708 
709  slotEnableChanged();
710  connect( cbEnableShading, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotMyChanged()) );
711  connect( cbEnableShading, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotEnableChanged()) );
712  connect( kcbViewShade, TQ_SIGNAL(changed(const TQColor&)), this, TQ_SLOT(slotMyChanged()) );
713  connect( kcbEditShade, TQ_SIGNAL(changed(const TQColor&)), this, TQ_SLOT(slotMyChanged()) );
714  connect( cmbSort, TQ_SIGNAL(activated(int)), this, TQ_SLOT(slotMyChanged()) );
715 }
716 
717 void KFLConfigPage::apply()
718 {
719  if ( ! m_changed )
720  return;
721  m_changed = false;
722 
723  // Change settings in the filelist
724  m_filelist->m_viewShade = kcbViewShade->color();
725  m_filelist->m_editShade = kcbEditShade->color();
726  m_filelist->m_enableBgShading = cbEnableShading->isChecked();
727  m_filelist->setSortType( cmbSort->currentItem() );
728  // repaint the affected items
729  m_filelist->triggerUpdate();
730 }
731 
732 void KFLConfigPage::reload()
733 {
734  // read in from config file
735  TDEConfig *config = kapp->config();
736  config->setGroup( "Filelist" );
737  cbEnableShading->setChecked( config->readBoolEntry("Shading Enabled", &m_filelist->m_enableBgShading ) );
738  kcbViewShade->setColor( config->readColorEntry("View Shade", &m_filelist->m_viewShade ) );
739  kcbEditShade->setColor( config->readColorEntry("Edit Shade", &m_filelist->m_editShade ) );
740  cmbSort->setCurrentItem( m_filelist->sortType() );
741  m_changed = false;
742 }
743 
744 void KFLConfigPage::slotEnableChanged()
745 {
746  kcbViewShade->setEnabled( cbEnableShading->isChecked() );
747  kcbEditShade->setEnabled( cbEnableShading->isChecked() );
748  lViewShade->setEnabled( cbEnableShading->isChecked() );
749  lEditShade->setEnabled( cbEnableShading->isChecked() );
750 }
751 
752 void KFLConfigPage::slotMyChanged()
753 {
754  m_changed = true;
755  slotChanged();
756 }
757 
758 //END KFLConfigPage
Kate
Namespace collecting as much of the internal Kate classes as we can manage.
Definition: kateapp.h:32

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.9.1
This website is maintained by Timothy Pearson.