Beispiel #1
0
	void ProfileWidget::on_DeleteFriend__released ()
	{
		auto indexList = Ui_.FriendsView_->selectionModel ()->selectedIndexes ();
		if (indexList.isEmpty ())
			return;

		int res = QMessageBox::question (this,
				tr ("Delete friend."),
				tr ("Are you sure to delete selected users from your friends?"
					"<br><i>Note: if you select a group then all users in this group will be deleted.</i>"),
				QMessageBox::Ok | QMessageBox::Cancel,
				QMessageBox::Cancel);

		if (res == QMessageBox::Ok)
		{
			LJAccount *account = qobject_cast<LJAccount*> (Profile_->GetParentAccount ());
			if (!account)
				return;

			QStringList names;
			for (const auto& index : indexList)
			{
				if (!index.parent ().isValid ())
					for (int i = 0; i < FriendsModel_->rowCount (index); ++i)
						names << FriendsModel_->index (i, Columns::Name, index).data ().toString ();
				else
					names << index.sibling (index.row (), Columns::Name).data ().toString ();
			}
			names.removeDuplicates ();
			account->DeleteFriends (names);
		}
	}