Exemplo n.º 1
0
    def initializePage(self):
        lp = prefs['library_path']
        self.default_library_name = None
        if not lp:
            fname = _('Calibre Library')
            try:
                base = os.path.expanduser(u'~')
            except ValueError:
                base = QDir.homePath().replace('/', os.sep)
            if iswindows:
                try:
                    x = winutil.special_folder_path(winutil.CSIDL_PERSONAL)
                except ValueError:
                    x = QDir.homePath().replace('/', os.sep)
                if x and os.access(x, os.W_OK):
                    base = x

            lp = os.path.join(base, fname)
            self.default_library_name = lp
            if not os.path.exists(lp):
                try:
                    os.makedirs(lp)
                except:
                    traceback.print_exc()
                    try:
                        lp = os.path.expanduser(u'~')
                    except ValueError:
                        lp = QDir.homePath().replace('/', os.sep)
        self.location.setText(lp)
        # Hide the library location settings if we are a portable install
        for x in ('location', 'button_change', 'libloc_label1',
                'libloc_label2'):
            getattr(self, x).setVisible(not isportable)
Exemplo n.º 2
0
    def saveSettings(self):
        sessionDir = QDir(DataPaths.path(DataPaths.Sessions))

        settings = Settings()
        settings.beginGroup('Web-Browser-Settings')
        settings.setValue('lastActiveSessionPath', sessionDir.relativeFilePath(self._lastActiveSessionPath))
        settings.endGroup()
Exemplo n.º 3
0
    def setDirectory(self, dirPath: str):
        self.currentDir = QDir(dirPath)
        self.sortingParser = EntrySortingFile(
            self.currentDir.filePath('.sorting'))
        self.entryProvider.setContext(dirPath)
        self.refreshListViewEntries()

        self.onDirectoryChanged.emit(self.currentDir.absolutePath())
Exemplo n.º 4
0
 def standardPath(self):
     '''
     @return: QString
     '''
     if const.OS_WIN:
         return '%APPDATA%/Chrome'
     elif const.OS_MACOS:
         return QDir.homePath(
         ) + '/Library/Application Support/Google/Chrome/'
     else:
         return QDir.homePath() + '/.config/chrome/'
Exemplo n.º 5
0
    def show_item(self):
        self.clear_content()
        info_path = self.path + QDir.separator() + self.name
        self.ui.nameInfoLabel.setText(self.name)
        self.ui.locationINfoLabel.setText(info_path)

        for img in QDir(info_path).entryList(self.filters, QDir.Files):
            full_path = info_path + QDir.separator() + img
            label = QLabel(self.ui.contentWidget)
            self.ui.contenLayout.addWidget(label)
            qimg = QImage(full_path)
            label.setPixmap(QPixmap.fromImage(qimg))
Exemplo n.º 6
0
    def loadSettings(self):
        sessionDir = QDir(DataPaths.path(DataPaths.Sessions))

        settings = Settings()
        settings.beginGroup('Web-Browser-Settings')
        self._lastActiveSessionPath = settings.value('lastActiveSessionPath', self.defaultSessionPath())
        settings.endGroup()

        if QDir.isRelativePath(self._lastActiveSessionPath):
            self._lastActiveSessionPath = sessionDir.absoluteFilePath(self._lastActiveSessionPath)

        # Fallback to default session
        if not RestoreManager.validateFile(self._lastActiveSessionPath):
            self._lastActiveSessionPath = self.defaultSessionPath()
Exemplo n.º 7
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.setWindowTitle('Direct tree')

        self.model = QFileSystemModel()
        self.model.setRootPath(QDir.rootPath())

        self.tree = QTreeView()
        self.tree.setModel(self.model)
        self.tree.setRootIndex(self.model.index(os.getcwd()))
        self.tree.doubleClicked.connect(self._on_double_clicked)
        self.tree.setAnimated(False)
        self.tree.setIndentation(20)
        self.tree.setSortingEnabled(True)

        self.textEdit = QTextEdit()
        self.textEdit.setReadOnly(True)

        splitter = QSplitter()
        splitter.addWidget(self.tree)
        splitter.addWidget(self.textEdit)
        splitter.setSizes([50, 200])

        self.setCentralWidget(splitter)
Exemplo n.º 8
0
    def loadTheme(self, name):
        activeThemePath = DataPaths.locate(DataPaths.Themes, name)

        if not activeThemePath:
            print('Warning: Cannot load theme %s' % name)
            activeThemePath = '%s/%s' % (DataPaths.path(
                DataPaths.Themes), const.DEFAULT_THEME_NAME)

        qss = gVar.appTools.readAllFileContents(activeThemePath + '/main.css')

        if const.OS_MACOS:
            qss += gVar.appTools.readAllFileContents(activeThemePath +
                                                     '/mac.css')
        elif const.OS_UNIX:
            qss += gVar.appTools.readAllFileContents(activeThemePath +
                                                     '/linux.css')
        elif const.OS_WIN:
            qss += gVar.appTools.readAllFileContents(activeThemePath +
                                                     '/windows.css')

        if self.isRightToLeft():
            qss += gVar.appTools.readAllFileContents(activeThemePath +
                                                     'rtl.css')

        if self.isPrivate():
            qss += gVar.appTools.readAllFileContents(activeThemePath +
                                                     'private.css')

        qss += gVar.appTools.readAllFileContents(activeThemePath +
                                                 'userChrome.css')

        relativePath = QDir.current().relativeFilePath(activeThemePath)
        qss = re.sub("url\\s*\\(\\s*([^\\*:\\);]+)\\s*\\)",
                     r'url(' + relativePath + r'/\1)', qss)
        self.setStyleSheet(qss)
    def __init__(self):
        super().__init__()

        path = QDir.rootPath()

        self.model = QFileSystemModel()
        self.model.setRootPath(path)

        self.tree_view = QTreeView()
        self.tree_view.setModel(self.model)
        self.tree_view.setSelectionMode(QTreeView.ExtendedSelection)
        self.tree_view.selectionModel().selectionChanged.connect(
            self._on_selection_changed)

        self.list_files = QListWidget()

        self.button_add = QPushButton('Добавить!')
        self.button_add.setEnabled(False)
        self.button_add.clicked.connect(self._on_add)

        splitter = QSplitter(Qt.Horizontal)
        splitter.addWidget(self.tree_view)
        splitter.addWidget(self.list_files)

        main_layout = QVBoxLayout(self)
        main_layout.addWidget(splitter)
        main_layout.addWidget(self.button_add)
Exemplo n.º 10
0
    def _saveImage(self):
        item = self._ui.treeImages.currentItem()
        if not item:
            return

        if not self._ui.mediaPreview.scene() or not self._ui.mediaPreview.scene().items():
            return

        # QGraphicsItem
        graphicsItem = self._ui.mediaPreview.scene().items()[0]
        if graphicsItem.type() != QGraphicsPixmapItem.Type or \
                not isinstance(graphicsItem, QGraphicsPixmapItem):
            return

        pixmapItem = graphicsItem
        if pixmapItem.pixmap().isNull():
            QMessageBox.warning(self, _('Error!'), _('This preview is not available!'))
            return

        imageFileName = gVar.appTools.getFileNameFromUrl(QUrl(item.text(1)))
        index = imageFileName.rfind('.')
        if index != -1:
            imageFileName = imageFileName[:index]
            imageFileName += '.png'

        filePath = gVar.appTools.getSaveFileName('SiteInfo-DownloadImage', self, _('Save image...'),
                pathjoin(QDir.homePath(), imageFileName), '*.png')

        if not filePath:
            return

        if not pixmapItem.pixmap().save(filePath, 'PNG'):
            QMessageBox.critical(self, _('Error!'), _('Cannot write to file!'))
            return
Exemplo n.º 11
0
 def image_import(self):
     """
     Take the path(s) of one or more images and import them to the application.
     :return: Nothing
     """
     file_dialog = QFileDialog()  # Create QFileDialog
     # Open the file dialog as Open File Names dialog (for image choice)
     f_path = file_dialog.getOpenFileNames(parent=None,
                                           caption="Open Image(s)",
                                           directory=QDir.homePath(),
                                           filter=self.IMG_FILTER,
                                           options=self.DIALOG_FLAG)[0]
     if f_path:  # If user chose at least one image
         img_id_counter = 0  # Set a counter for id
         for file in f_path:  # For all paths in f_paths
             image_tmp = Image()  # Create an Image object
             success = image_tmp.img_open(file)  # Set image parameters
             if success:  # If image exists
                 image_tmp.img_set_image_id(img_id_counter)  # Set image counter
                 img_id_counter += 1  # increase the counter by 1
                 # image_tmp.img_print_info()  # print image info for debugging
                 self.image_list.append(image_tmp)  # Append image to list
                 item_name = "../" + image_tmp.info.dir_name + "/" + image_tmp.info.name  # Set name for view
                 item_widget = QListWidgetItem(item_name)  # Append item to window image list
                 item_widget.setFlags(item_widget.flags() | QtCore.Qt.ItemIsUserCheckable)  # Set it checkable
                 item_widget.setCheckState(QtCore.Qt.Checked)  # Set it checked
                 self.ui_main_win.listImage.addItem(item_widget)  # Add item to list
                 self.ui_main_win.menuCamera_Settings.setEnabled(self.UP)  # Enable Camera menu
                 self.ui_main_win.actionCrabSFM.setEnabled(self.UP)  # Enable SFM action
Exemplo n.º 12
0
def get_library_path(gui_runner):
    library_path = prefs['library_path']
    if library_path is None:  # Need to migrate to new database layout
        base = os.path.expanduser('~')
        if iswindows:
            try:
                base = winutil.special_folder_path(winutil.CSIDL_PERSONAL)
            except ValueError:
                base = None
            if not base or not os.path.exists(base):
                from PyQt5.Qt import QDir
                base = unicode(QDir.homePath()).replace('/', os.sep)
        candidate = gui_runner.choose_dir(base)
        if not candidate:
            candidate = os.path.join(base, 'Calibre Library')
        library_path = os.path.abspath(candidate)
    if not os.path.exists(library_path):
        try:
            os.makedirs(library_path)
        except:
            gui_runner.show_error(_('Failed to create library'),
                    _('Failed to create calibre library at: %r.\n'
                      'You will be asked to choose a new library location.')%library_path,
                    det_msg=traceback.format_exc())
            library_path = gui_runner.choose_dir(get_default_library_path())
    return library_path
Exemplo n.º 13
0
def get_library_path(gui_runner):
    library_path = prefs['library_path']
    if library_path is None:  # Need to migrate to new database layout
        base = os.path.expanduser('~')
        if iswindows:
            try:
                base = winutil.special_folder_path(winutil.CSIDL_PERSONAL)
            except ValueError:
                base = None
            if not base or not os.path.exists(base):
                from PyQt5.Qt import QDir
                base = unicode(QDir.homePath()).replace('/', os.sep)
        candidate = gui_runner.choose_dir(base)
        if not candidate:
            candidate = os.path.join(base, 'Calibre Library')
        library_path = os.path.abspath(candidate)
    if not os.path.exists(library_path):
        try:
            os.makedirs(library_path)
        except:
            gui_runner.show_error(
                _('Failed to create library'),
                _('Failed to create calibre library at: %r.\n'
                  'You will be asked to choose a new library location.') %
                library_path,
                det_msg=traceback.format_exc())
            library_path = gui_runner.choose_dir(get_default_library_path())
    return library_path
Exemplo n.º 14
0
def get_library_path(parent=None):
    library_path = prefs['library_path']
    if library_path is None:  # Need to migrate to new database layout
        base = os.path.expanduser('~')
        if iswindows:
            base = winutil.special_folder_path(winutil.CSIDL_PERSONAL)
            if not base or not os.path.exists(base):
                from PyQt5.Qt import QDir
                base = unicode(QDir.homePath()).replace('/', os.sep)
        candidate = choose_dir(
            None,
            'choose calibre library',
            _('Choose a location for your calibre e-book library'),
            default_dir=base)
        if not candidate:
            candidate = os.path.join(base, 'Calibre Library')
        library_path = os.path.abspath(candidate)
    if not os.path.exists(library_path):
        try:
            os.makedirs(library_path)
        except:
            error_dialog(
                parent,
                _('Failed to create library'),
                _('Failed to create calibre library at: %r.\n'
                  'You will be asked to choose a new library location.') %
                library_path,
                det_msg=traceback.format_exc(),
                show=True)
            library_path = choose_dir(
                parent,
                'choose calibre library',
                _('Choose a location for your new calibre e-book library'),
                default_dir=get_default_library_path())
    return library_path
Exemplo n.º 15
0
 def save_game(self):
     path = QFileDialog.getSaveFileName(self, 'Create save file',
                                        QDir.currentPath() + '/sav')[0]
     if path != '':
         save(path, self.play_widget.game, self.play_widget.export_log(),
              self.play_widget.move_count)
         self.statusbar.showMessage('Game saved', 5000)
Exemplo n.º 16
0
    def checkFileNameAndTemp(self, name, path):
        # 分离文件名和后缀名
        info = list()
        index = name.rfind('.')
        if index <= 0:
            info = [name, ""]
        else:
            info = [name[0:index], name[index + 1:]]

        dirList = QDir(path).entryList()
        filename = name
        tempname = filename + '.tmp'
        cfgname = tempname + '.cfg'
        if not filename in dirList and not tempname in dirList and not cfgname in dirList:
            return filename
        num = 1
        filename = info[0] + ('.' if len(info[1]) != 0 else '') + info[1]
        while filename in dirList or tempname in dirList or cfgname in dirList:
            filename = info[0] + "(" + str(num) + ")" + (
                '.' if len(info[1]) != 0 else '') + info[1]
            tempname = filename + '.tmp'
            cfgname = tempname + '.cfg'
            num += 1

        return filename
Exemplo n.º 17
0
def get_library_path(parent=None):
    library_path = prefs['library_path']
    if library_path is None:  # Need to migrate to new database layout
        base = os.path.expanduser('~')
        if iswindows:
            base = winutil.special_folder_path(winutil.CSIDL_PERSONAL)
            if not base or not os.path.exists(base):
                from PyQt5.Qt import QDir
                base = unicode(QDir.homePath()).replace('/', os.sep)
        candidate = choose_dir(None, 'choose calibre library',
                _('Choose a location for your calibre e-book library'),
                default_dir=base)
        if not candidate:
            candidate = os.path.join(base, 'Calibre Library')
        library_path = os.path.abspath(candidate)
    if not os.path.exists(library_path):
        try:
            os.makedirs(library_path)
        except:
            error_dialog(parent, _('Failed to create library'),
                    _('Failed to create calibre library at: %r.\n'
                      'You will be asked to choose a new library location.')%library_path,
                    det_msg=traceback.format_exc(), show=True)
            library_path = choose_dir(parent, 'choose calibre library',
                _('Choose a location for your new calibre e-book library'),
                default_dir=get_default_library_path())
    return library_path
Exemplo n.º 18
0
def _init_translation(qt_app):
    """Sets up translation data for the application.
  qt_app -- The QApplication that is being set up.
  """
    # Set up translation for Qt's built-in strings.
    qt_translator = QTranslator(qt_app)
    if not qt_translator.load(
            'qt_' + QLocale.system().name(),
            QLibraryInfo.location(QLibraryInfo.TranslationsPath)):
        # TODO: Log the failure to load translation information.
        pass
    elif not qt_app.installTranslator(qt_translator):
        # TODO: Log the failure to install translation information.
        pass

    # Set up translation for app-specific strings.
    app_translator = QTranslator(qt_app)
    app_translations_path = QDir.toNativeSeparators('./qt_qm/translations')
    if not app_translator.load('scriptaseq_' + QLocale.system().name(),
                               app_translations_path):
        # TODO: Log the failure to load translation information.
        pass
    elif not qt_app.installTranslator(app_translator):
        # TODO: Log the failure to load translation information.
        pass
Exemplo n.º 19
0
    def __init__(self, parent, preferences):
        '''
        @param: parent QWidget
        @param: preferences Preferences
        '''
        super().__init__()
        self._ui = uic.loadUi('mc/preferences/ThemeManager.ui', self)
        self._preferences = preferences  # Preferences

        self._activeTheme = ''
        self._themeHash = {}  # QHash<QString, Theme>

        self._ui.listWidget.setLayoutDirection(Qt.LeftToRight)
        self._ui.license.hide()

        settings = Settings()
        settings.beginGroup('Themes')
        self._activeTheme = settings.value('activeTheme',
                                           const.DEFAULT_THEME_NAME)
        settings.endGroup()

        themePaths = DataPaths.allPaths(DataPaths.Themes)

        for path in themePaths:
            dir_ = QDir(path)
            list_ = dir_.entryList(QDir.AllDirs | QDir.NoDotAndDotDot)
            for name in list_:
                # Theme
                themeInfo = self._parseTheme(
                    dir_.absoluteFilePath(name) + '/', name)
                if not themeInfo.isValid:
                    continue

                item = QListWidgetItem(self._ui.listWidget)
                item.setText(themeInfo.name)
                item.setIcon(themeInfo.icon)
                item.setData(Qt.UserRole, name)

                if self._activeTheme == name:
                    self._ui.listWidget.setCurrentItem(item)

                self._ui.listWidget.addItem(item)

        self._ui.listWidget.currentItemChanged.connect(self._currentChanged)
        self._ui.license.clicked.connect(self._showLicense)

        self._currentChanged()
Exemplo n.º 20
0
 def load_game(self):
     path = QFileDialog.getOpenFileName(self, 'Open save file',
                                        QDir.currentPath() + '/sav')[0]
     if path != '':
         game, msg, count = load(path)
         self.play_widget.resume_from_save(game, msg, count)
         self.widgets.setCurrentWidget(self.play_widget)
         self.statusbar.showMessage('Loaded save file', 5000)
Exemplo n.º 21
0
 def standardPath(self):
     '''
     @return: QString
     '''
     if const.OS_WIN:
         return '%APPDATA%/Mozilla/'
     else:
         return QDir.homePath() + '/.mozilla/firefox/'
Exemplo n.º 22
0
 def standardPath(self):
     '''
     @return: QString
     '''
     if const.OS_WIN:
         return '%APPDATA%/Opera/'
     else:
         return QDir.homePath() + '/.opera/'
Exemplo n.º 23
0
    def resolveFromPath(self, name):
        '''
        @param: name QString
        @return: QString
        '''
        path = environ['PATH'].strip()

        if not path:
            return ''

        for item in path.split(pathsep):
            item = item.strip()
            if not item: continue
            d = QDir(item)
            if d.exists(name):
                return d.absoluteFilePath(name)

        return ''
Exemplo n.º 24
0
    def importBookmarks(self):
        '''
        @brief: Import bookmarks (it must return root folder)
        '''
        root = BookmarkItem(BookmarkItem.Folder)
        root.setTitle('Internet Explorer Import')

        self._readDir(QDir(self._path), root)
        return root
Exemplo n.º 25
0
 def getPath(self, parent):
     '''
     @param: Get filename from user (or a directory)
     @param: parent QWidget
     @return: QString
     '''
     filter_ = _('HTML Bookmarks') + '(*.htm *.html)'
     self._path, selectedFilter = QFileDialog.getOpenFileName(
         parent, _('Choose file...'), QDir.homePath(), filter_)
     return self._path
Exemplo n.º 26
0
 def getPath(self, parent):
     '''
     @param: parent QWidget
     @return: QString
     '''
     defaultPath = QDir.homePath() + '/bookmarks.html'
     filter_ = _('HTML Bookmarks') + '.html'
     self._path = gVar.appTools.getSaveFileName('HtmlExporter', parent,
                                                _('Choose file...'),
                                                defaultPath, filter_)
     return self._path
Exemplo n.º 27
0
    def __init__(self, win, ce, text, parent=None):
        super().__init__(parent)
        self.win = win
        self.content_editor = ce
        ChangeContentCommand.file_version_number = ChangeContentCommand.file_version_number + 1
        self.setText(text)

        sitedir = ce.site.source_path[ce.site.source_path.rfind("/") + 1:]
        if self.content_editor.content.content_type == ContentType.PAGE:
            subdir = "pages"
        else:
            subdir = "posts"
        self.temp_filename = os.path.join(
            QDir.tempPath(), "FlatSiteBuilder", sitedir, subdir,
            ce.content.source + "." +
            str(ChangeContentCommand.file_version_number) + ".undo")
        self.redo_filename = os.path.join(
            QDir.tempPath(), "FlatSiteBuilder", sitedir, subdir,
            ce.content.source + "." +
            str(ChangeContentCommand.file_version_number) + ".redo")
Exemplo n.º 28
0
    def next_item(self):
        print("switch to next")
        try:
            self.name = next(self.iter)
        except StopIteration:
            print("catch StopIteration")
            self.to_start_item()

        print(self.path + QDir.separator() + self.name)

        self.show_item()
Exemplo n.º 29
0
    def _openFile(self):
        fileTypes = ("%s(*.html *.htm *.shtml *.shtm *.xhtml);;"
                     "%s(*.png *.jpg *.jpeg *.bmp *.gif *.svg *.tiff);;"
                     "%s(*.txt);;"
                     "%s(*.*)")
        fileTypes %= ("HTML files", "Image files", "Text files", "All files")
        filePath = gVar.appTools.getOpenFileName("MainWindow-openFile",
                                                 self, "Open file...",
                                                 QDir.homePath(), fileTypes)

        if filePath:
            self.loadAddress(QUrl.fromLocalFile(filePath))
Exemplo n.º 30
0
 def setThemeFromGtk():
     f = QFile(QDir.homePath() + "/.gtkrc-2.0")
     if not f.open(QIODevice.ReadOnly | QIODevice.Text):
         return
     while not f.atEnd():
         l = f.readLine().trimmed()
         if l.startsWith("gtk-icon-theme-name="):
             s = l.split('=')[-1]
             syslog.syslog(syslog.LOG_DEBUG,
                           "DEBUG  setting gtk theme %s" % str(s))
             QIcon.setThemeName(s.remove('"'))
             break
Exemplo n.º 31
0
    def onRootPathChanged(self):
        self.setModel(None)
        self.setModel(self.model)
        self.fsindex = self.model.setRootPath(QDir.currentPath())
        self.setRootIndex(self.fsindex)
        sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding,
                                 QSizePolicy.MinimumExpanding)
        self.setSizePolicy(sizePolicy)
        self.setAutoExpandDelay(2)
        self.setAlternatingRowColors(False)
        self.setAnimated(True)
        self.setIndentation(20)
        self.setSortingEnabled(False)
        self.setRootIsDecorated(False)

        self.setHeaderHidden(True)
        self.hideColumn(1)
        self.hideColumn(2)
        self.hideColumn(3)
        self.setToolTip(QDir.currentPath())
        self.path = os.getcwd()
        self.path = self.checkPath(self.path)
Exemplo n.º 32
0
    def getOpenFileName(self):
        '''
        @return: QStringList
        '''
        fileTypes = '%s(*.png *.jpg *.jpeg *.bmp *gif *.svg *.tiff)' % _('Image files')
        image = gVar.appTools.getOpenFileName('SpeedDial-GetOpenFileName', None,
                _('Click to select image...'), QDir.homePath(), fileTypes)

        if not image:
            return []

        return [ gVar.appTools.pixmapToDataUrl(QPixmap(image)).toString(),
            QUrl.fromLocalFile(image).toEncoded() ]
Exemplo n.º 33
0
    def addDirectory(self, row):
        """
        Add a directory to the model and create the new last row containing the
        + button.

        @param[in] row The row where to add the new directory
        """
        # Use the QFileDialog to get the new directory from the user
        newDir = QtWidgets.QFileDialog.getExistingDirectory(
            self._parent, 'Root directory', '/',
            QtWidgets.QFileDialog.ShowDirsOnly |
            QtWidgets.QFileDialog.DontResolveSymlinks)
        #newDir = "test"
        newDir = QDir.toNativeSeparators(newDir)

        logging.debug(newDir)

        if newDir:
            #qtDebugTrace()
            # Set the directory path in the given row
            self._directoryData[row][self._dirColumn] = newDir
            logging.debug("dirs\n {}".format(pformat(self._directoryData)))

            # Insert a new row after the current one
            self.insertRows(row, 1)

            # Emit dataChanged
            startIndex = self.index(row, self._dirColumn)
            logging.debug("emitted row {}".format(row))
            # endIndex = self.index(row + 1, self.columnCount())
            self.dataChanged.emit(startIndex, startIndex)

            # Emit newButtonCreated with indexes of the changed area
            self.signals.newButtonCreated.emit(startIndex, startIndex)

            logging.info("New directory added: {}".format(newDir))

            # Emit DirectoryAdded with the name of the directory
            self.signals.directoryAdded.emit(newDir)
            return True

        return False
Exemplo n.º 34
0
            newData = curData
        else:
            newData = [data]

        # Set new data
        self._directoryData[dirRow][col] = newData

        # Emit dataChanged
        index = self.index(dirRow, col)
        self.dataChanged.emit(index, index)

if __name__ == '__main__':
    from PyQt5.Qt import QApplication
    import os
    import sys
    import fnmatch

    print(os.sep)
    app = QApplication(sys.argv)
    newDir = QtWidgets.QFileDialog.getExistingDirectory(
        None, 'Root directory', os.sep,
        QtWidgets.QFileDialog.ShowDirsOnly |
        QtWidgets.QFileDialog.DontResolveSymlinks)
    newDir = QDir.toNativeSeparators(newDir)

    for root, dirs, files in os.walk(newDir):
        for basename in files:
            if fnmatch.fnmatch(basename, '*.txt'):
                filename = os.path.join(root, basename)
                print(filename)
    sys.exit(app.exec_())