예제 #1
0
def create_standard_item_model(columns: list = None,
                               editable=False,
                               checkable=False):
    if columns is None:
        columns = []
    elif not isinstance(columns, list):
        columns = list(columns)
    model = QtGui.QStandardItemModel()
    for idx, col in enumerate(columns):
        item = create_standard_item(col, editable, checkable)
        model.appendRow(item)
    return model
예제 #2
0
파일: merge_purge.py 프로젝트: g438/zeex
 def set_handler_sort_asc(self, default_model=None, overwrite=False):
     if self.sortAscHandler is None or default_model is not None or overwrite:
         sort_asc = QtGui.QStandardItemModel()
         sort_asc.appendRow(QtGui.QStandardItem('True'))
         sort_asc.appendRow(QtGui.QStandardItem('False'))
         self.sortAscHandler = PushGridHandler(
             left_model=sort_asc,
             left_view=self.sortAscLeftView,
             left_button=self.sortAscLeftButton,
             left_delete=False,
             right_model=default_model,
             right_view=self.sortAscRightView,
             right_button=self.sortAscRightButton)
예제 #3
0
파일: map_grid.py 프로젝트: g438/zeex
 def list_to_model(items):
     """
     Creates a QtGui.StandardItemModel filled
     with QtGui.QStandardItems from the list of
     items.
     :param items: (list)
         of string-like items to store.
     :return: (QtGui.QStandardItemModel)
         With all items from the list.
     """
     model = QtGui.QStandardItemModel()
     for i in items:
         model.appendRow(QtGui.QStandardItem(i))
     return model
예제 #4
0
파일: push_grid.py 프로젝트: g438/zeex
    def __init__(self,
                 left_model=None,
                 left_view=None,
                 left_button=None,
                 left_delete=True,
                 right_model=None,
                 right_view=None,
                 right_button=None,
                 right_delete=True):

        self._left_model = left_model
        self.listViewLeft = left_view
        self.listViewRight = right_view
        self.btnPushLeft = left_button
        self.btnPushRight = right_button
        self._left_delete = left_delete
        self._right_delete = right_delete

        if right_model is None:
            self._right_model = QtGui.QStandardItemModel()
        elif isinstance(right_model, list):
            self._right_model = create_standard_item_model(right_model)
        else:
            self._right_model = right_model
        if isinstance(left_model, list):
            self._left_model = create_standard_item_model(left_model)
        elif not isinstance(self._left_model, QtGui.QStandardItemModel):
            self._left_model = QtGui.QStandardItemModel()
        self.listViewRight.setModel(self._right_model)
        self.connect_buttons()

        if self._left_model is not None:
            if isinstance(self._left_model, list):
                self.set_model_from_list(self._left_model)
            else:
                self.set_model(self._left_model)
예제 #5
0
파일: ftp.py 프로젝트: g438/zeex
 def get_filesystem_model(self):
     model = QtGui.QStandardItemModel()
     directories, files = [], []
     dir_row = 0
     with self() as ftp:
         for dirname, subdirs, files in ftp.walk():
             dir_item = QtGui.QStandardItem(dirname)
             directories.append(dirname)
             file_row = 0
             for f in files:
                 fp = dirname + "/" + f
                 file_item = QtGui.QStandardItem(fp)
                 dir_item.addChild(file_row, file_item)
                 file_row += 1
             model.setItem(dir_row, dir_item)
             dir_row += 1
     return model
예제 #6
0
    def set_table(self, table_name):
        Table = self.con.meta.tables[table_name]
        data = [[c.name, c.type] for c in Table.columns]
        data = [[widgets.create_standard_item(str(c), editable=True) for c in x] for x in data]
        model = QtGui.QStandardItemModel()
        [model.appendRow(r) for r in data]

        if self._sess is not None:
            self._sess.close()
        self._sess = self._con.Session()
        self._query = self._sess.query(Table)
        self._col_model = model
        self.labelTableNameValue.setText(table_name)
        self.labelRowCountValue.setText(str(self._query.count()))
        self.labelColumnCountValue.setText(str(len(self.con.get_column_names(table_name))))
        self.labelDatabaseValue.setText("{}: {}".format(self.con.engine.name, self.con.name))
        self.tableView.setModel(self._col_model)
        self._col_model.setHorizontalHeaderLabels(['Column Name', 'Data Type'])
예제 #7
0
파일: sql.py 프로젝트: g438/zeex
    def get_standard_item_model(self, model=None, replace=True) -> QtGui.QStandardItemModel:
        """
        Returns a QStandardItemModel with all databases.

        :param model: (QStandardItemModel)
            An optional existing model to add/replace rows on.


        :return: (QtGui.QStandardItemModel)
            - connection_name1
                - Table1
                    - Column1
                    - Column2..
                - ...
            - connection_name2
                - ...
                    - ...
        """
        if model is None:
            model = QtGui.QStandardItemModel()

        if replace is True:
            # Clear the model and append all standard items.
            model.clear()
            [model.appendRow(self.connection(name).get_standard_item())
             for name in self._connections.keys()]
        else:
            # Go through each item in the existing model and
            # Replace it with an updated connection
            for name in self._connections.keys():
                item = self.connection(name).get_standard_item()
                match = model.findItems(name)
                if match:
                    model.setItem(match[0].row(), item)
                else:
                    # No match found, append the item to the end.
                    model.appendRow(item)
        model.setHorizontalHeaderLabels(['Connections'])
        model.sort(0)
        return model
예제 #8
0
파일: map_grid.py 프로젝트: g438/zeex
 def __init__(self, *args, **kwargs):
     self._data_source = kwargs.pop('data_source', None)
     QtGui.QDialog.__init__(self, *args, **kwargs)
     self.setupUi(self)
     self.map_model = QtGui.QStandardItemModel(0, 2)
     self.configure()