Repository: spyder-ide/spyder

Issue:
Text not visible in new file switcher in KDE
## Description

**What steps will reproduce the problem?**
1. Ctrl+P

**What is the expected output? What do you see instead?**
I expect to see the text, but instead I see part of the first character and a white rectangle:
![spyder](https://cloud.githubusercontent.com/assets/506348/16517938/7ab376b8-3f80-11e6-8149-e4c8945fa74c.png)

**Please provide any additional information below**
Entering text changes the first letter displayed but it still not possible to see the full text.
## Version and main components
- Spyder Version: 3.0.0.dev0
- Python Version: 3.5.1
- Qt Versions: 5.6.0, PyQt5 5.6 on Linux (KDE)
## Dependencies

```
pyflakes >=0.6.0 :  1.2.3 (OK)
pep8 >=0.6       :  1.7.0 (OK)
pygments >=2.0   :  2.1.3 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
nbconvert >=4.0  :  4.2.0 (OK)
pandas >=0.13.1  :  0.18.1 (OK)
numpy >=1.7      :  1.11.0 (OK)
sphinx >=0.6.6   :  1.4.1 (OK)
rope >=0.9.4     :  0.9.4-1 (OK)
jedi >=0.8.1     :  0.9.0 (OK)
psutil >=0.3     :  4.1.0 (OK)
matplotlib >=1.0 :  1.5.1 (OK)
sympy >=0.7.3    :  None (NOK)

```



Discussion:
I think this only happens on the latest KDE, so moving to 3.1 for now


Resolving patch:
diff --git a/spyderlib/widgets/fileswitcher.py b/spyderlib/widgets/fileswitcher.py
--- a/spyderlib/widgets/fileswitcher.py
+++ b/spyderlib/widgets/fileswitcher.py
@@ -364,7 +364,10 @@ def set_dialog_position(self):
         self.move(left, top + self.tabs.tabBar().geometry().height() + 1)
 
     def fix_size(self, content, extra=50):
-        """Adjusts the width of the file switcher, based on the content."""
+        """
+        Adjusts the width and height of the file switcher,
+        based on its content.
+        """
         # Update size of dialog based on longest shortened path
         strings = []
         if content:
@@ -373,8 +376,20 @@ def fix_size(self, content, extra=50):
                 label.setTextFormat(Qt.PlainText)
                 strings.append(label.text())
                 fm = label.fontMetrics()
-            max_width = max([fm.width(s)*1.3 for s in strings])
+
+            # Max width
+            max_width = max([fm.width(s) * 1.3 for s in strings])
             self.list.setMinimumWidth(max_width + extra)
+
+            # Max height
+            if len(strings) < 8:
+                max_entries = len(strings)
+            else:
+                max_entries = 8
+            max_height = fm.height() * max_entries * 2.5
+            self.list.setMinimumHeight(max_height)
+
+            # Set position according to size
             self.set_dialog_position()
 
     # --- Helper methods: List widget
@@ -442,8 +457,12 @@ def goto_line(self, line_number):
 
     # --- Helper methods: Outline explorer
     def get_symbol_list(self):
-        """Get the object explorer data."""
-        return self.get_editor().highlighter.get_outlineexplorer_data()
+        """Get the list of symbols present in the file."""
+        try:
+            oedata = self.get_editor().get_outlineexplorer_data()
+        except AttributeError:
+            oedata = {}
+        return oedata
 
     # --- Handlers
     def item_selection_changed(self):
@@ -483,13 +502,11 @@ def setup_file_list(self, filter_text, current_path):
         for index, score in enumerate(scores):
             text, rich_text, score_value = score
             if score_value != -1:
-                text_item = '<big>' + rich_text + '</big>'
+                text_item = '<big>' + rich_text.replace('&', '') + '</big>'
                 if trying_for_line_number:
                     text_item += " [{0:} {1:}]".format(self.line_count[index],
                                                        _("lines"))
-                text_item += "<br><i>{0:}</i>".format(
-                    short_paths[index])
-
+                text_item += "<br><i>{0:}</i>".format(short_paths[index])
                 results.append((score_value, index, text_item))
 
         # Sort the obtained scores and populate the list widget
@@ -498,18 +515,21 @@ def setup_file_list(self, filter_text, current_path):
             index = result[1]
             text = result[-1]
             path = paths[index]
-            item = QListWidgetItem(self.tabs.tabIcon(index), text)
+            item = QListWidgetItem(ima.icon('FileIcon'), text)
             item.setToolTip(path)
             item.setSizeHint(QSize(0, 25))
             self.list.addItem(item)
             self.filtered_path.append(path)
 
+        # To adjust the delegate layout for KDE themes
+        self.list.files_list = True
+
         # Move selected item in list accordingly and update list size
         if current_path in self.filtered_path:
             self.set_current_row(self.filtered_path.index(current_path))
         elif self.filtered_path:
             self.set_current_row(0)
-        self.fix_size(short_paths)
+        self.fix_size(short_paths, extra=200)
 
         # If a line number is searched look for it
         self.line_number = line_number
@@ -541,20 +561,21 @@ def setup_symbol_list(self, filter_text, current_path):
                 results.append((score_value, line, text, rich_text,
                                 fold_level, icons[index], token))
 
-        template_1 = '<code>{0}<big>{1} {2}</big></code>'
-        template_2 = '<br><code>{0}</code><i>[Line {1}]</i>'
+        template = '{0}{1}'
 
         for (score, line, text, rich_text, fold_level, icon,
              token) in sorted(results):
             fold_space = '&nbsp;'*(fold_level)
             line_number = line + 1
             self.filtered_symbol_lines.append(line_number)
-            textline = template_1.format(fold_space, token, rich_text)
-            textline += template_2.format(fold_space, line_number)
+            textline = template.format(fold_space, rich_text)
             item = QListWidgetItem(icon, textline)
             item.setSizeHint(QSize(0, 16))
             self.list.addItem(item)
 
+        # To adjust the delegate layout for KDE themes
+        self.list.files_list = False
+
         # Move selected item in list accordingly
         # NOTE: Doing this is causing two problems:
         # 1. It makes the cursor to auto-jump to the last selected
diff --git a/spyderlib/widgets/helperwidgets.py b/spyderlib/widgets/helperwidgets.py
--- a/spyderlib/widgets/helperwidgets.py
+++ b/spyderlib/widgets/helperwidgets.py
@@ -122,13 +122,22 @@ def paint(self, painter, option, index):
 
         textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
         painter.save()
-        if style.objectName() == 'oxygen':
-            painter.translate(textRect.topLeft() + QPoint(5, -9))
+
+        # Adjustments for the file switcher
+        if hasattr(options.widget, 'files_list'):
+            if style.objectName() in ['oxygen', 'qtcurve', 'breeze']:
+                if options.widget.files_list:
+                    painter.translate(textRect.topLeft() + QPoint(4, -9))
+                else:
+                    painter.translate(textRect.topLeft())
+            else:
+                if options.widget.files_list:
+                    painter.translate(textRect.topLeft() + QPoint(4, 4))
+                else:
+                    painter.translate(textRect.topLeft() + QPoint(2, 4))
         else:
-            painter.translate(textRect.topLeft())
-            painter.setClipRect(textRect.translated(-textRect.topLeft()))
+            painter.translate(textRect.topLeft() + QPoint(0, -3))
         doc.documentLayout().draw(painter, ctx)
-
         painter.restore()
 
     def sizeHint(self, option, index):
@@ -137,9 +146,8 @@ def sizeHint(self, option, index):
 
         doc = QTextDocument()
         doc.setHtml(options.text)
-        doc.setTextWidth(options.rect.width())
 
-        return QSize(doc.idealWidth(), doc.size().height())
+        return QSize(doc.idealWidth(), doc.size().height() - 2)
 
 
 class IconLineEdit(QLineEdit):
diff --git a/spyderlib/widgets/sourcecode/codeeditor.py b/spyderlib/widgets/sourcecode/codeeditor.py
--- a/spyderlib/widgets/sourcecode/codeeditor.py
+++ b/spyderlib/widgets/sourcecode/codeeditor.py
@@ -1521,6 +1521,10 @@ def apply_highlighter_settings(self, color_scheme=None):
             else:
                 self.highlighter.rehighlight()
 
+    def get_outlineexplorer_data(self):
+        """Get data provided by the Outline Explorer"""
+        return self.highlighter.get_outlineexplorer_data()
+
     def set_font(self, font, color_scheme=None):
         """Set font"""
         # Note: why using this method to set color scheme instead of


Test patch: