void ContactsTreeWidget::loadContactList() {
  appInstance->logEvent("ContactsTreeWidget::loadContactList()", SEVERITY_DEBUG);
  GroupList *gl = appInstance->mUser->getGroupList();
  ContactList *cl;
  ContactList::iterator c**t;
  GroupList::iterator glIt;
  appInstance->mainWindow->contactsTree->treeModel->clear();
  for (glIt = gl->begin(); glIt != gl->end(); glIt++) {
    cl = glIt->second.contacts();
    // prevent adding empty "Unauthorized" group
    if(glIt->first != GROUP_INDEX_NOT_AUTHORIZED || !cl->empty()) {
      appInstance->mainWindow->contactsTree->addGroup(glIt->first, glIt->second);
    }
  }
  for (glIt = gl->begin(); glIt != gl->end(); glIt++) {
    cl = glIt->second.contacts();
    for(c**t = cl->begin(); c**t != cl->end(); c**t++) {
      appInstance->mainWindow->contactsTree->addContact(*c**t);
    }
  }
  appInstance->mainWindow->contactsTree->loadAvatars();
}
示例#2
0
int main(int argc, char** argv) {
	
const int Sentinel = 0;  //The value 0 Exits the program if entered by the user.

int input = 1; //Variable 'input' is where the value entered by the user is stored.

string name; //This value stores the name of a contact. 
//It is meant to be instantiated by the askName() function


ContactList clientList;

cout << "This program is designed to maintain contact information" << endl;


 
		while(input != Sentinel) //Loop structure. Loop will only exit when 0 is entered.
			{
				menu();          //display menu and choices
				cin >> input;    //User inputs a choice. Choice is saved in 'input'
				                 
				                 //Perform appropriate operation pending on the input value.
				if(input == 1)
					{ cout <<"(Add Contact)"<< endl;
					  clientList.addToHead(getContact());
					}
					
		   else if(input == 2)
					{ 
						if(clientList.empty())
							{ cout <<"Error:Cannot delete from empty contact list" << endl; }
					
						else
					  		{
								cout <<"(Delete Contact)" << endl;
					  			name = askName();
								if(clientList.verify(name))
								{clientList.delete_ByName(name);}
								else{ cout << "Error:Contact '" << name << "' not found in the contact list" << endl;}
							} 		
					}
					
		   else if(input == 3)
		   				if(clientList.empty())
							{ cout <<"Error:Cannot display empty contact list" << endl; }
						
						else{
							cout << "(Display all Contacts)"<< endl; 
					        clientList.displayList();
							}
					
		   else if(input == 4)
		   			
		   			if(clientList.empty())
						{ cout <<"Error:Cannot display specific contact from empty contact list" << endl; }
					
					else{
						cout <<"(Display Specific Contact)"<< endl;
					 	name = askName();
						if(clientList.verify(name))
						{clientList.get_ByName(name)->display();}
						
						else
					    {cout << "Error: Contact '" << name << "' not found in the contact list" << endl;}
					}
					
		
			}	
		
	return 0;
}