Пример #1
0
    def __init__(self):
        super().__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        self.setWindowTitle("SHPViewer - " + CUR_VERSION)

        windowFlag = Qt.Dialog
        windowFlag |= Qt.WindowMinimizeButtonHint
        windowFlag |= Qt.WindowMaximizeButtonHint
        windowFlag |= Qt.WindowCloseButtonHint
        self.setWindowFlags(windowFlag)

        self.shps = []
        self.colors = [
            QColor(0, 255, 0),
            QColor(0, 0, 255),
            QColor(0, 255, 255),
            QColor(128, 128, 255),
        ]

        self.leftMouseDown = False
        self.mouseDownPos = None
        self.orig = QPointF(0, 0)
        self.ratio = 10.0
Пример #2
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        self.connect(self.ui.button_cancel, QtCore.SIGNAL("clicked()"),
                     QtCore.SLOT("close()"))

        QtCore.QObject.connect(self.ui.button_open, QtCore.SIGNAL("clicked()"),
                               self.open_file)
        QtCore.QObject.connect(self.ui.select_disk, QtCore.SIGNAL("clicked()"),
                               self.select_disk)
        QtCore.QObject.connect(self.ui.button_create,
                               QtCore.SIGNAL("clicked()"),
                               self.button_create_clicked)
Пример #3
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        self.name, self.dni, self.phone, self.addres, self.birth = ('', '', '', '', '')
        self.dni_register = ''
        self.path = 'dbCrokiAlitas.db'
        
        self.ui.txtName.installEventFilter(self)
        self.ui.txtDNI.installEventFilter(self)
        self.ui.txtPhone.installEventFilter(self)
        self.ui.txtAddres.installEventFilter(self)
        self.ui.txtBirth.installEventFilter(self)

        self.ui.btnSaveUser.clicked.connect(self.save_user)
Пример #4
0
  	def __init__(self, parent=None):
		QtGui.QWidget.__init__(self, parent)
		self.ui = Ui_Dialog()
		self.ui.setupUi(self)

		self.connect(self.ui.button_cancel, QtCore.SIGNAL("clicked()"), QtCore.SLOT("close()"))
    
		QtCore.QObject.connect(self.ui.button_open, QtCore.SIGNAL("clicked()"), self.open_file)
		QtCore.QObject.connect(self.ui.select_disk, QtCore.SIGNAL("clicked()"), self.select_disk)
                QtCore.QObject.connect(self.ui.button_create, QtCore.SIGNAL("clicked()"), self.button_create_clicked)
Пример #5
0
 def __init__(self, element, packagelist, summary=None, report=None, package=None,
                                          checkcode=None, case=None,
                                          casecounter=None, totalcases=None):
     QtGui.QMainWindow.__init__(self)
     
     self.ui = Ui_Dialog()
     self.ui.setupUi(self)
     self.setFixedSize(self.width(), self.height())
     # self.checkcode checks for premature exit of the application
     self.checkcode = 0
 
     self.element = element
     self.case = self.element.xpath('case')
     self.packagelist = packagelist
             
     self.casecounter = 0
     self.totalcases = len(self.case)
     
     self.summary = list()
     self.report = list()
     
     self.package = package
     
     if self.package is None:
         #  if the test is of shell type
         self.ui.type_label.setText('Shell Test')
         packageText = 'Packages: {0}'.format(', '.join(self.packagelist))
         for lst in (self.summary, self.report):
             lst.append(packageText)
         self.ui.text_edit.append("The following packages will be tested: " \
                             "<b>{0}</b>".format(', '.join(self.packagelist)))
         self.ui.text_edit.append("Press 'Start' to begin testing ...")
     else:
         # if the test is of gui type
         self.ui.type_label.setText('GUI Test')
         singlePackage = 'Package: {0}'.format(self.package)
         for lst in (self.summary, self.report):
             lst.append(singlePackage)
         self.ui.text_edit.append("The package <b>'{0}'</b> " \
                                       "will be tested".format(self.package))
         self.ui.text_edit.append("Press 'Start' to begin testing ...")
     
     self.connect(self.ui.next_button, QtCore.SIGNAL("clicked()"), self.next_case)
     self.connect(self.ui.save_button, QtCore.SIGNAL("clicked()"), self.get_text)
Пример #6
0
class MainDlg(QDialog):
    def __init__(self):
        super().__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        self.setWindowTitle("SHPViewer - " + CUR_VERSION)

        windowFlag = Qt.Dialog
        windowFlag |= Qt.WindowMinimizeButtonHint
        windowFlag |= Qt.WindowMaximizeButtonHint
        windowFlag |= Qt.WindowCloseButtonHint
        self.setWindowFlags(windowFlag)

        self.shps = []
        self.colors = [
            QColor(0, 255, 0),
            QColor(0, 0, 255),
            QColor(0, 255, 255),
            QColor(128, 128, 255),
        ]

        self.leftMouseDown = False
        self.mouseDownPos = None
        self.orig = QPointF(0, 0)
        self.ratio = 10.0

    @pyqtSlot()
    def on_btn_clear_clicked(self):
        self.shps = []
        self.repaint()

    @pyqtSlot()
    def on_btn_open_file_clicked(self):
        filename, ok = QFileDialog.getOpenFileName(self, r'选择shp文件', r'',
                                                   "shp file (*.shp)")

        if not ok:
            return

        shp = read_shp(filename)
        if not shp:
            QMessageBox.information(self, "SHPViewer", "invalid shp file!")
            return

        shp['color'] = self.colors[len(self.shps) % len(self.colors)]

        # init orig and ratio when first shp loaded
        if not self.shps:
            bbox = shp['boudingbox']
            rect = self.rect()

            ratiox = rect.width() / (bbox['xmax'] - bbox['xmin'])
            ratioy = rect.height() / (bbox['ymax'] - bbox['ymin'])

            self.ratio = min(ratiox, ratioy) * 0.9

            self.orig.setX((bbox['xmax'] + bbox['xmin']) * self.ratio / 2 -
                           self.width() / 2)
            self.orig.setY((bbox['ymax'] + bbox['ymin']) * self.ratio / 2 -
                           self.height() / 2)

        self.shps.append(shp)
        self.repaint()

    def paintEvent(self, event):
        painter = QPainter(self)
        for shp in self.shps:
            painter.setPen(QPen(shp['color']))
            draw_shp(painter, self.rect(), shp, self.orig, self.ratio)

    # def closeEvent(self, event):
    #     if QMessageBox.Yes == QMessageBox.question(self, "SHPViewer", "确认退出?",
    #                                                QMessageBox.Yes | QMessageBox.No,
    #                                                QMessageBox.Yes):
    #         self.accept()
    #     else:
    #         event.ignore()

    def mousePressEvent(self, event):
        pt = event.pos()
        self.leftMouseDown = True
        self.mouseDownPos = pt

    def mouseReleaseEvent(self, event):
        self.leftMouseDown = False

    def mouseMoveEvent(self, event):
        if not self.leftMouseDown:
            return

        pt = event.pos()
        moved = pt - self.mouseDownPos
        self.mouseDownPos = pt

        # reverse y
        moved.setY(-moved.y())
        self.orig -= moved

        self.repaint()

    def wheelEvent(self, event):
        mousepos = event.pos()
        rect = self.rect()
        delta = event.angleDelta().y()

        mapx = (mousepos.x() + self.orig.x()) / self.ratio
        mapy = (rect.bottom() - mousepos.y() + self.orig.y()) / self.ratio

        if delta > 0:
            self.ratio *= 1.5
        elif delta < 0:
            self.ratio *= 0.6
            if self.ratio < 1:
                self.ratio = 1.0

        mapx *= self.ratio
        mapy *= self.ratio

        self.orig.setX(mapx - mousepos.x())
        self.orig.setY(mapy - rect.bottom() + mousepos.y())

        self.repaint()
Пример #7
0
class Start(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        self.connect(self.ui.button_cancel, QtCore.SIGNAL("clicked()"),
                     QtCore.SLOT("close()"))

        QtCore.QObject.connect(self.ui.button_open, QtCore.SIGNAL("clicked()"),
                               self.open_file)
        QtCore.QObject.connect(self.ui.select_disk, QtCore.SIGNAL("clicked()"),
                               self.select_disk)
        QtCore.QObject.connect(self.ui.button_create,
                               QtCore.SIGNAL("clicked()"),
                               self.button_create_clicked)

    @QtCore.pyqtSignature("bool")
    def open_file(self):
        #select image file
        if platform == 'linux2':
            self.img_src = QtGui.QFileDialog.getOpenFileName(
                self, self.tr("Select CD image"), os.environ["HOME"],
                "%s (*.iso *.img)" % self.tr("Images"))

        elif platform == 'win32':
            self.img_src = QtGui.QFileDialog.getOpenFileName(
                self, self.tr("Select CD image"))  # fix it

            #will be deleted
        self.ui.lineEdit.setText(self.img_src)

    @QtCore.pyqtSignature("bool")
    def select_disk(self):
        # select portable disk
        self.sd = selectDisk()
        #linux tools
        if platform == 'linux2':
            self.a = PartitionUtils()
            self.a.detect_removable_drives()

            for key in self.a.drives:
                self.sd.listWidget.insertItem(0, key)

        #windows tools
        elif platform == 'win32':
            self.a = win32_PartitionUtils()
            self.a.win32_detect_removable_drives()

            for key in self.a.drives:
                self.sd.listWidget.insertItem(0, key)

        self.connect(self.sd.listWidget,
                     QtCore.SIGNAL("itemClicked(QListWidgetItem *)"),
                     self.get_disk_destination)
        self.sd.exec_()

    @QtCore.pyqtSignature("bool")
    def get_disk_destination(self, item):
        self.ui.lineEdit_2.setText(item.text())
        self.disk_dest = str(item.text())

        print self.a.drives[str(self.disk_dest)]

    @QtCore.pyqtSignature("bool")
    def button_create_clicked(self):
        str(self.disk_dest)
        self.img_size = os.stat(self.img_src).st_size / mbyte

        if platform == 'linux2':
            self.disk_size = (int(self.a.drives[self.disk_dest]['size']) /
                              mbyte)

            if self.a.drives[self.disk_dest]['is_mount'] == '1':
                self.a.unmount_device(str(self.disk_dest))  # unmount!
                print("Disk is unmounted by HAL!")

            #self.a.mount_device(self.disk_dest)

        elif platform == 'win32':
            self.disk_size = self.a.win32_get_total_size()
            print self.disk_size

        if self.a.drives[self.disk_dest]['is_mount'] == '1':
            self.warning_dialog(
                self.tr("Warning!"),
                self.tr("Flash disk is Mounted!\nPlease Unmount Disk"))

        else:
            if self.img_size > self.disk_size:
                req_size = ((self.img_size - self.disk_size) / mbyte)

                self.warning_dialog(
                    self.tr("Warning!"),
                    self.
                    tr("There is no enough space on drive!\n%dMB more space is required"
                       % req_size))

            else:
                reply = QtGui.QMessageBox.question(
                    self, self.tr('Sha1sum Check'),
                    self.
                    tr('Do you want to check integrity of image from sha1sum file?'
                       ), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
                self.release = ''
                if reply == QtGui.QMessageBox.Yes:
                    self.release = self.__check_sum()

                self.confirm_dialog = confirmDialog(self.release, self.img_src,
                                                    self.img_size,
                                                    self.disk_size,
                                                    self.disk_dest)

                if self.confirm_dialog.exec_() == QtGui.QDialog.Accepted:
                    self.__burn_image()

    def warning_dialog(self, title, text):
        QtGui.QMessageBox.warning(self, title, text, QtGui.QMessageBox.Ok)

    def __check_sum(self):

        sha_dest = self.sha_dest = QtGui.QFileDialog.getOpenFileName(
            self, self.tr("Select Sha1sum File"), os.environ["HOME"],
            "%s (*.sha1sum)" % self.tr("Sha1sum"))
        sha_file = open(sha_dest, 'rb')

        a = sha_file.read()
        data = a.partition(' ')
        shasum = data[0]
        print data
        print "shasum from file: %s" % shasum
        print "Pardus release: %s" % data[2]
        release = data[2]

        self.max_value = int(self.img_size)

        def close_dialog():  # wtf!
            pb.close()
            cs.quit()

        pb = progressBar(
            title=self.tr("Verify sha1sum"),
            message=self.tr("The integrity of image file is checking..."),
            max_value=self.max_value)
        cs = checksumProgress(source=self.img_src)

        QtCore.QObject.connect(cs, QtCore.SIGNAL("incrementProgress()"),
                               pb.incrementProgress)
        QtCore.QObject.connect(cs, QtCore.SIGNAL("closeProgress()"),
                               close_dialog)

        cs.start()
        pb.exec_()
        cs.wait()

        if not cs.checksum():
            print "Checksum cannot validated!"

        elif shasum == cs.checksum():
            return release

        elif shasum != cs.checksum():
            return "Sha1sum file is different than images shasum!"

    def __burn_image(self):
        def close_dialog():  # wtf!
            copy_progress_bar.close()
            copy_progress.quit()

        copy_progress_bar = progressBar(
            title=self.tr("Copy Progress"),
            message=self.tr("Copy progress is running..."),
            max_value=int(self.img_size))
        copy_progress = copyProgress(img_source=self.img_src,
                                     disk_dest=self.disk_dest,
                                     img_size=self.img_size)

        QtCore.QObject.connect(copy_progress,
                               QtCore.SIGNAL("copyIncrementProgress()"),
                               copy_progress_bar.incrementProgress)
        QtCore.QObject.connect(copy_progress, QtCore.SIGNAL("closeProgress()"),
                               close_dialog)

        copy_progress.start()
        copy_progress_bar.exec_()
        copy_progress.wait()

        self.warning_dialog(self.tr("USB Image is Ready"),
                            self.tr("USB image is ready. Hayrini Gor!"))

        return True
Пример #8
0
class Start(QtGui.QMainWindow):
  	def __init__(self, parent=None):
		QtGui.QWidget.__init__(self, parent)
		self.ui = Ui_Dialog()
		self.ui.setupUi(self)

		self.connect(self.ui.button_cancel, QtCore.SIGNAL("clicked()"), QtCore.SLOT("close()"))
    
		QtCore.QObject.connect(self.ui.button_open, QtCore.SIGNAL("clicked()"), self.open_file)
		QtCore.QObject.connect(self.ui.select_disk, QtCore.SIGNAL("clicked()"), self.select_disk)
                QtCore.QObject.connect(self.ui.button_create, QtCore.SIGNAL("clicked()"), self.button_create_clicked)
	             
        @QtCore.pyqtSignature("bool")  
        def open_file(self):
                #select image file
            if platform == 'linux2':
                self.img_src = QtGui.QFileDialog.getOpenFileName(self, self.tr("Select CD image"), os.environ["HOME"], "%s (*.iso *.img)" % self.tr("Images"))   
                
            elif platform == 'win32':
               self.img_src = QtGui.QFileDialog.getOpenFileName(self, self.tr("Select CD image"))   # fix it 
            
                #will be deleted
            self.ui.lineEdit.setText(self.img_src)
    
        @QtCore.pyqtSignature("bool")  
        def select_disk(self):
                # select portable disk
		self.sd = selectDisk()
      		#linux tools
		if platform == 'linux2':
                    self.a = PartitionUtils()
                    self.a.detect_removable_drives()
                    
                    for key in  self.a.drives:
			self.sd.listWidget.insertItem(0,key)
	        
		#windows tools
                elif platform == 'win32':
                    self.a = win32_PartitionUtils()
                    self.a.win32_detect_removable_drives()

                    for key in self.a.drives:
                        self.sd.listWidget.insertItem(0,key)		
	  		    	    
		self.connect(self.sd.listWidget, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.get_disk_destination)
		self.sd.exec_()
		
    
        @QtCore.pyqtSignature("bool")  
        def get_disk_destination(self, item):		
		self.ui.lineEdit_2.setText(item.text())
		self.disk_dest = str(item.text())
		
		print self.a.drives[str(self.disk_dest)]
		  
                
	@QtCore.pyqtSignature("bool")
	def button_create_clicked(self):		  
		str(self.disk_dest)		
		self.img_size = os.stat(self.img_src).st_size / mbyte
		

		if platform == 'linux2':
                    self.disk_size = (int(self.a.drives[self.disk_dest]['size']) / mbyte)
                    
                    if self.a.drives[self.disk_dest]['is_mount'] == '1':
			  self.a.unmount_device(str(self.disk_dest)) # unmount!
			  print ("Disk is unmounted by HAL!")
                    
                    #self.a.mount_device(self.disk_dest) 

                elif platform == 'win32':
                    self.disk_size = self.a.win32_get_total_size()
                    print self.disk_size

		if self.a.drives[self.disk_dest]['is_mount'] == '1' :		
			self.warning_dialog(self.tr("Warning!"), self.tr("Flash disk is Mounted!\nPlease Unmount Disk")) 
	
		else:		  
			if self.img_size > self.disk_size:
				req_size = ((self.img_size - self.disk_size) / mbyte)

				self.warning_dialog(self.tr("Warning!"), self.tr("There is no enough space on drive!\n%dMB more space is required" % req_size ))
					
			else:	
                            	reply = QtGui.QMessageBox.question(self, self.tr('Sha1sum Check'), self.tr('Do you want to check integrity of image from sha1sum file?'), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
                                self.release = ''
                                if reply == QtGui.QMessageBox.Yes:
                                   self.release = self.__check_sum()
                                   
                                self.confirm_dialog =  confirmDialog(self.release, self.img_src, self.img_size, self.disk_size, self.disk_dest)
				
				if self.confirm_dialog.exec_() == QtGui.QDialog.Accepted: 
				    self.__burn_image()
				    				  
	def warning_dialog(self, title, text):
		QtGui.QMessageBox.warning(self, title, text, QtGui.QMessageBox.Ok)
			
	def __check_sum(self):
	  
            	sha_dest =  self.sha_dest = QtGui.QFileDialog.getOpenFileName(self, self.tr("Select Sha1sum File"), os.environ["HOME"], "%s (*.sha1sum)" % self.tr("Sha1sum"))   
                sha_file = open(sha_dest, 'rb')
                
                a =  sha_file.read()
                data = a.partition(' ')
                shasum = data[0]
                print data
                print "shasum from file: %s" % shasum
                print "Pardus release: %s" % data[2]
                release = data[2]
                           
		self.max_value = int(self.img_size)
		
		def close_dialog(): # wtf!
		  pb.close()
		  cs.quit()

		pb = progressBar(title = self.tr("Verify sha1sum"), message = self.tr("The integrity of image file is checking..."), max_value = self.max_value)                               			
                cs = checksumProgress(source = self.img_src)

                QtCore.QObject.connect(cs, QtCore.SIGNAL("incrementProgress()"), pb.incrementProgress)
		QtCore.QObject.connect(cs, QtCore.SIGNAL("closeProgress()"), close_dialog)

		cs.start()		
                pb.exec_()
		cs.wait()  
		
		
		if not cs.checksum():
		  print "Checksum cannot validated!"
		
                elif shasum == cs.checksum():
                    return release
                
                elif shasum != cs.checksum():
                    return "Sha1sum file is different than images shasum!"
		  

	def __burn_image(self):
	  
		def close_dialog(): # wtf!
		    copy_progress_bar.close()
		    copy_progress.quit()
		    
		copy_progress_bar = progressBar(title = self.tr("Copy Progress"), message = self.tr("Copy progress is running..."), max_value = int(self.img_size) )				    
		copy_progress = copyProgress(img_source = self.img_src, disk_dest = self.disk_dest, img_size = self.img_size) 
                                    
                QtCore.QObject.connect(copy_progress, QtCore.SIGNAL("copyIncrementProgress()"), copy_progress_bar.incrementProgress)
                QtCore.QObject.connect(copy_progress, QtCore.SIGNAL("closeProgress()"), close_dialog)
                                                   
                copy_progress.start()
                copy_progress_bar.exec_()
                copy_progress.wait()
                
		self.warning_dialog(self.tr("USB Image is Ready"), self.tr("USB image is ready. Hayrini Gor!"))

		return True	
Пример #9
0
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        self.name, self.dni, self.phone, self.addres, self.birth = ('', '', '', '', '')
        self.dni_register = ''
        self.path = 'dbCrokiAlitas.db'
        
        self.ui.txtName.installEventFilter(self)
        self.ui.txtDNI.installEventFilter(self)
        self.ui.txtPhone.installEventFilter(self)
        self.ui.txtAddres.installEventFilter(self)
        self.ui.txtBirth.installEventFilter(self)

        self.ui.btnSaveUser.clicked.connect(self.save_user)

        
    
    #----------------------------------------------------------------------
    def eventFilter(self, obj, event):
        if event.type() == QtCore.QEvent.FocusOut:

            if self.ui.txtName is obj:
                if self.validate_txt(self.ui.txtName.text()):
                    self.name = self.ui.txtName.text().title().strip()
                    self.ui.txtName.setText(self.name)
                else:
                    self.name = ''
                    self.ui.txtName.setText('')
                    self.ui.txtName.setPlaceholderText('Por favor ingrese un nombre válido')

            if self.ui.txtDNI is obj:
                if self.validate_num(self.ui.txtDNI.text().replace(',','')):
                    self.dni = int(self.ui.txtDNI.text().replace(',',''))
                    self.ui.txtDNI.setText('{:,}'.format(self.dni))
                else:
                    self.dni = ''
                    self.ui.txtDNI.setText('')
                    self.ui.txtDNI.setPlaceholderText('Por favor, escriba un número')

            if self.ui.txtPhone is obj:
                if self.validate_num(self.ui.txtPhone.text()):
                    self.phone = int(self.ui.txtPhone.text())
                    self.ui.txtPhone.setText(str(self.phone))
                else:
                    self.phone = ''
                    self.ui.txtPhone.setText('')
                    self.ui.txtPhone.setPlaceholderText('Por favor, escriba un número')

            if self.ui.txtDNIRegister is obj:
                if self.validate_num(self.ui.txtDNIRegister.text()):
                    self.dni_register = int(self.ui.txtDNIRegister.text())
                else:
                    self.ui.txtDNIRegister.setText('')
                    self.ui.txtDNIRegister.setPlaceholderText('Por favor, escriba un número')

        return super(MainWindow, self).eventFilter(obj, event)
    

    #----------------------------------------------------------------------
    def save_user(self):
        user = dict(
            name = self.name,
            dni = self.dni,
            phone = self.phone,
            addres = self.ui.txtAddres.text(),
            birth = self.ui.txtBirth.text(),
        )
        
        self.conn = connect(self.path)

        if all([user[value] for value in ['name', 'dni', 'phone']]):
            if not validate_duplicate(self.conn, 'users', 'dni', user['dni']):
                print (user)
                try:
                    with self.conn as conn:
                        insert_data(conn, 'users', **user)
                except:
                    close(self.conn)
                finally:
                    close(self.conn)
                    self.ui.lblBanner.setText(f'Usuario {self.name} creado correctamente')
                    self.ui.txtName.setText('')
                    self.ui.txtDNI.setText('')
                    self.ui.txtPhone.setText('')
                    self.ui.txtAddres.setText('')
                    self.ui.txtBirth.setText('')
                    self.ui.txtName.setPlaceholderText('')
                    self.ui.txtDNI.setPlaceholderText('')
                    self.ui.txtPhone.setPlaceholderText('')

            else:
                self.ui.lblBanner.setText(f"El usuario {user['dni']} ya existe")

        else:
            self.ui.lblBanner.setText('Verifique los datos')

    
    #----------------------------------------------------------------------
    def validate_txt(self, *fields):
        validator = [re.match(r'^[a-z\sáéíóú.]+$', field, re.I) for field in fields]
        return all(validator)


    #----------------------------------------------------------------------
    def validate_num(self, *fields):
        validator = [re.match(r'^[0-9]+$', field) for field in fields]
        return all(validator)
Пример #10
0
class Main(QtGui.QMainWindow):
    """class for creating a QDialog."""
    def __init__(self, element, packagelist, summary=None, report=None, package=None,
                                             checkcode=None, case=None,
                                             casecounter=None, totalcases=None):
        QtGui.QMainWindow.__init__(self)
        
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.setFixedSize(self.width(), self.height())
        # self.checkcode checks for premature exit of the application
        self.checkcode = 0
    
        self.element = element
        self.case = self.element.xpath('case')
        self.packagelist = packagelist
                
        self.casecounter = 0
        self.totalcases = len(self.case)
        
        self.summary = list()
        self.report = list()
        
        self.package = package
        
        if self.package is None:
            #  if the test is of shell type
            self.ui.type_label.setText('Shell Test')
            packageText = 'Packages: {0}'.format(', '.join(self.packagelist))
            for lst in (self.summary, self.report):
                lst.append(packageText)
            self.ui.text_edit.append("The following packages will be tested: " \
                                "<b>{0}</b>".format(', '.join(self.packagelist)))
            self.ui.text_edit.append("Press 'Start' to begin testing ...")
        else:
            # if the test is of gui type
            self.ui.type_label.setText('GUI Test')
            singlePackage = 'Package: {0}'.format(self.package)
            for lst in (self.summary, self.report):
                lst.append(singlePackage)
            self.ui.text_edit.append("The package <b>'{0}'</b> " \
                                          "will be tested".format(self.package))
            self.ui.text_edit.append("Press 'Start' to begin testing ...")
        
        self.connect(self.ui.next_button, QtCore.SIGNAL("clicked()"), self.next_case)
        self.connect(self.ui.save_button, QtCore.SIGNAL("clicked()"), self.get_text)
        
    def update_text(self):
        """Update the text by parsing through the case tag."""
        self.ui.text_observation.clear()
        self.ui.group_box.setTitle('Case {0} of {1}'.format(self.casecounter+1,
                                                            self.totalcases))
        if self.package is not None:
            self.ui.package_label.setText('Package: {0}'.format(self.package))
            self.ui.text_edit.clear()
            # get the list of files that were downloaded
            filesDownloaded = []
            for files in self.case[self.casecounter].iter('download'):
                filesDownloaded.append(files.text)
            if filesDownloaded:
                self.ui.text_edit.append("Using files in '{0}'".format(os.getcwd()))
            # get the text
            textList = []
            for text in self.case[self.casecounter].iter():
                if text.text.strip() == '':
                    continue
                if text.tag == 'link':
                    textList.append('{0}'.format(text.text))
                    continue
                if text.tag == 'download':
                    textList.append('{0}'.format(os.path.basename(text.text)))
                    continue
                textList.append(text.text)            
            if textList:
                self.ui.text_edit.append('')
            self.ui.text_edit.append('\n'.join(textList))
        else:
            self.ui.package_label.setText('Package(s): ' \
                                      '{0}'.format(', '.join(self.packagelist)))
            self.ui.text_edit.clear()
            # get the text
            textList = []
            for element in self.case[self.casecounter].iter('text'):
                textList.append(element.text)
            if textList:
                self.ui.text_edit.append('')
                for number, element in enumerate(textList, 1):
                    self.ui.text_edit.append('<b>{0}</b>. {1}'.format(number, element))
            # get the commands
            commandList = []
            for element in self.case[self.casecounter].iter('command'):
                commandList.append(element.text)
            if commandList:
                self.ui.text_edit.append('')
                self.ui.text_edit.append('{0}'.format('\n'.join(commandList)))
            
    def next_case(self):
        """Increment the case counter and display the next case."""
        if self.casecounter < self.totalcases:
            self.ui.next_button.setEnabled(True)
            self.ui.text_edit.setEnabled(True)
            self.ui.label.setEnabled(True)
            self.ui.yes_button.setEnabled(True)
            self.ui.no_button.setEnabled(True)
            self.ui.unable_button.setEnabled(True)
            self.ui.save_button.setEnabled(True)
            # update the text based on the testcase
            self.ui.next_button.setText('N&ext')
            self.update_text()            
            self.ui.next_button.setEnabled(False)
        else:
            self.ui.quit_button.setEnabled(True)            
            self.ui.text_observation.setEnabled(False)
            self.ui.label.setEnabled(False)
            self.ui.yes_button.setEnabled(False)
            self.ui.clear_button.setEnabled(False)
            self.ui.no_button.setEnabled(False)
            self.ui.label_observation.setEnabled(False)
            self.ui.unable_button.setEnabled(False)
            self.ui.next_button.setEnabled(False)
            # set the checkcode to 1 since everything is ok
            self.checkcode = 1            
            self.ui.package_label.setText('')
            self.ui.text_observation.setPlainText('')
            self.ui.text_edit.setText("End of package testing. " \
                                      "Press 'Finish' to exit.")
            self.ui.group_box.setTitle('Finished')

    def get_text(self):
        """Get the observation from the user."""
        if self.ui.yes_button.isChecked():
            self.report.append('Case {0} of {1}: Success'.format(self.casecounter+1,
                                                            self.totalcases))
            self.summary.append('Case {0} of {1}: Success'.format(self.casecounter+1,
                                                            self.totalcases))
        elif self.ui.unable_button.isChecked():
            failure_message = 'Case {0} of {1}: The user was unable to perform ' \
                        'this test'.format(self.casecounter+1, self.totalcases)
            for lst in (self.summary, self.report):
                lst.append(failure_message)
            observation = self.ui.text_observation.toPlainText()
            if observation == '':
                self.report.append('\tCase {0}: No observation ' \
                                          'entered.'.format(self.casecounter+1))
            else:
                self.report.append('\tCase {0} Observation: ' \
                                   '{1}'.format(self.casecounter+1, observation))
        elif self.ui.no_button.isChecked():
            self.report.append('Case {0} of {1}: Failed'.format(self.casecounter+1,
                                                          self.totalcases))
            self.summary.append('Case {0} of {1}: Failed'.format(self.casecounter+1,
                                                          self.totalcases))
            observation = self.ui.text_observation.toPlainText()
            if observation == '':
                self.report.append('\tCase {0}: No observation ' \
                                        'entered.'.format(self.casecounter+1))
            else:
                self.report.append('\tCase {0} Observation: ' \
                                   '{1}'.format(self.casecounter+1, observation))
        else:
            self.report.append('Case {0} of {1}: ' \
                               'No information entered'.format(self.casecounter+1,
                                                             self.totalcases))
            self.summary.append('Case {0} of {1}: Failed'.format(self.casecounter+1,
                                                             self.totalcases))
        # disable everything related to input
        self.ui.text_edit.setEnabled(False)
        self.ui.text_observation.setEnabled(False)
        self.ui.label.setEnabled(False)
        self.ui.yes_button.setEnabled(False)
        self.ui.clear_button.setEnabled(False)
        self.ui.no_button.setEnabled(False)
        self.ui.label_observation.setEnabled(False)
        self.ui.unable_button.setEnabled(False)        
        self.ui.save_button.setEnabled(False)        
        self.ui.next_button.setEnabled(True)
        self.casecounter += 1