Commits

Virgil Dupras committed 07fa1ba

Added the possibility of having a table without column defs.

  • Participants
  • Parent commits 9a8ef50

Comments (0)

Files changed (2)

         self.model = model
         self._headerView = headerView
         self._headerView.setDefaultAlignment(Qt.AlignLeft)
-        for col in columns:
-            modelcol = self.model.column_by_name(col.attrname)
+        def setspecs(col, modelcol):
             modelcol.default_width = col.defaultWidth
             modelcol.editor = col.editor
             modelcol.alignment = col.alignment
             modelcol.cantTruncate = col.cantTruncate
+        if columns:
+            for col in columns:
+                modelcol = self.model.column_by_name(col.attrname)
+                setspecs(col, modelcol)
+        else:
+            col = Column('', 100)
+            for modelcol in self.model.column_list:
+                setspecs(col, modelcol)
         self.model.view = self
         self._headerView.sectionMoved.connect(self.headerSectionMoved)
         self._headerView.sectionResized.connect(self.headerSectionResized)
 class Table(QAbstractTableModel):
     # Flags you want when index.isValid() is False. In those cases, _getFlags() is never called.
     INVALID_INDEX_FLAGS = Qt.ItemIsEnabled
+    COLUMNS = []
     
     def __init__(self, model, view):
         QAbstractTableModel.__init__(self)