2021-04-28 02:51:45 +00:00
|
|
|
# Python imports
|
|
|
|
from random import randint
|
|
|
|
|
|
|
|
|
|
|
|
# Lib imports
|
|
|
|
|
|
|
|
|
|
|
|
# Application imports
|
2021-04-22 06:32:18 +00:00
|
|
|
from .view import View
|
2021-03-18 05:29:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Window:
|
|
|
|
def __init__(self):
|
2021-04-28 02:51:45 +00:00
|
|
|
self.id_length = 10
|
|
|
|
self.id = ""
|
|
|
|
self.name = ""
|
|
|
|
self.nickname = ""
|
2021-09-04 03:57:00 +00:00
|
|
|
self.isHidden = False
|
2021-04-28 02:51:45 +00:00
|
|
|
self.views = []
|
|
|
|
|
|
|
|
self.generate_id()
|
|
|
|
|
|
|
|
|
|
|
|
def random_with_N_digits(self, n):
|
|
|
|
range_start = 10**(n-1)
|
|
|
|
range_end = (10**n)-1
|
|
|
|
return randint(range_start, range_end)
|
|
|
|
|
|
|
|
def generate_id(self):
|
|
|
|
self.id = str(self.random_with_N_digits(self.id_length))
|
|
|
|
|
2021-04-28 04:30:58 +00:00
|
|
|
def get_window_id(self):
|
|
|
|
return self.id
|
2021-03-18 05:29:58 +00:00
|
|
|
|
|
|
|
def create_view(self):
|
|
|
|
view = View()
|
|
|
|
self.views.append(view)
|
2021-04-24 11:39:09 +00:00
|
|
|
return view
|
2021-03-18 05:29:58 +00:00
|
|
|
|
|
|
|
def pop_view(self):
|
|
|
|
self.views.pop()
|
|
|
|
|
2021-04-28 02:51:45 +00:00
|
|
|
def delete_view_by_id(self, vid):
|
2021-04-24 11:39:09 +00:00
|
|
|
for view in self.views:
|
|
|
|
if view.id == vid:
|
2021-04-28 02:51:45 +00:00
|
|
|
self.views.remove(view)
|
2021-04-24 11:39:09 +00:00
|
|
|
break
|
2021-03-18 05:29:58 +00:00
|
|
|
|
2021-04-24 11:39:09 +00:00
|
|
|
|
|
|
|
def get_view_by_id(self, vid):
|
|
|
|
for view in self.views:
|
|
|
|
if view.id == vid:
|
|
|
|
return view
|
|
|
|
|
|
|
|
def get_view_by_index(self, index):
|
2021-03-18 05:29:58 +00:00
|
|
|
return self.views[index]
|
2021-04-28 02:51:45 +00:00
|
|
|
|
|
|
|
def get_views_count(self):
|
|
|
|
return len(self.views)
|
|
|
|
|
|
|
|
def get_all_views(self):
|
|
|
|
return self.views
|
|
|
|
|
|
|
|
def list_files_from_views(self):
|
|
|
|
for view in self.views:
|
|
|
|
print(view.files)
|