2012-02-09 14:18:15 -05:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012, RetroShare Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
|
|
#include "FriendRecommendDialog.h"
|
|
|
|
#include "ui_FriendRecommendDialog.h"
|
|
|
|
#include "msgs/MessageComposer.h"
|
|
|
|
#include "settings/rsharesettings.h"
|
|
|
|
|
2012-11-06 18:26:47 -05:00
|
|
|
void FriendRecommendDialog::showYourself()
|
2012-02-09 14:18:15 -05:00
|
|
|
{
|
2012-11-06 18:26:47 -05:00
|
|
|
FriendRecommendDialog *dlg = new FriendRecommendDialog();
|
2012-02-09 14:18:15 -05:00
|
|
|
dlg->show();
|
|
|
|
}
|
|
|
|
|
2012-11-06 18:26:47 -05:00
|
|
|
FriendRecommendDialog::FriendRecommendDialog() :
|
|
|
|
QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
|
2012-02-09 14:18:15 -05:00
|
|
|
ui(new Ui::FriendRecommendDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
|
|
|
|
Settings->loadWidgetInformation(this);
|
|
|
|
|
|
|
|
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(sendMsg()));
|
|
|
|
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
|
|
|
|
|
|
|
ui->recommendList->setHeaderText(tr("Recommend friends"));
|
|
|
|
ui->recommendList->setModus(FriendSelectionWidget::MODUS_CHECK);
|
2012-11-24 09:48:31 -05:00
|
|
|
ui->recommendList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL);
|
2012-02-09 14:18:15 -05:00
|
|
|
ui->recommendList->start();
|
|
|
|
|
|
|
|
ui->toList->setHeaderText(tr("To"));
|
|
|
|
ui->toList->setModus(FriendSelectionWidget::MODUS_CHECK);
|
|
|
|
ui->toList->start();
|
|
|
|
|
|
|
|
ui->messageEdit->setText(MessageComposer::recommendMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
FriendRecommendDialog::~FriendRecommendDialog()
|
|
|
|
{
|
|
|
|
Settings->saveWidgetInformation(this);
|
|
|
|
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FriendRecommendDialog::sendMsg()
|
|
|
|
{
|
|
|
|
std::list<std::string> recommendIds;
|
|
|
|
ui->recommendList->selectedSslIds(recommendIds, false);
|
|
|
|
|
|
|
|
if (recommendIds.empty()) {
|
|
|
|
QMessageBox::warning(this, "RetroShare", tr("Please select at least one friend for recommendation."), QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::list<std::string> toIds;
|
|
|
|
ui->toList->selectedSslIds(toIds, false);
|
|
|
|
|
|
|
|
if (toIds.empty()) {
|
|
|
|
QMessageBox::warning(this, "RetroShare", tr("Please select at least one friend as recipient."), QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::list<std::string>::iterator toId;
|
|
|
|
for (toId = toIds.begin(); toId != toIds.end(); toId++) {
|
|
|
|
MessageComposer::recommendFriend(recommendIds, *toId, ui->messageEdit->toHtml(), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
done(Accepted);
|
|
|
|
}
|