Filelight – graphical disk usage analyzer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

97 lignes
2.4 KiB

  1. //Author: Max Howell <max.howell@methylblue.com>, (C) 2003-4
  2. //Copyright: See COPYING file that comes with this distribution
  3. #include "historyAction.h"
  4. #include <tdeaccel.h>
  5. #include <tdeconfig.h>
  6. #include <tdelocale.h>
  7. inline
  8. HistoryAction::HistoryAction( const TQString &text, const char *icon, const TDEShortcut &cut, TDEActionCollection *ac, const char *name )
  9. : TDEAction( text, icon, cut, 0, 0, ac, name )
  10. , m_text( text )
  11. {
  12. // ui files make this false, but we can't rely on UI file as it isn't compiled in :(
  13. TDEAction::setEnabled( false );
  14. }
  15. void
  16. HistoryAction::push( const TQString &path )
  17. {
  18. if( !path.isEmpty() && m_list.last() != path )
  19. {
  20. m_list.append( path );
  21. setActionMenuTextOnly( this, path );
  22. TDEAction::setEnabled( true );
  23. }
  24. }
  25. TQString
  26. HistoryAction::pop()
  27. {
  28. const TQString s = m_list.last();
  29. m_list.pop_back();
  30. setActionMenuTextOnly( this, m_list.last() );
  31. setEnabled();
  32. return s;
  33. }
  34. HistoryCollection::HistoryCollection( TDEActionCollection *ac, TQObject *parent, const char *name )
  35. : TQObject( parent, name )
  36. , m_b( new HistoryAction( i18n( "Back" ), "back", TDEStdAccel::back(), ac, "go_back" ) )
  37. , m_f( new HistoryAction( i18n( "Forward" ), "forward", TDEStdAccel::forward(), ac, "go_forward" ) )
  38. , m_receiver( 0 )
  39. {
  40. connect( m_b, TQT_SIGNAL(activated()), TQT_SLOT(pop()) );
  41. connect( m_f, TQT_SIGNAL(activated()), TQT_SLOT(pop()) );
  42. }
  43. void
  44. HistoryCollection::push( const KURL &url ) //slot
  45. {
  46. if( !url.isEmpty() )
  47. {
  48. if( !m_receiver )
  49. {
  50. m_f->clear();
  51. m_receiver = m_b;
  52. }
  53. m_receiver->push( url.path( 1 ) );
  54. }
  55. m_receiver = 0;
  56. }
  57. void
  58. HistoryCollection::pop() //slot
  59. {
  60. KURL url;
  61. const TQString path = ((HistoryAction*)sender())->pop(); //FIXME here we remove the constness
  62. url.setPath( path );
  63. m_receiver = (sender() == m_b) ? m_f : m_b;
  64. emit activated( url );
  65. }
  66. void
  67. HistoryCollection::save( TDEConfig *config )
  68. {
  69. config->writePathEntry( "backHistory", m_b->m_list );
  70. config->writePathEntry( "forwardHistory", m_f->m_list );
  71. }
  72. void
  73. HistoryCollection::restore( TDEConfig *config )
  74. {
  75. m_b->m_list = config->readPathListEntry( "backHistory" );
  76. m_f->m_list = config->readPathListEntry( "forwardHistory" );
  77. //TODO texts are not updated - no matter
  78. }
  79. #include "historyAction.moc"