Exemple #1
0
    def rewrite_html(self):
        session = DB.get_session()

        movies = session.query(Movie).all()

        total = len(movies)
        self.p_bar_movies.setMaximum(total)
        i = 1
        for m in movies:
            view = write_movie_html(session, m)
            m.view = view
            session.commit()

            self.p_bar_movies.setValue(i)
            i += 1

        series = session.query(Series).all()

        total = len(series)
        self.p_bar_series.setMaximum(total)
        i = 1
        for s in series:
            view = write_series_html(session, s)
            s.view = view
            session.commit()

            self.p_bar_series.setValue(i)
            i += 1
Exemple #2
0
    def __init__(self, main):
        super(RewriteHtml, self).__init__()

        self.session = DB.get_session()
        self.cb_categories = []
        self.main = main

        self.setWindowTitle(texts.rewrite_html)
        width = int(0.4 * main.frameSize().width())
        height = int(0.2 * main.frameSize().height())
        self.setGeometry(0, 0, width, height)

        self.subwindow = QWidget()
        p = self.palette()
        p.setColor(self.backgroundRole(), QColor(230, 230, 250))
        self.setPalette(p)
        self.setWidget(self.subwindow)

        self.vbox_main = QVBoxLayout(self.subwindow)
        self.vbox_main.setContentsMargins(20, 20, 20, 20)

        # Series Left Side
        self.fm = QFormLayout()
        self.fm.setSpacing(10)
        self.fm.setContentsMargins(0, 0, 5, 0)

        self.lb_movies = QLabel(texts.movie_s)
        self.p_bar_movies = QProgressBar()
        self.p_bar_movies.setValue(0)
        self.fm.setWidget(0, QFormLayout.LabelRole, self.lb_movies)
        self.fm.setWidget(0, QFormLayout.FieldRole, self.p_bar_movies)

        self.lb_series = QLabel(texts.series_p)
        self.p_bar_series = QProgressBar()
        self.p_bar_series.setValue(0)
        self.fm.setWidget(1, QFormLayout.LabelRole, self.lb_series)
        self.fm.setWidget(1, QFormLayout.FieldRole, self.p_bar_series)

        self.pb_rewrite = pb_create(texts.pb_rewrite_html)
        self.pb_rewrite.clicked.connect(self.rewrite_html)
        self.pb_rewrite.setShortcut('Ctrl+R')
        self.fm.setWidget(2, QFormLayout.FieldRole, self.pb_rewrite)

        self.vbox_main.addLayout(self.fm)
Exemple #3
0
    def __init__(self, main):
        """
        Class for delete directors who are orphan in database.

        :param main: Reference for main windows.
        """
        super(DeleteOrphansDirector, self).__init__()

        self.session = DB.get_session()
        self.director = self.session.query(Director)
        self.main = main

        window_title = texts.delete_orphans + ' ' + texts.director_p
        self.setWindowTitle(window_title)

        self.subwindow = QWidget()
        p = self.palette()
        p.setColor(self.backgroundRole(), QColor(230, 230, 250))
        self.setPalette(p)
        self.setWidget(self.subwindow)

        font = QFont()
        font.setPointSize(12)

        # Vbox Main
        self.vbox_main = QVBoxLayout(self.subwindow)
        self.vbox_main.setContentsMargins(20, 20, 20, 20)
        self.vbox_main.setSpacing(10)

        # Table Cast
        self.table = QTableWidget()
        self.table.setColumnCount(2)
        self.table.setContentsMargins(20, 0, 0, 0)

        self.table.setHorizontalHeaderLabels([
            texts.director_s,
            'Del'
        ])

        # table set column width
        w = int(0.5 * main.frameSize().width())
        col_1 = int(0.60 * (w - 50))
        col_2 = int(0.20 * (w - 50))
        col_width = col_1 + col_2 + 4

        self.table.setColumnWidth(0, col_1)
        self.table.setColumnWidth(1, col_2)
        self.table.rowHeight(30)
        self.table.setFixedWidth(col_width)

        self.table.horizontalHeader().setFont(font)
        self.table.horizontalHeader().setStyleSheet(
            'background-color: rgb(230, 230, 230);')
        self.table.verticalHeader().setVisible(False)

        self.rows = 0
        self.ch_del = []

        self.vbox_main.addWidget(self.table)

        # Buttons
        self.pb_delete = pb_create(texts.pb_delete, 12, 40)
        self.pb_delete.setMinimumHeight(40)
        self.pb_delete.setShortcut('Ctrl+D')
        self.pb_delete.clicked.connect(self.delete)

        self.pb_leave = pb_create(texts.pb_leave, 12, 40)
        self.pb_leave.setMinimumHeight(40)
        self.pb_leave.setShortcut('Ctrl+Q')
        self.pb_leave.clicked.connect(self.close)

        self.pb_help = pb_create(texts.pb_help, height=40)
        self.pb_help.setMinimumHeight(40)
        self.pb_help.clicked.connect(self.help)
        self.pb_help.setShortcut('Ctrl+H')

        self.pb_select_all = pb_create(texts.pb_select_all, 12, 40)
        self.pb_select_all.setMinimumHeight(40)
        self.pb_select_all.setShortcut('Ctrl+A')
        self.pb_select_all.clicked.connect(self.select_all)

        self.hb_pb = QHBoxLayout()
        self.hb_pb.setSpacing(10)
        self.hb_pb.addWidget(self.pb_delete)
        self.hb_pb.addWidget(self.pb_leave)
        self.hb_pb.addWidget(self.pb_help)
        self.hb_pb.addWidget(self.pb_select_all)

        self.vbox_main.addLayout(self.hb_pb)

        self.width = col_width + 44
        self.height = int(0.8 * main.frameSize().height())
        self.setGeometry(0, 0, self.width, self.height)

        self.create_table()
Exemple #4
0
    def __init__(self, main):
        super(EditSeason, self).__init__()

        self.session = DB.get_session()
        self.main = main
        self.season = None
        self.episodes_all = None

        windows_title = texts.insert + ' ' + texts.series_p
        self.setWindowTitle(windows_title)
        width = int(0.95 * main.frameSize().width())
        height = int(0.8 * main.frameSize().height())
        self.setGeometry(0, 0, width, height)
        self.tb_witdh_cast = (0.5 * width) - 50
        self.tb_witdh_episode = width - 50

        self.subwindow = QWidget()
        p = self.palette()
        p.setColor(self.backgroundRole(), QColor(230, 230, 250))
        self.setPalette(p)
        self.setWidget(self.subwindow)

        self.vbox_main = QVBoxLayout(self.subwindow)
        self.vbox_main.setContentsMargins(20, 20, 20, 20)

        # Series Left
        self.hbox_left = hbox_create([])

        # Series Left Side
        self.fm_left = QFormLayout()
        self.fm_left.setSpacing(10)
        self.fm_left.setContentsMargins(0, 0, 5, 0)

        # Series
        self.lb_series = QLabel(texts.series_s)
        series = db_select_all(self.session, Series)
        self.cb_series = QComboBox()
        populate_combobox(self.cb_series, series)

        self.fm_left.setWidget(0, QFormLayout.LabelRole, self.lb_series)
        self.fm_left.setWidget(0, QFormLayout.FieldRole, self.cb_series)

        # Season Num Year
        text = texts.season_s + '/' + texts.year_s
        self.lb_season = QLabel(text)
        self.le_season_num = le_create(255, texts.season_num_tt)
        self.le_season_num.setPlaceholderText(texts.season_num)

        self.le_year = le_create(4)
        self.le_year.setPlaceholderText(texts.year_s)

        self.fm_left.setWidget(1, QFormLayout.LabelRole, self.lb_season)
        self.hbox_ny = hbox_create([self.le_season_num, self.le_year])
        self.fm_left.setLayout(1, QFormLayout.FieldRole, self.hbox_ny)

        # Media
        self.lb_media = QLabel(texts.media_s)
        media = db_select_all(self.session, Media)
        self.cb_media = QComboBox()
        populate_combobox(self.cb_media, media)

        self.fm_left.setWidget(2, QFormLayout.LabelRole, self.lb_media)
        self.fm_left.setWidget(2, QFormLayout.FieldRole, self.cb_media)

        # IMDB URL
        self.lb_url_imdb = QLabel(texts.lb_search_season_imdb)
        self.le_url_imdb = le_create(tooltip=texts.ms_episode_search,
                                     place_holder='IMDB URL')
        self.le_url_imdb.returnPressed.connect(
            lambda site='imdb': self.scraping_episodes(site))

        self.fm_left.setWidget(3, QFormLayout.LabelRole, self.lb_url_imdb)
        self.fm_left.setWidget(3, QFormLayout.FieldRole, self.le_url_imdb)

        # Minha Série URL
        self.lb_urL_ms = QLabel(texts.lb_search_season_ms)
        self.le_url_ms = le_create(tooltip=texts.ms_episode_search,
                                   place_holder='Minha Série URL')
        self.le_url_ms.returnPressed.connect(
            lambda site='ms': self.scraping_episodes(site))

        self.fm_left.setWidget(4, QFormLayout.LabelRole, self.lb_urL_ms)
        self.fm_left.setWidget(4, QFormLayout.FieldRole, self.le_url_ms)

        # PB Search
        self.lb_episode_search = QLabel(texts.lb_episode_search)
        self.fm_left.setWidget(5, QFormLayout.LabelRole, self.lb_episode_search)

        self.pb_search_imdb = pb_create(texts.imdb)
        self.pb_search_imdb.clicked.connect(
            lambda site: self.scraping_episodes('imdb'))
        self.pb_search_ms = pb_create(texts.pb_ms_search)
        self.pb_search_ms.clicked.connect(
            lambda site: self.scraping_episodes('ms'))

        self.hbox_url_pb = hbox_create([self.pb_search_imdb, self.pb_search_ms])

        self.fm_left.setLayout(5, QFormLayout.FieldRole, self.hbox_url_pb)

        self.lb_progress = QLabel(texts.progress)
        self.p_bar = QProgressBar()
        self.p_bar.setValue(0)

        self.fm_left.setWidget(6, QFormLayout.LabelRole, self.lb_progress)
        self.fm_left.setWidget(6, QFormLayout.FieldRole, self.p_bar)

        self.vbox_main.addLayout(self.hbox_left)

        # PB Main
        line_h = line_h_create('2px', '#000000')
        self.hbox_3 = hbox_create([line_h])
        self.vbox_main.addLayout(self.hbox_3)

        self.pb_save = pb_create(texts.pb_save, 12, 40)
        self.pb_save.clicked.connect(self.save_season_episodes)
        self.pb_save.setShortcut('Ctrl+S')

        self.pb_clear = pb_create(texts.pb_clear, 12, 40)
        self.pb_clear.clicked.connect(self.clear)
        self.pb_clear.setShortcut('Ctrl+L')

        self.pb_help = pb_create(texts.pb_help, 12, 40)
        self.pb_help.clicked.connect(self.help)
        self.pb_help.setShortcut('Ctrl+H')

        self.pb_leave = pb_create(texts.pb_leave, 12, 40)
        self.pb_leave.clicked.connect(self.close)
        self.pb_leave.setShortcut('Ctrl+Q')

        self.hbox_4 = hbox_create(
            [self.pb_save, self.pb_clear, self.pb_help, self.pb_leave])

        self.vbox_main.addLayout(self.hbox_4)

        self.vbox_right = QVBoxLayout()
        self.vbox_right.setContentsMargins(5, 0, 0, 0)

        # Cast Table
        self.table_cast = QTableWidget()
        self.table_cast.setColumnCount(4)

        self.headers_cast = [
            texts.actor_s,
            texts.character_s,
            texts.order,
            texts.star.capitalize(),
        ]
        self.table_cast.setHorizontalHeaderLabels(self.headers_cast)

        self.table_cast.setColumnWidth(0, 0.30 * self.tb_witdh_cast)
        self.table_cast.setColumnWidth(1, 0.40 * self.tb_witdh_cast)
        self.table_cast.setColumnWidth(2, 0.15 * self.tb_witdh_cast)
        self.table_cast.setColumnWidth(3, 0.15 * self.tb_witdh_cast)

        self.rows_cast = 0

        self.vbox_right.addWidget(self.table_cast)

        self.hbox_left.addLayout(self.fm_left)

        line_v = line_v_create('2px', '#000000')

        self.hbox_left.addWidget(line_v)
        self.hbox_left.addLayout(self.vbox_right)

        # Episode
        self.vbox_episode = QVBoxLayout()

        # Episode Add Row
        self.hbox_episode = QHBoxLayout()

        self.lb_episode = QLabel(texts.episode_s)
        self.pb_add_row_episode = pb_create('+', 12, 30, 50)
        self.pb_add_row_episode.clicked.connect(self.table_episode_add_row)

        self.p_bar = QProgressBar(self.subwindow)
        self.p_bar.setValue(0)

        self.hbox_episode.addWidget(self.lb_episode)
        self.hbox_episode.addWidget(self.pb_add_row_episode)
        self.hbox_episode.addWidget(self.p_bar)

        spacer_item = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        self.hbox_episode.addItem(spacer_item)

        # Episode Table
        self.table_episode = QTableWidget()
        self.table_episode.setObjectName('table-episode')

        self.table_episode.setColumnCount(3)

        self.headers_episode = [
            texts.code,
            texts.title_s,
            texts.summary_s,
        ]
        self.table_episode.setHorizontalHeaderLabels(self.headers_episode)

        self.table_episode.setColumnWidth(0, 0.10 * self.tb_witdh_episode)
        self.table_episode.setColumnWidth(1, 0.20 * self.tb_witdh_episode)
        self.table_episode.setColumnWidth(2, 0.70 * self.tb_witdh_episode)

        self.rows_episode = 0
        self.result_episode = []
        self.table_episode.itemChanged.connect(self.item_changed)

        line_h_4 = line_h_create('2px', '#000000')

        self.vbox_episode.addLayout(self.hbox_episode)
        self.vbox_episode.addWidget(self.table_episode)
        self.vbox_main.addWidget(line_h_4)
        self.vbox_main.addLayout(self.vbox_episode)

        self.errors = {
            'no error': 1,
            'no series': 2,
            'no season': 3,
            'db error': 4,
        }

        self.cb_series.setFocus()

        self.cb_series.currentIndexChanged.connect(self.selected_series)
Exemple #5
0
    def __init__(self, main):
        """
        Class to provide all methods to insert movie in database.

        :param main: Reference for main windows.
        """
        super(InsertMovie, self).__init__()

        self.session = DB.get_session()
        self.movie = None
        self.cb_categories = []
        self.main = main

        windows_title = texts.insert + ' ' + texts.movie_p
        self.setWindowTitle(windows_title)
        width = int(0.95 * main.frameSize().width())
        height = int(0.8 * main.frameSize().height())
        self.setGeometry(0, 0, width, height)
        self.tb_width = (0.5 * width) - 50

        self.subwindow = QWidget()
        p = self.palette()
        p.setColor(self.backgroundRole(), QColor(230, 230, 250))
        self.setPalette(p)
        self.setWidget(self.subwindow)

        self.vbox_main = QVBoxLayout(self.subwindow)

        # Search in IMDB
        self.pb_search_confirm_imdb = pb_create(texts.pb_imdb_search_confirm,
                                                height=25,
                                                width=200)
        self.pb_search_confirm_imdb.setToolTip(texts.imdb_search_tt)
        self.pb_search_confirm_imdb.setShortcut('CTRL+Alt+I')
        self.pb_search_confirm_imdb.clicked.connect(self.search_confirmed_imdb)

        self.pb_search_confirm_ad = pb_create(texts.pb_ad_search_confirm,
                                              height=25,
                                              width=300)
        self.pb_search_confirm_ad.setToolTip(texts.ad_search_tt)
        self.pb_search_confirm_ad.setShortcut('CTRL+Alt+D')
        self.pb_search_confirm_ad.clicked.connect(self.search_confirmed_ad)

        self.lb_imdb_url = QLabel(texts.lb_search_imdb)
        self.lb_imdb_url.setEnabled(False)
        self.lb_imdb_url.setHidden(True)
        self.le_imdb_url = le_create(tooltip=texts.imdb_search_tt)
        self.le_imdb_url.setEnabled(False)
        self.le_imdb_url.setHidden(True)

        self.lb_ad_url = QLabel(texts.lb_search_ad)
        self.lb_ad_url.setEnabled(False)
        self.lb_ad_url.setHidden(True)
        self.le_ad_url = le_create(tooltip=texts.ad_search_tt)

        self.le_ad_url.setEnabled(False)
        self.le_ad_url.setHidden(True)

        self.pb_search_imdb = pb_create(texts.pb_imdb_ad_search,
                                        height=25,
                                        width=200)
        self.pb_search_imdb.clicked.\
            connect(lambda type: self.set_movie_scrapping('imdb'))
        self.pb_search_imdb.setShortcut('CTRL+Shift+I')
        self.pb_search_imdb.setEnabled(False)
        self.pb_search_imdb.setHidden(True)

        self.pb_search_ad = pb_create(texts.pb_imdb_ad_search,
                                      height=25,
                                      width=200)
        self.pb_search_ad.clicked.connect(
            lambda type: self.set_movie_scrapping('ad'))
        self.pb_search_ad.setShortcut('CTRL+Shift+A')
        self.pb_search_ad.setEnabled(False)
        self.pb_search_ad.setHidden(True)

        self.hbox_search = hbox_create([
            self.pb_search_confirm_imdb, self.lb_imdb_url, self.le_imdb_url,
            self.pb_search_confirm_ad, self.lb_ad_url, self.le_ad_url
        ])
        self.hbox_search.setContentsMargins(20, 10, 20, 0)

        self.hbox_pb_search = hbox_create([])
        self.hbox_pb_search.setContentsMargins(20, 0, 20, 0)

        self.line = line_h_create('2px', '#000000')

        self.vbox_main.addLayout(self.hbox_search)
        self.vbox_main.addLayout(self.hbox_pb_search)
        self.vbox_main.addWidget(self.line)

        # Form Layout 1
        self.fm_1 = QFormLayout()
        self.fm_1.setContentsMargins(20, 20, 20, 20)
        self.fm_1.setSpacing(10)

        # Title
        self.lb_title = QLabel(texts.title_s)
        self.le_title = le_create(255)
        self.fm_1.setWidget(0, QFormLayout.LabelRole, self.lb_title)
        self.fm_1.setWidget(0, QFormLayout.FieldRole, self.le_title)

        # Year
        self.lb_year = QLabel(texts.year_s)
        self.le_year = le_create(4)
        self.fm_1.setWidget(1, QFormLayout.LabelRole, self.lb_year)
        self.fm_1.setWidget(1, QFormLayout.FieldRole, self.le_year)

        # Media
        self.lb_media = QLabel(texts.media_s)
        media = db_select_all(self.session, Media)
        self.cb_media = cb_create()
        populate_combobox(self.cb_media, media)
        self.fm_1.setWidget(2, QFormLayout.LabelRole, self.lb_media)
        self.fm_1.setWidget(2, QFormLayout.FieldRole, self.cb_media)

        # Category 1
        category = db_select_all(self.session, Category)
        self.lb_category_1 = QLabel(texts.category_1)
        self.cb_category_1 = cb_create()
        populate_combobox(self.cb_category_1, category)
        self.fm_1.setWidget(3, QFormLayout.LabelRole, self.lb_category_1)
        self.fm_1.setWidget(3, QFormLayout.FieldRole, self.cb_category_1)

        # Box
        box = db_select_all(self.session, Box)
        self.lb_box = QLabel(texts.box)
        self.cb_box = cb_create()
        populate_combobox(self.cb_box, box)
        self.fm_1.setWidget(4, QFormLayout.LabelRole, self.lb_box)
        self.fm_1.setWidget(4, QFormLayout.FieldRole, self.cb_box)

        # Poster
        self.lb_poster = QLabel(texts.poster)
        self.le_poster = le_create(255)
        self.fm_1.setWidget(5, QFormLayout.LabelRole, self.lb_poster)
        self.fm_1.setWidget(5, QFormLayout.FieldRole, self.le_poster)

        # Form Layout 2
        self.fm_2 = QFormLayout()
        self.fm_2.setContentsMargins(20, 20, 20, 20)
        self.fm_2.setSpacing(10)

        # Original Title
        self.lb_original_title = QLabel(texts.original_title_s)
        self.le_original_title = le_create(255)
        self.fm_2.setWidget(0, QFormLayout.LabelRole, self.lb_original_title)
        self.fm_2.setWidget(0, QFormLayout.FieldRole, self.le_original_title)

        # Director
        director = db_select_all(self.session, Director)
        self.lb_director = QLabel(texts.director_s)
        self.cb_director = cb_create()
        populate_combobox(self.cb_director, director)
        self.fm_2.setWidget(1, QFormLayout.LabelRole, self.lb_director)
        self.fm_2.setWidget(1, QFormLayout.FieldRole, self.cb_director)

        self.lb_time = QLabel(texts.lb_time)
        self.le_time = le_create(10, texts.time_tt)
        self.fm_2.setWidget(2, QFormLayout.LabelRole, self.lb_time)
        self.fm_2.setWidget(2, QFormLayout.FieldRole, self.le_time)

        # Category 2
        category = db_select_all(self.session, Category)
        self.lb_category_2 = QLabel(texts.category_1)
        self.cb_category_2 = cb_create()
        populate_combobox(self.cb_category_2, category)
        self.fm_2.setWidget(3, QFormLayout.LabelRole, self.lb_category_2)
        self.fm_2.setWidget(3, QFormLayout.FieldRole, self.cb_category_2)

        # KeyWord
        keyword = db_select_all(self.session, Keyword)
        self.lb_keyword = QLabel(texts.keyword)
        self.cb_keyword = cb_create()
        populate_combobox(self.cb_keyword, keyword)
        self.fm_2.setWidget(4, QFormLayout.LabelRole, self.lb_keyword)
        self.fm_2.setWidget(4, QFormLayout.FieldRole, self.cb_keyword)

        # Web URL
        self.lb_web_url = QLabel(texts.lb_url)
        self.le_web_url = le_create(255)
        self.fm_2.setWidget(5, QFormLayout.LabelRole, self.lb_web_url)
        self.fm_2.setWidget(5, QFormLayout.FieldRole, self.le_web_url)

        # Horizontal Layout for Frame layout
        self.hbox_fms = hbox_create([])
        self.hbox_fms.addLayout(self.fm_1)
        self.hbox_fms.addLayout(self.fm_2)

        self.vbox_main.addLayout(self.hbox_fms)

        # Cast Summary
        self.hbox_summary_cast = hbox_create([])
        self.hbox_summary_cast.setContentsMargins(20, 0, 20, 0)
        self.vbox_summary = QVBoxLayout()

        # Summary
        self.lb_summary = QLabel(texts.summary_s)
        self.le_summary = QTextEdit()
        self.vbox_summary.addWidget(self.lb_summary)
        self.vbox_summary.addWidget(self.le_summary)
        self.vbox_summary.setSpacing(20)
        self.hbox_summary_cast.addLayout(self.vbox_summary)
        self.hbox_summary_cast.setSpacing(20)

        # Cast Label Button
        self.vbox_cast = QVBoxLayout()

        self.lb_cast = QLabel(texts.cast_s)
        self.pb_add_row = QPushButton('+')
        self.pb_add_row.setToolTip(texts.pb_add_row_tt)
        self.pb_add_row.clicked.connect(self.table_add_rows)
        self.pb_add_row.setShortcut('Ctrl+T')

        self.hbox_cast = hbox_create([self.lb_cast, self.pb_add_row])
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        self.hbox_cast.addItem(spacer)

        self.vbox_cast.addLayout(self.hbox_cast)

        # Cast Table
        self.table = QTableWidget()
        self.table.setColumnCount(4)

        self.headers = [
            texts.actor_s,
            texts.character_s,
            texts.order,
            texts.star.capitalize(),
        ]
        self.table.setHorizontalHeaderLabels(self.headers)

        self.table.setColumnWidth(0, 0.30 * self.tb_width)
        self.table.setColumnWidth(1, 0.40 * self.tb_width)
        self.table.setColumnWidth(2, 0.15 * self.tb_width)
        self.table.setColumnWidth(3, 0.15 * self.tb_width)

        self.rows = 0
        self.cb_actor = []
        self.cb_character = []
        self.le_order = []
        self.chbox_star = []
        self.table_add_rows()

        self.vbox_cast.addWidget(self.table)
        self.hbox_summary_cast.addLayout(self.vbox_cast)

        self.vbox_main.addLayout(self.hbox_summary_cast)

        # Buttons Save Clear
        self.grid_layout = QGridLayout()
        self.grid_layout.setContentsMargins(10, 10, 10, 10)
        self.grid_layout.setSpacing(10)

        self.pb_save = pb_create(texts.pb_save, height=40)
        self.pb_save.clicked.connect(self.insert_movie)
        self.pb_save.setShortcut('Ctrl+S')
        self.grid_layout.addWidget(self.pb_save, 0, 0, 1, 1)

        self.pb_clear = pb_create(texts.pb_clear, height=40)
        self.pb_clear.clicked.connect(self.clear)
        self.pb_clear.setShortcut('Ctrl+L')
        self.grid_layout.addWidget(self.pb_clear, 0, 1, 1, 1)

        self.pb_help = pb_create(texts.pb_help, height=40)
        self.pb_help.clicked.connect(self.help)
        self.pb_help.setShortcut('Ctrl+H')
        self.grid_layout.addWidget(self.pb_help, 0, 2, 1, 1)

        self.pb_leave = pb_create(texts.pb_leave, height=40)
        self.pb_leave.clicked.connect(self.close)
        self.pb_leave.setShortcut('Ctrl+Q')
        self.grid_layout.addWidget(self.pb_leave, 0, 3, 1, 1)

        self.vbox_main.addLayout(self.grid_layout)

        # Tab Order
        self.le_title.setFocus()
        self.setTabOrder(self.le_title, self.le_original_title)
        self.setTabOrder(self.le_original_title, self.le_year)
        self.setTabOrder(self.le_year, self.cb_director)
        self.setTabOrder(self.cb_media, self.le_time)
        self.setTabOrder(self.le_time, self.cb_category_1)
        self.setTabOrder(self.cb_category_1, self.cb_category_2)
        self.setTabOrder(self.cb_category_2, self.cb_box)
        self.setTabOrder(self.cb_box, self.cb_keyword)
        self.setTabOrder(self.cb_keyword, self.le_poster)
        self.setTabOrder(self.le_poster, self.le_web_url)
        self.setTabOrder(self.le_web_url, self.le_summary)
Exemple #6
0
    season = relationship(Season, order_by='desc(Episode.code)')

    UniqueConstraint(season_id, code)

    def __repr__(self):
        return '<{0}: {1}>'.format(self.code, self.name)


if not install:
    from db.db_settings import Database

    db = Database()
    engine = db.get_engine()
    Base.metadata.create_all(engine)

    session = db.get_session()
    session.add_all([
        Media(name='Blu-Ray'),
        Media(name='DVD'),
        Media(name='HD'),
        Media(name='Web'),
    ])
    categories = [
        Category(name='Ação'),
        Category(name='Adulto'),
        Category(name='Aventura'),
        Category(name='Animação'),
        Category(name='Biografia'),
        Category(name='Comedia'),
        Category(name='Policial'),
        Category(name='Documentário'),
Exemple #7
0
    def __init__(self, main):
        """
        Search movie by title.

        :param main: Reference for main windows.
        """
        super(ViewSeriesSearchUrl, self).__init__()

        self.session = DB.get_session()
        self.main = main
        self.row_select = -1

        text = texts.series_s + ' ' + texts.search_web_url
        self.setWindowTitle(text)
        self.width = int(0.8 * main.frameSize().width())
        self.height = int(0.8 * main.frameSize().height())
        self.setGeometry(0, 0, self.width, self.height)

        self.subwindow = QWidget()
        p = self.palette()
        p.setColor(self.backgroundRole(), QColor(230, 230, 250))
        self.setPalette(p)
        self.setWidget(self.subwindow)

        self.vbox_main = QVBoxLayout(self.subwindow)
        self.vbox_main.setContentsMargins(20, 20, 20, 20)

        # Title
        self.lb_title = QLabel(texts.title_s)
        self.lb_title.setMaximumSize(QSize(100, 25))
        series = db_select_all(self.session, Series)
        self.cb_title = cb_create()
        populate_combobox(self.cb_title, series)

        # Words
        text = texts.or_s + ' ' + texts.with_the_p + ' ' + texts.term_p
        self.lb_term = QLabel(text)
        self.le_term = le_create(30, texts.with_term_tt)
        self.le_term.setPlaceholderText('pressione enter')
        self.le_term.editingFinished.connect(self.query_term)

        # HBoxSearch
        self.hbox_search = hbox_create(
            [self.lb_title, self.cb_title, self.lb_term, self.le_term])
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        self.hbox_search.addItem(spacer)

        self.vbox_main.addLayout(self.hbox_search)

        # total
        self.lb_total = QLabel(texts.lb_total)
        self.le_total = le_create(255)
        self.le_total.setMaximumWidth(100)

        # Buttons
        self.pb_clear = pb_create(texts.pb_clear, 11, 30)
        self.pb_clear.setMaximumWidth(100)
        self.pb_clear.setShortcut('Ctrl+L')
        self.pb_clear.clicked.connect(self.clear)
        self.pb_leave = pb_create(texts.pb_leave, 11, 30)
        self.pb_leave.setMaximumWidth(100)
        self.pb_leave.setShortcut('Ctrl+Q')
        self.pb_leave.clicked.connect(self.close)

        # Hbox_result
        self.hbox_result = hbox_create(
            [self.lb_total, self.le_total, self.pb_clear, self.pb_leave])
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        self.hbox_result.addItem(spacer)

        self.vbox_main.addLayout(self.hbox_result)

        # Table
        self.table = QTableWidget()
        self.table.horizontalHeader().sectionClicked.connect(
            self.repaint_cells)
        self.rows = 0
        self.clear_table()
        query = self.session.query(Series).all()
        self.set_table(query)

        self.vbox_main.addWidget(self.table)

        self.cb_title.currentIndexChanged.connect(self.query_title)
Exemple #8
0
    def __init__(self, main):
        """
        Class for edit creator.

        :param main: Reference for main windows.
        :param type: Type object, movie or series.
        """
        super(EditCreator, self).__init__()

        self.session = DB.get_session()
        self.main = main
        self.id = None
        self.series_creator = None

        title = texts.edit + texts.series_s + texts.creator_p
        self.setWindowTitle(title)
        width = int(0.4 * main.frameSize().width())
        height = int(0.6 * main.frameSize().height())
        self.setGeometry(0, 0, width, height)

        self.subwindow = QWidget()
        p = self.palette()
        p.setColor(self.backgroundRole(), QColor(230, 230, 250))
        self.setPalette(p)
        self.setWidget(self.subwindow)

        font = QFont()
        font.setPointSize(12)

        # Vbox Main
        self.vbox_main = QVBoxLayout(self.subwindow)
        self.vbox_main.setContentsMargins(20, 20, 20, 20)
        self.vbox_main.setSpacing(10)

        # Select Label and Combobox
        series = self.session.query(Series).all()
        self.lb_select = QLabel(texts.series_s)
        self.lb_select.setFont(font)
        self.lb_select.setFixedHeight(25)
        self.cb_select = cb_create('')
        self.cb_select.setFont(font)
        self.cb_select.setFixedHeight(30)
        populate_combobox(self.cb_select, series)
        self.vbox_main.addWidget(self.lb_select)
        self.vbox_main.addWidget(self.cb_select)

        self.lb_creator = QLabel(texts.creator_p)
        self.lb_creator.setFont(font)
        self.lb_creator.setFixedHeight(25)
        self.pb_add_row = pb_create('+', 11, 25, 50)
        self.pb_add_row.setToolTip(texts.pb_add_row_tt)
        self.pb_add_row.setShortcut('Ctrl+T')
        self.pb_add_row.clicked.connect(self.table_add_rows)

        self.hbox_creator = hbox_create([self.lb_creator, self.pb_add_row])
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        self.hbox_creator.addItem(spacer)

        self.vbox_main.addLayout(self.hbox_creator)

        # Creator Table
        self.table = QTableWidget()
        self.table.setColumnCount(3)
        self.table.setContentsMargins(20, 0, 0, 0)

        font = QFont()
        font.setPointSize(12)

        self.table.setHorizontalHeaderLabels([
            texts.creator_s,
            texts.order,
            'Del'
        ])

        # table set column width
        self.table.setColumnWidth(0, int(0.60 * (width - 50)))
        self.table.setColumnWidth(1, int(0.20 * (width - 50)))
        self.table.setColumnWidth(2, int(0.20 * (width - 50)))

        # self.table.horizontalHeader().setFixedHeight(30)
        self.table.horizontalHeader().setFont(font)
        self.table.horizontalHeader().setStyleSheet(
            'background-color: rgb(230, 230, 230);')
        self.table.verticalHeader().setVisible(False)

        self.vbox_main.addWidget(self.table)

        self.rows = 0
        self.chbox_count = 0
        self.cb_creator = []
        self.le = []
        self.chbox_del = []

        # Buttons Save Clear
        self.grid_layout = QGridLayout()
        self.grid_layout.setContentsMargins(0, 0, 0, 0)
        self.grid_layout.setSpacing(10)

        self.pb_save = pb_create(texts.pb_save, height=40)
        self.pb_save.clicked.connect(self.save_series_creator)
        self.pb_save.setShortcut('Ctrl+S')
        self.grid_layout.addWidget(self.pb_save, 0, 0, 1, 1)

        self.pb_clear = pb_create(texts.pb_clear, height=40)
        self.pb_clear.clicked.connect(self.clear)
        self.pb_clear.setShortcut('Ctrl+L')
        self.grid_layout.addWidget(self.pb_clear, 0, 1, 1, 1)

        self.pb_help = pb_create(texts.pb_help, height=40)
        self.pb_help.clicked.connect(self.help)
        self.pb_help.setShortcut('Ctrl+H')
        self.grid_layout.addWidget(self.pb_help, 0, 2, 1, 1)

        self.pb_leave = pb_create(texts.pb_leave, height=40)
        self.pb_leave.clicked.connect(self.close)
        self.pb_save.setShortcut('Ctrl+Q')
        self.grid_layout.addWidget(self.pb_leave, 0, 3, 1, 1)

        self.vbox_main.addLayout(self.grid_layout)

        self.cb_select.currentIndexChanged.connect(self.selected_series)
Exemple #9
0
    def __init__(self, main, type):
        """
        Search movie or series by categories.

        :param main: Reference for main windows.
        :param type: String if is "movie" then search for movie if not search
        by "series".
        """
        super(SearchMSCategory, self).__init__()

        self.session = DB.get_session()
        self.type = type
        self.main = main
        self.row_select = -1

        if self.type == 'movie':
            self.obj = self.session.query(Movie).order_by(Movie.category_1_id)
            name = texts.movie_p
        else:
            self.obj = self.session.query(Series).order_by(
                Series.category_1_id)
            name = texts.series_p

        windows_title = texts.search + ' ' + name + ' ' + texts.for_ \
                        + ' ' + texts.category_p
        self.setWindowTitle(windows_title)
        self.width = int(0.9 * main.frameSize().width())
        self.height = int(0.9 * main.frameSize().height())
        self.setGeometry(0, 0, self.width, self.height)

        self.subwindow = QWidget()
        p = self.palette()
        p.setColor(self.backgroundRole(), QColor(230, 230, 250))
        self.setPalette(p)
        self.setWidget(self.subwindow)

        self.vbox_main = QVBoxLayout(self.subwindow)
        self.vbox_main.setContentsMargins(20, 20, 20, 20)

        # Category
        self.lb_category = QLabel(texts.category_s)
        self.lb_category.setMaximumSize(QSize(100, 25))
        if self.type == 'movie':
            categories = self.session.query(Category). \
                filter(or_(Category.id == Movie.category_1_id,
                           Category.id == Movie.category_2_id)).\
                order_by(Category.name)
        else:
            categories = self.session.query(Category). \
                filter(or_(Category.id == Series.category_1_id,
                           Category.id == Series.category_2_id)).\
                order_by(Category.name)
        self.cb_category = cb_create()
        populate_combobox(self.cb_category, categories)

        # total
        self.lb_total = QLabel(texts.lb_total)
        self.lb_total.setMaximumSize(QSize(100, 25))
        self.le_total = le_create(255)

        # Buttons
        self.pb_clear = pb_create(texts.pb_clear, 11, 30)
        self.pb_clear.setShortcut('Ctrl+L')
        self.pb_clear.clicked.connect(self.clear)
        self.pb_leave = pb_create(texts.pb_leave, 11, 30)
        self.pb_leave.setShortcut('Ctrl+Q')
        self.pb_leave.clicked.connect(self.close)

        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)

        # Hbox
        self.hbox = hbox_create([
            self.lb_category, self.cb_category, self.lb_total, self.le_total,
            self.pb_clear, self.pb_leave
        ])
        self.hbox.addSpacerItem(spacer)
        self.vbox_main.addLayout(self.hbox)

        # Table
        self.table = QTableWidget()
        self.table.setObjectName('table-search')
        self.rows = 0

        self.clear_table()
        self.set_table(self.obj)

        self.vbox_main.addWidget(self.table)

        self.cb_category.currentIndexChanged.connect(self.query_category)
Exemple #10
0
    def __init__(self, main):
        """
        Search movie by title.

        :param main: Reference for main windows.
        """
        super(SearchMovieBox, self).__init__()

        self.session = DB.get_session()
        self.main = main
        self.row_select = -1
        self.movies = self.session.query(Movie).\
            filter(Movie.box_id == Box.id).all()

        windows_title = texts.search + ' ' + texts.movie_s + ' ' + \
                        texts.for_ + ' ' + texts.box

        self.setWindowTitle(windows_title)
        self.width = int(0.9 * main.frameSize().width())
        self.height = int(0.9 * main.frameSize().height())
        self.setGeometry(0, 0, self.width, self.height)

        self.subwindow = QWidget()
        p = self.palette()
        p.setColor(self.backgroundRole(), QColor(230, 230, 250))
        self.setPalette(p)
        self.setWidget(self.subwindow)

        self.vbox_main = QVBoxLayout(self.subwindow)
        self.vbox_main.setContentsMargins(20, 20, 20, 20)

        # Title
        self.lb_box = QLabel(texts.box)
        self.lb_box.setMaximumSize(QSize(100, 25))
        box = db_select_all(self.session, Box)
        self.cb_box = cb_create()
        populate_combobox(self.cb_box, box)

        # Words
        text = texts.or_s + ' ' + texts.with_the_p + ' ' + texts.term_p
        self.lb_term = QLabel(text)
        self.le_term = le_create(30, texts.with_term_tt)
        self.le_term.setPlaceholderText('pressione enter')
        self.le_term.editingFinished.connect(self.query_term)

        # HBoxSearch
        self.hbox_search = hbox_create(
            [self.lb_box, self.cb_box, self.lb_term, self.le_term])
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        self.hbox_search.addItem(spacer)

        self.vbox_main.addLayout(self.hbox_search)

        # total
        self.lb_total = QLabel(texts.lb_total)
        self.le_total = le_create(255)
        self.le_total.setMaximumWidth(100)

        # Buttons
        self.pb_clear = pb_create(texts.pb_clear, 11, 30)
        self.pb_clear.setMaximumWidth(100)
        self.pb_clear.setShortcut('Ctrl+L')
        self.pb_clear.clicked.connect(self.clear)
        self.pb_leave = pb_create(texts.pb_leave, 11, 30)
        self.pb_leave.setMaximumWidth(100)
        self.pb_leave.setShortcut('Ctrl+Q')
        self.pb_leave.clicked.connect(self.close)

        # Hbox_result
        self.hbox_result = hbox_create(
            [self.lb_total, self.le_total, self.pb_clear, self.pb_leave])
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        self.hbox_result.addItem(spacer)

        self.vbox_main.addLayout(self.hbox_result)

        # Table
        self.table = QTableWidget()
        self.table.setObjectName('table-search')
        self.rows = 0
        self.clear_table()
        movies = self.session.query(Movie).filter(
            Movie.box_id.isnot(None)).all()
        self.set_table(movies)

        self.vbox_main.addWidget(self.table)

        self.cb_box.currentIndexChanged.connect(self.query_box)
Exemple #11
0
    def __init__(self, main, op):
        """
        Class for edit category, actor, character, box, media and keyword
        according given op.

        :param main: Reference for main windows.
        :param op: String representing the class to be edited.
        """
        super(EditOthers, self).__init__()

        self.main = main
        self.op = op
        self.session = DB.get_session()
        self.cls = None
        self.obj = None

        self.name = ''
        if self.op == 'category':
            self.cls = Category
            self.name = texts.category_s
        elif self.op == 'actor':
            self.cls = Actor
            self.name = texts.actor_s
        elif self.op == 'character':
            self.cls = Character
            self.name = texts.character_s
        elif self.op == 'box':
            self.cls = Box
            self.name = texts.box
        elif self.op == 'media':
            self.cls = Media
            self.name = texts.media_s
        elif self.op == 'keyword':
            self.cls = Keyword
            self.name = texts.keyword

        self.window_title = texts.edit + ' ' + self.name
        self.setWindowTitle(self.window_title)
        self.setGeometry(0, 0, 511, 205)

        self.subwindow = QWidget()
        p = self.palette()
        p.setColor(self.backgroundRole(), QColor(230, 230, 250))
        self.setPalette(p)
        self.setWidget(self.subwindow)

        font = QFont()
        font.setPointSize(11)

        # Vbox Main
        self.vbox_main = QVBoxLayout(self.subwindow)
        self.vbox_main.setContentsMargins(20, 20, 20, 20)
        self.vbox_main.setSpacing(10)

        # Select Label and Combobox
        objs = db_select_all(self.session, self.cls)
        text = texts.select + ' ' + self.name
        self.lb_select = QLabel(text)
        self.lb_select.setFont(font)
        self.lb_select.setFixedHeight(25)
        self.cb_select = cb_create('')
        self.cb_select.setFont(font)
        self.cb_select.setFixedHeight(30)
        populate_combobox(self.cb_select, objs)
        self.cb_select.setEditable(False)
        self.vbox_main.addWidget(self.lb_select)
        self.vbox_main.addWidget(self.cb_select)

        # PB Select
        self.pb_select = pb_create(texts.pb_leave)
        self.pb_select.setFixedHeight(40)
        self.pb_select.setEnabled(True)
        self.pb_select.setHidden(False)
        self.pb_select.clicked.connect(self.close)

        self.pb_help_1 = pb_create(texts.pb_help)
        self.pb_help_1.setFixedHeight(40)
        self.pb_help_1.setEnabled(True)
        self.pb_help_1.setHidden(False)
        self.pb_help_1.clicked.connect(self.help)
        self.pb_help_1.setShortcut('Ctrl+H')

        self.hbox_select = QHBoxLayout()
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        self.hbox_select.addItem(spacer)
        self.hbox_select.addWidget(self.pb_select)
        self.hbox_select.addWidget(self.pb_help_1)
        self.hbox_select.addItem(spacer)
        self.vbox_main.addLayout(self.hbox_select)

        # Title
        text = texts.actual_value + ' ' + self.name
        self.lb = QLabel(text)
        self.lb.setFont(font)
        self.lb.setFixedHeight(25)
        self.le = le_create()
        self.le.setFont(font)
        self.lb.setEnabled(False)
        self.lb.setHidden(True)
        self.le.setEnabled(False)
        self.le.setHidden(True)
        self.vbox_main.addWidget(self.lb)
        self.vbox_main.addWidget(self.le)

        # Buttons
        self.pb_save = pb_create(texts.pb_save)
        self.pb_save.setShortcut('Ctrl+S')
        self.pb_save.clicked.connect(self.edit_object)
        self.pb_save.setMaximumHeight(40)

        self.pb_help_2 = pb_create(texts.pb_help)
        self.pb_help_2.clicked.connect(self.help)
        self.pb_help_2.setShortcut('Ctrl+H')
        self.pb_help_2.setMaximumHeight(40)

        self.pb_leave = pb_create(texts.pb_leave)
        self.pb_leave.clicked.connect(self.close)
        self.pb_leave.setShortcut('Ctrl+Q')
        self.pb_leave.setMaximumHeight(40)

        self.hb_pb = hbox_create([self.pb_save, self.pb_help_2, self.pb_leave])

        self.pb_save.setEnabled(False)
        self.pb_save.setHidden(True)
        self.pb_help_2.setEnabled(False)
        self.pb_help_2.setHidden(True)
        self.pb_leave.setEnabled(False)
        self.pb_leave.setHidden(True)

        self.vbox_main.addLayout(self.hb_pb)

        self.cb_select.currentIndexChanged.connect(self.obj_selected)
Exemple #12
0
    def __init__(self, main, type):
        """
        Search movie or series by title.

        :param main: Reference for main windows.
        :param type: String if is "movie" then search for movie if not search
        by "series".
        """
        super(SearchMSTitle, self).__init__()

        self.session = DB.get_session()
        self.type = type
        self.main = main
        self.row_select = -1

        if self.type == 'movie':
            self.obj = self.session.query(Movie).order_by(Movie.name)
            name = texts.movie_p
        else:
            self.obj = self.session.query(Series).order_by(Series.name)
            name = texts.series_p

        windows_title = texts.search + ' ' + name + ' ' + texts.for_ \
                        + ' ' + texts.title_p
        self.setWindowTitle(windows_title)
        self.width = int(0.9 * main.frameSize().width())
        self.height = int(0.9 * main.frameSize().height())
        self.setGeometry(0, 0, self.width, self.height)

        self.subwindow = QWidget()
        p = self.palette()
        p.setColor(self.backgroundRole(), QColor(230, 230, 250))
        self.setPalette(p)
        self.setWidget(self.subwindow)

        self.vbox_main = QVBoxLayout(self.subwindow)
        self.vbox_main.setContentsMargins(20, 20, 20, 20)

        # Title
        self.lb_title = QLabel(texts.title_s)
        self.lb_title.setMaximumSize(QSize(100, 25))
        self.cb_title = cb_create()
        self.cb_title.addItem('', 0)
        for ms in self.obj:
            self.cb_title.addItem(ms.name, ms.id)

        # Words
        text = texts.or_s + ' ' + texts.with_the_p + ' ' + texts.term_p
        self.lb_term = QLabel(text)
        self.le_term = le_create(30, texts.with_term_tt)
        self.le_term.setPlaceholderText('pressione enter')
        #

        # HBoxSearch
        self.hbox_search = hbox_create(
            [self.lb_title, self.cb_title, self.lb_term, self.le_term])
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        self.hbox_search.addItem(spacer)

        self.vbox_main.addLayout(self.hbox_search)

        # total
        self.lb_total = QLabel(texts.lb_total)
        self.le_total = le_create(255)
        self.le_total.setMaximumWidth(100)

        # Buttons
        self.pb_clear = pb_create(texts.pb_clear, 11, 30)
        self.pb_clear.setMaximumWidth(100)
        self.pb_clear.setShortcut('Ctrl+L')
        # self.pb_clear.clicked.connect(self.clear)
        self.pb_leave = pb_create(texts.pb_leave, 11, 30)
        self.pb_leave.setMaximumWidth(100)
        self.pb_leave.setShortcut('Ctrl+Q')
        self.pb_leave.clicked.connect(self.close)

        # Hbox_result
        self.hbox_result = hbox_create(
            [self.lb_total, self.le_total, self.pb_clear, self.pb_leave])
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        self.hbox_result.addItem(spacer)

        self.vbox_main.addLayout(self.hbox_result)

        # Table
        self.table = QTableWidget()
        self.table.setObjectName('table-search')
        self.rows = 0
        self.clear_table()

        self.set_table(self.obj)

        self.vbox_main.addWidget(self.table)

        self.cb_title.currentIndexChanged.connect(self.query_title)
        self.le_term.editingFinished.connect(self.query_term)
Exemple #13
0
    def __init__(self, main):
        """
        Class for edit series.

        :param main: Reference for main windows.
        """
        super(EditSeries, self).__init__()

        self.session = DB.get_session()
        self.series = None
        self.cb_categories = []
        self.cast_values = []
        self.main = main

        windows_title = texts.edit + ' ' + texts.series_p
        self.setWindowTitle(windows_title)
        width = int(0.95 * main.frameSize().width())
        height = int(0.8 * main.frameSize().height())
        self.setGeometry(0, 0, width, height)
        table_width = (0.5 * width) - 50

        self.subwindow = QWidget()
        p = self.palette()
        p.setColor(self.backgroundRole(), QColor(230, 230, 250))
        self.setPalette(p)
        self.setWidget(self.subwindow)

        self.vbox_main = QVBoxLayout(self.subwindow)

        # Select Label and Combobox
        series = db_select_all(self.session, Series)
        self.lb_select = QLabel(texts.series_s)
        self.cb_select = cb_create()
        populate_combobox(self.cb_select, series)

        self.hbox_select = hbox_create([self.lb_select, self.cb_select])
        spacer_item = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        self.hbox_select.addItem(spacer_item)

        self.hbox_select.setContentsMargins(20, 20, 20, 0)

        self.line = line_h_create('2px', '#000000')

        self.vbox_main.addLayout(self.hbox_select)
        self.vbox_main.addWidget(self.line)

        # Form Layout 1
        self.fm_1 = QFormLayout()
        self.fm_1.setContentsMargins(20, 20, 20, 20)
        self.fm_1.setSpacing(10)

        # Title
        self.lb_title = QLabel(texts.title_s)
        self.le_title = le_create(255)
        self.fm_1.setWidget(0, QFormLayout.LabelRole, self.lb_title)
        self.fm_1.setWidget(0, QFormLayout.FieldRole, self.le_title)

        # Year
        self.lb_year = QLabel(texts.year_s)
        self.le_year = le_create(4)
        self.fm_1.setWidget(1, QFormLayout.LabelRole, self.lb_year)
        self.fm_1.setWidget(1, QFormLayout.FieldRole, self.le_year)

        # Media
        self.lb_media = QLabel(texts.media_s)
        media = db_select_all(self.session, Media)
        self.cb_media = cb_create()
        populate_combobox(self.cb_media, media)
        self.fm_1.setWidget(2, QFormLayout.LabelRole, self.lb_media)
        self.fm_1.setWidget(2, QFormLayout.FieldRole, self.cb_media)

        # Category 1
        category = db_select_all(self.session, Category)
        self.lb_category_1 = QLabel(texts.category_1)
        self.cb_category_1 = cb_create()
        populate_combobox(self.cb_category_1, category)
        self.fm_1.setWidget(3, QFormLayout.LabelRole, self.lb_category_1)
        self.fm_1.setWidget(3, QFormLayout.FieldRole, self.cb_category_1)

        # Poster
        self.lb_poster = QLabel(texts.poster)
        self.le_poster = le_create(255)
        self.fm_1.setWidget(4, QFormLayout.LabelRole, self.lb_poster)
        self.fm_1.setWidget(4, QFormLayout.FieldRole, self.le_poster)

        # Search URL
        self.lb_search_url = QLabel(texts.lb_search_url)
        self.le_search_url = le_create(255)
        self.fm_1.setWidget(5, QFormLayout.LabelRole, self.lb_search_url)
        self.fm_1.setWidget(5, QFormLayout.FieldRole, self.le_search_url)

        # Web URL
        self.lb_web_url = QLabel(texts.lb_url)
        self.le_web_url = le_create(255)
        self.fm_1.setWidget(6, QFormLayout.LabelRole, self.lb_web_url)
        self.fm_1.setWidget(6, QFormLayout.FieldRole, self.le_web_url)

        # Form Layout 2
        self.fm_2 = QFormLayout()
        self.fm_2.setContentsMargins(20, 20, 20, 20)
        self.fm_2.setSpacing(10)

        # Original Title
        self.lb_original_title = QLabel(texts.original_title_s)
        self.le_original_title = le_create(255)
        self.fm_2.setWidget(0, QFormLayout.LabelRole, self.lb_original_title)
        self.fm_2.setWidget(0, QFormLayout.FieldRole, self.le_original_title)

        # Seasons
        self.lb_seasons = QLabel(texts.season_p)
        self.le_seasons = le_create(tooltip=texts.season_num_tt)
        self.fm_2.setWidget(1, QFormLayout.LabelRole, self.lb_seasons)
        self.fm_2.setWidget(1, QFormLayout.FieldRole, self.le_seasons)

        # Director
        self.lb_creator = QLabel(texts.director_s)
        self.le_creator = le_create(tooltip=texts.director_tt)
        self.le_creator.setReadOnly(True)
        self.fm_2.setWidget(2, QFormLayout.LabelRole, self.lb_creator)
        self.fm_2.setWidget(2, QFormLayout.FieldRole, self.le_creator)

        # Category 2
        category = db_select_all(self.session, Category)
        self.lb_category_2 = QLabel(texts.category_1)
        self.cb_category_2 = cb_create()
        populate_combobox(self.cb_category_2, category)
        self.fm_2.setWidget(3, QFormLayout.LabelRole, self.lb_category_2)
        self.fm_2.setWidget(3, QFormLayout.FieldRole, self.cb_category_2)

        # KeyWord
        keyword = db_select_all(self.session, Keyword)
        self.lb_keyword = QLabel(texts.keyword)
        self.cb_keyword = cb_create()
        populate_combobox(self.cb_keyword, keyword)
        self.fm_2.setWidget(4, QFormLayout.LabelRole, self.lb_keyword)
        self.fm_2.setWidget(4, QFormLayout.FieldRole, self.cb_keyword)

        # Search Url Label
        self.lb_url = QLabel('Wait URL')
        self.lb_url.setMaximumWidth(170)
        self.lb_url.setOpenExternalLinks(True)
        self.lb_url.setStyleSheet("padding: 4px; "
                                  "border: 1px solid black; "
                                  "background-color: rgb(219, 219, 219); "
                                  "color : blue;")

        self.fm_2.setWidget(5, QFormLayout.LabelRole, self.lb_url)

        # Horizontal Layout for Frame layout
        self.hbox_fms = hbox_create([])
        self.hbox_fms.addLayout(self.fm_1)
        self.hbox_fms.addLayout(self.fm_2)

        self.vbox_main.addLayout(self.hbox_fms)

        # Cast Summary
        self.hbox_summary_cast = hbox_create([], 0)
        self.hbox_summary_cast.setContentsMargins(20, 0, 20, 0)
        self.vbox_summary = QVBoxLayout()

        # Summary
        self.lb_summary = QLabel(texts.summary_s)
        self.le_summary = QTextEdit()
        self.vbox_summary.addWidget(self.lb_summary)
        self.vbox_summary.addWidget(self.le_summary)
        self.vbox_summary.setSpacing(20)
        self.hbox_summary_cast.addLayout(self.vbox_summary)
        self.hbox_summary_cast.setSpacing(20)

        # Horizontal Layout for Frame layout
        self.hbox_fms = hbox_create([])
        self.hbox_fms.addLayout(self.fm_1)
        self.hbox_fms.addLayout(self.fm_2)

        self.vbox_main.addLayout(self.hbox_fms)

        # Cast Summary
        self.hbox_summary_cast = hbox_create([])
        self.hbox_summary_cast.setContentsMargins(20, 0, 20, 0)
        self.vbox_summary = QVBoxLayout()

        # Summary
        self.lb_summary = QLabel(texts.summary_s)
        self.le_summary = QTextEdit()
        self.vbox_summary.addWidget(self.lb_summary)
        self.vbox_summary.addWidget(self.le_summary)
        self.vbox_summary.setSpacing(20)
        self.hbox_summary_cast.addLayout(self.vbox_summary)
        self.hbox_summary_cast.setSpacing(20)

        # Cast Label Button
        self.vbox_cast = QVBoxLayout()

        self.lb_cast = QLabel()
        self.lb_cast.setText(texts.lb_no_edit_cast)

        self.hbox_cast = hbox_create([self.lb_cast])
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        self.hbox_cast.addItem(spacer)

        self.vbox_cast.addLayout(self.hbox_cast)

        # Cast Table
        self.table = QTableWidget()
        self.table.setColumnCount(3)

        self.headers = [
            texts.actor_s.lower(),
            texts.character_s.lower(),
            texts.star.lower()
        ]
        self.table.setHorizontalHeaderLabels(self.headers)

        self.table.setColumnWidth(0, 0.45 * table_width)
        self.table.setColumnWidth(1, 0.45 * table_width)
        self.table.setColumnWidth(2, 0.10 * table_width)

        self.vbox_cast.addWidget(self.table)
        self.hbox_summary_cast.addLayout(self.vbox_cast)

        self.rows = 0

        self.vbox_main.addLayout(self.hbox_summary_cast)

        # Buttons Save Clear
        self.grid_layout = QGridLayout()
        self.grid_layout.setContentsMargins(10, 10, 10, 10)
        self.grid_layout.setSpacing(10)

        self.pb_save = pb_create(texts.pb_save, height=40)
        self.pb_save.clicked.connect(self.edit_series)
        self.pb_save.setShortcut('Ctrl+S')
        self.grid_layout.addWidget(self.pb_save, 0, 0, 1, 1)

        self.pb_delete = pb_create(texts.pb_delete, height=40)
        self.pb_delete.clicked.connect(self.delete_series)
        self.pb_delete.setShortcut('Ctrl+Shift+D')
        self.grid_layout.addWidget(self.pb_delete, 0, 1, 1, 1)

        self.pb_clear = pb_create(texts.pb_clear, height=40)
        self.pb_clear.clicked.connect(self.clear)
        self.pb_clear.setShortcut('Ctrl+L')
        self.grid_layout.addWidget(self.pb_clear, 0, 2, 1, 1)

        self.pb_help = pb_create(texts.pb_help, height=40)
        self.pb_help.clicked.connect(self.help)
        self.pb_help.setShortcut('Ctrl+H')
        self.grid_layout.addWidget(self.pb_help, 0, 3, 1, 1)

        self.pb_leave = pb_create(texts.pb_leave, height=40)
        self.pb_leave.clicked.connect(self.close)
        self.pb_leave.setShortcut('Ctrl+E')
        self.grid_layout.addWidget(self.pb_leave, 0, 4, 1, 1)

        self.vbox_main.addLayout(self.grid_layout)

        # Tab Order
        self.le_title.setFocus()
        self.setTabOrder(self.le_title, self.le_original_title)
        self.setTabOrder(self.le_original_title, self.le_year)
        self.setTabOrder(self.le_year, self.cb_media)
        self.setTabOrder(self.cb_media, self.le_seasons)
        self.setTabOrder(self.le_seasons, self.cb_category_1)
        self.setTabOrder(self.cb_category_1, self.cb_category_2)
        self.setTabOrder(self.cb_category_2, self.cb_keyword)
        self.setTabOrder(self.cb_keyword, self.le_web_url)
        self.setTabOrder(self.le_web_url, self.le_poster)
        self.setTabOrder(self.le_poster, self.le_search_url)

        self.cb_select.currentIndexChanged.connect(self.fill_series)

        # Resize Event
        def resizeEvent(self, event):
            """
            Resize actors and character combobox in table cast if windows resize.

            :param event: Window.
            """
            width = event.size().width()
            self.tb_width = (0.5 * width) - 50
            self.table.setColumnWidth(0, 0.30 * self.tb_width)
            self.table.setColumnWidth(1, 0.40 * self.tb_width)
            self.table.setColumnWidth(2, 0.15 * self.tb_width)
            self.table.setColumnWidth(3, 0.15 * self.tb_width)

            # Important don't delete it
            QMdiSubWindow.resizeEvent(self, event)
Exemple #14
0
    def __init__(self, main, type):
        """
        Search movie by title.

        :param main: Reference for main windows.
        """
        super(SearchMSMediaYear, self).__init__()

        self.session = DB.get_session()
        self.main = main
        self.type = type
        self.row_select = -1

        if self.type == 'movie':
            self.obj = self.session.query(Movie).order_by(desc(
                Movie.year)).all()
            name = texts.movie_p
        else:
            self.obj = self.session.query(Series).order_by(desc(
                Series.year)).all()
            name = texts.series_p

        windows_title = texts.search + ' ' + name + ' ' + \
                        texts.for_ + ' ' + texts.media_s + '/' + texts.year_s

        self.setWindowTitle(windows_title)
        self.width = int(0.9 * main.frameSize().width())
        self.height = int(0.9 * main.frameSize().height())
        self.setGeometry(0, 0, self.width, self.height)

        self.subwindow = QWidget()
        p = self.palette()
        p.setColor(self.backgroundRole(), QColor(230, 230, 250))
        self.setPalette(p)
        self.setWidget(self.subwindow)

        self.vbox_main = QVBoxLayout(self.subwindow)
        self.vbox_main.setContentsMargins(20, 20, 20, 20)

        # Media
        self.lb_media = QLabel(texts.media_s)
        self.lb_media.setMaximumSize(QSize(100, 25))
        if self.type == 'movie':
            media = self.session.query(Media).\
                filter(Media.id == Movie.media_id)
        else:
            media = self.session.query(Media). \
                filter(Media.id == Series.media_id)
        self.cb_media = cb_create()
        self.cb_media.setMaximumWidth(300)
        populate_combobox(self.cb_media, media)

        # Year
        self.lb_year = QLabel(texts.year_s)
        self.cb_year = QComboBox()
        self.cb_year.addItem('', 0)
        self.cb_year.setMinimumWidth(100)

        if self.type == 'movie':
            years = self.session.query(Movie.year).distinct().\
                order_by(desc(Movie.year)).all()
            years = [y[0] for y in years]
        else:
            years = self.session.query(Series.year).distinct().order_by(
                desc(Series.year)).all()
            years = [y[0] for y in years]

        self.cb_year.addItems(years)

        self.hbox_my = hbox_create(
            [self.lb_media, self.cb_media, self.lb_year, self.cb_year])
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        self.hbox_my.addItem(spacer)

        self.vbox_main.addLayout(self.hbox_my)

        # total
        self.lb_total = QLabel(texts.lb_total)
        self.le_total = le_create(255)
        self.le_total.setMaximumWidth(100)

        # Buttons
        self.pb_clear = pb_create(texts.pb_clear, 11, 30)
        self.pb_clear.setMaximumWidth(100)
        self.pb_clear.setShortcut('Ctrl+L')
        self.pb_clear.clicked.connect(self.clear)
        self.pb_leave = pb_create(texts.pb_leave, 11, 30)
        self.pb_leave.setMaximumWidth(100)
        self.pb_leave.setShortcut('Ctrl+Q')
        self.pb_leave.clicked.connect(self.close)

        # Hbox result
        self.hbox_result = hbox_create(
            [self.lb_total, self.le_total, self.pb_clear, self.pb_leave])
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        self.hbox_result.addItem(spacer)

        self.vbox_main.addLayout(self.hbox_result)

        # Table
        self.table = QTableWidget()
        self.table.setObjectName('table-search')
        if self.type == 'movie':
            self.num_col = 6
        else:
            self.num_col = 5
        self.rows = 0
        self.clear_table()

        self.set_table(self.obj)

        self.vbox_main.addWidget(self.table)

        self.cb_media.currentIndexChanged.connect(self.query_media)
        self.cb_year.currentIndexChanged.connect(self.query_year)
Exemple #15
0
    def __init__(self, main):
        """
        Class for edit movie or series cast.

        :param main: Reference for main windows.
        :param type: Type object, movie or series.
        """
        super(EditSeasonCast, self).__init__()

        self.main = main
        self.session = DB.get_session()
        self.id = None
        self.season_cast = None
        self.actor = self.session.query(Actor).order_by(Actor.name).all()
        self.character = self.session.query(Character).order_by(
            Character.name).all()

        windows_title = texts.season_p + ' ' + texts.cast_s

        self.setWindowTitle(windows_title)
        width = int(0.6 * main.frameSize().width())
        height = int(0.8 * main.frameSize().height())
        self.setGeometry(0, 0, width, height)

        self.subwindow = QWidget()
        p = self.palette()
        p.setColor(self.backgroundRole(), QColor(230, 230, 250))
        self.setPalette(p)
        self.setWidget(self.subwindow)

        font = QFont()
        font.setPointSize(11)

        # Vbox Main
        self.vbox_main = QVBoxLayout(self.subwindow)
        self.vbox_main.setContentsMargins(20, 20, 20, 20)
        self.vbox_main.setSpacing(10)

        # Series
        series = db_select_all(self.session, Series)

        self.lb_series = QLabel(texts.series_p)
        self.lb_series.setFont(font)
        self.lb_series.setFixedHeight(25)
        self.cb_series = cb_create('')
        self.cb_series.setFont(font)
        self.cb_series.setFixedHeight(30)
        populate_combobox(self.cb_series, series)

        self.hbox_1 = hbox_create([self.lb_series, self.cb_series])

        self.lb_seasons = QLabel(texts.season_p)
        self.cb_seasons = cb_create('')

        self.hbox_2 = hbox_create([self.lb_seasons, self.cb_seasons])

        self.vbox_main.addLayout(self.hbox_1)
        self.vbox_main.addLayout(self.hbox_2)

        # Cast Table Add Row
        self.lb_cast = QLabel(texts.cast_s)
        self.lb_cast.setFont(font)
        self.lb_cast.setFixedHeight(25)
        self.pb_add_row = pb_create('+', 11, 25, 50)
        self.pb_add_row.setToolTip(texts.pb_add_row_tt)
        self.pb_add_row.setShortcut('Ctrl+T')
        self.pb_add_row.clicked.connect(self.table_add_rows)

        self.hbox_cast = hbox_create([self.lb_cast, self.pb_add_row])
        spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                             QSizePolicy.Minimum)
        self.hbox_cast.addItem(spacer)

        self.vbox_main.addLayout(self.hbox_cast)

        # Cast Table
        self.table = QTableWidget()
        self.table.setColumnCount(5)
        self.table.setContentsMargins(20, 0, 0, 0)

        font = QFont()
        font.setPointSize(12)

        self.headers = [
            texts.actor_s,
            texts.character_s,
            texts.order,
            texts.star.capitalize(),
            'Del'
        ]
        self.table.setHorizontalHeaderLabels(self.headers)

        # table set column width
        self.table.setColumnWidth(0, int(0.25 * (width - 50)))
        self.table.setColumnWidth(1, int(0.45 * (width - 50)))
        self.table.setColumnWidth(2, int(0.10 * (width - 50)))
        self.table.setColumnWidth(3, int(0.10 * (width - 50)))
        self.table.setColumnWidth(4, int(0.10 * (width - 45)))

        # self.table.horizontalHeader().setFixedHeight(30)
        self.table.horizontalHeader().setFont(font)
        self.table.horizontalHeader().setStyleSheet(
            'background-color: rgb(230, 230, 230);')
        self.table.verticalHeader().setVisible(False)

        self.vbox_main.addWidget(self.table)

        self.rows = 0
        self.cb_count = 0
        self.ch_del_count = 0
        self.cb_actor = []
        self.cb_character = []
        self.le_order = []
        self.chbox_star = []
        self.chbox_del = []

        # Buttons Save Clear
        self.grid_layout = QGridLayout()
        self.grid_layout.setContentsMargins(0, 0, 0, 0)
        self.grid_layout.setSpacing(10)

        self.pb_save = pb_create(texts.pb_save, height=40)
        self.pb_save.clicked.connect(self.save_cast)
        self.pb_save.setShortcut('Ctrl+S')
        self.grid_layout.addWidget(self.pb_save, 0, 0, 1, 1)

        self.pb_clear = pb_create(texts.pb_clear, height=40)
        self.pb_clear.clicked.connect(self.clear)
        self.pb_clear.setShortcut('Ctrl+L')
        self.grid_layout.addWidget(self.pb_clear, 0, 1, 1, 1)

        self.pb_help = pb_create(texts.pb_help, height=40)
        self.pb_help.clicked.connect(self.help)
        self.pb_help.setShortcut('Ctrl+H')
        self.grid_layout.addWidget(self.pb_help, 0, 2, 1, 1)

        self.pb_leave = pb_create(texts.pb_leave, height=40)
        self.pb_leave.clicked.connect(self.close)
        self.pb_save.setShortcut('Ctrl+Q')
        self.grid_layout.addWidget(self.pb_leave, 0, 3, 1, 1)

        self.vbox_main.addLayout(self.grid_layout)

        self.cb_series.currentIndexChanged.connect(self.selected_series)