# Path: dunyadesktop_app/widgets/combobox.py
# class ComboBox(QComboBox):
#     """Combobox of the attributes."""
#     def __init__(self, parent):
#         QComboBox.__init__(self, parent)
#         self.setEditable(True)
#         self.setInsertPolicy(QComboBox.NoInsert)
# 
#         if platform.system() == 'Linux':
#             self.setFixedHeight(23)
#         else:
#             self.setFixedHeight(25)
# 
#         self._set_cancel_button()
# 
#         # signals
#         self.currentIndexChanged.connect(self.change_lineedit_status)
#         self.cancel_button.clicked.connect(self.reset_attribute_selection)
#         self.lineEdit().textEdited.connect(lambda:
#                                            self.cancel_button.setVisible(True))
#         self.lineEdit().editingFinished.connect(self.check_lineedit_status)
#         self.dialog_filtering = FilteringDialog(self)
#         self.dialog_filtering.ok_button_clicked.connect(
#             lambda: self.set_selection(self.dialog_filtering.selection))
# 
#     def _set_cancel_button(self):
#         self.cancel_button = QToolButton(self)
#         self.cancel_button.setIcon(QIcon(ICON_PATH_CANCEL))
#         self.cancel_button.setVisible(False)
# 
#     def resizeEvent(self, QResizeEvent):
#         """Sets the position of cancel button."""
#         button_size = self.cancel_button.sizeHint()
#         frame_width = self.lineEdit().style().pixelMetric(
#             QStyle.PM_DefaultFrameWidth)
#         self.cancel_button.move(
#             self.rect().right() - BUTTON_POS * frame_width-button_size.width(),
#             (self.rect().bottom() - button_size.height() + 1) / 2)
#         super(ComboBox, self).resizeEvent(QResizeEvent)
# 
#     def wheelEvent(self, QWheelEvent):
#         """Wheel event of mouse is disabled."""
#         pass
# 
#     def mousePressEvent(self, QMouseEvent):
#         """Popups the filtering dialog when the combobox is clicked."""
#         self.dialog_filtering.attribute = self.attribute
#         self.dialog_filtering.setWindowTitle("")
#         self.dialog_filtering.filtering_model.add_items(self.attribute)
#         self.dialog_filtering.move(QMouseEvent.globalPos().x(),
#                                    QMouseEvent.globalPos().y())
#         self.dialog_filtering.show()
# 
#     def set_placeholder_text(self, text):
#         font = QFont()
#         font.setPointSize(FONT_SIZE)
# 
#         self.lineEdit().setPlaceholderText(text)
#         self.lineEdit().setFont(font)
# 
#     def add_items(self, attribute):
#         """Adds the items of given attribute to the combobox"""
#         self.attribute = attribute
#         for att in self.attribute:
#             self.addItem(att['name'])
#         self.setCurrentIndex(-1)
# 
#     def get_attribute_id(self):
#         """Returns the id of selected item"""
#         index = self.currentIndex()
#         if index is not -1:
#             try:
#                 return self.attribute[index]['uuid']
#             except:
#                 return self.attribute[index]['mbid']
#         else:
#             return ''
# 
#     def set_selection(self, index):
#         """Sets the selected item on the combobox."""
#         try:
#             index_row = index.row()
#         except:
#             index_row = index
#         self.setCurrentIndex(index_row)
#         self.lineEdit().setText(self.attribute[index_row]['name'])
#         self.cancel_button.setVisible(True)
# 
#     def reset_attribute_selection(self):
#         """Resets the selection."""
#         self.lineEdit().setText('')
#         self.setCurrentIndex(-1)
#         self.cancel_button.setVisible(False)
# 
#     def change_lineedit_status(self):
#         """Changes the background color of the combobox according to the user
#         """
#         if self.currentIndex() is not -1:
#             self.lineEdit().setReadOnly(True)
#             self.change_background("#F3F4E3;")
#         else:
#             self.lineEdit().setReadOnly(False)
#             self.change_background()
# 
#     def change_background(self, color=''):
#         """Changes the background color of the combobox according to the query
#         results of """
#         pass
# 
#     def check_lineedit_status(self):
#         """Checks the lineedit widget and set the cancel button as
#         visible/invisible"""
#         if str(u''.join(self.lineEdit().text()).encode('utf-8').strip()) == '':
#             self.cancel_button.setVisible(False)


import os
import platform
from PyQt5.QtWidgets import (QFrame, QGridLayout, QSizePolicy, QLayout,
                             QHBoxLayout, QToolButton, QSpacerItem)
from PyQt5.QtGui import QCursor, QIcon
from PyQt5.QtCore import Qt, QSize
from .combobox import ComboBox
        size_policy.setHorizontalStretch(0)
        size_policy.setVerticalStretch(0)
        size_policy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(size_policy)
        self.setCursor(QCursor(Qt.ArrowCursor))
        self.setFrameShape(QFrame.StyledPanel)
        self.setFrameShadow(QFrame.Raised)
        self.setLineWidth(1)

    def _set_layout(self, layout):
        """Sets the size policies of layout and initializes the comoboxes and
        query button."""
        layout.setSizeConstraint(QLayout.SetNoConstraint)
        layout.setMargin(MARGIN)
        layout.setSpacing(SPACING)

        # combo boxes
        # melodic structure
        self.comboBox_melodic = ComboBox(self)
        layout.addWidget(self.comboBox_melodic, 0, 0, 1, 1)

        # form structure
        self.comboBox_form = ComboBox(self)
        layout.addWidget(self.comboBox_form, 0, 2, 1, 1)

        # rhythmic structure
        self.comboBox_rhythm = ComboBox(self)
        layout.addWidget(self.comboBox_rhythm, 0, 4, 1, 1)

        # composer

# Path: dunyadesktop_app/widgets/combobox.py
# class ComboBox(QComboBox):
#     """Combobox of the attributes."""
#     def __init__(self, parent):
#         QComboBox.__init__(self, parent)
#         self.setEditable(True)
#         self.setInsertPolicy(QComboBox.NoInsert)
# 
#         if platform.system() == 'Linux':
#             self.setFixedHeight(23)
#         else:
#             self.setFixedHeight(25)
# 
#         self._set_cancel_button()
# 
#         # signals
#         self.currentIndexChanged.connect(self.change_lineedit_status)
#         self.cancel_button.clicked.connect(self.reset_attribute_selection)
#         self.lineEdit().textEdited.connect(lambda:
#                                            self.cancel_button.setVisible(True))
#         self.lineEdit().editingFinished.connect(self.check_lineedit_status)
#         self.dialog_filtering = FilteringDialog(self)
#         self.dialog_filtering.ok_button_clicked.connect(
#             lambda: self.set_selection(self.dialog_filtering.selection))
# 
#     def _set_cancel_button(self):
#         self.cancel_button = QToolButton(self)
#         self.cancel_button.setIcon(QIcon(ICON_PATH_CANCEL))
#         self.cancel_button.setVisible(False)
# 
#     def resizeEvent(self, QResizeEvent):
#         """Sets the position of cancel button."""
#         button_size = self.cancel_button.sizeHint()
#         frame_width = self.lineEdit().style().pixelMetric(
#             QStyle.PM_DefaultFrameWidth)
#         self.cancel_button.move(
#             self.rect().right() - BUTTON_POS * frame_width-button_size.width(),
#             (self.rect().bottom() - button_size.height() + 1) / 2)
#         super(ComboBox, self).resizeEvent(QResizeEvent)
# 
#     def wheelEvent(self, QWheelEvent):
#         """Wheel event of mouse is disabled."""
#         pass
# 
#     def mousePressEvent(self, QMouseEvent):
#         """Popups the filtering dialog when the combobox is clicked."""
#         self.dialog_filtering.attribute = self.attribute
#         self.dialog_filtering.setWindowTitle("")
#         self.dialog_filtering.filtering_model.add_items(self.attribute)
#         self.dialog_filtering.move(QMouseEvent.globalPos().x(),
#                                    QMouseEvent.globalPos().y())
#         self.dialog_filtering.show()
# 
#     def set_placeholder_text(self, text):
#         font = QFont()
#         font.setPointSize(FONT_SIZE)
# 
#         self.lineEdit().setPlaceholderText(text)
#         self.lineEdit().setFont(font)
# 
#     def add_items(self, attribute):
#         """Adds the items of given attribute to the combobox"""
#         self.attribute = attribute
#         for att in self.attribute:
#             self.addItem(att['name'])
#         self.setCurrentIndex(-1)
# 
#     def get_attribute_id(self):
#         """Returns the id of selected item"""
#         index = self.currentIndex()
#         if index is not -1:
#             try:
#                 return self.attribute[index]['uuid']
#             except:
#                 return self.attribute[index]['mbid']
#         else:
#             return ''
# 
#     def set_selection(self, index):
#         """Sets the selected item on the combobox."""
#         try:
#             index_row = index.row()
#         except:
#             index_row = index
#         self.setCurrentIndex(index_row)
#         self.lineEdit().setText(self.attribute[index_row]['name'])
#         self.cancel_button.setVisible(True)
# 
#     def reset_attribute_selection(self):
#         """Resets the selection."""
#         self.lineEdit().setText('')
#         self.setCurrentIndex(-1)
#         self.cancel_button.setVisible(False)
# 
#     def change_lineedit_status(self):
#         """Changes the background color of the combobox according to the user
#         """
#         if self.currentIndex() is not -1:
#             self.lineEdit().setReadOnly(True)
#             self.change_background("#F3F4E3;")
#         else:
#             self.lineEdit().setReadOnly(False)
#             self.change_background()
# 
#     def change_background(self, color=''):
#         """Changes the background color of the combobox according to the query
#         results of """
#         pass
# 
#     def check_lineedit_status(self):
#         """Checks the lineedit widget and set the cancel button as
#         visible/invisible"""
#         if str(u''.join(self.lineEdit().text()).encode('utf-8').strip()) == '':
#             self.cancel_button.setVisible(False)


# Path: dunyadesktop_app/widgets/audioattframe.py
import os
import platform
from PyQt5.QtWidgets import (QFrame, QGridLayout, QSizePolicy, QLayout,
                             QHBoxLayout, QToolButton, QSpacerItem)
from PyQt5.QtGui import QCursor, QIcon
from PyQt5.QtCore import Qt, QSize
from .combobox import ComboBox

        size_policy.setHorizontalStretch(0)
        size_policy.setVerticalStretch(0)
        size_policy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(size_policy)
        self.setCursor(QCursor(Qt.ArrowCursor))
        self.setFrameShape(QFrame.StyledPanel)
        self.setFrameShadow(QFrame.Raised)
        self.setLineWidth(1)

    def _set_layout(self, layout):
        """Sets the size policies of layout and initializes the comoboxes and
        query button."""
        layout.setSizeConstraint(QLayout.SetNoConstraint)
        layout.setMargin(MARGIN)
        layout.setSpacing(SPACING)

        # combo boxes
        # melodic structure
        self.comboBox_melodic = ComboBox(self)
        layout.addWidget(self.comboBox_melodic, 0, 0, 1, 1)

        # form structure
        self.comboBox_form = ComboBox(self)
        layout.addWidget(self.comboBox_form, 0, 2, 1, 1)

        # rhythmic structure
        self.comboBox_rhythm = ComboBox(self)
        layout.addWidget(self.comboBox_rhythm, 0, 4, 1, 1)

        # composer

        self.comboBox_composer = ComboBox(self)