NodeTypesPanel::NodeTypesPanel() { layout = new QGridLayout; layout->setAlignment(Qt::AlignTop); int row = 0; caption = new QLabel("<h2>" + i18n("Custom Node Types") + "</h2>"); layout->addWidget(caption, row, 0); ++row; typelist = new QListWidget; layout->addWidget(typelist, row, 0, 4, 1); ++row; typelist->addItems(Controller::create()->getDataStore()->getCustomNodeTypeNames()); btnAdd = new QPushButton(i18n("Add new Node Type")); layout->addWidget(btnAdd, row, 1); ++row; connect(btnAdd, SIGNAL(clicked()), this, SLOT(addType())); btnEdit = new QPushButton(i18n("Edit Node Type")); layout->addWidget(btnEdit, row, 1); ++row; connect(btnEdit, SIGNAL(clicked()), this, SLOT(editType())); btnDelete = new QPushButton(i18n("Delete Node Type")); layout->addWidget(btnDelete, row, 1); ++row; connect(btnDelete, SIGNAL(clicked()), this, SLOT(deleteType())); btnExit = new QPushButton(i18n("Close")); btnExit->setMinimumWidth(100); layout->addWidget(btnExit, row, 0, 1, 1, Qt::AlignRight); connect(btnExit, SIGNAL(clicked()), this, SLOT(sendExit())); setLayout(layout); connect(typelist, SIGNAL(itemSelectionChanged()), this, SLOT(updateButtons())); updateButtons(); }
// ==== CONTEXT MENU ==== // Type table context menu -> Delete void MainWindow::on_actionDeleteType_triggered(){ deleteType(); }
// Delete button -> clicked void MainWindow::on_typeDeleteButton_clicked(){ deleteType(); }
/** Set up the CCntSqlStatement objects held by the class. */ void CPplCommAddrTable::ConstructL() { // Statement types TCntSqlStatementType insertType(EInsert, KSqlContactCommAddrTableName() ); TCntSqlStatementType selectType(ESelect, KSqlContactCommAddrTableName() ); TCntSqlStatementType updateType(EUpdate, KSqlContactCommAddrTableName() ); TCntSqlStatementType deleteType(EDelete, KSqlContactCommAddrTableName() ); // Where clauses // sizes of the clauses const TInt KWhereContactIdBufSize(KCommAddrContactId().Size() + KWhereStringEqualsStringFormatText().Size() + KCommAddrContactIdParam().Size() ); const TInt KWhereCommAddrIdBufSize(KCommAddrId().Size() + KWhereStringEqualsStringFormatText().Size() + KCommAddrIdParam().Size() ); const TInt KWhereAndClauseBufSize(KWhereCommAddrIdBufSize + KSqlAnd().Size() + KWhereCommAddrIdBufSize); HBufC* whereContactIdClause = HBufC::NewLC(KWhereContactIdBufSize); // for WHERE contact_id = [contact id value] whereContactIdClause->Des().AppendFormat(KWhereStringEqualsStringFormatText, &KCommAddrContactId, &KCommAddrContactIdParam ); // for WHERE comm_addr_id = [comm addr id value] HBufC* whereCommAddrIdClause = HBufC::NewLC(KWhereCommAddrIdBufSize); whereCommAddrIdClause->Des().AppendFormat(KWhereStringEqualsStringFormatText, &KCommAddrId, &KCommAddrIdParam ); // for WHERE value = [value string] AND type = [type value] HBufC* whereValueAndTypeClause = HBufC::NewLC(KWhereAndClauseBufSize); TPtr whereValueAndTypeClausePtr = whereValueAndTypeClause->Des(); whereValueAndTypeClausePtr.AppendFormat(KWhereStringEqualsStringFormatText, &KCommAddrValue, &KCommAddrValueParam ); whereValueAndTypeClausePtr.Append(KSqlAnd); whereValueAndTypeClausePtr.AppendFormat(KWhereStringEqualsStringFormatText, &KCommAddrType, &KCommAddrTypeParam ); // INSERT // insert new comm addr record // INSERT INTO comm_addr // (comm_addr_id, contact_id, type, value, extra_value, extra_type_info) // VALUES (NULL, [contact id value], [type value], // [value string], [extra value string], [extra type info]); // iInsertStmnt = TSqlProvider::GetSqlStatementL(insertType); iInsertStmnt->SetParamL(KCommAddrId(), KCommAddrIdParam() ); iInsertStmnt->SetParamL(KCommAddrContactId(), KCommAddrContactIdParam() ); iInsertStmnt->SetParamL(KCommAddrValue(), KCommAddrValueParam() ); iInsertStmnt->SetParamL(KCommAddrExtraValue(), KCommAddrExtraValueParam() ); iInsertStmnt->SetParamL(KCommAddrType(), KCommAddrTypeParam() ); iInsertStmnt->SetParamL(KCommAddrExtraTypeInfo(), KCommAddrExtraTypeInfoParam() ); // SELECT // select all fields for all comm addrs for a particular item id // For a statement in the following format: // SELECT comm_addr_id, type, value, extra_value,extra_type_info FROM comm_addr // WHERE contact_id = [contact id value]; // iWholeSelectStmnt = TSqlProvider::GetSqlStatementL(selectType); iWholeSelectStmnt->SetParamL(KCommAddrId(), KNullDesC() ); iWholeSelectStmnt->SetParamL(KCommAddrType(), KNullDesC() ); iWholeSelectStmnt->SetParamL(KCommAddrValue(), KNullDesC() ); iWholeSelectStmnt->SetParamL(KCommAddrExtraValue(), KNullDesC() ); iWholeSelectStmnt->SetParamL(KCommAddrExtraTypeInfo(), KNullDesC() ); iWholeSelectStmnt->SetConditionL(*whereContactIdClause); // select fields for contacts that match phone, email or SIP lookup // For a statement in the following format: // SELECT contact_id, extra_value FROM comm_addr // WHERE value = [value string] AND type = [type value]; // iMatchSelectStmnt = TSqlProvider::GetSqlStatementL(selectType); iMatchSelectStmnt->SetParamL(KCommAddrContactId(), KNullDesC() ); iMatchSelectStmnt->SetParamL(KCommAddrExtraValue(), KNullDesC() ); iMatchSelectStmnt->SetConditionL(*whereValueAndTypeClause); // UPDATE // update comm addr record // For a statement in the following format: // UPDATE comm_addr SET // contact_id = [contact id value], // type = [type value], // value = [value string], // extra_value = [extra value string] // extra_type_info = [ extra type info ] // WHERE comm_addr_id = [comm addr id value]; // iUpdateStmnt = TSqlProvider::GetSqlStatementL(updateType); iUpdateStmnt->SetParamL(KCommAddrContactId(), KCommAddrContactIdParam() ); iUpdateStmnt->SetParamL(KCommAddrValue(), KCommAddrValueParam() ); iUpdateStmnt->SetParamL(KCommAddrExtraValue(), KCommAddrExtraValueParam() ); iUpdateStmnt->SetParamL(KCommAddrType(), KCommAddrTypeParam() ); iUpdateStmnt->SetParamL(KCommAddrExtraTypeInfo(), KCommAddrExtraTypeInfoParam() ); iUpdateStmnt->SetConditionL(*whereCommAddrIdClause); // DELETE // delete single comm addr record // For a statement in the following format: // DELETE FROM comm_addr WHERE comm_addr_id = [comm addr id value]; // iSingleDeleteStmnt = TSqlProvider::GetSqlStatementL(deleteType); iSingleDeleteStmnt->SetConditionL(*whereCommAddrIdClause); // delete all comm addrs for a particular contact item // For a statement in the following format: // DELETE FROM comm_addr WHERE contact_id = [contact id value]; // iAllForItemDeleteStmnt = TSqlProvider::GetSqlStatementL(deleteType); iAllForItemDeleteStmnt->SetConditionL(*whereContactIdClause); CleanupStack::PopAndDestroy(3, whereContactIdClause); // and whereCommAddrIdClause, whereValueAndTypeClause }
/** Set up the CCntSqlStatement objects held by the class. */ void CPplGroupsTable::ConstructL() { // Statement types TCntSqlStatementType insertType(EInsert, KSqlContactGroupTableName); TCntSqlStatementType selectType(ESelect, KSqlContactGroupTableName); TCntSqlStatementType updateType(EUpdate, KSqlContactGroupTableName); TCntSqlStatementType deleteType(EDelete, KSqlContactGroupTableName); TCntSqlStatementType countContactsType(ESelect, KSqlContactTableName); // Where clauses // sizes of the clauses const TInt KWhereGroupClauseBufSize(KGroupContactGroupId().Size() + KWhereStringEqualsStringFormatText().Size() + KGroupContactGroupIdParam().Size() ); const TInt KWhereMemberClauseBufSize(KGroupContactGroupMemberId().Size() + KWhereStringEqualsStringFormatText().Size() + KGroupContactGroupMemberIdParam().Size() ); const TInt KWhereOrClauseBufSize(KWhereGroupClauseBufSize + KSqlOr().Size() + KWhereMemberClauseBufSize); // for WHERE contact_group_id = [contact id value] HBufC* whereGroupIdClause = HBufC::NewLC(KWhereGroupClauseBufSize); whereGroupIdClause->Des().AppendFormat(KWhereStringEqualsStringFormatText, &KGroupContactGroupId, &KGroupContactGroupIdParam ); // for WHERE contact_group_member_id = [contact id value] HBufC* whereMemberIdClause = HBufC::NewLC(KWhereMemberClauseBufSize); whereMemberIdClause->Des().AppendFormat(KWhereStringEqualsStringFormatText, &KGroupContactGroupMemberId, &KGroupContactGroupMemberIdParam ); // for WHERE contact_group_id = [contact id value] // OR contact_group_member_id = [contact id value] HBufC* whereGroupOrMemberIdClause = HBufC::NewLC(KWhereOrClauseBufSize); TPtr whereGroupOrMemberIdClausePtr = whereGroupOrMemberIdClause->Des(); whereGroupOrMemberIdClausePtr.AppendFormat(KWhereStringEqualsStringFormatText, &KGroupContactGroupId, &KGroupContactGroupIdParam); whereGroupOrMemberIdClausePtr.Append(KSqlOr); whereGroupOrMemberIdClausePtr.AppendFormat(KWhereStringEqualsStringFormatText, &KGroupContactGroupMemberId, &KGroupContactGroupMemberIdParam); // for WHERE contact_id = [contact_id] HBufC* whereContactIdClause = HBufC::NewLC(KWhereGroupClauseBufSize); whereContactIdClause->Des().AppendFormat(KWhereStringEqualsStringFormatText, &KContactId, &KContactIdParam ); // INSERT // insert group-member relationships // For a statement in the following format: // INSERT INTO groups // (group_id, contact_group_id, contact_group_member_id) // VALUES (NULL, [contact group id value], [contact group member id value]); // iInsertStmnt = TSqlProvider::GetSqlStatementL(insertType); iInsertStmnt->SetParamL(KGroupContactGroupId(), KGroupContactGroupIdParam()); iInsertStmnt->SetParamL(KGroupContactGroupMemberId(), KGroupContactGroupMemberIdParam()); // SELECT // select group id // For a statement in the following format: // SELECT contact_group_id FROM groups // WHERE contact_group_member_id = [contact id value]; // iSelectGroupsStmnt = TSqlProvider::GetSqlStatementL(selectType); iSelectGroupsStmnt->SetParamL(KGroupContactGroupId(), KNullDesC() ); iSelectGroupsStmnt->SetConditionL(*whereMemberIdClause); // select member id // For a statement in the following format: // SELECT contact_group_member_id FROM groups // WHERE contact_group_id = [contact id value]; // iSelectMembersStmnt = TSqlProvider::GetSqlStatementL(selectType); iSelectMembersStmnt->SetParamL(KGroupContactGroupMemberId(), KNullDesC() ); iSelectMembersStmnt->SetConditionL(*whereGroupIdClause); // DELETE // delete all where group or member equals id // For a statement in the following format: // DELETE FROM groups WHERE contact_group_id = [contact id value] // OR contact_group_member_id = [contact id value]; // iDeleteStmnt = TSqlProvider::GetSqlStatementL(deleteType); iDeleteStmnt->SetConditionL(*whereGroupOrMemberIdClause); // SELECT // SELECt count(*) FROM contact WHERE contact_id = [contact_id] iCountContactsStmnt = TSqlProvider::GetSqlStatementL(countContactsType); iCountContactsStmnt->SetParamL(KSqlCount, KSpace); iCountContactsStmnt->SetConditionL(*whereContactIdClause); CleanupStack::PopAndDestroy(4, whereGroupIdClause); // and whereContactIdClause, whereMemberIdClause, whereGroupOrMemberIdClause }