예제 #1
0
    def _deleteSelectedFile(self):
        """
        Remove a file from the SRC dir
        """

        title = "Delete file"
        question = "Really delete %s ?" % (self._currentSelection['filename'])

        choice = QMessageBox.question(self, title, question,
                                      QMessageBox.Yes | QMessageBox.No)

        if choice == QMessageBox.Yes:
            fn = os.path.join(self.case_dir, self._currentSelection['subpath'],
                              self._currentSelection['filename'])

            try:
                os.remove(fn)
            except Exception:
                # TODO add error popup
                pass

            d = os.path.split(fn)[0]
            if os.path.basename(d) in ('DRAFT', 'STASH'):
                l = os.listdir(d)
                if len(l) < 1:
                    try:
                        os.rmdir(d)
                    except Exception:
                        pass
        else:
            pass
예제 #2
0
    def event(self, ev):

        result = QMessageBox.event(self, ev)

        self.setMinimumHeight(10)
        self.setMaximumHeight(16777215)
        self.setMinimumWidth(10)
        self.setMaximumWidth(16777215)
        self.setSizePolicy(QSizePolicy.Expanding,
                           QSizePolicy.Expanding)

        text = self.findChild(QTextEdit)
        if text != None:
            self.setMinimumHeight(10)
            self.setMaximumHeight(16777215)
            self.setMinimumWidth(1050)
            self.setMaximumWidth(16777215)

            text.setMinimumHeight(10)
            text.setMaximumHeight(16777215)
            text.setMinimumWidth(1000)
            text.setMaximumWidth(16777215)
            text.setSizePolicy(QSizePolicy.Expanding,
                               QSizePolicy.Expanding)

        return result
예제 #3
0
    def _removeSelectedFile(self):
        """
        Remove a file from the SRC dir
        """

        title = "Remove file"
        question = "Remove %s from the SRC folder (Stored in DRAFT) ?" % (self._currentSelection['filename'])

        choice = QMessageBox.question(self,
                                      title,
                                      question,
                                      QMessageBox.Yes | QMessageBox.No)

        if choice == QMessageBox.Yes:
            fn = os.path.join(self.case_dir,
                              self._currentSelection['subpath'],
                              self._currentSelection['filename'])


            draft = os.path.join(self.case_dir,
                               self._currentSelection['subpath'],
                               'DRAFT')
            if not os.path.exists(draft):
                os.mkdir(draft)
            fn2 = os.path.join(draft, self._currentSelection['filename'])

            if os.path.exists(fn2):
                q = 'A file named %s allready exists in DRAFT.\nDo you want to overwrite it?' % (self._currentSelection['filename'])
                choice2 = QMessageBox.question(self,
                                                     '',
                                                     q,
                                                     QMessageBox.Yes | QMessageBox.No)
                if choice2 == QMessageBox.No:
                    return


            shutil.move(fn, fn2)
        else:
            pass
예제 #4
0
    def closeOpenedFile(self):
        """
        Close an opened file
        """

        if self.saved == False and self.readOnly == False:
            choice = QMessageBox.question(
                self, 'Built-in editor', 'File changed.\nDo you want to save?',
                QMessageBox.Yes | QMessageBox.No)
            if choice == QMessageBox.Yes:
                self.saveFile()
            else:
                pass

        self.saved = True
        self.opened = False

        self.filename = ''
        self.textEdit.setPlainText('')
예제 #5
0
    def closeApplication(self):
        """
        Close the editor
        """
        if self.opened == True:
            choice = QMessageBox.question(self, 'Built-in editor',
                                          "Exit text editor?",
                                          QMessageBox.Yes | QMessageBox.No)
        else:
            choice = QMessageBox.Yes

        if choice == QMessageBox.Yes:
            self.closeOpenedFile()

            settings = QtCore.QSettings()
            settings.setValue("MainWindow/Geometry", self.saveGeometry())

            self.close()
        else:
            pass
예제 #6
0
 def __init__(self, parent=None):
     QMessageBox.__init__(self, parent=parent)
     self.setSizeGripEnabled(True)