Beispiel #1
0
	void ProfileWidget::on_UpdateProfile__released ()
	{
		LJAccount *account = qobject_cast<LJAccount*> (Profile_->GetParentAccount ());
		if (!account)
			return;
		account->updateProfile ();
	}
Beispiel #2
0
	void ProfileWidget::on_Delete__released ()
	{
		auto index = Ui_.FriendsView_->selectionModel ()->currentIndex ();
		index = index.sibling (index.row (), Columns::Name);
		if (!index.isValid ())
			return;

		QString msg;
		index.parent ().isValid () ?
			msg = tr ("Are you sure to delete user <b>%1</b> from your friends.")
					.arg (index.data ().toString ()) :
			msg = tr ("Are you sure to delete group <b>%1</b>"
					"<br><i>Note: all friends in this group will <b>not</b> be deleted.</i>")
					.arg (index.data ().toString ());
		int res = QMessageBox::question (this,
				tr ("Change friendslist"),
				msg,
				QMessageBox::Ok | QMessageBox::Cancel,
				QMessageBox::Cancel);

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

			if (!index.parent ().isValid ())
				account->DeleteGroup (Item2FriendGroup_ [FriendsModel_->itemFromIndex (index)].Id_);
			else
				account->DeleteFriend (index.data ().toString ());
		}
	}
Beispiel #3
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);
		}
	}
Beispiel #4
0
	void LJBloggingPlatform::RestoreAccounts ()
	{
		QSettings settings (QSettings::IniFormat, QSettings::UserScope,
				QCoreApplication::organizationName (),
				QCoreApplication::applicationName () +
						"_Blogique_Metida_Accounts");
		int size = settings.beginReadArray ("Accounts");
		for (int i = 0; i < size; ++i)
		{
			settings.setArrayIndex (i);
			QByteArray data = settings.value ("SerializedData").toByteArray ();
			LJAccount *acc = LJAccount::Deserialize (data, this);
			if (!acc)
			{
				qWarning () << Q_FUNC_INFO
						<< "unserializable acount"
						<< i;
				continue;
			}
			LJAccounts_ << acc;
			emit accountAdded (acc);

			acc->Init ();
			Core::Instance ().GetLocalStorage ()->AddAccount (acc->GetAccountID ());
		}
		settings.endArray ();
	}
Beispiel #5
0
	void ProfileWidget::handleUserGroupChanged (const QString& username,
			const QString& bgColor, const QString& fgColor, int groupId)
	{
		LJAccount *account = qobject_cast<LJAccount*> (Profile_->GetParentAccount ());
		if (!account)
			return;

		account->AddNewFriend (username, bgColor, fgColor, groupId);
	}
Beispiel #6
0
	void ProfileWidget::on_AddFriend__released ()
	{
		std::unique_ptr<AddEditFriendDialog> aefd (new AddEditFriendDialog (Profile_));
		aefd->setWindowTitle (tr ("Add new friend."));

		if (aefd->exec () == QDialog::Rejected)
			return;

		const QString& userName = aefd->GetUserName ();
		const QString& bgcolor = aefd->GetBackgroundColorName ();
		const QString& fgcolor = aefd->GetForegroundColorName ();
		uint realId =  aefd->GetGroupRealId ();

		LJAccount *account = qobject_cast<LJAccount*> (Profile_->GetParentAccount ());
		if (!account)
			return;

		account->AddNewFriend (userName, bgcolor, fgcolor, realId);
	}