KBFX – an alternative to T-Menu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
3.3KB

  1. /*
  2. * Copyright (C) 2006
  3. * Siraj Razick <siraj@kdemail.net>
  4. * PhobosK <phobosk@mail.kbfx.net>
  5. * see Also AUTHORS
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Library General Public License version 2 as
  9. * published by the Free Software Foundation
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this program; if not, write to the
  18. * Free Software Foundation, Inc.,
  19. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. */
  21. #include "kbfxplasmacanvasstack.h"
  22. KbfxPlasmaCanvasStack::KbfxPlasmaCanvasStack()
  23. {
  24. m_current= 0;//set to NULL
  25. m_count = 0;
  26. m_height = 0;
  27. m_width = 0;
  28. m_groupChain.setAutoDelete ( TRUE );
  29. m_name = "Unset:Faulty plugin";
  30. }
  31. KbfxPlasmaCanvasStack::~KbfxPlasmaCanvasStack()
  32. {
  33. //TODO: needs to manage memory here
  34. for ( uint i = 0; i < ( uint ) m_count; ++i )
  35. {
  36. m_groupChain.at ( i )->~KbfxPlasmaCanvasGroupView();
  37. m_groupChain.remove ( m_groupChain.at ( i ) );
  38. }
  39. Dict::Iterator it;
  40. for ( it = m_dict.begin();it != m_dict.end();++it )
  41. {
  42. m_dict.remove ( it );
  43. }
  44. delete m_current;
  45. }
  46. void
  47. KbfxPlasmaCanvasStack::raise ( uint id )
  48. {
  49. KbfxPlasmaCanvasGroupView * _gvPtr = m_groupChain.at ( id );
  50. if ( !_gvPtr )
  51. tqDebug ( "Error item not in Stack" );
  52. else
  53. {
  54. for ( uint i = 0; i < m_groupChain.count (); ++i )
  55. {
  56. m_groupChain.at ( i )->hide();
  57. }
  58. m_height = _gvPtr->height();
  59. _gvPtr->show();
  60. }
  61. }
  62. bool
  63. KbfxPlasmaCanvasStack::contains ( TQString name )
  64. {
  65. //FIXME:Depricated Data Structure Needs fixing
  66. if ( m_dict.contains ( name ) == true )
  67. return true;
  68. else
  69. return false;
  70. }
  71. void
  72. KbfxPlasmaCanvasStack::addGroup ( KbfxPlasmaCanvasGroupView * gPtr )
  73. {
  74. if ( gPtr == NULL )
  75. {
  76. tqDebug
  77. ( "KbfxPlasmaCanvasStack.cpp:34:Null Pointer Passed to addGroup()" );
  78. return;
  79. }
  80. else
  81. {
  82. m_groupChain.append ( gPtr );
  83. m_height = gPtr->height();
  84. m_width = gPtr->width();
  85. // KbfxPlasmaDataStack stackinfo;
  86. /// stackinfo
  87. m_dict[gPtr->name() ] = m_count;
  88. m_count++;
  89. }
  90. }
  91. KbfxPlasmaCanvasStack::Dict
  92. KbfxPlasmaCanvasStack::getDict()
  93. {
  94. return m_dict;
  95. }
  96. void
  97. KbfxPlasmaCanvasStack::hide()
  98. {
  99. for ( uint i = 0; i < m_groupChain.count (); ++i )
  100. {
  101. m_groupChain.at ( i )->hide();
  102. }
  103. }
  104. void
  105. KbfxPlasmaCanvasStack::raiseByName ( TQString name )
  106. {
  107. for ( uint i = 0; i < m_groupChain.count (); ++i )
  108. {
  109. m_groupChain.at ( i )->hide();
  110. }
  111. for ( uint i = 0; i < m_groupChain.count (); ++i )
  112. {
  113. if ( m_groupChain.at ( i )->name() == name )
  114. {
  115. m_groupChain.at ( i )->show();
  116. m_height = m_groupChain.at ( i )->height();
  117. }
  118. }
  119. }
  120. KbfxPlasmaCanvasGroupView *
  121. KbfxPlasmaCanvasStack::activeViewByName ( TQString name )
  122. {
  123. for ( uint i = 0; i < m_groupChain.count (); ++i )
  124. {
  125. if ( m_groupChain.at ( i )->name() == name )
  126. {
  127. return m_groupChain.at ( i );
  128. }
  129. }
  130. return new KbfxPlasmaCanvasGroupView();
  131. }
  132. TQString
  133. KbfxPlasmaCanvasStack::getItemName ( int id )
  134. {
  135. return m_groupChain.at ( id )->name();
  136. }
  137. #include "kbfxplasmacanvasstack.moc"