# Path: reggata/gui/common_widgets.py
# class WaitDialog(QtGui.QDialog):
# 
#     def __init__(self, parent=None, indeterminate=False):
#         super(WaitDialog, self).__init__(parent)
#         self.setModal(True)
#         self.setWindowTitle("Reggata")
# 
#         vbox = QtGui.QVBoxLayout()
# 
#         self.msg_label = QtGui.QLabel(self.tr("Please, wait..."))
#         vbox.addWidget(self.msg_label)
# 
#         self.progress_bar = QtGui.QProgressBar()
#         self.progress_bar.setMinimum(0)
#         self.progress_bar.setMaximum(100)
#         vbox.addWidget(self.progress_bar)
# 
#         if indeterminate:
#             self.progress_bar.setTextVisible(False)
#             self.timer = QtCore.QTimer()
#             self.connect(self.timer, QtCore.SIGNAL("timeout()"), self.indeterminate_timer)
#             self.timer.start(100)
# 
#         self.setLayout(vbox)
# 
#     def startWithWorkerThread(self, thread):
#         if consts.DEBUG:
#             # Breakpoints do not work in other threads.
#             # If you want to debug code of worker background threads, set consts.DEBUG to True
#             thread.run()
#         else:
#             thread.start()
#             thread.wait(1000)
#             if thread.isRunning():
#                 self.exec_()
# 
#         if thread.isExceptionRaised():
#             raise Exception(thread.exceptionDescription())
# 
# 
#     def indeterminate_timer(self):
#         value = self.progress_bar.value()
#         value = value + int((self.progress_bar.maximum() - self.progress_bar.minimum())/5.0)
#         self.progress_bar.setValue(value if value <= self.progress_bar.maximum() \
#                                    else self.progress_bar.minimum())
# 
# 
#     def exception(self, exceptionInfo):
#         '''
#             This slot is usually connected to the 'exception' signal, emitted from a
#         worker thread.
#         '''
#         self.reject()
# 
# 
#     def closeEvent(self, close_event):
#         close_event.ignore() # Disable close button (X) of the dialog.
# 
# 
#     def set_progress(self, percent_completed):
#         '''This slot is called to display progress in percents.'''
#         logger.debug("Completed {}%".format(percent_completed))
#         self.progress_bar.setValue(percent_completed)
# 
# Path: reggata/logic/abstract_dialogs_facade.py
# class AbstractDialogsFacade(object):
# 
#     def execUserDialog(self, user, gui, dialogMode):
#         raise NotImplementedError()
# 
#     def execChangeUserPasswordDialog(self, user, gui):
#         raise NotImplementedError()
# 
#     def execItemDialog(self, item, gui, repo, dialogMode):
#         raise NotImplementedError()
# 
#     def execItemsDialog(self, items, gui, repo, dialogMode, sameDstPath):
#         raise NotImplementedError()
# 
#     def startThreadWithWaitDialog(self, thread, gui, indeterminate):
#         raise NotImplementedError()
# 
#     def getOpenFileName(self, gui, textMessageForUser):
#         raise NotImplementedError()
# 
#     def getOpenFileNames(self, gui, textMessageForUser):
#         raise NotImplementedError()
# 
#     def getExistingDirectory(self, gui, textMessageForUser):
#         raise NotImplementedError()
# 
#     def getOpenFilesAndDirs(self, gui, textMessageForUser):
#         raise NotImplementedError()
# 
#     def getSaveFileName(self, gui, textMessageForUser):
#         raise NotImplementedError()
# 
#     def execMessageBox(self, parent, text, title, buttons):
#         raise NotImplementedError()


import os
from PyQt4 import QtCore
from reggata.gui.common_widgets import WaitDialog
from reggata.logic.abstract_dialogs_facade import AbstractDialogsFacade
'''
Created on 23.09.2012
@author: vitvlkv
'''


# TODO: Class should be renamed in something like... PreselectedFilesDialogsFacade
class DropFilesDialogsFacade(AbstractDialogsFacade):

    def __init__(self, userDialogs):
        self.__selectedFiles = []
        self.__userDialogs = userDialogs


    def setSelectedFiles(self, selectedFiles):
        self.__selectedFiles = selectedFiles


    def execItemDialog(self, item, gui, repo, dialogMode):
        return self.__userDialogs.execItemDialog(item, gui, repo, dialogMode)


    def execItemsDialog(self, items, gui, repo, dialogMode, sameDstPath):
        return self.__userDialogs.execItemsDialog(items, gui, repo, dialogMode, sameDstPath)


    def startThreadWithWaitDialog(self, thread, gui, indeterminate):

# Path: reggata/gui/common_widgets.py
# class WaitDialog(QtGui.QDialog):
# 
#     def __init__(self, parent=None, indeterminate=False):
#         super(WaitDialog, self).__init__(parent)
#         self.setModal(True)
#         self.setWindowTitle("Reggata")
# 
#         vbox = QtGui.QVBoxLayout()
# 
#         self.msg_label = QtGui.QLabel(self.tr("Please, wait..."))
#         vbox.addWidget(self.msg_label)
# 
#         self.progress_bar = QtGui.QProgressBar()
#         self.progress_bar.setMinimum(0)
#         self.progress_bar.setMaximum(100)
#         vbox.addWidget(self.progress_bar)
# 
#         if indeterminate:
#             self.progress_bar.setTextVisible(False)
#             self.timer = QtCore.QTimer()
#             self.connect(self.timer, QtCore.SIGNAL("timeout()"), self.indeterminate_timer)
#             self.timer.start(100)
# 
#         self.setLayout(vbox)
# 
#     def startWithWorkerThread(self, thread):
#         if consts.DEBUG:
#             # Breakpoints do not work in other threads.
#             # If you want to debug code of worker background threads, set consts.DEBUG to True
#             thread.run()
#         else:
#             thread.start()
#             thread.wait(1000)
#             if thread.isRunning():
#                 self.exec_()
# 
#         if thread.isExceptionRaised():
#             raise Exception(thread.exceptionDescription())
# 
# 
#     def indeterminate_timer(self):
#         value = self.progress_bar.value()
#         value = value + int((self.progress_bar.maximum() - self.progress_bar.minimum())/5.0)
#         self.progress_bar.setValue(value if value <= self.progress_bar.maximum() \
#                                    else self.progress_bar.minimum())
# 
# 
#     def exception(self, exceptionInfo):
#         '''
#             This slot is usually connected to the 'exception' signal, emitted from a
#         worker thread.
#         '''
#         self.reject()
# 
# 
#     def closeEvent(self, close_event):
#         close_event.ignore() # Disable close button (X) of the dialog.
# 
# 
#     def set_progress(self, percent_completed):
#         '''This slot is called to display progress in percents.'''
#         logger.debug("Completed {}%".format(percent_completed))
#         self.progress_bar.setValue(percent_completed)
# 
# Path: reggata/logic/abstract_dialogs_facade.py
# class AbstractDialogsFacade(object):
# 
#     def execUserDialog(self, user, gui, dialogMode):
#         raise NotImplementedError()
# 
#     def execChangeUserPasswordDialog(self, user, gui):
#         raise NotImplementedError()
# 
#     def execItemDialog(self, item, gui, repo, dialogMode):
#         raise NotImplementedError()
# 
#     def execItemsDialog(self, items, gui, repo, dialogMode, sameDstPath):
#         raise NotImplementedError()
# 
#     def startThreadWithWaitDialog(self, thread, gui, indeterminate):
#         raise NotImplementedError()
# 
#     def getOpenFileName(self, gui, textMessageForUser):
#         raise NotImplementedError()
# 
#     def getOpenFileNames(self, gui, textMessageForUser):
#         raise NotImplementedError()
# 
#     def getExistingDirectory(self, gui, textMessageForUser):
#         raise NotImplementedError()
# 
#     def getOpenFilesAndDirs(self, gui, textMessageForUser):
#         raise NotImplementedError()
# 
#     def getSaveFileName(self, gui, textMessageForUser):
#         raise NotImplementedError()
# 
#     def execMessageBox(self, parent, text, title, buttons):
#         raise NotImplementedError()


# Path: reggata/gui/drop_files_dialogs_facade.py
import os
from PyQt4 import QtCore
from reggata.gui.common_widgets import WaitDialog
from reggata.logic.abstract_dialogs_facade import AbstractDialogsFacade

'''
Created on 23.09.2012
@author: vitvlkv
'''


# TODO: Class should be renamed in something like... PreselectedFilesDialogsFacade
class DropFilesDialogsFacade(AbstractDialogsFacade):

    def __init__(self, userDialogs):
        self.__selectedFiles = []
        self.__userDialogs = userDialogs


    def setSelectedFiles(self, selectedFiles):
        self.__selectedFiles = selectedFiles


    def execItemDialog(self, item, gui, repo, dialogMode):
        return self.__userDialogs.execItemDialog(item, gui, repo, dialogMode)


    def execItemsDialog(self, items, gui, repo, dialogMode, sameDstPath):
        return self.__userDialogs.execItemsDialog(items, gui, repo, dialogMode, sameDstPath)


    def startThreadWithWaitDialog(self, thread, gui, indeterminate):

        wd = WaitDialog(gui, indeterminate)