Esempio n. 1
0
def _newSubrepoIcon(repotype, valid=True):
    subiconame = _subrepoType2IcoMap.get(repotype)
    if subiconame is None:
        ico = qtlib.geticon('thg-subrepo')
    else:
        ico = qtlib.geticon(subiconame)
        ico = qtlib.getoverlaidicon(ico, qtlib.geticon('thg-subrepo'))
    if not valid:
        ico = qtlib.getoverlaidicon(ico, qtlib.geticon('dialog-warning'))
    return ico
Esempio n. 2
0
def _newSubrepoIcon(repotype, valid=True):
    subiconame = _subrepoType2IcoMap.get(repotype)
    if subiconame is None:
        ico = qtlib.geticon('thg-subrepo')
    else:
        ico = qtlib.geticon(subiconame)
        ico = qtlib.getoverlaidicon(ico, qtlib.geticon('thg-subrepo'))
    if not valid:
        ico = qtlib.getoverlaidicon(ico, qtlib.geticon('dialog-warning'))
    return ico
Esempio n. 3
0
 def data(self, column, role):
     if role == Qt.DecorationRole and column == 0:
         baseiconname = 'hg'
         if paths.is_unc_path(self.rootpath()):
             baseiconname = 'thg-remote-repo'
         ico = qtlib.geticon(baseiconname)
         if not self._valid:
             ico = qtlib.getoverlaidicon(ico, qtlib.geticon('dialog-warning'))
         elif self._sharedpath:
             ico = qtlib.getoverlaidicon(ico, qtlib.geticon('hg-sharedrepo'))
         return ico
     elif role in (Qt.DisplayRole, Qt.EditRole):
         return [self.shortname, self.shortpath][column]()
Esempio n. 4
0
    def data(self, column, role):
        if role == Qt.DecorationRole:
            if column == 0:
                subiconame = SubrepoItem._subrepoType2IcoMap.get(self._repotype, None)
                if subiconame is None:
                    # Unknown (or generic) subrepo type
                    ico = qtlib.geticon('thg-subrepo')
                else:
                    # Overlay the "subrepo icon" on top of the selected subrepo
                    # type icon
                    ico = qtlib.geticon(subiconame)
                    ico = qtlib.getoverlaidicon(ico, qtlib.geticon('thg-subrepo'))

                if not self._valid:
                    ico = qtlib.getoverlaidicon(ico, qtlib.geticon('dialog-warning'))

                return QVariant(ico)
            return QVariant()
        else:
            return super(SubrepoItem, self).data(column, role)
Esempio n. 5
0
    def data(self, column, role):
        if role == Qt.DecorationRole:
            if column == 0:
                subiconame = SubrepoItem._subrepoType2IcoMap.get(self._repotype, None)
                if subiconame is None:
                    # Unknown (or generic) subrepo type
                    ico = qtlib.geticon('thg-subrepo')
                else:
                    # Overlay the "subrepo icon" on top of the selected subrepo
                    # type icon
                    ico = qtlib.geticon(subiconame)
                    ico = qtlib.getoverlaidicon(ico, qtlib.geticon('thg-subrepo'))

                if not self._valid:
                    ico = qtlib.getoverlaidicon(ico, qtlib.geticon('dialog-warning'))

                return QVariant(ico)
            return QVariant()
        else:
            return super(SubrepoItem, self).data(column, role)
Esempio n. 6
0
 def data(self, column, role):
     if role == Qt.DecorationRole and column == 0:
         baseiconname = 'hg'
         if paths.is_unc_path(self.rootpath()):
             baseiconname = 'thg-remote-repo'
         ico = qtlib.geticon(baseiconname)
         if not self._valid:
             ico = qtlib.getoverlaidicon(ico,
                                         qtlib.geticon('dialog-warning'))
         return ico
     elif role in (Qt.DisplayRole, Qt.EditRole):
         return [self.shortname, self.shortpath][column]()
Esempio n. 7
0
    def _makeFileIcon(self, e):
        if e.subkind in _subrepoType2IcoMap:
            ic = qtlib.geticon(_subrepoType2IcoMap[e.subkind])
            # use fine-tuned status overlay if any
            n = _subrepoStatus2IcoMap.get(e.status)
            if n:
                return qtlib.getoverlaidicon(ic, qtlib.geticon(n))
            ic = qtlib.getoverlaidicon(ic, qtlib.geticon('thg-subrepo'))
        elif e.isdir:
            ic = self._fileiconprovider.icon(QFileIconProvider.Folder)
        else:
            # do not use fileiconprovier.icon(fileinfo), which may return icon
            # with shell (i.e. status of working directory) overlay.
            # default file icon looks ugly with status overlay on Windows
            ic = qtlib.geticon('text-x-generic')

        if not e.status:
            return ic
        st = status.statusTypes[e.status]
        if st.icon:
            icOverlay = qtlib.geticon(st.icon)
            ic = qtlib.getoverlaidicon(ic, icOverlay)

        return ic
Esempio n. 8
0
def getSubrepoIcoDict():
    'Return a dictionary mapping each subrepo type to the corresponding icon'
    _subrepoType2IcoMap = {
        'hg': 'hg',
        'git': 'thg-git-subrepo',
        'svn': 'thg-svn-subrepo',
        'hgsubversion': 'thg-svn-subrepo',
        'empty': 'hg'
    }
    icOverlay = geticon('thg-subrepo')
    subrepoIcoDict = {}
    for stype in _subrepoType2IcoMap:
        ic = geticon(_subrepoType2IcoMap[stype])
        ic = getoverlaidicon(ic, icOverlay)
        subrepoIcoDict[stype] = ic
    return subrepoIcoDict
def getSubrepoIcoDict():
    "Return a dictionary mapping each subrepo type to the corresponding icon"
    _subrepoType2IcoMap = {
        "hg": "hg",
        "git": "thg-git-subrepo",
        "svn": "thg-svn-subrepo",
        "hgsubversion": "thg-svn-subrepo",
        "empty": "hg",
    }
    icOverlay = geticon("thg-subrepo")
    subrepoIcoDict = {}
    for stype in _subrepoType2IcoMap:
        ic = geticon(_subrepoType2IcoMap[stype])
        ic = getoverlaidicon(ic, icOverlay)
        subrepoIcoDict[stype] = ic
    return subrepoIcoDict
Esempio n. 10
0
def getSubrepoIcoDict():
    'Return a dictionary mapping each subrepo type to the corresponding icon'
    _subrepoType2IcoMap = {
      'hg': 'hg',
      'git': 'thg-git-subrepo',
      'svn': 'thg-svn-subrepo',
      'hgsubversion': 'thg-svn-subrepo',
      'empty': 'hg'
    }
    icOverlay = geticon('thg-subrepo')
    subrepoIcoDict = {}
    for stype in _subrepoType2IcoMap:
        ic = geticon(_subrepoType2IcoMap[stype])
        ic = getoverlaidicon(ic, icOverlay)
        subrepoIcoDict[stype] = ic
    return subrepoIcoDict
Esempio n. 11
0
 def data(self, column, role):
     if role == Qt.DecorationRole:
         if column == 0:
             ico = qtlib.geticon('hg')
             if not self._valid:
                 ico = qtlib.getoverlaidicon(ico, qtlib.geticon('dialog-warning'))
             return QVariant(ico)
         return QVariant()
     elif role == Qt.FontRole:
         if self._isActiveTab:
             font = QFont()
             font.setBold(True)
         else:
             return QVariant()
         return QVariant(font)
     if column == 0:
         return QVariant(self.shortname())
     elif column == 1:
         return QVariant(self.shortpath())
     return QVariant()
Esempio n. 12
0
    def fileIcon(self, index):
        if not index.isValid():
            if self.isDir(index):
                return self._diricon
            else:
                return self._fileicon
        e = index.internalPointer()
        ic = e.icon
        if not ic:
            if self.isDir(index):
                ic = self._diricon
            else:
                ext = os.path.splitext(e.path)[1]
                if not ext:
                    ic = self._fileicon
                else:
                    ic = self._icons.get(ext, None)
                    if not ic:
                        ic = self._fileiconprovider.icon(
                            QFileInfo(self._wjoin(e.path)))
                        if not ic.availableSizes():
                            ic = self._fileicon
                        self._icons[ext] = ic
            e.seticon(ic)

        if not e.status:
            return ic
        st = status.statusTypes[e.status]
        if st.icon:
            icOverlay = qtlib.geticon(st.icon[:-4])
            if e.status == 'S':
                _subrepoType2IcoMap = {
                  'hg': 'hg',
                  'git': 'thg-git-subrepo',
                  'svn': 'thg-svn-subrepo',
                }
                stype = self.subrepoType(index)
                if stype in _subrepoType2IcoMap:
                    ic = qtlib.geticon(_subrepoType2IcoMap[stype])
            ic = qtlib.getoverlaidicon(ic, icOverlay)
        return ic
Esempio n. 13
0
    def fileIcon(self, index):
        if not index.isValid():
            if self.isDir(index):
                return self._diricon
            else:
                return self._fileicon
        e = index.internalPointer()
        ic = e.icon
        if not ic:
            if self.isDir(index):
                ic = self._diricon
            else:
                ext = os.path.splitext(e.path)[1]
                if not ext:
                    ic = self._fileicon
                else:
                    ic = self._icons.get(ext, None)
                    if not ic:
                        ic = self._fileiconprovider.icon(
                            QFileInfo(self._wjoin(e.path)))
                        if not ic.availableSizes():
                            ic = self._fileicon
                        self._icons[ext] = ic
            e.seticon(ic)

        if not e.status:
            return ic
        st = status.statusTypes[e.status]
        if st.icon:
            icOverlay = qtlib.geticon(st.icon[:-4])
            if e.status == 'S':
                _subrepoType2IcoMap = {
                    'hg': 'hg',
                    'git': 'thg-git-subrepo',
                    'svn': 'thg-svn-subrepo',
                }
                stype = self.subrepoType(index)
                if stype in _subrepoType2IcoMap:
                    ic = qtlib.geticon(_subrepoType2IcoMap[stype])
            ic = qtlib.getoverlaidicon(ic, icOverlay)
        return ic
Esempio n. 14
0
 def fileIcon(self, index):
     ic = QApplication.style().standardIcon(
         self.isDir(index) and QStyle.SP_DirIcon or QStyle.SP_FileIcon)
     if not index.isValid():
         return ic
     e = index.internalPointer()
     if not e.status:
         return ic
     st = status.statusTypes[e.status]
     if st.icon:
         icOverlay = qtlib.geticon(st.icon[:-4])
         if e.status == 'S':
             _subrepoType2IcoMap = {
               'hg': 'hg',
               'git': 'thg-git-subrepo',
               'svn': 'thg-svn-subrepo',
             }
             stype = self.subrepoType(index)
             if stype:
                 ic = qtlib.geticon(_subrepoType2IcoMap[stype])
         ic = qtlib.getoverlaidicon(ic,
             icOverlay)  # XXX
     return ic
Esempio n. 15
0
 def data(self, column, role):
     if role == Qt.DecorationRole:
         if column == 0:
             baseiconname = 'hg'
             if paths.is_unc_path(self.rootpath()):
                 baseiconname = 'thg-remote-repo'
             ico = qtlib.geticon(baseiconname)
             if not self._valid:
                 ico = qtlib.getoverlaidicon(ico, qtlib.geticon('dialog-warning'))
             return QVariant(ico)
         return QVariant()
     elif role == Qt.FontRole:
         if self._isActiveTab:
             font = QFont()
             font.setBold(True)
         else:
             return QVariant()
         return QVariant(font)
     if column == 0:
         return QVariant(self.shortname())
     elif column == 1:
         return QVariant(self.shortpath())
     return QVariant()