MessageView::MessageView(MessageView::ViewType type, Session* session, QWidget* parent) : QWidget(parent) { d.setupUi(this); d.viewType = type; d.topicLabel->setMinimumHeight(d.lineEditor->sizeHint().height()); d.helpLabel->setMinimumHeight(d.lineEditor->sizeHint().height()); connect(d.splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(onSplitterMoved())); setFocusProxy(d.lineEditor); d.textBrowser->setBuddy(d.lineEditor); d.formatter.setHighlights(QStringList(session->nickName())); d.formatter.setMessageFormat("class='message'"); d.formatter.setEventFormat("class='event'"); d.formatter.setNoticeFormat("class='notice'"); d.formatter.setActionFormat("class='action'"); d.formatter.setUnknownFormat("class='unknown'"); d.formatter.setHighlightFormat("class='highlight'"); d.formatter.setTimeStampFormat("class='timestamp'"); d.session = session; connect(&d.parser, SIGNAL(customCommand(QString,QStringList)), this, SLOT(onCustomCommand(QString,QStringList))); d.topicLabel->setVisible(type == ChannelView); d.listView->setVisible(type == ChannelView); if (type == ChannelView) { d.listView->setSession(session); connect(d.listView, SIGNAL(queried(QString)), this, SIGNAL(queried(QString))); connect(d.listView, SIGNAL(doubleClicked(QString)), this, SIGNAL(queried(QString))); connect(d.listView, SIGNAL(commandRequested(IrcCommand*)), d.session, SLOT(sendCommand(IrcCommand*))); }
BufferView::BufferView(QWidget* parent) : QWidget(parent) { d.buffer = 0; d.titleBar = new TitleBar(this); d.listView = new ListView(this); d.textInput = new TextInput(this); d.textBrowser = new TextBrowser(this); d.textBrowser->setBuddy(d.textInput); d.textBrowser->setFocusPolicy(Qt::ClickFocus); d.textBrowser->viewport()->setAttribute(Qt::WA_AcceptTouchEvents, false); d.splitter = new QSplitter(this); d.splitter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); QShortcut* zoomIn = new QShortcut(QKeySequence::ZoomIn, this); zoomIn->setContext(Qt::WidgetWithChildrenShortcut); connect(zoomIn, SIGNAL(activated()), d.textBrowser, SLOT(zoomIn())); QShortcut* zoomOut = new QShortcut(QKeySequence::ZoomOut, this); zoomOut->setContext(Qt::WidgetWithChildrenShortcut); connect(zoomOut, SIGNAL(activated()), d.textBrowser, SLOT(zoomOut())); QShortcut* resetZoom = new QShortcut(QKeySequence("Ctrl+0"), this); resetZoom->setContext(Qt::WidgetWithChildrenShortcut); connect(resetZoom, SIGNAL(activated()), d.textBrowser, SLOT(resetZoom())); QShortcut* pageDown = new QShortcut(QKeySequence::MoveToNextPage, this); pageDown->setContext(Qt::WidgetWithChildrenShortcut); connect(pageDown, SIGNAL(activated()), d.textBrowser, SLOT(scrollToNextPage())); QShortcut* pageUp = new QShortcut(QKeySequence::MoveToPreviousPage, this); pageUp->setContext(Qt::WidgetWithChildrenShortcut); connect(pageUp, SIGNAL(activated()), d.textBrowser, SLOT(scrollToPreviousPage())); QVBoxLayout* layout = new QVBoxLayout(this); layout->setSpacing(0); layout->setMargin(0); layout->addWidget(d.splitter); layout->addWidget(d.textInput); layout->setStretchFactor(d.splitter, 1); connect(d.titleBar, SIGNAL(offsetChanged(int)), d.textBrowser, SLOT(moveShadow(int))); d.titleBar->raise(); d.splitter->addWidget(d.textBrowser); d.splitter->addWidget(d.listView); d.splitter->setStretchFactor(0, 1); connect(d.listView, SIGNAL(queried(QString)), this, SLOT(query(QString))); connect(d.textBrowser, SIGNAL(queried(QString)), this, SLOT(query(QString))); }
MessageView::MessageView(ViewInfo::Type type, IrcConnection* connection, IrcChannelStackView* stackView) : QWidget(stackView) { d.setupUi(this); d.viewType = type; d.sentId = 1; #if QT_VERSION >= 0x040700 d.awayReply.invalidate(); #else d.awayReply = QTime(); #endif d.playback = false; d.parser = stackView->parser(); d.firstNames = true; d.messageTimer = new QTimer(this); connect(d.messageTimer, SIGNAL(timeout()), this, SLOT(sendMessageLine())); d.joined = 0; d.parted = 0; d.connected = 0; d.disconnected = 0; d.chatInput = new CWidgetChatInput(this, true); d.verticalLayoutInputWidget->addWidget(d.chatInput); d.widgetInput->setFixedHeight(130); d.chatInput->setFixedHeight(130); connect(d.splitter, SIGNAL(splitterMoved(int, int)), this, SLOT(onSplitterMoved())); setFocusProxy(d.chatInput->textEdit()); d.textBrowser->setBuddy(d.chatInput->textEdit()); d.textBrowser->viewport()->installEventFilter(this); connect(d.textBrowser, SIGNAL(anchorClicked(QUrl)), SLOT(onAnchorClicked(QUrl))); d.highlighter = new SyntaxHighlighter(d.textBrowser->document()); d.connection = connection; connect(d.connection, SIGNAL(statusChanged(IrcConnection::Status)), this, SLOT(onConnectionStatusChanged())); if (type == ViewInfo::Server) connect(d.connection, SIGNAL(socketError(QAbstractSocket::SocketError)), this, SLOT(onSocketError())); d.topicLabel->setVisible(type == ViewInfo::Channel); d.listView->setVisible(type == ViewInfo::Channel); if (type == ViewInfo::Channel) { d.listView->setConnection(connection); connect(d.listView, SIGNAL(queried(QString)), this, SIGNAL(queried(QString))); connect(d.listView, SIGNAL(doubleClicked(QString)), this, SIGNAL(queried(QString))); connect(d.listView, SIGNAL(commandRequested(IrcCommand*)), d.connection, SLOT(sendCommand(IrcCommand*))); connect(d.topicLabel, SIGNAL(edited(QString)), this, SLOT(onTopicEdited(QString))); } else if (type == ViewInfo::Server) {
void ListView::onQueryTriggered() { QAction* action = qobject_cast<QAction*>(sender()); if (action) emit queried(action->data().toString()); }
void ListView::onDoubleClicked(const QModelIndex& index) { if (index.isValid()) emit queried(index.data(Irc::NameRole).toString()); }