Beispiel #1
0
    def loadLibraryFiles(self, libName):
        self.contentsList.DeleteAllItems()
        self.contentsList.files = []
        self.contentsList.SetScrollPos(wx.VERTICAL, 0)
        index = self.indexManager.getIndex(libName)
        try:
            files = index.getFilesInIndex()
            self.contentsList.Freeze()
            for afile in files:
                self.contentsList.files.append(afile)
                # listIndex = self.contentsList.InsertStringItem(sys.maxint, afile)
                # self.contentsList.SetItemData(listIndex, afile)
                # self.contentsList.SetStringItem(listIndex, 1, files[afile])
            self.contentsList.files.sort()
            numFiles = len(self.contentsList.files)
            self.contentsList.SetItemCount(numFiles)
            wx.GetTopLevelParent(self).SetStatusText(_("%(numberFiles)d files in library." % {"numberFiles": numFiles}))
            self.contentsList.Thaw()

            # self.contentsList.SortItems(self.itemSorter)
        except PyLucene.JavaError:
            self.fixCorruptIndex(libName)
Beispiel #2
0
    def queryLibrary(self, query):
        libName = self.indexList.GetStringSelection()
        if query.strip() == "":
            self.loadLibraryFiles(libName)
            return

        query = query
        index = self.indexManager.getIndex(libName)
        files = index.getFilesInIndex()
        # hits = index.search("url", query)
        self.contentsList.DeleteAllItems()
        self.contentsList.files = []
        self.contentsList.SetScrollPos(wx.VERTICAL, 0)

        for afile in files:
            if afile.find(query) != -1:
                self.contentsList.files.append(afile)

        self.contentsList.files.sort()
        numFiles = len(self.contentsList.files)
        self.contentsList.SetItemCount(numFiles)
        wx.GetTopLevelParent(self).SetStatusText(
            _("%(results)d results for query '%(query)s'" % {"results": numFiles, "query": query})
        )