diff options
author | Remko Tronçon <git@el-tramo.be> | 2012-12-30 16:47:37 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2012-12-30 18:03:54 (GMT) |
commit | 96b31c598f5c229c3acc0579ddfe22dd503e2b9d (patch) | |
tree | d73db22e591e49f088f359b9876df232eb99c6a9 /Swift | |
parent | b19210aa48e7cea40929593daed997668fe789be (diff) | |
download | swift-contrib-96b31c598f5c229c3acc0579ddfe22dd503e2b9d.zip swift-contrib-96b31c598f5c229c3acc0579ddfe22dd503e2b9d.tar.bz2 |
Enable & fix pedantic CLang warnings.
Change-Id: I70109624b4bd7aab9ba679a3eaabc225dd64a03a
Diffstat (limited to 'Swift')
28 files changed, 83 insertions, 59 deletions
diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp index 50709f7..d380cd5 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.cpp +++ b/Swift/Controllers/Chat/ChatControllerBase.cpp @@ -13,6 +13,7 @@ #include <boost/shared_ptr.hpp> #include <boost/smart_ptr/make_shared.hpp> #include <boost/date_time/posix_time/posix_time.hpp> +#include <boost/numeric/conversion/cast.hpp> #include <boost/algorithm/string.hpp> #include <Swift/Controllers/Intl.h> @@ -62,7 +63,7 @@ void ChatControllerBase::createDayChangeTimer() { boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); boost::posix_time::ptime midnight(now.date() + boost::gregorian::days(1)); long millisecondsUntilMidnight = (midnight - now).total_milliseconds(); - dateChangeTimer_ = boost::shared_ptr<Timer>(timerFactory_->createTimer(millisecondsUntilMidnight)); + dateChangeTimer_ = boost::shared_ptr<Timer>(timerFactory_->createTimer(boost::numeric_cast<int>(millisecondsUntilMidnight))); dateChangeTimer_->onTick.connect(boost::bind(&ChatControllerBase::handleDayChangeTick, this)); dateChangeTimer_->start(); } @@ -112,7 +113,7 @@ void ChatControllerBase::handleAllMessagesRead() { } int ChatControllerBase::getUnreadCount() { - return targetedUnreadMessages_.size(); + return boost::numeric_cast<int>(targetedUnreadMessages_.size()); } void ChatControllerBase::handleSendMessageRequest(const std::string &body, bool isCorrectionMessage) { @@ -260,7 +261,7 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr<MessageEvent> m logMessage(body, from, selfJID_, timeStamp, true); } chatWindow_->show(); - chatWindow_->setUnreadMessageCount(unreadMessages_.size()); + chatWindow_->setUnreadMessageCount(boost::numeric_cast<int>(unreadMessages_.size())); onUnreadCountChanged(); postHandleIncomingMessage(messageEvent); } @@ -296,13 +297,14 @@ std::string ChatControllerBase::getErrorMessage(boost::shared_ptr<ErrorPayload> case ErrorPayload::UnexpectedRequest: return QT_TRANSLATE_NOOP("", "Unexpected request"); } } + assert(false); return defaultMessage; } void ChatControllerBase::handleGeneralMUCInvitation(MUCInviteEvent::ref event) { unreadMessages_.push_back(event); chatWindow_->show(); - chatWindow_->setUnreadMessageCount(unreadMessages_.size()); + chatWindow_->setUnreadMessageCount(boost::numeric_cast<int>(unreadMessages_.size())); onUnreadCountChanged(); chatWindow_->addMUCInvitation(senderDisplayNameFromMessage(event->getInviter()), event->getRoomJID(), event->getReason(), event->getPassword(), event->getDirect()); eventController_->handleIncomingEvent(event); diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 50eee68..d966d3f 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -228,6 +228,9 @@ void MUCController::receivedActivity() { } } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch-enum" + void MUCController::handleJoinFailed(boost::shared_ptr<ErrorPayload> error) { receivedActivity(); std::string errorMessage = QT_TRANSLATE_NOOP("", "Unable to enter this room"); @@ -275,6 +278,8 @@ void MUCController::handleJoinFailed(boost::shared_ptr<ErrorPayload> error) { } } +#pragma clang diagnostic pop + void MUCController::handleJoinComplete(const std::string& nick) { receivedActivity(); joined_ = true; @@ -386,6 +391,7 @@ std::string MUCController::roleToFriendlyName(MUCOccupant::Role role) { case MUCOccupant::Visitor: return QT_TRANSLATE_NOOP("", "visitor"); case MUCOccupant::NoRole: return ""; } + assert(false); return ""; } @@ -396,6 +402,7 @@ std::string MUCController::roleToSortName(MUCOccupant::Role role) { case MUCOccupant::Visitor: return "3"; case MUCOccupant::NoRole: return "4"; } + assert(false); return "5"; } @@ -487,7 +494,6 @@ std::string MUCController::roleToGroupName(MUCOccupant::Role role) { case MUCOccupant::Participant: result = QT_TRANSLATE_NOOP("", "Participants"); break; case MUCOccupant::Visitor: result = QT_TRANSLATE_NOOP("", "Visitors"); break; case MUCOccupant::NoRole: result = QT_TRANSLATE_NOOP("", "Occupants"); break; - default: assert(false); } return result; } @@ -611,7 +617,8 @@ void MUCController::appendToJoinParts(std::vector<NickJoinPart>& joinParts, cons switch (newEvent.type) { case Join: type = (type == Part) ? PartThenJoin : Join; break; case Part: type = (type == Join) ? JoinThenPart : Part; break; - default: /*Nothing to see here */;break; + case PartThenJoin: break; + case JoinThenPart: break; } (*it).type = type; break; diff --git a/Swift/Controllers/FileTransfer/FileTransferController.cpp b/Swift/Controllers/FileTransfer/FileTransferController.cpp index 3feaf49..d4a082a 100644 --- a/Swift/Controllers/FileTransfer/FileTransferController.cpp +++ b/Swift/Controllers/FileTransfer/FileTransferController.cpp @@ -138,7 +138,7 @@ void FileTransferController::handleFileTransferStateChange(FileTransfer::State s case FileTransfer::State::WaitingForStart: return; } - std::cerr << "Unhandled FileTransfer::State!" << std::endl; + assert(false); } void FileTransferController::handleProgressPercentageChange(int percentage) { diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 28d890d..c5bfcb8 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -297,7 +297,7 @@ void MainController::handleConnected() { myStatusLooksOnline_ = true; if (freshLogin) { profileController_ = new ProfileController(client_->getVCardManager(), uiFactory_, uiEventStream_); - srand(time(NULL)); + srand(static_cast<unsigned int>(time(NULL))); int randomPort = 10000 + rand() % 10000; client_->getFileTransferManager()->startListeningOnPort(randomPort); ftOverview_ = new FileTransferOverview(client_->getFileTransferManager()); diff --git a/Swift/Controllers/Roster/ContactRosterItem.cpp b/Swift/Controllers/Roster/ContactRosterItem.cpp index 8c388bf..5b1b6e0 100644 --- a/Swift/Controllers/Roster/ContactRosterItem.cpp +++ b/Swift/Controllers/Roster/ContactRosterItem.cpp @@ -24,12 +24,12 @@ StatusShow::Type ContactRosterItem::getStatusShow() const { StatusShow::Type ContactRosterItem::getSimplifiedStatusShow() const { switch (shownPresence_ ? shownPresence_->getShow() : StatusShow::None) { - case StatusShow::Online: return StatusShow::Online; break; - case StatusShow::Away: return StatusShow::Away; break; - case StatusShow::XA: return StatusShow::Away; break; - case StatusShow::FFC: return StatusShow::Online; break; - case StatusShow::DND: return StatusShow::DND; break; - case StatusShow::None: return StatusShow::None; break; + case StatusShow::Online: return StatusShow::Online; + case StatusShow::Away: return StatusShow::Away; + case StatusShow::XA: return StatusShow::Away; + case StatusShow::FFC: return StatusShow::Online; + case StatusShow::DND: return StatusShow::DND; + case StatusShow::None: return StatusShow::None; } assert(false); return StatusShow::None; diff --git a/Swift/Controllers/Roster/Roster.cpp b/Swift/Controllers/Roster/Roster.cpp index 65cf4d2..b5c5998 100644 --- a/Swift/Controllers/Roster/Roster.cpp +++ b/Swift/Controllers/Roster/Roster.cpp @@ -198,13 +198,13 @@ void Roster::removeFilter(RosterFilter *filter) { } void Roster::filterContact(ContactRosterItem* contact, GroupRosterItem* group) { - int oldDisplayedSize = group->getDisplayedChildren().size(); + size_t oldDisplayedSize = group->getDisplayedChildren().size(); bool hide = true; foreach (RosterFilter *filter, filters_) { hide &= (*filter)(contact); } group->setDisplayed(contact, filters_.empty() || !hide); - int newDisplayedSize = group->getDisplayedChildren().size(); + size_t newDisplayedSize = group->getDisplayedChildren().size(); if (oldDisplayedSize == 0 && newDisplayedSize > 0) { onGroupAdded(group); } diff --git a/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp b/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp index e433b50..db8a2fd 100644 --- a/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp +++ b/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp @@ -6,6 +6,8 @@ #include <Swift/Controllers/Roster/TableRoster.h> +std::ostream& operator<<(std::ostream& os, const Swift::TableRoster::Index& i); + std::ostream& operator<<(std::ostream& os, const Swift::TableRoster::Index& i) { os << "(" << i.section << ", " << i.row << ")"; return os; diff --git a/Swift/Controllers/StatusUtil.cpp b/Swift/Controllers/StatusUtil.cpp index fd1fea3..a72f340 100644 --- a/Swift/Controllers/StatusUtil.cpp +++ b/Swift/Controllers/StatusUtil.cpp @@ -6,6 +6,7 @@ #include <Swift/Controllers/StatusUtil.h> +#include <cassert> #include <Swift/Controllers/Intl.h> namespace Swift { @@ -19,6 +20,7 @@ std::string statusShowTypeToFriendlyName(StatusShow::Type type) { case StatusShow::DND: return QT_TRANSLATE_NOOP("", "Busy"); case StatusShow::None: return QT_TRANSLATE_NOOP("", "Offline"); } + assert(false); return ""; } diff --git a/Swift/Controllers/UnitTest/MockMainWindow.h b/Swift/Controllers/UnitTest/MockMainWindow.h index be1a932..19ab522 100644 --- a/Swift/Controllers/UnitTest/MockMainWindow.h +++ b/Swift/Controllers/UnitTest/MockMainWindow.h @@ -12,16 +12,16 @@ namespace Swift { class Roster; class MockMainWindow : public MainWindow { public: - MockMainWindow() : roster(NULL) {}; - virtual ~MockMainWindow() {}; - virtual void setRosterModel(Roster* roster) {this->roster = roster;}; - virtual void setMyNick(const std::string& /*name*/) {};; - virtual void setMyJID(const JID& /*jid*/) {};; - virtual void setMyAvatarPath(const std::string& /*path*/) {}; - virtual void setMyStatusText(const std::string& /*status*/) {}; - virtual void setMyStatusType(StatusShow::Type /*type*/) {}; - virtual void setAvailableAdHocCommands(const std::vector<DiscoItems::Item>& /*commands*/) {}; - virtual void setConnecting() {}; + MockMainWindow() : roster(NULL) {} + virtual ~MockMainWindow() {} + virtual void setRosterModel(Roster* roster) {this->roster = roster;} + virtual void setMyNick(const std::string& /*name*/) {} + virtual void setMyJID(const JID& /*jid*/) {} + virtual void setMyAvatarPath(const std::string& /*path*/) {} + virtual void setMyStatusText(const std::string& /*status*/) {} + virtual void setMyStatusType(StatusShow::Type /*type*/) {} + virtual void setAvailableAdHocCommands(const std::vector<DiscoItems::Item>& /*commands*/) {} + virtual void setConnecting() {} virtual void setStreamEncryptionStatus(bool /*tlsInPlaceAndValid*/) {} virtual void openCertificateDialog(const std::vector<Certificate::ref>& /*chain*/) {} Roster* roster; diff --git a/Swift/Controllers/XMPPEvents/EventController.cpp b/Swift/Controllers/XMPPEvents/EventController.cpp index d84dfe3..8cb259b 100644 --- a/Swift/Controllers/XMPPEvents/EventController.cpp +++ b/Swift/Controllers/XMPPEvents/EventController.cpp @@ -7,6 +7,7 @@ #include <Swift/Controllers/XMPPEvents/EventController.h> #include <boost/bind.hpp> +#include <boost/numeric/conversion/cast.hpp> #include <algorithm> #include <Swiften/Base/foreach.h> @@ -48,7 +49,7 @@ void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceE if ((messageEvent && messageEvent->isReadable()) || subscriptionEvent || errorEvent || mucInviteEvent) { events_.push_back(sourceEvent); sourceEvent->onConclusion.connect(boost::bind(&EventController::handleEventConcluded, this, sourceEvent)); - onEventQueueLengthChange(events_.size()); + onEventQueueLengthChange(boost::numeric_cast<int>(events_.size())); onEventQueueEventAdded(sourceEvent); if (sourceEvent->getConcluded()) { handleEventConcluded(sourceEvent); @@ -59,7 +60,7 @@ void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceE void EventController::handleEventConcluded(boost::shared_ptr<StanzaEvent> event) { event->onConclusion.disconnect(boost::bind(&EventController::handleEventConcluded, this, event)); events_.erase(std::remove(events_.begin(), events_.end(), event), events_.end()); - onEventQueueLengthChange(events_.size()); + onEventQueueLengthChange(boost::numeric_cast<int>(events_.size())); } void EventController::disconnectAll() { diff --git a/Swift/QtUI/EventViewer/EventDelegate.cpp b/Swift/QtUI/EventViewer/EventDelegate.cpp index 9ecdd34..fdb1866 100644 --- a/Swift/QtUI/EventViewer/EventDelegate.cpp +++ b/Swift/QtUI/EventViewer/EventDelegate.cpp @@ -29,7 +29,6 @@ QSize EventDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIn case SubscriptionEventType: return subscriptionDelegate_.sizeHint(option, item); case ErrorEventType: return errorDelegate_.sizeHint(option, item); case MUCInviteEventType: return mucInviteDelegate_.sizeHint(option, item); - default: return QStyledItemDelegate::sizeHint(option, index); } } @@ -44,7 +43,6 @@ void EventDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, case SubscriptionEventType: subscriptionDelegate_.paint(painter, option, item);break; case ErrorEventType: errorDelegate_.paint(painter, option, item);break; case MUCInviteEventType: mucInviteDelegate_.paint(painter, option, item);break; - default: QStyledItemDelegate::paint(painter, option, index); } } diff --git a/Swift/QtUI/QtAffiliationEditor.cpp b/Swift/QtUI/QtAffiliationEditor.cpp index ed03c23..0896b92 100644 --- a/Swift/QtUI/QtAffiliationEditor.cpp +++ b/Swift/QtUI/QtAffiliationEditor.cpp @@ -76,4 +76,4 @@ MUCOccupant::Affiliation QtAffiliationEditor::affiliationFromIndex(int affiliati } } -}
\ No newline at end of file +} diff --git a/Swift/QtUI/QtAffiliationEditor.h b/Swift/QtUI/QtAffiliationEditor.h index 913b2cc..96536eb 100644 --- a/Swift/QtUI/QtAffiliationEditor.h +++ b/Swift/QtUI/QtAffiliationEditor.h @@ -34,4 +34,4 @@ namespace Swift { std::map<MUCOccupant::Affiliation, std::vector<JID> > affiliations_; std::vector<ChangePair> changes_; }; -}
\ No newline at end of file +} diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp index d3a5676..7d8f16e 100644 --- a/Swift/QtUI/QtChatTabs.cpp +++ b/Swift/QtUI/QtChatTabs.cpp @@ -237,7 +237,7 @@ void QtChatTabs::handleTabTitleUpdated(QWidget* widget) { switch (tabbable->getWidgetAlertState()) { case QtTabbable::WaitingActivity : tabTextColor = QColor(217, 20, 43); break; case QtTabbable::ImpendingActivity : tabTextColor = QColor(27, 171, 32); break; - default : tabTextColor = QColor(); + case QtTabbable::NoActivity : tabTextColor = QColor(); break; } tabs_->tabBar()->setTabTextColor(index, tabTextColor); diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp index 81820a3..967ebec 100644 --- a/Swift/QtUI/QtChatView.cpp +++ b/Swift/QtUI/QtChatView.cpp @@ -365,7 +365,7 @@ void QtChatView::resetView() { connect(webPage_->mainFrame(), SIGNAL(contentsSizeChanged(const QSize&)), this, SLOT(handleFrameSizeChanged()), Qt::UniqueConnection); } -QWebElement findElementWithID(QWebElement document, QString elementName, QString id) { +static QWebElement findElementWithID(QWebElement document, QString elementName, QString id) { QWebElementCollection elements = document.findAll(elementName); foreach(QWebElement element, elements) { if (element.attribute("id") == id) { diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 28549f8..5d57184 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -576,6 +576,7 @@ std::string QtChatWindow::addAction(const std::string &message, const std::strin return addMessage(" *" + linkimoticonify(P2QSTRING(message)) + "*", senderName, senderIsSelf, label, avatarPath, "font-style:italic ", time); } +// FIXME: Move this to a different file std::string formatSize(const boost::uintmax_t bytes) { static const char *siPrefix[] = {"k", "M", "G", "T", "P", "E", "Z", "Y", NULL}; int power = 0; @@ -587,11 +588,11 @@ std::string formatSize(const boost::uintmax_t bytes) { return str( boost::format("%.1lf %sB") % engBytes % (power > 0 ? siPrefix[power-1] : "") ); } -QString encodeButtonArgument(const QString& str) { +static QString encodeButtonArgument(const QString& str) { return Qt::escape(P2QSTRING(Base64::encode(createByteArray(Q2PSTRING(str))))); } -QString decodeButtonArgument(const QString& str) { +static QString decodeButtonArgument(const QString& str) { return P2QSTRING(byteArrayToString(Base64::decode(Q2PSTRING(str)))); } diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index 3416b42..c32ae83 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -37,6 +37,9 @@ namespace Swift { class QtChatWindowJSBridge; class SettingsProvider; + // FIXME: Move this to a different file + std::string formatSize(const boost::uintmax_t bytes); + class LabelModel : public QAbstractListModel { Q_OBJECT public: diff --git a/Swift/QtUI/QtFileTransferListItemModel.cpp b/Swift/QtUI/QtFileTransferListItemModel.cpp index cf1de07..71961c2 100644 --- a/Swift/QtUI/QtFileTransferListItemModel.cpp +++ b/Swift/QtUI/QtFileTransferListItemModel.cpp @@ -9,14 +9,14 @@ #include <boost/bind.hpp> #include <boost/cstdint.hpp> +#include "QtChatWindow.h" // for formatSize + #include <Swiften/Base/boost_bsignals.h> #include <Swift/Controllers/FileTransfer/FileTransferController.h> #include <Swift/Controllers/FileTransfer/FileTransferOverview.h> namespace Swift { -extern std::string formatSize(const boost::uintmax_t bytes); - QtFileTransferListItemModel::QtFileTransferListItemModel(QObject *parent) : QAbstractItemModel(parent), fileTransferOverview(0) { } diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp index e54bd51..875235d 100644 --- a/Swift/QtUI/QtHistoryWindow.cpp +++ b/Swift/QtUI/QtHistoryWindow.cpp @@ -23,6 +23,7 @@ #include <QLineEdit> #include <boost/smart_ptr/make_shared.hpp> +#include <boost/numeric/conversion/cast.hpp> #include <boost/date_time/gregorian/gregorian.hpp> namespace Swift { @@ -183,7 +184,7 @@ void QtHistoryWindow::handleScrollReachedTop() { int year, month, day; QDate firstDate = *dates_.begin(); firstDate.getDate(&year, &month, &day); - onScrollReachedTop(boost::gregorian::date(year, month, day)); + onScrollReachedTop(boost::gregorian::date(boost::numeric_cast<unsigned short>(year), boost::numeric_cast<unsigned short>(month), boost::numeric_cast<unsigned short>(day))); } void QtHistoryWindow::handleScrollReachedBottom() { @@ -194,7 +195,7 @@ void QtHistoryWindow::handleScrollReachedBottom() { int year, month, day; QDate lastDate = *dates_.rbegin(); lastDate.getDate(&year, &month, &day); - onScrollReachedBottom(boost::gregorian::date(year, month, day)); + onScrollReachedBottom(boost::gregorian::date(boost::numeric_cast<unsigned short>(year), boost::numeric_cast<unsigned short>(month), boost::numeric_cast<unsigned short>(day))); } void QtHistoryWindow::handleReturnPressed() { @@ -205,7 +206,7 @@ void QtHistoryWindow::handleCalendarClicked(const QDate& date) { int year, month, day; QDate tempDate = date; // getDate discards const qualifier tempDate.getDate(&year, &month, &day); - onCalendarClicked(boost::gregorian::date(year, month, day)); + onCalendarClicked(boost::gregorian::date(boost::numeric_cast<unsigned short>(year), boost::numeric_cast<unsigned short>(month), boost::numeric_cast<unsigned short>(day))); } void QtHistoryWindow::setDate(const boost::gregorian::date& date) { @@ -242,7 +243,7 @@ boost::gregorian::date QtHistoryWindow::getLastVisibleDate() { int year, month, day; lastDate.getDate(&year, &month, &day); - return boost::gregorian::date(year, month, day); + return boost::gregorian::date(boost::numeric_cast<unsigned short>(year), boost::numeric_cast<unsigned short>(month), boost::numeric_cast<unsigned short>(day)); } return boost::gregorian::date(boost::gregorian::not_a_date_time); } diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index 96e08a3..4d10956 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -67,9 +67,9 @@ namespace Swift{ #if defined(SWIFTEN_PLATFORM_MACOSX) -#define SWIFT_APPCAST_URL "http://swift.im/appcast/swift-mac-dev.xml" +//#define SWIFT_APPCAST_URL "http://swift.im/appcast/swift-mac-dev.xml" #else -#define SWIFT_APPCAST_URL "" +//#define SWIFT_APPCAST_URL "" #endif po::options_description QtSwift::getOptionsDescription() { diff --git a/Swift/QtUI/QtWebView.cpp b/Swift/QtUI/QtWebView.cpp index 388f06a..1222ee2 100644 --- a/Swift/QtUI/QtWebView.cpp +++ b/Swift/QtUI/QtWebView.cpp @@ -9,6 +9,7 @@ #include <QKeyEvent> #include <QFocusEvent> +#include <boost/numeric/conversion/cast.hpp> #include <QMenu> namespace Swift { @@ -30,7 +31,7 @@ void QtWebView::keyPressEvent(QKeyEvent* event) { modifiers, event->text(), event->isAutoRepeat(), - event->count()); + boost::numeric_cast<unsigned short>(event->count())); QWebView::keyPressEvent(translatedEvent); delete translatedEvent; } diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index 54304d4..df7cc87 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -20,7 +20,12 @@ def generateDefaultTheme(dir) : Import("env") myenv = env.Clone() + +# Disable warnings that affect Qt myenv["CXXFLAGS"] = filter(lambda x : x != "-Wfloat-equal", myenv["CXXFLAGS"]) +if "clang" in env["CC"] : + myenv.Append(CXXFLAGS = ["-Wno-float-equal", "-Wno-shorten-64-to-32", "-Wno-missing-prototypes", "-Wno-unreachable-code", "-Wno-disabled-macro-expansion"]) + myenv.UseFlags(env["SWIFT_CONTROLLERS_FLAGS"]) myenv.UseFlags(env["SWIFTOOLS_FLAGS"]) if myenv["HAVE_XSS"] : diff --git a/Swift/QtUI/Whiteboard/ColorWidget.h b/Swift/QtUI/Whiteboard/ColorWidget.h index 6abdf00..ae1af0f 100644 --- a/Swift/QtUI/Whiteboard/ColorWidget.h +++ b/Swift/QtUI/Whiteboard/ColorWidget.h @@ -10,7 +10,7 @@ namespace Swift { class ColorWidget : public QWidget { - Q_OBJECT; + Q_OBJECT public: ColorWidget(QWidget* parent = 0); QSize sizeHint() const; diff --git a/Swift/QtUI/Whiteboard/FreehandLineItem.h b/Swift/QtUI/Whiteboard/FreehandLineItem.h index f3c6607..b1af3d1 100644 --- a/Swift/QtUI/Whiteboard/FreehandLineItem.h +++ b/Swift/QtUI/Whiteboard/FreehandLineItem.h @@ -10,8 +10,6 @@ #include <QPainter> #include <iostream> -using namespace std; - namespace Swift { class FreehandLineItem : public QGraphicsItem { public: diff --git a/Swift/QtUI/Whiteboard/GView.h b/Swift/QtUI/Whiteboard/GView.h index 88ea326..6a4fd2f 100644 --- a/Swift/QtUI/Whiteboard/GView.h +++ b/Swift/QtUI/Whiteboard/GView.h @@ -18,7 +18,7 @@ namespace Swift { class GView : public QGraphicsView { - Q_OBJECT; + Q_OBJECT public: enum Mode { Rubber, Line, Rect, Circle, HandLine, Text, Polygon, Select }; enum Type { New, Update, MoveUp, MoveDown }; diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp index 50d7f54..414e590 100644 --- a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp +++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp @@ -10,6 +10,7 @@ #include <boost/bind.hpp> #include <boost/smart_ptr/make_shared.hpp> +#include <boost/numeric/conversion/cast.hpp> #include <Swiften/Whiteboard/WhiteboardSession.h> #include <Swiften/Elements/WhiteboardPayload.h> @@ -264,7 +265,9 @@ namespace Swift { std::vector<std::pair<int, int> > points; QVector<QPointF>::const_iterator it = freehandLineItem->points().constBegin(); for ( ; it != freehandLineItem->points().constEnd(); ++it) { - points.push_back(std::pair<int, int>(it->x()+item->pos().x(), it->y()+item->pos().y())); + points.push_back(std::pair<int, int>( + boost::numeric_cast<int>(it->x()+item->pos().x()), + boost::numeric_cast<int>(it->y()+item->pos().y()))); } element->setColor(WhiteboardColor(color.red(), color.green(), color.blue(), color.alpha())); @@ -310,7 +313,9 @@ namespace Swift { std::vector<std::pair<int, int> > points; QVector<QPointF>::const_iterator it = polygon.begin(); for (; it != polygon.end(); ++it) { - points.push_back(std::pair<int, int>(it->x()+item->pos().x(), it->y()+item->pos().y())); + points.push_back(std::pair<int, int>( + boost::numeric_cast<int>(it->x()+item->pos().x()), + boost::numeric_cast<int>(it->y()+item->pos().y()))); } element->setPoints(points); @@ -328,10 +333,10 @@ namespace Swift { QGraphicsEllipseItem* ellipseItem = qgraphicsitem_cast<QGraphicsEllipseItem*>(item); if (ellipseItem) { QRectF rect = ellipseItem->rect(); - int cx = rect.x()+rect.width()/2 + item->pos().x(); - int cy = rect.y()+rect.height()/2 + item->pos().y(); - int rx = rect.width()/2; - int ry = rect.height()/2; + int cx = boost::numeric_cast<int>(rect.x()+rect.width()/2 + item->pos().x()); + int cy = boost::numeric_cast<int>(rect.y()+rect.height()/2 + item->pos().y()); + int rx = boost::numeric_cast<int>(rect.width()/2); + int ry = boost::numeric_cast<int>(rect.height()/2); WhiteboardEllipseElement::ref element = boost::make_shared<WhiteboardEllipseElement>(cx, cy, rx, ry); QColor penColor = ellipseItem->pen().color(); diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h index 4665ef0..3957bb7 100644 --- a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h +++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h @@ -30,7 +30,7 @@ namespace Swift { class QtWhiteboardWindow : public QWidget, public WhiteboardWindow { - Q_OBJECT; + Q_OBJECT public: QtWhiteboardWindow(WhiteboardSession::ref whiteboardSession); void show(); diff --git a/Swift/QtUI/Whiteboard/TextDialog.h b/Swift/QtUI/Whiteboard/TextDialog.h index f4d9a13..64a0fe2 100644 --- a/Swift/QtUI/Whiteboard/TextDialog.h +++ b/Swift/QtUI/Whiteboard/TextDialog.h @@ -16,12 +16,10 @@ #include <iostream> -using namespace std; - namespace Swift { class TextDialog : public QDialog { - Q_OBJECT; + Q_OBJECT public: TextDialog(QGraphicsTextItem* item, QWidget* parent = 0); |