/* ERR_NICKNAMEINUSE */
void Server::handleServer433(QString prefix, QStringList params) {
- qDebug() << "433:" << params;
QString errnick = params[0];
emit displayMsg(Message::Error, "", tr("Nick %1 is already taken").arg(errnick));
// if there is a problem while connecting to the server -> we handle it
}
void ChannelWidgetInput::keyPressEvent(QKeyEvent * event) {
- if(event->key() == Qt::Key_Tab) {
- // Tabcomplete
- if(text().length() > 0) {
- tabComplete->complete();
- }
+ if(event->key() == Qt::Key_Tab) { // Tabcomplete
+ tabComplete->complete();
event->accept();
-
} else {
tabComplete->disable();
if(event->key() == Qt::Key_Up) {
tree->header()->hide();
tree->setSortingEnabled(true);
connect(tree, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(itemClicked(QTreeWidgetItem*)));
+ connect(tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*)));
+ connect(this, SIGNAL(fakeUserInput(BufferId, QString)), guiProxy, SLOT(gsUserInput(BufferId, QString)));
+
}
void NetworkView::setBuffers(QList<Buffer *> buffers) {
}
}
+void NetworkView::itemDoubleClicked(QTreeWidgetItem *item) {
+ Buffer *b = bufitems.key(item);
+ if(b) {
+ if(Buffer::ChannelBuffer == b->bufferType()) {
+ emit fakeUserInput(b->bufferId(), QString("/join " + b->bufferName()));
+ }
+ }
+}
+
void NetworkView::selectBuffer(Buffer *b) {
QTreeWidgetItem *item = 0;
if(bufitems.contains(b)) item = bufitems[b];
#include <QtGui>
#include "ui_networkview.h"
+#include "guiproxy.h"
#include "buffer.h"
typedef QHash<QString, QHash<QString, Buffer*> > BufferHash;
signals:
void bufferSelected(Buffer *);
-
+ void fakeUserInput(BufferId, QString);
+
private slots:
void itemClicked(QTreeWidgetItem *item);
-
+ void itemDoubleClicked(QTreeWidgetItem *item);
+
private:
int mode;
QString name;
TabCompleter::TabCompleter(QLineEdit *l, QObject *parent) : QObject(parent) {
lineEdit = l;
enabled = false;
+ startOfLineSuffix = QString(": "); // TODO make start of line suffix configurable
}
void TabCompleter::updateNickList(QStringList l) {
}
void TabCompleter::updateChannelList(QStringList l) {
-
+ channelList = l;
}
void TabCompleter::buildCompletionList() {
for (int i = 0; i < lastCompletionLength; i++) {
lineEdit->backspace();
}
- lineEdit->insert(*nextCompletion + ' ');
- lastCompletionLength = nextCompletion->length() + 1;
+
+ // insert completion
+ lineEdit->insert(*nextCompletion);
+
+ // remember charcount to delete next time and advance to next completion
+ lastCompletionLength = nextCompletion->length();
nextCompletion++;
- } else if (completionList.begin() != completionList.end()) {
+
+ // we're completing the first word of the line
+ if(lineEdit->text().length() == lastCompletionLength) {
+ lineEdit->insert(startOfLineSuffix);
+ lastCompletionLength += 2;
+ }
+
+ // we're at the end of the list -> start over again
+ } else {
nextCompletion = completionList.begin();
}
void updateChannelList(QStringList);
private:
+ bool enabled;
+ QString startOfLineSuffix;
QLineEdit *lineEdit;
QStringList completionTemplates;
- QStringList nickList;
QStringList channelList;
- int lastCompletionLength;
- bool enabled;
-
+ QStringList nickList;
QStringList completionList;
QStringList::Iterator nextCompletion;
-
+ int lastCompletionLength;
+
void buildCompletionList();
};