def smethod_0(iwin32Window_0): RunwayList.RunwayList() runwayList = RunwayList() if (not QFile.exists(RunwayList.fileName)): return runwayList # try # { file0 = QFile(RunwayList.fileName) file0.open(QIODevice.ReadOnly) dataStream = QDataStream(file0) # using (BinaryReader binaryReader = new BinaryReader(File.Open(RunwayList.fileName, FileMode.Open, FileAccess.Read))) # { str0 = dataStream.readQString( ) #Encoding.Default.GetString(binaryReader.ReadBytes("PHXASA".Length)) num = dataStream.readInt() #binaryReader.ReadByte() if (not str0 == "PHXASA" or (num != 2 and num != 3)): return runwayList num1 = dataStream.readInt() for i in range(num1): runwayList.Add(Runway.smethod_0(dataStream, num)) # catch (Exception exception1) # { # Exception exception = exception1 # ErrorMessageBox.smethod_0(iwin32Window_0, string.Format(Messages.ERR_FAILED_TO_LOAD_RWY_DATA_FILE, exception.Message)) # } runwayList.method_1() return runwayList
def ReadUserInfoFile(self): try: if not QFile.exists(self.m_strUserInfoFullName): return file0 = QFile(self.m_strUserInfoFullName) file0.open(QIODevice.ReadOnly) dataStream = QDataStream(file0) str0 = dataStream.readQString() self.m_strUserInfoFullName = dataStream.readQString() self.m_Key = dataStream.readQString() self.m_IV = dataStream.readQString() userInfoCount = dataStream.readInt() for i in range(userInfoCount): userInfo = MYUSERINFO() userInfo.readData(dataStream) self.ListUserInfo.append(userInfo) file0.close() return True except: return False
def smethod_0(iwin32Window_0): FatoList.FatoList() fatoList = FatoList() if (not QFile.exists(FatoList.fileName)): return fatoList file0 = QFile(FatoList.fileName) file0.open(QIODevice.ReadOnly) dataStream = QDataStream(file0) str0 = dataStream.readQString() num = dataStream.readInt() if (not (str0 == "PHXHSAF") or num != 1): raise Messages.ERR_INVALID_FILE_FORMAT # throw new Exception(Messages.ERR_INVALID_FILE_FORMAT) num1 = dataStream.readInt() for i in range(num1): fatoList.append(Fato.smethod_0(dataStream, num)) fatoList.method_1() return fatoList
def dropMimeData(self, mime_data, action, row, col_unused, parent_unused, filling_empty_model=False): if action == Qt.IgnoreAction: return True if not mime_data.hasFormat("application/vnd.text.list"): return False if not filling_empty_model and row == self.rowCount(): # It's forbidden to insert before the first commit (last row of the # model). return False if row != -1: begin_row = row else: return False encoded_data = mime_data.data("application/vnd.text.list") stream = QDataStream(encoded_data, QIODevice.ReadOnly) new_items = [] rows = 0 while not stream.atEnd(): text = stream.readQString() item_branch, item_row_s = str(text).split(' ') new_items.append([int(item_row_s),]) rows += 1 # Now new_items contains 1 element lists with the row of the inserted # commit. We will complete these lists with the actual Commit object. # item_branch contains the name of the branch. for (branch, model) in self._all_models_dict.items(): if branch.name == item_branch: item_model = model # We're going to store the data to be inserted in a dictionnary before # inserting the rows. This is to avoid problems when copying rows from # a model to somewhere above in the same model. The insertion of rows # causes a shift of all the rows, including the ones to be copied from. data_to_be_inserted = {} insert_row = begin_row for item in new_items: item_row = item[0] for column, field in enumerate(self.get_columns()): item_index = self.createIndex(item_row, column) data = item_model.data(item_index, Qt.EditRole) data_to_be_inserted[(insert_row, column)] = data insert_row += 1 self.start_history_event() parents_col = self.get_columns().index("parents") children_col = self.get_columns().index("children") _row = begin_row for item in new_items: replaced_row = _row replaced_index = self.createIndex(replaced_row, 0) while self.is_deleted(replaced_index): replaced_row += 1 replaced_index = self.createIndex(replaced_row, 0) replaced_commit = self.git_model.get_commits()[replaced_index.row()] new_parents = [replaced_commit,] new_children = list(self.git_model.c_data(replaced_commit, "children")) self.insertRows(_row, 1, QModelIndex()) for column, field in enumerate(self.get_columns()): index = self.createIndex(_row, column) self.setData(index, data_to_be_inserted[(_row, column)]) self.setData(self.createIndex(_row, children_col), new_children) self.setData(self.createIndex(_row, parents_col), [replaced_commit,]) this_commit = self.git_model.get_commits()[_row] # Updating parent's children and children parent's for child in new_children: row_of_child = self.git_model.row_of(child) _parents = list(self.git_model.c_data(child, "parents")) parents_position = _parents.index(replaced_commit) # Removing only the replaced commit from the parents _parents.pop(parents_position) _parents.insert(parents_position, this_commit) self.setData(self.createIndex(row_of_child, parents_col), _parents) for parent in new_parents: row_of_parent = self.git_model.row_of(parent) self.setData(self.createIndex(row_of_parent, children_col), [this_commit,]) _row += 1 self.reset() return True