# -*- coding: utf-8 -*-
from __future__ import (unicode_literals, division, absolute_import, print_function)
__license__   = 'GPL v3'
__copyright__ = '2015, DaltonST <DaltonShiTzu@outlook.com>'

__my_version__ = "3.6.79"

from PyQt5.Qt import (Qt, QDialog, QLabel, QLineEdit, QVBoxLayout, QHBoxLayout, QWidget, QPushButton,
        QGridLayout, pyqtSignal, QDialogButtonBox, QScrollArea, QFont, QPalette, QColor,
        QTabWidget, QIcon, QToolButton, QSplitter, QGroupBox, QSpacerItem, QCheckBox,
        QSizePolicy, QFrame, QSize, QKeySequence, QMenu, QShortcut)


class WorkSeriesReplaceDialog(QDialog):

    def __init__(self, gui,icon,guidb,execute_work_series_search_and_replace):


        QDialog.__init__(self, gui)
        self.gui = gui

        self.guidb = guidb

        self.execute_work_series_search_and_replace = execute_work_series_search_and_replace

        self.layout = QVBoxLayout()
        self.setLayout(self.layout)

        font = QFont()

        font.setBold(False)
        font.setPointSize(11)

        self.layout.addSpacing(2)

        self.text_heading = QLabel()
        self.text_heading.setTextFormat(1)
        self.text_heading.setText("<center><font color='#0404B4'>Search & Replace a Specific Work Series Name [Selected Books]</font></center>")
        self.text_heading.setFont(font)
        self.layout.addWidget(self.text_heading)
        self.layout.addSpacing(20)


        self.setWindowTitle('Quarantine And Scrub                                                                                                                          ')
        self.setWindowIcon(icon)

        font.setBold(True)
        font.setPointSize(8)

        self.label1 = QLabel()
        self.label1.setTextFormat(1)
        self.label1.setText("<center><font color='#0404B4'>Work Series Name for which to Search && Replace</font></center>")
        self.label1.setFont(font)
        self.layout.addWidget(self.label1)

        self.msg1 = QLineEdit(self)
        self.msg1.setText('?')
        self.layout.addWidget(self.msg1)
        self.label1.setBuddy(self.msg1)

        self.layout.addSpacing(10)

        self.use_substring_checkbox = QCheckBox('Is a Partial Match Sufficient to Replace a Work Series Name?')
        self.layout.addWidget(self.use_substring_checkbox)

        self.layout.addSpacing(10)

        self.label2 = QLabel()
        self.label2.setTextFormat(1)
        self.label2.setText("<center><font color='#0404B4'>New Work Series Name</font></center>")
        self.label2.setFont(font)
        self.layout.addWidget(self.label2)

        self.msg2 = QLineEdit(self)
        self.msg2.setText('?')
        self.layout.addWidget(self.msg2)
        self.label2.setBuddy(self.msg2)

        self.layout.addSpacing(30)

        self.push_button1 = QPushButton(" ", self)
        self.push_button1.setText("Execute: Work Series Name Search && Replace [Selected Books]")
        self.push_button1.clicked.connect(self.__do_push_button1)
        self.push_button1.setFont(font)
        self.layout.addWidget(self.push_button1)

        self.layout.addSpacing(20)

        font.setBold(True)
        font.setPointSize(8)

        button_box = QDialogButtonBox(QDialogButtonBox.Cancel)
        button_box.rejected.connect(self.reject)
        self.layout.addWidget(button_box)

        self.resize(self.sizeHint())


    def __do_push_button1(self):
        self.work_series_keyword_old = unicode(self.msg1.text())
        self.work_series_keyword_old = self.work_series_keyword_old.strip()
        self.work_series_new = unicode(self.msg2.text())
        self.work_series_new = self.work_series_new.strip()
        self.use_substring = unicode(self.use_substring_checkbox.isChecked())
        self.execute_work_series_search_and_replace(self.guidb,self.work_series_keyword_old,self.use_substring,self.work_series_new)



#END of workseriesreplacedialog.py