Commit fa52ed00 authored by Daenyth's avatar Daenyth
Browse files

Merge branch 'master' into mtgjson-importer

parents 40f95362 032c41f3
...@@ -50,15 +50,21 @@ elseif(WIN32) ...@@ -50,15 +50,21 @@ elseif(WIN32)
endif() endif()
# Define proper compilation flags # Define proper compilation flags
IF (CMAKE_COMPILER_IS_GNUCC) IF(MSVC)
# Visual Studio:
# Maximum optimization
set(CMAKE_CXX_FLAGS_RELEASE "/Ox")
# Generate complete debugging information
#set(CMAKE_CXX_FLAGS_DEBUG "/Zi")
ELSEIF (CMAKE_COMPILER_IS_GNUCXX)
# linux/gcc, bsd/gcc, windows/mingw # linux/gcc, bsd/gcc, windows/mingw
set(CMAKE_CXX_FLAGS_RELEASE "-s -O2") set(CMAKE_CXX_FLAGS_RELEASE "-s -O2")
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -O0") set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -O0")
else() ELSE()
# other: osx/llvm, bsd/llvm # other: osx/llvm, bsd/llvm
set(CMAKE_CXX_FLAGS_RELEASE "-O2") set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
ENDIF (CMAKE_COMPILER_IS_GNUCC) ENDIF()
# GNU systems need to define the Mersenne exponent for the RNG to compile w/o warning # GNU systems need to define the Mersenne exponent for the RNG to compile w/o warning
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
......
...@@ -154,8 +154,11 @@ INCLUDE_DIRECTORIES(${QT_MOBILITY_MULTIMEDIAKIT_INCLUDE_DIR}) ...@@ -154,8 +154,11 @@ INCLUDE_DIRECTORIES(${QT_MOBILITY_MULTIMEDIAKIT_INCLUDE_DIR})
# Build cockatrice binary and link it # Build cockatrice binary and link it
ADD_EXECUTABLE(cockatrice WIN32 MACOSX_BUNDLE ${cockatrice_SOURCES} ${cockatrice_QM} ${cockatrice_RESOURCES_RCC} ${cockatrice_MOC_SRCS}) ADD_EXECUTABLE(cockatrice WIN32 MACOSX_BUNDLE ${cockatrice_SOURCES} ${cockatrice_QM} ${cockatrice_RESOURCES_RCC} ${cockatrice_MOC_SRCS})
TARGET_LINK_LIBRARIES(cockatrice cockatrice_common ${QT_LIBRARIES} ${QT_MOBILITY_MULTIMEDIAKIT_LIBRARY}) TARGET_LINK_LIBRARIES(cockatrice cockatrice_common ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES} ${QT_MOBILITY_MULTIMEDIAKIT_LIBRARY})
if(MSVC)
set_target_properties(cockatrice PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS")
endif(MSVC)
if(UNIX) if(UNIX)
if(APPLE) if(APPLE)
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QCursor> #include <QCursor>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <math.h> #include <cmath>
#ifdef _WIN32
#include "round.h"
#endif /* _WIN32 */
#include "carddatabase.h" #include "carddatabase.h"
#include "cardinfowidget.h" #include "cardinfowidget.h"
#include "abstractcarditem.h" #include "abstractcarditem.h"
...@@ -143,7 +146,7 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS ...@@ -143,7 +146,7 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
painter->restore(); painter->restore();
} }
void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{ {
painter->save(); painter->save();
......
#define _USE_MATH_DEFINES
#include <cmath>
#include "arrowitem.h" #include "arrowitem.h"
#include "playertarget.h" #include "playertarget.h"
#include "carditem.h" #include "carditem.h"
#include "cardzone.h" #include "cardzone.h"
#include "player.h" #include "player.h"
#include "math.h"
#include <QPainter> #include <QPainter>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QGraphicsScene> #include <QGraphicsScene>
...@@ -64,7 +66,7 @@ void ArrowItem::updatePath(const QPointF &endPoint) ...@@ -64,7 +66,7 @@ void ArrowItem::updatePath(const QPointF &endPoint)
{ {
const double arrowWidth = 15.0; const double arrowWidth = 15.0;
const double headWidth = 40.0; const double headWidth = 40.0;
const double headLength = headWidth / sqrt(2); const double headLength = headWidth / pow(2, 0.5); // aka headWidth / sqrt (2) but this produces a compile error with MSVC++
const double phi = 15; const double phi = 15;
if (!startItem) if (!startItem)
......
...@@ -148,7 +148,7 @@ QString CardZone::getTranslatedName(bool hisOwn, GrammaticalCase gc) const ...@@ -148,7 +148,7 @@ QString CardZone::getTranslatedName(bool hisOwn, GrammaticalCase gc) const
return QString(); return QString();
} }
void CardZone::mouseDoubleClickEvent(QGraphicsSceneMouseEvent */*event*/) void CardZone::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * /*event*/)
{ {
if (doubleClickAction) if (doubleClickAction)
doubleClickAction->trigger(); doubleClickAction->trigger();
......
...@@ -13,7 +13,7 @@ QRectF GeneralCounter::boundingRect() const ...@@ -13,7 +13,7 @@ QRectF GeneralCounter::boundingRect() const
return QRectF(0, 0, radius * 2, radius * 2); return QRectF(0, 0, radius * 2, radius * 2);
} }
void GeneralCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) void GeneralCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{ {
QRectF mapRect = painter->combinedTransform().mapRect(boundingRect()); QRectF mapRect = painter->combinedTransform().mapRect(boundingRect());
int translatedHeight = mapRect.size().height(); int translatedHeight = mapRect.size().height();
......
...@@ -19,7 +19,7 @@ public: ...@@ -19,7 +19,7 @@ public:
int getNumber() const { return dataNode->getNumber(); } int getNumber() const { return dataNode->getNumber(); }
void setNumber(int _number) { dataNode->setNumber(_number); } void setNumber(int _number) { dataNode->setNumber(_number); }
float getPrice() const { return dataNode->getPrice(); } float getPrice() const { return dataNode->getPrice(); }
void setPrice(float _price) { dataNode->setPrice(_price); } void setPrice(const float _price) { dataNode->setPrice(_price); }
QString getName() const { return dataNode->getName(); } QString getName() const { return dataNode->getName(); }
void setName(const QString &_name) { dataNode->setName(_name); } void setName(const QString &_name) { dataNode->setName(_name); }
DecklistCardNode *getDataNode() const { return dataNode; } DecklistCardNode *getDataNode() const { return dataNode; }
......
...@@ -266,7 +266,7 @@ FilterItemList *FilterTree::attrTypeList(CardFilter::Attr attr, ...@@ -266,7 +266,7 @@ FilterItemList *FilterTree::attrTypeList(CardFilter::Attr attr,
int FilterTree::findTermIndex(CardFilter::Attr attr, CardFilter::Type type, int FilterTree::findTermIndex(CardFilter::Attr attr, CardFilter::Type type,
const QString &term) const QString &term)
{ {
attrTypeList(attr, type)->termIndex(term); return attrTypeList(attr, type)->termIndex(term);
} }
int FilterTree::findTermIndex(const CardFilter *f) int FilterTree::findTermIndex(const CardFilter *f)
......
...@@ -180,9 +180,9 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourc ...@@ -180,9 +180,9 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourc
if (!gameTypeFilter.isEmpty() && gameTypes.intersect(gameTypeFilter).isEmpty()) if (!gameTypeFilter.isEmpty() && gameTypes.intersect(gameTypeFilter).isEmpty())
return false; return false;
if ((maxPlayersFilterMin != -1) && (game.max_players() < maxPlayersFilterMin)) if ((maxPlayersFilterMin != -1) && ((int)game.max_players() < maxPlayersFilterMin))
return false; return false;
if ((maxPlayersFilterMax != -1) && (game.max_players() > maxPlayersFilterMax)) if ((maxPlayersFilterMax != -1) && ((int)game.max_players() > maxPlayersFilterMax))
return false; return false;
return true; return true;
......
...@@ -75,7 +75,7 @@ QRectF HandZone::boundingRect() const ...@@ -75,7 +75,7 @@ QRectF HandZone::boundingRect() const
return QRectF(0, 0, 100, zoneHeight); return QRectF(0, 0, 100, zoneHeight);
} }
void HandZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) void HandZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{ {
if (bgPixmap.isNull()) if (bgPixmap.isNull())
painter->fillRect(boundingRect(), Qt::darkGreen); painter->fillRect(boundingRect(), Qt::darkGreen);
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
***************************************************************************/ ***************************************************************************/
#include <QApplication> #include <QApplication>
#include <QFile>
#include <QTextStream>
#include <QTextCodec> #include <QTextCodec>
#include <QtPlugin> #include <QtPlugin>
#include <QTranslator> #include <QTranslator>
...@@ -28,7 +30,6 @@ ...@@ -28,7 +30,6 @@
#include <QIcon> #include <QIcon>
#include <QDir> #include <QDir>
#include <QDesktopServices> #include <QDesktopServices>
#include <stdio.h>
#include "main.h" #include "main.h"
#include "window_main.h" #include "window_main.h"
...@@ -56,11 +57,11 @@ QString translationPath = QString(); ...@@ -56,11 +57,11 @@ QString translationPath = QString();
void myMessageOutput(QtMsgType /*type*/, const char *msg) void myMessageOutput(QtMsgType /*type*/, const char *msg)
{ {
static FILE *f = NULL; QFile file("qdebug.txt");
if (!f) file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
f = fopen("qdebug.txt", "w"); QTextStream out(&file);
fprintf(f, "%s\n", msg); out << msg << endl;
fflush(f); file.close();
} }
void installNewTranslator() void installNewTranslator()
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
#include <QPen> #include <QPen>
#include <QTimer> #include <QTimer>
#include <QDebug> #include <QDebug>
#include <math.h> #include <cmath>
#ifdef _WIN32
#include "round.h"
#endif /* _WIN32 */
#include "phasestoolbar.h" #include "phasestoolbar.h"
#include "pixmapgenerator.h" #include "pixmapgenerator.h"
...@@ -85,7 +88,7 @@ void PhaseButton::mousePressEvent(QGraphicsSceneMouseEvent * /*event*/) ...@@ -85,7 +88,7 @@ void PhaseButton::mousePressEvent(QGraphicsSceneMouseEvent * /*event*/)
emit clicked(); emit clicked();
} }
void PhaseButton::mouseDoubleClickEvent(QGraphicsSceneMouseEvent */*event*/) void PhaseButton::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * /*event*/)
{ {
triggerDoubleClickAction(); triggerDoubleClickAction();
} }
......
...@@ -105,7 +105,7 @@ void PileZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event) ...@@ -105,7 +105,7 @@ void PileZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
setCursor(Qt::OpenHandCursor); setCursor(Qt::OpenHandCursor);
} }
void PileZone::mouseReleaseEvent(QGraphicsSceneMouseEvent */*event*/) void PileZone::mouseReleaseEvent(QGraphicsSceneMouseEvent * /*event*/)
{ {
setCursor(Qt::OpenHandCursor); setCursor(Qt::OpenHandCursor);
} }
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
#include "pb/serverinfo_user.pb.h" #include "pb/serverinfo_user.pb.h"
#include <QPainter> #include <QPainter>
#include <QSvgRenderer> #include <QSvgRenderer>
#include <math.h> #include <cmath>
#ifdef _WIN32
#include "round.h"
#endif /* _WIN32 */
#include <QDebug> #include <QDebug>
QMap<QString, QPixmap> PhasePixmapGenerator::pmCache; QMap<QString, QPixmap> PhasePixmapGenerator::pmCache;
......
...@@ -85,7 +85,7 @@ void PlayerArea::updateBgPixmap() ...@@ -85,7 +85,7 @@ void PlayerArea::updateBgPixmap()
update(); update();
} }
void PlayerArea::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) void PlayerArea::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{ {
painter->fillRect(bRect, bgPixmapBrush); painter->fillRect(bRect, bgPixmapBrush);
} }
...@@ -1430,7 +1430,7 @@ QRectF Player::boundingRect() const ...@@ -1430,7 +1430,7 @@ QRectF Player::boundingRect() const
return bRect; return bRect;
} }
void Player::paint(QPainter * /*painter*/, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) void Player::paint(QPainter * /*painter*/, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{ {
} }
......
...@@ -5,7 +5,10 @@ ...@@ -5,7 +5,10 @@
#include <QPainter> #include <QPainter>
#include <QPixmapCache> #include <QPixmapCache>
#include <QDebug> #include <QDebug>
#include <math.h> #include <cmath>
#ifdef _WIN32
#include "round.h"
#endif /* _WIN32 */
PlayerCounter::PlayerCounter(Player *_player, int _id, const QString &_name, int _value, QGraphicsItem *parent) PlayerCounter::PlayerCounter(Player *_player, int _id, const QString &_name, int _value, QGraphicsItem *parent)
: AbstractCounter(_player, _id, _name, false, _value, parent) : AbstractCounter(_player, _id, _name, false, _value, parent)
...@@ -87,7 +90,8 @@ void PlayerTarget::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*o ...@@ -87,7 +90,8 @@ void PlayerTarget::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*o
cachedPixmap = QPixmap(translatedSize.width(), translatedSize.height()); cachedPixmap = QPixmap(translatedSize.width(), translatedSize.height());
QPainter tempPainter(&cachedPixmap); QPainter tempPainter(&cachedPixmap);
QRadialGradient grad(translatedRect.center(), sqrt(translatedSize.width() * translatedSize.width() + translatedSize.height() * translatedSize.height()) / 2); // pow(foo, 0.5) equals to sqrt(foo), but using sqrt(foo) in this context will produce a compile error with MSVC++
QRadialGradient grad(translatedRect.center(), pow(translatedSize.width() * translatedSize.width() + translatedSize.height() * translatedSize.height(), 0.5) / 2);
grad.setColorAt(1, Qt::black); grad.setColorAt(1, Qt::black);
grad.setColorAt(0, QColor(180, 180, 180)); grad.setColorAt(0, QColor(180, 180, 180));
tempPainter.fillRect(QRectF(0, 0, translatedSize.width(), translatedSize.height()), grad); tempPainter.fillRect(QRectF(0, 0, translatedSize.width(), translatedSize.height()), grad);
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
#include <QPainter> #include <QPainter>
#include <QPalette> #include <QPalette>
#include <QTimer> #include <QTimer>
#include <math.h> #include <cmath>
#ifdef _WIN32
#include "round.h"
#endif /* _WIN32 */
ReplayTimelineWidget::ReplayTimelineWidget(QWidget *parent) ReplayTimelineWidget::ReplayTimelineWidget(QWidget *parent)
: QWidget(parent), maxBinValue(1), maxTime(1), timeScaleFactor(1.0), currentTime(0), currentEvent(0) : QWidget(parent), maxBinValue(1), maxTime(1), timeScaleFactor(1.0), currentTime(0), currentEvent(0)
......
#ifndef MSVC_ROUND_FIX
#define MSVC_ROUND_FIX
/**
* This helper function exists only because MS VC++ 2010 does not support round() in
* <cmath>. round() works with g++ and clang++ but is formally a C++11 extension.
* So this file exists for MS VC++ only.
*/
inline double round(double val) {
return floor(val + 0.5);
}
#endif /* MSVC_ROUND_FIX */
...@@ -46,7 +46,7 @@ QRectF StackZone::boundingRect() const ...@@ -46,7 +46,7 @@ QRectF StackZone::boundingRect() const
return QRectF(0, 0, 100, zoneHeight); return QRectF(0, 0, 100, zoneHeight);
} }
void StackZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) void StackZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{ {
if (bgPixmap.isNull()) if (bgPixmap.isNull())
painter->fillRect(boundingRect(), QColor(113, 43, 43)); painter->fillRect(boundingRect(), QColor(113, 43, 43));
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "abstractclient.h" #include "abstractclient.h"
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QPushButton>
#include <QLineEdit>
#include "pending_command.h" #include "pending_command.h"
#include "pb/session_commands.pb.h" #include "pb/session_commands.pb.h"
...@@ -21,34 +23,90 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor, AbstractClient *_clien ...@@ -21,34 +23,90 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor, AbstractClient *_clien
ignoreList = new UserList(_tabSupervisor, client, UserList::IgnoreList); ignoreList = new UserList(_tabSupervisor, client, UserList::IgnoreList);
userInfoBox = new UserInfoBox(client, false); userInfoBox = new UserInfoBox(client, false);
userInfoBox->updateInfo(userInfo); userInfoBox->updateInfo(userInfo);
connect(allUsersList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool))); connect(allUsersList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool)));
connect(buddyList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool))); connect(buddyList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool)));
connect(ignoreList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool))); connect(ignoreList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool)));
connect(client, SIGNAL(userJoinedEventReceived(const Event_UserJoined &)), this, SLOT(processUserJoinedEvent(const Event_UserJoined &))); connect(client, SIGNAL(userJoinedEventReceived(const Event_UserJoined &)), this, SLOT(processUserJoinedEvent(const Event_UserJoined &)));
connect(client, SIGNAL(userLeftEventReceived(const Event_UserLeft &)), this, SLOT(processUserLeftEvent(const Event_UserLeft &))); connect(client, SIGNAL(userLeftEventReceived(const Event_UserLeft &)), this, SLOT(processUserLeftEvent(const Event_UserLeft &)));
connect(client, SIGNAL(buddyListReceived(const QList<ServerInfo_User> &)), this, SLOT(buddyListReceived(const QList<ServerInfo_User> &))); connect(client, SIGNAL(buddyListReceived(const QList<ServerInfo_User> &)), this, SLOT(buddyListReceived(const QList<ServerInfo_User> &)));
connect(client, SIGNAL(ignoreListReceived(const QList<ServerInfo_User> &)), this, SLOT(ignoreListReceived(const QList<ServerInfo_User> &))); connect(client, SIGNAL(ignoreListReceived(const QList<ServerInfo_User> &)), this, SLOT(ignoreListReceived(const QList<ServerInfo_User> &)));
connect(client, SIGNAL(addToListEventReceived(const Event_AddToList &)), this, SLOT(processAddToListEvent(const Event_AddToList &))); connect(client, SIGNAL(addToListEventReceived(const Event_AddToList &)), this, SLOT(processAddToListEvent(const Event_AddToList &)));
connect(client, SIGNAL(removeFromListEventReceived(const Event_RemoveFromList &)), this, SLOT(processRemoveFromListEvent(const Event_RemoveFromList &))); connect(client, SIGNAL(removeFromListEventReceived(const Event_RemoveFromList &)), this, SLOT(processRemoveFromListEvent(const Event_RemoveFromList &)));
PendingCommand *pend = client->prepareSessionCommand(Command_ListUsers()); PendingCommand *pend = client->prepareSessionCommand(Command_ListUsers());
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(processListUsersResponse(const Response &))); connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(processListUsersResponse(const Response &)));
client->sendCommand(pend); client->sendCommand(pend);
QVBoxLayout *vbox = new QVBoxLayout; QVBoxLayout *vbox = new QVBoxLayout;
vbox->addWidget(userInfoBox); vbox->addWidget(userInfoBox);
vbox->addWidget(allUsersList); vbox->addWidget(allUsersList);
QHBoxLayout *addToBuddyList = new QHBoxLayout;
addBuddyEdit = new QLineEdit;
addBuddyEdit->setPlaceholderText(tr("Add to Buddy List"));
connect(addBuddyEdit, SIGNAL(returnPressed()), this, SLOT(addToBuddyList()));
QPushButton *addBuddyButton = new QPushButton("Add");
connect(addBuddyButton, SIGNAL(clicked()), this, SLOT(addToBuddyList()));
addToBuddyList->addWidget(addBuddyEdit);
addToBuddyList->addWidget(addBuddyButton);
QHBoxLayout *addToIgnoreList = new QHBoxLayout;
addIgnoreEdit = new QLineEdit;
addIgnoreEdit->setPlaceholderText(tr("Add to Ignore List"));
connect(addIgnoreEdit, SIGNAL(returnPressed()), this, SLOT(addToIgnoreList()));
QPushButton *addIgnoreButton = new QPushButton("Add");
connect(addIgnoreButton, SIGNAL(clicked()), this, SLOT(addToIgnoreList()));
addToIgnoreList->addWidget(addIgnoreEdit);
addToIgnoreList->addWidget(addIgnoreButton);
QVBoxLayout *buddyPanel = new QVBoxLayout;
buddyPanel->addWidget(buddyList);
buddyPanel->addLayout(addToBuddyList);
QVBoxLayout *ignorePanel = new QVBoxLayout;
ignorePanel->addWidget(ignoreList);
ignorePanel->addLayout(addToIgnoreList);
QHBoxLayout *mainLayout = new QHBoxLayout; QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addWidget(buddyList); mainLayout->addLayout(buddyPanel);
mainLayout->addWidget(ignoreList); mainLayout->addLayout(ignorePanel);
mainLayout->addLayout(vbox); mainLayout->addLayout(vbox);
setLayout(mainLayout); setLayout(mainLayout);
} }
void TabUserLists::addToBuddyList()
{
QString userName = addBuddyEdit->text();
if (userName.length() < 1) return;
std::string listName = "buddy";
addToList(listName, userName);
addBuddyEdit->clear();
}
void TabUserLists::addToIgnoreList()
{
QString userName = addIgnoreEdit->text();
if (userName.length() < 1) return;
std::string listName = "ignore";
addToList(listName, userName);
addIgnoreEdit->clear();
}
void TabUserLists::addToList(const std::string &listName, const QString &userName)
{
Command_AddToList cmd;
cmd.set_list(listName);
cmd.set_user_name(userName.toStdString());
client->sendCommand(client->prepareSessionCommand(cmd));
}
void TabUserLists::retranslateUi() void TabUserLists::retranslateUi()
{ {
allUsersList->retranslateUi(); allUsersList->retranslateUi();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment