# Path: pytripgui/view/qt_view_adapter.py
# class LineEdit:
#     def __init__(self, line_edit):
#         self._ui = line_edit
# 
#     @property
#     def text(self):
#         return self._ui.text()
# 
#     @text.setter
#     def text(self, text):
#         self._ui.setText(str(text))
# 
#     def clear(self):
#         self._ui.clear()
# 
#     def set_enabled(self, enabled):
#         self._ui.setEnabled(enabled)
# 
#     def emit_on_text_change(self, callback):
#         """
#         When user have changed text in UI, callback will be called with new text:
#         callback(new_text)
#         """
#         self._ui.textChanged.connect(callback)
# 
#     def set_validator(self, validator):
#         self._ui.setValidator(validator)
# 
#     def enable_validation(self, validator, custom_validation=None):
#         self._ui.setValidator(validator)
#         if custom_validation:
#             self._ui.textChanged.connect(custom_validation)
#         else:
#             self._ui.textChanged.connect(self.validate)
# 
#     def disable_validation(self):
#         self._ui.textChanged.disconnect()
# 
#     def validate(self):
#         if self._ui.validator():
#             state = self._ui.validator().validate(self._ui.text(), 0)[0]
#             if state == QValidator.Acceptable:
#                 self.reset_border()
#                 return True
#             self.highlight_border()
#         return False
# 
#     def highlight_border(self):
#         self._ui.setStyleSheet("border: 1px solid red")
# 
#     def reset_border(self):
#         self._ui.setStyleSheet("")
# 
# class ComboBox:
#     def __init__(self, combo_box):
#         self._ui = combo_box
#         self.last_index = 0
# 
#         self._on_item_change_user_callback = None
#         self._ui.currentIndexChanged.connect(self._on_item_change_callback)
# 
#     def fill(self, combo_list, lambda_names):
#         self.last_index = 0
#         self._ui.clear()
#         for item in combo_list:
#             self._ui.addItem(lambda_names(item), item)
# 
#     def append_element(self, data, name):
#         self._ui.addItem(name, data)
#         self.current_index = self.count - 1
# 
#     def emit_on_item_change(self, callback):
#         self._on_item_change_user_callback = callback
# 
#     def _on_item_change_callback(self):
#         if self._on_item_change_user_callback:
#             self._on_item_change_user_callback()
#         self.last_index = self.current_index
# 
#     def set_current_item_text(self, text):
#         self._ui.setItemText(self.current_index, text)
# 
#     def remove_current_item(self):
#         self.last_index = -1
#         self._ui.removeItem(self.current_index)
# 
#     @property
#     def current_index(self):
#         return self._ui.currentIndex()
# 
#     @property
#     def current_text(self):
#         return self._ui.currentText()
# 
#     @property
#     def count(self):
#         return self._ui.count()
# 
#     @current_index.setter
#     def current_index(self, index):
#         self._ui.setCurrentIndex(index)
# 
#     @property
#     def data(self):
#         data = []
#         for i in range(self.count):
#             data.append(self._ui.itemData(i))
#         return data
# 
#     @property
#     def current_data(self):
#         return self._ui.currentData()
# 
#     @property
#     def last_data(self):
#         return self._ui.itemData(self.last_index)
# 
# class UserInfoBox:
#     def __init__(self, parent_ui):
#         self._parent_ui = parent_ui
# 
#     def show_error(self, name, content):
#         QMessageBox.critical(self._parent_ui, name, content)
# 
#     def show_info(self, name, content):
#         QMessageBox.information(self._parent_ui, name, content)
# 
# class PushButton:
#     def __init__(self, push_button):
#         self._ui = push_button
# 
#     def emit_on_click(self, callback):
#         self._ui.clicked.connect(callback)
# 
# Path: pytripgui/view/qt_gui.py
# class UiTripConfig(QtWidgets.QDialog):
#     def __init__(self, parent=None):
#         super(UiTripConfig, self).__init__(parent)
#         ui_path = os.path.join(current_directory, 'trip_config.ui')
#         uic.loadUi(ui_path, self)


from pytripgui.view.qt_view_adapter import LineEdit, ComboBox, UserInfoBox, PushButton
from pytripgui.view.qt_gui import UiTripConfig
from PyQt5.QtWidgets import QFileDialog
import logging


logger = logging.getLogger(__name__)


class ConfigQtView:
    stackedWidget_local_index = 0
    stackedWidget_remote_index = 1
    """
    """
    def __init__(self, parent=None):
        self._ui = UiTripConfig(parent)

        self.name = LineEdit(self._ui.configName_lineEdit)

# Path: pytripgui/view/qt_view_adapter.py
# class LineEdit:
#     def __init__(self, line_edit):
#         self._ui = line_edit
# 
#     @property
#     def text(self):
#         return self._ui.text()
# 
#     @text.setter
#     def text(self, text):
#         self._ui.setText(str(text))
# 
#     def clear(self):
#         self._ui.clear()
# 
#     def set_enabled(self, enabled):
#         self._ui.setEnabled(enabled)
# 
#     def emit_on_text_change(self, callback):
#         """
#         When user have changed text in UI, callback will be called with new text:
#         callback(new_text)
#         """
#         self._ui.textChanged.connect(callback)
# 
#     def set_validator(self, validator):
#         self._ui.setValidator(validator)
# 
#     def enable_validation(self, validator, custom_validation=None):
#         self._ui.setValidator(validator)
#         if custom_validation:
#             self._ui.textChanged.connect(custom_validation)
#         else:
#             self._ui.textChanged.connect(self.validate)
# 
#     def disable_validation(self):
#         self._ui.textChanged.disconnect()
# 
#     def validate(self):
#         if self._ui.validator():
#             state = self._ui.validator().validate(self._ui.text(), 0)[0]
#             if state == QValidator.Acceptable:
#                 self.reset_border()
#                 return True
#             self.highlight_border()
#         return False
# 
#     def highlight_border(self):
#         self._ui.setStyleSheet("border: 1px solid red")
# 
#     def reset_border(self):
#         self._ui.setStyleSheet("")
# 
# class ComboBox:
#     def __init__(self, combo_box):
#         self._ui = combo_box
#         self.last_index = 0
# 
#         self._on_item_change_user_callback = None
#         self._ui.currentIndexChanged.connect(self._on_item_change_callback)
# 
#     def fill(self, combo_list, lambda_names):
#         self.last_index = 0
#         self._ui.clear()
#         for item in combo_list:
#             self._ui.addItem(lambda_names(item), item)
# 
#     def append_element(self, data, name):
#         self._ui.addItem(name, data)
#         self.current_index = self.count - 1
# 
#     def emit_on_item_change(self, callback):
#         self._on_item_change_user_callback = callback
# 
#     def _on_item_change_callback(self):
#         if self._on_item_change_user_callback:
#             self._on_item_change_user_callback()
#         self.last_index = self.current_index
# 
#     def set_current_item_text(self, text):
#         self._ui.setItemText(self.current_index, text)
# 
#     def remove_current_item(self):
#         self.last_index = -1
#         self._ui.removeItem(self.current_index)
# 
#     @property
#     def current_index(self):
#         return self._ui.currentIndex()
# 
#     @property
#     def current_text(self):
#         return self._ui.currentText()
# 
#     @property
#     def count(self):
#         return self._ui.count()
# 
#     @current_index.setter
#     def current_index(self, index):
#         self._ui.setCurrentIndex(index)
# 
#     @property
#     def data(self):
#         data = []
#         for i in range(self.count):
#             data.append(self._ui.itemData(i))
#         return data
# 
#     @property
#     def current_data(self):
#         return self._ui.currentData()
# 
#     @property
#     def last_data(self):
#         return self._ui.itemData(self.last_index)
# 
# class UserInfoBox:
#     def __init__(self, parent_ui):
#         self._parent_ui = parent_ui
# 
#     def show_error(self, name, content):
#         QMessageBox.critical(self._parent_ui, name, content)
# 
#     def show_info(self, name, content):
#         QMessageBox.information(self._parent_ui, name, content)
# 
# class PushButton:
#     def __init__(self, push_button):
#         self._ui = push_button
# 
#     def emit_on_click(self, callback):
#         self._ui.clicked.connect(callback)
# 
# Path: pytripgui/view/qt_gui.py
# class UiTripConfig(QtWidgets.QDialog):
#     def __init__(self, parent=None):
#         super(UiTripConfig, self).__init__(parent)
#         ui_path = os.path.join(current_directory, 'trip_config.ui')
#         uic.loadUi(ui_path, self)


# Path: pytripgui/config_vc/config_view.py
from pytripgui.view.qt_view_adapter import LineEdit, ComboBox, UserInfoBox, PushButton
from pytripgui.view.qt_gui import UiTripConfig
from PyQt5.QtWidgets import QFileDialog
import logging



logger = logging.getLogger(__name__)


class ConfigQtView:
    stackedWidget_local_index = 0
    stackedWidget_remote_index = 1
    """
    """
    def __init__(self, parent=None):
        self._ui = UiTripConfig(parent)

        self.name = LineEdit(self._ui.configName_lineEdit)

        self.user_name = LineEdit(self._ui.username_lineEdit)