diff options
author | Tobias Markmann <tm@ayena.de> | 2016-03-31 14:57:35 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-03-31 14:57:35 (GMT) |
commit | cfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch) | |
tree | 18d94153a302445196fc0c18586abf44a1ce4a38 /Swift/QtUI/ChatList/QtChatListWindow.cpp | |
parent | 1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff) | |
download | swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2 |
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines
in the process.
Changed CheckTabs.py tool to disallow hard tabs in source
files.
Test-Information:
Manually checked 30 random files that the conversion worked
as expected.
Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swift/QtUI/ChatList/QtChatListWindow.cpp')
-rw-r--r-- | Swift/QtUI/ChatList/QtChatListWindow.cpp | 248 |
1 files changed, 124 insertions, 124 deletions
diff --git a/Swift/QtUI/ChatList/QtChatListWindow.cpp b/Swift/QtUI/ChatList/QtChatListWindow.cpp index b990b84..eddd0cd 100644 --- a/Swift/QtUI/ChatList/QtChatListWindow.cpp +++ b/Swift/QtUI/ChatList/QtChatListWindow.cpp @@ -31,197 +31,197 @@ namespace Swift { QtChatListWindow::QtChatListWindow(UIEventStream *uiEventStream, SettingsProvider* settings, QWidget* parent) : QTreeView(parent), isOnline_(false) { - eventStream_ = uiEventStream; - settings_ = settings; - bookmarksEnabled_ = false; - model_ = new ChatListModel(); - setModel(model_); - delegate_ = new ChatListDelegate(settings_->getSetting(QtUISettingConstants::COMPACT_ROSTER)); - setItemDelegate(delegate_); - setHeaderHidden(true); + eventStream_ = uiEventStream; + settings_ = settings; + bookmarksEnabled_ = false; + model_ = new ChatListModel(); + setModel(model_); + delegate_ = new ChatListDelegate(settings_->getSetting(QtUISettingConstants::COMPACT_ROSTER)); + setItemDelegate(delegate_); + setHeaderHidden(true); #ifdef SWIFT_PLATFORM_MACOSX - setAlternatingRowColors(true); + setAlternatingRowColors(true); #endif - expandAll(); - setAnimated(true); - setIndentation(0); - setDragEnabled(true); - setRootIsDecorated(true); - setupContextMenus(); - connect(this, SIGNAL(activated(const QModelIndex&)), this, SLOT(handleItemActivated(const QModelIndex&))); - connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(handleClicked(const QModelIndex&))); + expandAll(); + setAnimated(true); + setIndentation(0); + setDragEnabled(true); + setRootIsDecorated(true); + setupContextMenus(); + connect(this, SIGNAL(activated(const QModelIndex&)), this, SLOT(handleItemActivated(const QModelIndex&))); + connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(handleClicked(const QModelIndex&))); - settings_->onSettingChanged.connect(boost::bind(&QtChatListWindow::handleSettingChanged, this, _1)); + settings_->onSettingChanged.connect(boost::bind(&QtChatListWindow::handleSettingChanged, this, _1)); } QtChatListWindow::~QtChatListWindow() { - settings_->onSettingChanged.disconnect(boost::bind(&QtChatListWindow::handleSettingChanged, this, _1)); - delete model_; - delete delegate_; - delete mucMenu_; - delete emptyMenu_; + settings_->onSettingChanged.disconnect(boost::bind(&QtChatListWindow::handleSettingChanged, this, _1)); + delete model_; + delete delegate_; + delete mucMenu_; + delete emptyMenu_; } void QtChatListWindow::handleSettingChanged(const std::string& setting) { - if (setting == QtUISettingConstants::COMPACT_ROSTER.getKey()) { - delegate_->setCompact(settings_->getSetting(QtUISettingConstants::COMPACT_ROSTER)); - repaint(); - } + if (setting == QtUISettingConstants::COMPACT_ROSTER.getKey()) { + delegate_->setCompact(settings_->getSetting(QtUISettingConstants::COMPACT_ROSTER)); + repaint(); + } } void QtChatListWindow::handleClearRecentsRequested() { - onClearRecentsRequested(); + onClearRecentsRequested(); } void QtChatListWindow::setBookmarksEnabled(bool enabled) { - bookmarksEnabled_ = enabled; + bookmarksEnabled_ = enabled; } void QtChatListWindow::handleClicked(const QModelIndex& index) { - ChatListGroupItem* item = dynamic_cast<ChatListGroupItem*>(static_cast<ChatListItem*>(index.internalPointer())); - if (item) { - setExpanded(index, !isExpanded(index)); - } + ChatListGroupItem* item = dynamic_cast<ChatListGroupItem*>(static_cast<ChatListItem*>(index.internalPointer())); + if (item) { + setExpanded(index, !isExpanded(index)); + } } void QtChatListWindow::setupContextMenus() { - mucMenu_ = new QMenu(); - onlineOnlyActions_ << mucMenu_->addAction(tr("Add New Bookmark"), this, SLOT(handleAddBookmark())); - onlineOnlyActions_ << mucMenu_->addAction(tr("Edit Bookmark"), this, SLOT(handleEditBookmark())); - onlineOnlyActions_ << mucMenu_->addAction(tr("Remove Bookmark"), this, SLOT(handleRemoveBookmark())); - emptyMenu_ = new QMenu(); - onlineOnlyActions_ << emptyMenu_->addAction(tr("Add New Bookmark"), this, SLOT(handleAddBookmark())); + mucMenu_ = new QMenu(); + onlineOnlyActions_ << mucMenu_->addAction(tr("Add New Bookmark"), this, SLOT(handleAddBookmark())); + onlineOnlyActions_ << mucMenu_->addAction(tr("Edit Bookmark"), this, SLOT(handleEditBookmark())); + onlineOnlyActions_ << mucMenu_->addAction(tr("Remove Bookmark"), this, SLOT(handleRemoveBookmark())); + emptyMenu_ = new QMenu(); + onlineOnlyActions_ << emptyMenu_->addAction(tr("Add New Bookmark"), this, SLOT(handleAddBookmark())); } void QtChatListWindow::handleItemActivated(const QModelIndex& index) { - ChatListItem* item = model_->getItemForIndex(index); - if (ChatListMUCItem* mucItem = dynamic_cast<ChatListMUCItem*>(item)) { - onMUCBookmarkActivated(mucItem->getBookmark()); - } - else if (ChatListRecentItem* recentItem = dynamic_cast<ChatListRecentItem*>(item)) { - onRecentActivated(recentItem->getChat()); - } - else if (ChatListWhiteboardItem* whiteboardItem = dynamic_cast<ChatListWhiteboardItem*>(item)) { - if (!whiteboardItem->getChat().isMUC || bookmarksEnabled_) { - eventStream_->send(boost::make_shared<ShowWhiteboardUIEvent>(whiteboardItem->getChat().jid)); - } - } + ChatListItem* item = model_->getItemForIndex(index); + if (ChatListMUCItem* mucItem = dynamic_cast<ChatListMUCItem*>(item)) { + onMUCBookmarkActivated(mucItem->getBookmark()); + } + else if (ChatListRecentItem* recentItem = dynamic_cast<ChatListRecentItem*>(item)) { + onRecentActivated(recentItem->getChat()); + } + else if (ChatListWhiteboardItem* whiteboardItem = dynamic_cast<ChatListWhiteboardItem*>(item)) { + if (!whiteboardItem->getChat().isMUC || bookmarksEnabled_) { + eventStream_->send(boost::make_shared<ShowWhiteboardUIEvent>(whiteboardItem->getChat().jid)); + } + } } void QtChatListWindow::clearBookmarks() { - model_->clearBookmarks(); + model_->clearBookmarks(); } void QtChatListWindow::addMUCBookmark(const MUCBookmark& bookmark) { - model_->addMUCBookmark(bookmark); + model_->addMUCBookmark(bookmark); } void QtChatListWindow::removeMUCBookmark(const MUCBookmark& bookmark) { - model_->removeMUCBookmark(bookmark); + model_->removeMUCBookmark(bookmark); } void QtChatListWindow::addWhiteboardSession(const ChatListWindow::Chat& chat) { - model_->addWhiteboardSession(chat); + model_->addWhiteboardSession(chat); } void QtChatListWindow::removeWhiteboardSession(const JID& jid) { - model_->removeWhiteboardSession(jid); + model_->removeWhiteboardSession(jid); } void QtChatListWindow::setRecents(const std::list<ChatListWindow::Chat>& recents) { - model_->setRecents(recents); + model_->setRecents(recents); } void QtChatListWindow::setUnreadCount(int unread) { - emit onCountUpdated(unread); + emit onCountUpdated(unread); } void QtChatListWindow::setOnline(bool isOnline) { - isOnline_ = isOnline; + isOnline_ = isOnline; } void QtChatListWindow::handleRemoveBookmark() { - const ChatListMUCItem* mucItem = dynamic_cast<const ChatListMUCItem*>(contextMenuItem_); - if (!mucItem) return; - eventStream_->send(boost::shared_ptr<UIEvent>(new RemoveMUCBookmarkUIEvent(mucItem->getBookmark()))); + const ChatListMUCItem* mucItem = dynamic_cast<const ChatListMUCItem*>(contextMenuItem_); + if (!mucItem) return; + eventStream_->send(boost::shared_ptr<UIEvent>(new RemoveMUCBookmarkUIEvent(mucItem->getBookmark()))); } void QtChatListWindow::handleAddBookmarkFromRecents() { - const ChatListRecentItem* item = dynamic_cast<const ChatListRecentItem*>(contextMenuItem_); - if (item) { - const ChatListWindow::Chat& chat = item->getChat(); - MUCBookmark bookmark(chat.jid, chat.jid.toBare().toString()); - bookmark.setNick(chat.nick); - bookmark.setPassword(chat.password); - eventStream_->send(boost::shared_ptr<UIEvent>(new AddMUCBookmarkUIEvent(bookmark))); - } + const ChatListRecentItem* item = dynamic_cast<const ChatListRecentItem*>(contextMenuItem_); + if (item) { + const ChatListWindow::Chat& chat = item->getChat(); + MUCBookmark bookmark(chat.jid, chat.jid.toBare().toString()); + bookmark.setNick(chat.nick); + bookmark.setPassword(chat.password); + eventStream_->send(boost::shared_ptr<UIEvent>(new AddMUCBookmarkUIEvent(bookmark))); + } } void QtChatListWindow::handleAddBookmark() { - (new QtAddBookmarkWindow(eventStream_))->show(); + (new QtAddBookmarkWindow(eventStream_))->show(); } void QtChatListWindow::handleEditBookmark() { - const ChatListMUCItem* mucItem = dynamic_cast<const ChatListMUCItem*>(contextMenuItem_); - if (!mucItem) return; - QtEditBookmarkWindow* window = new QtEditBookmarkWindow(eventStream_, mucItem->getBookmark()); - window->show(); + const ChatListMUCItem* mucItem = dynamic_cast<const ChatListMUCItem*>(contextMenuItem_); + if (!mucItem) return; + QtEditBookmarkWindow* window = new QtEditBookmarkWindow(eventStream_, mucItem->getBookmark()); + window->show(); } void QtChatListWindow::dragEnterEvent(QDragEnterEvent *event) { - if (event->mimeData()->hasUrls() && event->mimeData()->urls().size() == 1) { - event->acceptProposedAction(); - } + if (event->mimeData()->hasUrls() && event->mimeData()->urls().size() == 1) { + event->acceptProposedAction(); + } } void QtChatListWindow::contextMenuEvent(QContextMenuEvent* event) { - QModelIndex index = indexAt(event->pos()); - ChatListItem* baseItem = index.isValid() ? static_cast<ChatListItem*>(index.internalPointer()) : NULL; - contextMenuItem_ = baseItem; - - foreach(QAction* action, onlineOnlyActions_) { - action->setEnabled(isOnline_); - } - - if (!baseItem) { - emptyMenu_->exec(QCursor::pos()); - return; - } - - ChatListMUCItem* mucItem = dynamic_cast<ChatListMUCItem*>(baseItem); - if (mucItem) { - if (!bookmarksEnabled_) { - return; - } - mucMenu_->exec(QCursor::pos()); - return; - } - - ChatListRecentItem* recentItem = dynamic_cast<ChatListRecentItem*>(baseItem); - if (recentItem) { - const ChatListWindow::Chat& chat = recentItem->getChat(); - if (chat.isMUC) { - QMenu mucRecentsMenu; - QAction* bookmarkAction = NULL; - const ChatListMUCItem* mucItem = model_->getChatListMUCItem(chat.jid); - if (mucItem) { - contextMenuItem_ = mucItem; - bookmarkAction = mucRecentsMenu.addAction(tr("Edit Bookmark"), this, SLOT(handleEditBookmark())); - } - else { - bookmarkAction = mucRecentsMenu.addAction(tr("Add to Bookmarks"), this, SLOT(handleAddBookmarkFromRecents())); - } - bookmarkAction->setEnabled(isOnline_); - mucRecentsMenu.addAction(tr("Clear recents"), this, SLOT(handleClearRecentsRequested())); - mucRecentsMenu.exec(QCursor::pos()); - return; - } - } - - QMenu menu; - menu.addAction(tr("Clear recents"), this, SLOT(handleClearRecentsRequested())); - menu.exec(event->globalPos()); + QModelIndex index = indexAt(event->pos()); + ChatListItem* baseItem = index.isValid() ? static_cast<ChatListItem*>(index.internalPointer()) : NULL; + contextMenuItem_ = baseItem; + + foreach(QAction* action, onlineOnlyActions_) { + action->setEnabled(isOnline_); + } + + if (!baseItem) { + emptyMenu_->exec(QCursor::pos()); + return; + } + + ChatListMUCItem* mucItem = dynamic_cast<ChatListMUCItem*>(baseItem); + if (mucItem) { + if (!bookmarksEnabled_) { + return; + } + mucMenu_->exec(QCursor::pos()); + return; + } + + ChatListRecentItem* recentItem = dynamic_cast<ChatListRecentItem*>(baseItem); + if (recentItem) { + const ChatListWindow::Chat& chat = recentItem->getChat(); + if (chat.isMUC) { + QMenu mucRecentsMenu; + QAction* bookmarkAction = NULL; + const ChatListMUCItem* mucItem = model_->getChatListMUCItem(chat.jid); + if (mucItem) { + contextMenuItem_ = mucItem; + bookmarkAction = mucRecentsMenu.addAction(tr("Edit Bookmark"), this, SLOT(handleEditBookmark())); + } + else { + bookmarkAction = mucRecentsMenu.addAction(tr("Add to Bookmarks"), this, SLOT(handleAddBookmarkFromRecents())); + } + bookmarkAction->setEnabled(isOnline_); + mucRecentsMenu.addAction(tr("Clear recents"), this, SLOT(handleClearRecentsRequested())); + mucRecentsMenu.exec(QCursor::pos()); + return; + } + } + + QMenu menu; + menu.addAction(tr("Clear recents"), this, SLOT(handleClearRecentsRequested())); + menu.exec(event->globalPos()); } } |