示例#1
0
/**
 * @brief fill the listWidget based on m_elementIdsList
 * @author Olivier CHURLAUD <*****@*****.**>
 */
void LeftPannel::fillListWidget()
{
    Macaw::DEBUG_IN("[LeftPannel] Enters fillListWidget()");

    m_ui->listWidget->clear();

    DatabaseManager *databaseManager = ServicesManager::instance()->databaseManager();

    // Add the "All" element
    if(m_typeElement != Macaw::isPlaylist) {
        // First space needed for sorting
        Entity l_entity(" All");
        l_entity.setId(0);

        this->addEntityToListWidget(l_entity);
    }

    foreach(int l_objectId, m_elementIdsList) {
        if(l_objectId == -1) {
            // First space needed for sorting
            Entity l_entity(" Unknown");
            l_entity.setId(-1);

            this->addEntityToListWidget(l_entity);
        } else {
            Entity l_entity;
            switch (m_typeElement)
            {
            case Macaw::isPeople:
                l_entity = databaseManager->getOnePeopleById(l_objectId);
                break;
            case Macaw::isTag:
                l_entity = databaseManager->getOneTagById(l_objectId);
                break;
            }

            this->addEntityToListWidget(l_entity);
        }
    }
    if(m_ui->listWidget->selectedItems().isEmpty()) {
        m_ui->listWidget->item(0)->setSelected(true);
    }
    m_ui->listWidget->sortItems();

    Macaw::DEBUG_OUT("[LeftPannel] Exits fillListWidget()");
}
示例#2
0
PeopleDialog::PeopleDialog(int id, QWidget *parent) :
    QDialog(parent),
    m_ui(new Ui::PeopleDialog)
{
    Macaw::DEBUG("[PeopleDialog] Constructor called");

    DatabaseManager *databaseManager = ServicesManager::instance()->databaseManager();

    m_ui->setupUi(this);
    this->setWindowTitle(tr("Edit People Metadata"));
    this->setAttribute(Qt::WA_DeleteOnClose);

    // If id is 0 it means we create a new People
    if (id != 0)
    {
        m_people = databaseManager->getOnePeopleById(id);
        setName(m_people.name());
        setBirthday(m_people.birthday());
        setBiography(m_people.biography());
    }
    Macaw::DEBUG("[PeopleDialog] Construction done");
}