def __init__(self, parent, name='AuditGameDialog'):
     BaseDialogWindow.__init__(self, parent, name=name)
     #self.grid = QGridLayout(self, 2, 1, 5, 7)
     self.frame = KTextBrowser(self)
     self.frame.setNotifyClick(True)
     self.frame.setSource = self.setSource
     self.doc = AuditGameDocument(self.app)
     #self.grid.addWidget(self.frame, 0, 0)
     self.progress_label = QLabel(self)
     self.progress = KProgress(self)
     #self.grid.addWidget(self.progress, 1, 0)
     self.setMainWidget(self.frame)
     layout = self.layout()
     # we use insertWidget instead of
     # addWidget here so the widgets
     # are above the dialog buttons
     # self frame should be at 0 index in the layout
     # we set the progress and label below this
     layout.insertWidget(1, self.progress)
     # inserting into index 1 here knocks self.progress down to 2
     layout.insertWidget(1, self.progress_label)
     # disable and hide extra buttons
     self.enableButtonApply(False)
     self.showButtonApply(False)
     self.enableButtonCancel(False)
     self.showButtonCancel(False)
     # the dialog should be a little taller than what
     # it defaults to
     self.resize(0, 300)
class AuditGameDialog(BaseDialogWindow):
    def __init__(self, parent, name='AuditGameDialog'):
        BaseDialogWindow.__init__(self, parent, name=name)
        #self.grid = QGridLayout(self, 2, 1, 5, 7)
        self.frame = KTextBrowser(self)
        self.frame.setNotifyClick(True)
        self.frame.setSource = self.setSource
        self.doc = AuditGameDocument(self.app)
        #self.grid.addWidget(self.frame, 0, 0)
        self.progress_label = QLabel(self)
        self.progress = KProgress(self)
        #self.grid.addWidget(self.progress, 1, 0)
        self.setMainWidget(self.frame)
        layout = self.layout()
        # we use insertWidget instead of
        # addWidget here so the widgets
        # are above the dialog buttons
        # self frame should be at 0 index in the layout
        # we set the progress and label below this
        layout.insertWidget(1, self.progress)
        # inserting into index 1 here knocks self.progress down to 2
        layout.insertWidget(1, self.progress_label)
        # disable and hide extra buttons
        self.enableButtonApply(False)
        self.showButtonApply(False)
        self.enableButtonCancel(False)
        self.showButtonCancel(False)
        # the dialog should be a little taller than what
        # it defaults to
        self.resize(0, 300)
        
    def report_md5check(self, filename, count):
        self.progress_label.setText('checking %s' % filename)
        self.progress.setProgress(count)
        self.app.processEvents()
    
    def audit_game(self, name, from_install=True, time='now'):
        filehandler = self.app.make_new_fileshandler()
        total = len(filehandler.datahandler.get_installed_files(name))
        self.progress.setTotalSteps(total)
        filehandler.archivehelper.report_installed_file_handled = self.report_md5check
        unchanged, changed, extra = filehandler.audit_game_files(name,
                                                                 from_install=from_install, time=time)
        self.doc.set_info(unchanged, changed, extra)
        self.frame.setText(self.doc.output())
        self.progress_label.setText('Audit Completed')

    def setSource(self, url):
        print url
        if url == 'show':
            self.doc.append_unchanged_files()
            self.frame.setText(self.doc.output())