示例#1
0
void TreeLeaf::setInitialSettings(int i_parent_id, const QString &str_name, int i_tree_id)
{
    setAutoDelete(false); //do not delete instance of the object after the "run" execution
    setItemColor();
    //
    m_iParentID = i_parent_id;  // id of the parent node (id_parent_node). For the trop-levels node it is 0
    //
    m_iDBTreeID = i_tree_id;
    //
    this->setText(0, str_name);
    //
    m_strDatabaseNodeName = str_name;
    //
    //if (0 == m_iParentID)
        this->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable);
    //else
    //    this->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable/*|Qt::ItemIsDropEnabled|Qt::ItemIsDragEnabled*/);
    //
    //no attachments requested yet.
    //
    m_bIsAttachmentRequestedAlready = false;
    //
    //force delete is disabled
    //
    m_bForceDelete = false;
}
示例#2
0
bool  TreeLeaf::restoreSubtree  ()
{
    if ( isPossibleToRestoreNode() == false )
        return false;
    //
    setActiveStatus_DB(true);
    //
    setObjectStatus(OBJECT_OK);
    //
    QString str_msg;
    str_msg = "node ";
    str_msg += this->text(0);
    str_msg += " restored.";
    //
    placeStatusBarMsg(str_msg);
    //
    setItemColor();
    //restore all attachments
    restoreAllAttachments();
    //
    for (int i = 0; i < this->childCount(); i++)
    {
        TreeLeaf* ptr_child_leaf =  (TreeLeaf*) this->child(i);
        if (ptr_child_leaf)
            ptr_child_leaf->restoreSubtree();
    };
    //
    return true;
};
示例#3
0
//
// Thread pool processes
//
bool TreeLeaf::exec()
{
    QMutexLocker locker(&m_RunLocker);
    //
    switch(getObjectStatus())
    {
    case AbstractDatabaseObject::OBJECT_OK:
        return true;
    case AbstractDatabaseObject::OBJECT_NAME_UPDATING:
        {
            bool b_update_name = updateName_DB();
            if (b_update_name)
            {
                QString str_message = QString("(id = %1) new name='%2'").arg(m_iID).arg(this->text(0));
                Logger::getInstance().logIt(en_LOG_UPDATE_NODE, str_message );
            };
        };
        break;
    case AbstractDatabaseObject::OBJECT_TREE_ID_UPDATING:
        updateTreeID_DB();
        break;
    case AbstractDatabaseObject::OBJECT_DESCRIPTOR_UPDATING:
        {
            bool b_update = updateDescriptor_DB();
            if (b_update)
            {
                QString str_message = QString("(id = %1) name='%2' updated").arg(m_iID).arg(this->text(0));
                Logger::getInstance().logIt(en_LOG_DESCRIPTOR_NODE, str_message );
            };
        };
        break;
    case AbstractDatabaseObject::OBJECT_DELETING:
        setObjectStatus(OBJECT_DELETED);
        IconManager::getInstance().minusInUse(m_iIconID);
        deleteAllAttachments();
        setActiveStatus_DB(false);
        setItemColor();
        notifyAboutAttachmentUpdate(true, tr(""));
        {
            QString str_message = QString("(id = %1) name='%2'").arg(m_iID).arg(this->text(0));
            Logger::getInstance().logIt(en_LOG_DELETE_NODE, str_message );
        }
        return true;
    case AbstractDatabaseObject::OBJECT_ATTACHMENT_INSERT: //do nothing
        return true;
    default:
/*
#ifdef QT_DEBUG
        DB_OBJECT_STATUS status = getObjectStatus(); //just for check under debugger
#endif
*/
        Q_ASSERT( FALSE );
        return false;
    };
    //
    setObjectStatus(AbstractDatabaseObject::OBJECT_OK);
    return true;
    //
//    m_RunLocker.unlock();
}
示例#4
0
void ColorList::addItem(const QString& text, const QColor& color)
{
    QListWidgetItem* item = new QListWidgetItem(this);
    item->setText(text);
    if(count() == 1)
    {
        setIconSize(QSize(100, sizeHintForRow(0) - 4));
    }
    setItemColor(item, color);

}
示例#5
0
void GraphViewEvent::setEvent(Event* event)
{
    if(event)
    {
        mEvent = event;
        QString eventTitle = ( (mEvent->mType == Event::eDefault) ? tr("Event") : tr("Bound") ) ;
        this->setItemTitle(eventTitle + " : " + mEvent->getName());
        setItemColor(mEvent->getColor());
    }
    update();
}
示例#6
0
void ColorList::editItemColor(QListWidgetItem* item)
{
    if(!item)
    {
        return;
    }
    QColor col = QColorDialog::getColor(color(item));
    if(col.isValid())
    {
        setItemColor(item, col);
    }
}
示例#7
0
bool TreeLeaf::restoreObject()
{
    if ( isPossibleToRestoreNode() == false )
        return false;
    //
    QString str_msg;
    //
    setActiveStatus_DB(true);
    //
    setObjectStatus(OBJECT_OK);
    //
    str_msg = "node ";
    str_msg += this->text(0);
    str_msg += " restored.";
    //
    placeStatusBarMsg(str_msg);
    //
    setItemColor();
    //
    return true;
};