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