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

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
  • kwin
  •   lib
  • libkonq
Generated for kate by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |