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 test_mime_data(self): class DummyItem(object): def data(s, role): self.assertEqual(role, Qt.UserRole) return 42 mw = self._get_one() data = mw.mimeData([DummyItem()]).data('application/vnd.re-eat.meal_recipe') stream = QDataStream(data, QIODevice.ReadOnly) self.assertEqual(stream.readInt(), 42) self.assertEqual(stream.readQVariant(), mw.date) self.assertEqual(stream.readInt(), mw.index)
def test_mime_data(self): class DummyItem(object): def data(s, role): self.assertEqual(role, Qt.UserRole) return 42 mw = self._get_one() data = mw.mimeData([DummyItem() ]).data('application/vnd.re-eat.meal_recipe') stream = QDataStream(data, QIODevice.ReadOnly) self.assertEqual(stream.readInt(), 42) self.assertEqual(stream.readQVariant(), mw.date) self.assertEqual(stream.readInt(), mw.index)
def dropMimeData(self, index, data, action): if action == Qt.IgnoreAction: return True if data.hasFormat('application/vnd.re-eat.meal_recipe'): encodedData = data.data('application/vnd.re-eat.meal_recipe') stream = QDataStream(encodedData, QIODevice.ReadOnly) while not stream.atEnd(): id = stream.readInt() date = stream.readQVariant() index = stream.readInt() self.recipeRemoved.emit(id, date, index) return True return False
def dropMimeData(self, index, data, action): if action == Qt.IgnoreAction: return True if data.hasFormat('application/vnd.re-eat.meal_recipe'): encodedData = data.data('application/vnd.re-eat.meal_recipe') stream = QDataStream(encodedData, QIODevice.ReadOnly) while not stream.atEnd(): id = stream.readInt() date = stream.readQVariant() index = stream.readInt() self.recipeRemoved.emit(id, date, index) return True 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 test_drag_information_are_correct(self): rw = RecipesWidget() self.assertIn('application/vnd.re-eat.recipe', rw.mimeTypes()) items = [rw.item(i) for i in (0, 1)] ids = [item.data(Qt.UserRole) for item in items] data = rw.mimeData(items) stream = QDataStream(data.data('application/vnd.re-eat.recipe')) result = [] while not stream.atEnd(): result.append(stream.readInt()) self.assertListEqual(result, ids)
def test_drag_information_are_correct(self): rw = RecipesWidget() self.assertIn('application/vnd.re-eat.recipe', rw.mimeTypes()) items = [rw.item(i) for i in (0, 1)] ids = [item.data(Qt.UserRole) for item in items] data = rw.mimeData(items) stream = QDataStream(data.data('application/vnd.re-eat.recipe')) result = [] while not stream.atEnd(): result.append(stream.readInt()) self.assertListEqual(result, ids)
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 restoreState(self, state): """ Restore the toolbox from a :class:`QByteArray` `state`. .. note:: The toolbox should already be populated for the state changes to take effect. """ # In version 1 of saved state the state was saved in # a simple dict repr string. if isinstance(state, QByteArray): stream = QDataStream(state, QIODevice.ReadOnly) version = stream.readInt() if version == 2: expanded = stream.readQStringList() for action in map(self.tabAction, range(self.count())): if (action.text() in expanded) != action.isChecked(): action.trigger() return True return False
def restoreState(self, state): """ Restore the toolbox from a :class:`QByteArray` `state`. .. note:: The toolbox should already be populated for the state changes to take effect. """ # In version 1 of saved state the state was saved in # a simple dict repr string. if isinstance(state, QByteArray): stream = QDataStream(state, QIODevice.ReadOnly) version = stream.readInt() if version == 2: expanded = stream.readQStringList() for action in map(self.tabAction, range(self.count())): if (action.text() in expanded) != action.isChecked(): action.trigger() return True return False