Esempio n. 1
0
File: actions.py Progetto: g438/zeex
 def append_df_model(self, model):
     file_path = model.filePath
     f = QtGui.QStandardItem(file_path)
     c = QtGui.QStandardItem(str(model.dataFrame().index.size))
     row = self.rowCount()
     self.setItem(row, 0, f)
     self.setItem(row, 1, c)
Esempio n. 2
0
 def __init__(self, settings_ini: (str, SettingsINI), parent=None):
     """
     :param settings_ini: (str, SettingsINI)
         can be a settings_ini file path or configured SettingsINI object.
     """
     self.df_manager = DataFrameModelManager()
     QtGui.QMainWindow.__init__(self, parent=parent)
     self.setupUi(self)
     self.icons = Icons()
     self.dialog_settings = SettingsDialog(settings=settings_ini)
     self.dialog_merge_purge = MergePurgeDialog(self.df_manager)
     self.dialog_export = DataFrameModelExportDialog(self.df_manager,
                                                     parent=self)
     self.dialog_import = DataFrameModelImportDialog(self.df_manager,
                                                     parent=self)
     self.dialog_new_folder = DirectoryPathCreateDialog(self.treeView,
                                                        parent=self)
     self.dialog_cloud = None
     self.key_delete = QtGui.QShortcut(self)
     self.key_enter = QtGui.QShortcut(self)
     self.key_zip = QtGui.QShortcut(self)
     self.key_rename = QtGui.QShortcut(self)
     self.connect_window_title()
     self.connect_actions()
     self.connect_treeview()
     self.connect_icons()
     self.connect_settings_dialog()
     self.connect_import_dialog()
     self.connect_export_dialog()
     self.connect_cloud_dialog()
     self.current_model = None
Esempio n. 3
0
File: main.py Progetto: g438/zeex
 def __init__(self, main_controller: MainController, configure=True):
     QtGui.QMainWindow.__init__(self)
     self.control = main_controller
     self.setupUi(self)
     self.dialog_cloud = None
     self.window_sql = DatabasesMainWindow(parent=self)
     self.window_ftp = FtpMainWindow(main_controller, parent=self)
     self.key_enter = QtGui.QShortcut(self)
     self.key_delete = QtGui.QShortcut(self)
     if configure:
         self.configure()
Esempio n. 4
0
 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)
Esempio n. 5
0
 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
Esempio n. 6
0
File: ftp.py Progetto: 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
Esempio n. 7
0
 def push_combo_boxes(self):
     left_item = self.comboBoxLeft.currentText()
     right_item = self.comboBoxRight.currentText()
     row = self.map_model.rowCount()
     for col, val in enumerate([left_item, right_item]):
         item = QtGui.QStandardItem(val)
         item.setEditable(False)
         self.map_model.setItem(row, col, item)
Esempio n. 8
0
File: main.py Progetto: g438/zeex
 def __init__(self,
              *args,
              df_manager: DataFrameModelManager = None,
              connection_manager: AlchemyConnectionManager = None,
              **kwargs):
     QtGui.QMainWindow.__init__(self, *args, **kwargs)
     self.bookmarks = BookmarkManager('sql_bookmark_manager')
     self._last_df_model = None
     self._last_text_dir = ''
     self._last_text_path = ''
     self.con_manager = connection_manager
     self.df_manager = df_manager
     self._dialog_add_con = None
     self._dialog_import = None
     self._key_enter = QtGui.QShortcut(self)
     self._key_ctrl_t = QtGui.QShortcut(self)
     self.configure()
Esempio n. 9
0
def main():
    app = QtGui.QApplication(sys.argv)

    view = FtpView()
    view.setUrl(QtCore.QUrl(u"ftp://speedtest.tele2.net"))
    view.show()

    sys.exit(app.exec_())
Esempio n. 10
0
 def set_model_from_list(self, items: list, left=True):
     if left:
         model = self._left_model
     else:
         model = self._right_model
     model.clear()
     [model.appendRow(QtGui.QStandardItem(str(i))) for i in items]
     self.set_model(model, left=left)
Esempio n. 11
0
 def add_recent_file_menu_entry(self, name, model):
     action = QtGui.QAction(name, self.menuRecent_Files)
     action.triggered.connect(partial(self.open_tableview_window, model))
     actions = self.menuRecent_Files.actions()
     if actions:
         self.menuRecent_Files.insertAction(actions[0], action)
     else:
         self.menuRecent_Files.addAction(action)
Esempio n. 12
0
File: main.py Progetto: g438/zeex
 def connect_cloud_dialog(self):
     try:
         self.dialog_cloud = DropBoxViewDialog(self.treeView_2, self)
         self.actionViewCloud.triggered.connect(self.dialog_cloud.show)
         self.actionViewCloud.setIcon(
             QtGui.QIcon(':/standard_icons/dropbox.png'))
     except Exception as e:
         logging.warning("Error connecting to cloud: {}".format(e))
         self.actionViewCloud.setVisible(False)
Esempio n. 13
0
    def set_renames(self, columns: list, fill_missing=True, include_found=False, clear_current=True):
        if clear_current:
            self.clear()

        renames = self.db.get_renames(columns, fill_missing=False)

        if include_found is False:
            renames = {key: value for key, value in renames.items() if value is None}

        if fill_missing is True:
            renames = {key: (value if value is not None else key) for key, value in renames.items()}

        idx = 0
        for orig_name, new_name in renames.items():
            oitem = QtGui.QStandardItem(orig_name)
            nitem = QtGui.QStandardItem(new_name)
            self.setItem(idx, 0, oitem)
            self.setItem(idx, 1, nitem)
            idx += 1
Esempio n. 14
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
Esempio n. 15
0
 def connect_export_dialog(self):
     """
     Sets defaults of the DataFrameModelExport Dialog.
     :return: None
     """
     self.dialog_export.signalExported.connect(self._flush_export)
     self.dialog_export.setWindowIcon(
         QtGui.QIcon(':/standard_icons/export_generic.png'))
     sep = self.dialog_settings.separatorComboBox.currentText()
     enc = self.dialog_settings.encodingComboBox.currentText()
     self.dialog_export.set_encoding(enc)
     self.dialog_export.set_separator(sep)
Esempio n. 16
0
    def set_folders(self, metadata, clear=True):
        if clear:
            self.clear()
        self.setHorizontalHeaderLabels(['folders/files'])
        data = defaultdict(list)
        for entry in metadata.entries:
            if '.' in entry.path_lower[-5:]:
                dirname = os.path.dirname(entry.path_lower)
                filename = os.path.basename(entry.path_lower)
            else:
                dirname = entry.path_lower
                filename = None
            data[dirname].append(filename)

        for dirname, files in sorted(data.items()):
            d = QtGui.QStandardItem(dirname)
            d.setEditable(False)
            files = [f for f in files if f]
            for f in files:
                f = QtGui.QStandardItem(f)
                f.setEditable(False)
                d.appendRow(f)
            self.appendRow(d)
Esempio n. 17
0
    def connect_actions(self):
        """
        Connects all project actions.
        :return: None
        """

        self.actionPreferences.triggered.connect(self.dialog_settings.show)
        self.actionAddFolder.triggered.connect(self.dialog_new_folder.show)
        self.actionNew.triggered.connect(self.dialog_import.show)
        self.actionOpen.triggered.connect(self.open_tableview_window)
        self.actionSave.triggered.connect(self.dialog_export.show)
        self.actionRemove.triggered.connect(self.remove_tree_selected_path)
        self.actionRename.triggered.connect(self.open_rename_path_dialog)
        self.actionMergePurge.triggered.connect(self.open_merge_purge_dialog)
        self.actionUnzip.triggered.connect(self.handle_compression)
        self.actionZip.triggered.connect(self.handle_compression)
        self.key_delete.setKey('del')
        self.key_enter.setKey('return')
        self.key_zip.setKey(QtGui.QKeySequence(self.tr('Ctrl+Z')))
        self.key_rename.setKey(QtGui.QKeySequence(self.tr('Ctrl+R')))
        self.key_delete.activated.connect(self.remove_tree_selected_path)
        self.key_enter.activated.connect(self.open_tableview_window)
        self.key_zip.activated.connect(self.handle_compression)
        self.key_rename.activated.connect(self.open_rename_path_dialog)
Esempio n. 18
0
    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)
Esempio n. 19
0
File: main.py Progetto: g438/zeex
    def configure(self):
        self.connect_cloud_dialog()

        self.control.main_window = self
        self.btnOpenFile.clicked.connect(self.open_combo_box_file)
        self.btnClearFilter.clicked.connect(
            lambda: self.lineEditFilter.setText(''))
        self.btnOpenProject.clicked.connect(
            lambda: self.control.tree_set_project_from_file_path(
                self.comboBoxProject.currentText()))

        self.control.register_tree_views(projects=self.treeView,
                                         project=self.treeView_2,
                                         configure=True)

        self.lineEditFilter.textChanged.connect(self.filter)
        self.actionFTP.triggered.connect(self.window_ftp.show)
        self.actionGeneralSettings.triggered.connect(
            self.control.dialog_settings_main.show)
        self.actionProjectSettings.triggered.connect(
            self.open_project_settings)
        self.actionClearAll.triggered.connect(self.clear_all)
        self.actionOpenProject.triggered.connect(self.control.tree_set_project)
        self.actionNewProject.triggered.connect(self.create_new_project)
        self.actionZip.triggered.connect(self.handle_compression)
        self.actionUnzip.triggered.connect(self.handle_compression)
        self.actionEdit.setVisible(False)
        self.actionSQL.triggered.connect(self.window_sql.show)
        self.actionOpenSheet.triggered.connect(self.open_sheet)

        self.actionMergePurge.triggered.connect(
            lambda: self.control.current_project.get_dialog_merge_purge().show(
            ))
        self.actionRename.triggered.connect(
            lambda: self.control.current_project.get_dialog_rename_path().show(
            ))
        self.actionImportSheet.triggered.connect(
            lambda: self.control.current_project.dialog_import_df_model.show())

        self.key_enter.setKey('return')
        self.key_delete.setKey('del')
        self.key_enter.activated.connect(self.control.tree_set_project)
        self.key_enter.activated.connect(self.open_sheet)
        self.key_delete.activated.connect(self.remove_tree_selected_path)
        # TODO: Show these actions when they do something.
        self.actionSaveFile.setVisible(False)
        self.actionPurgeFile.setVisible(False)
        self.setWindowIcon(QtGui.QIcon(':/standard_icons/home.png'))
Esempio n. 20
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'])
Esempio n. 21
0
File: columns.py Progetto: g438/zeex
    def sync_columns(self):
        current_items = [i.text() for i in self.get_items()]
        current_checked = [i.text() for i in self.get_items_checked()]
        checkstates = {c:(True if c in current_checked else False) for c in current_items}
        self.clear()
        cols = [str(c) for c in self.df.columns]
        cols = [QtGui.QStandardItem(c) for c in sorted(cols)]
        for c in cols:
            checked = checkstates.get(c.text(), False)

            if not checked:
                checkstate = QtCore.Qt.Unchecked
            else:
                checkstate = QtCore.Qt.Checked

            c.setCheckable(True)
            c.setEditable(False)
            c.setCheckState(checkstate)
            self.appendRow(c)
Esempio n. 22
0
File: sql.py Progetto: 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
Esempio n. 23
0
 def _handle_dtype(self, dtype):
     return QtGui.QStandardItem(str(dtype))
Esempio n. 24
0
 def configure(self):
     self.setWindowIcon(QtGui.QIcon(':/standard_icons/add.png'))
     self.setWindowTitle("DropBox")
     self.dialog_add_folder.setWindowTitle("Add DropBox Folder")
     self.dialog_add_folder.signalDirectoryCreated.connect(self.refresh)
     super(DropBoxViewDialog, self).configure()
Esempio n. 25
0
 def _handle_new_name(self, name):
     return QtGui.QStandardItem(name)
Esempio n. 26
0
 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()
Esempio n. 27
0
def get_ok_msg_box(parent, msg, title='Message!'):
    msgBox = QtGui.QMessageBox(parent)
    msgBox.setText(msg)
    msgBox.setWindowTitle(title)
    return msgBox
Esempio n. 28
0
 def connect_icons(self):
     self.setWindowIcon(QtGui.QIcon(':/standard_icons/spreadsheet.png'))
Esempio n. 29
0
File: main.py Progetto: g438/zeex
 def __init__(self,  items=None):
     super(FieldsListModel, self).__init__()
     if items:
         for item in items:
             item = QtGui.QStandardItem(item)
             self.appendRow(item)
Esempio n. 30
0
def create_standard_item(name, editable=False, checkable=False):
    item = QtGui.QStandardItem(str(name))
    item.setEditable(editable)
    item.setCheckable(checkable)
    return item