Advertisement
fbcyborg

folderview.debug

Aug 4th, 2012
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.65 KB | None | 0 0
  1. diff --git a/plasma/applets/folderview/iconview.cpp b/plasma/applets/folderview/iconview.cpp
  2. index 8f56a11..adc25c0 100644
  3. --- a/plasma/applets/folderview/iconview.cpp
  4. +++ b/plasma/applets/folderview/iconview.cpp
  5. @@ -87,6 +87,11 @@ IconView::IconView(QGraphicsWidget *parent)
  6.        m_dropActions(0),
  7.        m_editor(0)
  8.  {
  9. +    std::string debug_path = std::string(getenv("HOME")) + "/.kde/share/folderview.debug";
  10. +    //std::cerr << debug_path;
  11. +    debug_stream.open(debug_path.c_str(), std::fstream::out | std::fstream::app);
  12. +    debug_stream << "logging setRange() function calls\n\n";
  13. +
  14.      m_actionOverlay = new ActionOverlay(this);
  15.  
  16.      setAcceptHoverEvents(true);
  17. @@ -117,6 +122,8 @@ IconView::~IconView()
  18.  {
  19.      // Make sure that we don't leave any open popup views on the screen when we're deleted
  20.      delete m_popupView;
  21. +    debug_stream << "\n";
  22. +    debug_stream.close();
  23.  }
  24.  
  25.  void IconView::setModel(QAbstractItemModel *model)
  26. @@ -388,6 +395,7 @@ void IconView::rowsInserted(const QModelIndex &parent, int first, int last)
  27.          }
  28.  
  29.          m_validRows = m_items.size();
  30. +        debug_stream << "updateScrollbar in rowsInserted" << __LINE__ << "\n";
  31.          updateScrollBar();
  32.      }
  33.  }
  34. @@ -408,6 +416,7 @@ void IconView::rowsRemoved(const QModelIndex &parent, int first, int last)
  35.          } else {
  36.              // All the items were removed
  37.              m_items.clear();
  38. +            debug_stream << "updateScrollbar in rowsRemoved" << __LINE__ << "\n";
  39.              updateScrollBar();
  40.              markAreaDirty(visibleArea());                                                                                    
  41.          }                                                                                                                    
  42. @@ -425,6 +434,7 @@ void IconView::rowsRemoved(const QModelIndex &parent, int first, int last)                                
  43.          }                                                                                                                    
  44.          m_items.remove(first, last - first + 1);                                                                              
  45.          m_validRows = m_items.size();
  46. +        debug_stream << "updateScrollbar in rowsRemoved" << __LINE__ << "\n";
  47.          updateScrollBar();
  48.      }
  49.  }
  50. @@ -488,6 +498,7 @@ void IconView::listingStarted(const KUrl &url)
  51.  void IconView::listingClear()
  52.  {
  53.      markAreaDirty(visibleArea());
  54. +    debug_stream << "updateScrollbar in listingClear" << __LINE__ << "\n";
  55.      updateScrollBar();
  56.      update();
  57.  }
  58. @@ -703,6 +714,7 @@ void IconView::layoutItems()
  59.              }
  60.              // If we've finished laying out all the icons
  61.              if (!m_needPostLayoutPass && count == m_items.size() && !listingInProgress()) {
  62. +                debug_stream << "first doLayoutSanityCheck in layoutItems " << __LINE__ << "\n";
  63.                  needUpdate |= doLayoutSanityCheck();
  64.              }
  65.          } else {
  66. @@ -740,6 +752,7 @@ void IconView::layoutItems()
  67.                  needUpdate = true;
  68.              }
  69.          }
  70. +        debug_stream << "second doLayoutSanityCheck in layoutItems " << __LINE__ << "\n";
  71.          needUpdate |= doLayoutSanityCheck();
  72.          m_needPostLayoutPass = false;
  73.          emit busy(false);
  74. @@ -756,6 +769,7 @@ void IconView::layoutItems()
  75.          update();
  76.      }
  77.  
  78. +    debug_stream << "updateScrollbar in layoutItems " << __LINE__ << "\n";
  79.      updateScrollBar();
  80.  }
  81.  
  82. @@ -823,6 +837,7 @@ void IconView::alignIconsToGrid()
  83.      }
  84.  
  85.      if (layoutChanged) {
  86. +        debug_stream << "doLayoutSanityCheck in alignIconsToGrid " << __LINE__ << "\n";
  87.          doLayoutSanityCheck();
  88.          markAreaDirty(visibleArea());
  89.          m_layoutBroken = true;
  90. @@ -856,17 +871,22 @@ bool IconView::doLayoutSanityCheck()
  91.  
  92.      const QRect cr = contentsRect().toRect();
  93.      int scrollValue = m_scrollBar->value();
  94. +    debug_stream << "contentsRect at doLayoutSanityCheck start: (width " << cr.width() << ") (height " << cr.height() << ")\n";
  95. +    debug_stream << "boundingRect at doLayoutSanityCheck start: (width " << boundingRect.width() << ") (height " << boundingRect.height() << ")\n";
  96. +    debug_stream << "scrollValue at doLayoutSanityCheck start: " << scrollValue << "\n";
  97.      QPoint delta(0, 0);
  98.  
  99.      // Make sure no items have negative coordinates
  100.      if (boundingRect.y() < cr.top() || boundingRect.x() < cr.left()) {
  101.          delta.rx() = qMax(0, cr.left() - boundingRect.x());
  102.          delta.ry() = qMax(0, cr.top() - boundingRect.y());
  103. +        debug_stream << "delta adjusted in \"make sure no items have negative coords\" " << delta.rx() << " "<< delta.ry() << "\n";
  104.      }
  105.  
  106.      // Remove any empty space above the visible area
  107.      if (delta.y() == 0 && scrollValue > 0) {
  108.          delta.ry() = -qBound(0, boundingRect.top() - cr.top(), scrollValue);
  109. +        debug_stream << "delta adjusted in \"remove any empty space above the visible area\" " << delta.rx() << " "<< delta.ry() << "\n";
  110.      }
  111.  
  112.      if (!delta.isNull()) {
  113. @@ -881,6 +901,10 @@ bool IconView::doLayoutSanityCheck()
  114.          boundingRect = boundingRect.translated(delta) | cr;
  115.          scrollValue += delta.y();
  116.  
  117. +        debug_stream << "setRange() in doLayoutSanityCheck in if (!delta.isNull())\n";
  118. +        debug_stream << "brect (width " << boundingRect.width() << ") (height" << boundingRect.height() << ")\n";
  119. +        debug_stream << "cr (width" << cr.width() << ") (height " << cr.height() << ")\n";
  120. +        debug_stream << "(scrollValue " << scrollValue << ") (max " << qMax(boundingRect.height() - cr.height(), scrollValue) << ")\n";
  121.          m_scrollBar->setRange(0, qMax(boundingRect.height() - cr.height(), scrollValue));
  122.          m_scrollBar->setValue(scrollValue);
  123.  
  124. @@ -895,6 +919,10 @@ bool IconView::doLayoutSanityCheck()
  125.      }
  126.  
  127.      boundingRect |= cr;
  128. +    debug_stream << "setRange() in doLayoutSanityCheck out of if(!delta.isNull())\n";
  129. +    debug_stream << "brect (width" << boundingRect.width() << ") (height " << boundingRect.height() << ")\n";
  130. +    debug_stream << "cr (width " << cr.width() << ") (height " << cr.height() << ")\n";
  131. +    debug_stream << "(scrollValue " << scrollValue << ") (max " << qMax(boundingRect.height() - cr.height(), scrollValue) << ")\n";
  132.      m_scrollBar->setRange(0, qMax(boundingRect.height() - cr.height(), scrollValue));
  133.      m_scrollBar->setValue(scrollValue);
  134.  
  135. @@ -917,11 +945,13 @@ void IconView::updateScrollBar()
  136.          boundingRect.adjust(-10, -10, 10, 10);
  137.          boundingRect |= cr;
  138.  
  139. +        debug_stream << "setRange() in updateScrollBar " << __LINE__ << " " << 0 << " " << boundingRect.height() - cr.height() << "\n";
  140.          m_scrollBar->setRange(0, boundingRect.height() - cr.height());
  141.          m_scrollBar->setPageStep(cr.height());
  142.          m_scrollBar->setSingleStep(gridSize().height());
  143.      } else {
  144.          // The view is empty
  145. +        debug_stream << "setRange() in updateScrollBar " << __LINE__ << " " << 0 << " " << 0 << "\n";
  146.          m_scrollBar->setRange(0, 0);
  147.      }
  148.  
  149. @@ -954,6 +984,7 @@ void IconView::finishedScrolling()
  150.                  }
  151.              }
  152.              m_scrollBar->setValue(m_scrollBar->value() - deltaY);
  153. +            debug_stream << "setRange() in finishedScrolling " << __LINE__ << " " << 0 << " " << m_scrollBar->maximum() - deltaY << "\n";
  154.              m_scrollBar->setRange(0, m_scrollBar->maximum() - deltaY);
  155.              markAreaDirty(visibleArea());
  156.              boundingRect.translate(0, -deltaY);
  157. @@ -965,10 +996,12 @@ void IconView::finishedScrolling()
  158.          boundingRect |= cr;
  159.          int max = qMax(m_scrollBar->value(), boundingRect.height() - cr.height());
  160.          if (m_scrollBar->maximum() > max) {
  161. +            debug_stream << "setRange() in finishedScrolling " << __LINE__ << " " << 0 << " " << max << "\n";
  162.              m_scrollBar->setRange(0, max);
  163.          }
  164.      } else {
  165.          // The view is empty
  166. +                debug_stream << "setRange() in finishedScrolling " << __LINE__ << " " << 0 << " " << 0 << "\n";
  167.          m_scrollBar->setRange(0, 0);
  168.      }
  169.  
  170. @@ -1519,6 +1552,7 @@ void IconView::resizeEvent(QGraphicsSceneResizeEvent *e)
  171.          // A check is done when the timer fires to make sure that a relayout
  172.          // is really necessary.
  173.          m_delayedRelayoutTimer.start(500, this);
  174. +        debug_stream << "updateScrollbar in resizeEvent" << __LINE__ << "\n";
  175.          updateScrollBar();
  176.      }
  177.  }
  178. @@ -2364,6 +2398,7 @@ void IconView::dropEvent(QGraphicsSceneDragDropEvent *event)
  179.      }
  180.  
  181.      // Make sure no icons have negative coordinates etc.
  182. +    debug_stream << "doLayoutSanityCheck in dropEvent" << __LINE__ << "\n";
  183.      doLayoutSanityCheck();
  184.      markAreaDirty(visibleArea());
  185.      m_regionCache.clear();
  186. @@ -2456,6 +2491,7 @@ void IconView::changeEvent(QEvent *event)
  187.                  }
  188.                  m_regionCache.clear();
  189.                  markAreaDirty(mapToViewport(rect()).toAlignedRect());
  190. +                debug_stream << "updateScrollbar in changeEvent" << __LINE__ << "\n";
  191.                  updateScrollBar();
  192.              }    
  193.          }
  194. diff --git a/plasma/applets/folderview/iconview.h b/plasma/applets/folderview/iconview.h
  195. index e648ff0..fcd55ff 100644
  196. --- a/plasma/applets/folderview/iconview.h
  197. +++ b/plasma/applets/folderview/iconview.h
  198. @@ -33,6 +33,11 @@
  199.  #include <QBasicTimer>
  200.  
  201.  
  202. +#include <fstream>
  203. +#include <iostream>
  204. +#include <string>
  205. +
  206. +
  207.  class KUrl;
  208.  class KFileItemList;
  209.  class KonqOperations;
  210. @@ -284,6 +289,7 @@ private:
  211.      ActionOverlay *m_actionOverlay;
  212.      QStringList m_popupPreviewPlugins;
  213.      QString m_searchQuery;
  214. +    std::fstream debug_stream;
  215.  };
  216.  
  217.  #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement