Added a static Method Client::fakeInput(BufferId, Message) to help easy automation of stuff like joining channels.
case BufferTreeModel::BufferNameRole:
return buf->bufferName();
case BufferTreeModel::BufferTypeRole:
- return buf->bufferType();
+ return int(buf->bufferType());
case BufferTreeModel::BufferActiveRole:
return buf->isActive();
- case BufferTreeModel::BufferInfoRole:
+ case BufferTreeModel::BufferUidRole:
return buf->bufferInfo().uid();
default:
return QVariant();
}
}
-// we received a double click on a buffer, so we're going to join it
-void BufferTreeModel::doubleClickReceived(const QModelIndex &clicked) {
- if(isBufferIndex(clicked)) {
- Buffer *buffer = getBufferByIndex(clicked);
- if(!buffer->isStatusBuffer())
- emit fakeUserInput(buffer->bufferInfo(), QString("/join " + buffer->bufferName()));
- }
-}
-
void BufferTreeModel::bufferActivity(Buffer::ActivityLevel level, Buffer *buffer) {
BufferTreeItem *bufferItem = static_cast<BufferTreeItem*>(getOrCreateBufferItemIndex(buffer).internalPointer());
if(buffer != currentBuffer)
BufferTypeRole = Qt::UserRole,
BufferActiveRole,
BufferNameRole,
- BufferInfoRole
+ BufferUidRole
};
BufferTreeModel(QObject *parent = 0);
void bufferUpdated(Buffer *);
void changeCurrent(const QModelIndex &, const QModelIndex &);
void selectBuffer(Buffer *buffer);
- void doubleClickReceived(const QModelIndex &);
void bufferActivity(Buffer::ActivityLevel, Buffer *buffer);
signals:
return instance()->connectedToCore;
}
+void Client::fakeInput(uint bufferUid, QString message) {
+ Buffer *buff = buffer(bufferUid);
+ if(!buff)
+ qWarning() << "No Buffer with uid" << bufferUid << "can't send Input" << message;
+ else
+ emit instance()->sendInput(buff->bufferInfo(), message);
+}
+
+void Client::fakeInput(BufferInfo bufferInfo, QString message) {
+ fakeInput(bufferInfo, message);
+}
+
void Client::connectToCore(const QVariantMap &conn) {
// TODO implement SSL
coreConnectionInfo = conn;
static bool isConnected();
+ static void fakeInput(uint bufferUid, QString message);
+ static void fakeInput(BufferInfo bufferInfo, QString message);
+
static void storeSessionData(const QString &key, const QVariant &data);
static QVariant retrieveSessionData(const QString &key, const QVariant &def = QVariant());
static QStringList sessionDataKeys();
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include "client.h"
#include "bufferview.h"
+#include "buffertreemodel.h"
/*****************************************
* The TreeView showing the Buffers
connect(selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
model(), SLOT(changeCurrent(const QModelIndex &, const QModelIndex &)));
- connect(this, SIGNAL(doubleClicked(const QModelIndex &)),
- model(), SLOT(doubleClickReceived(const QModelIndex &)));
-
connect(model(), SIGNAL(selectionChanged(const QModelIndex &)),
this, SLOT(select(const QModelIndex &)));
connect(this, SIGNAL(selectionChanged(const QModelIndex &, QItemSelectionModel::SelectionFlags)),
selectionModel(), SLOT(select(const QModelIndex &, QItemSelectionModel::SelectionFlags)));
+ connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(joinChannel(QModelIndex)));
}
void BufferView::setFilteredModel(QAbstractItemModel *model, BufferViewFilter::Modes mode, QStringList nets) {
QTreeView::dropEvent(event);
}
+void BufferView::joinChannel(const QModelIndex &index) {
+ Buffer::Type bufferType = (Buffer::Type)index.data(BufferTreeModel::BufferTypeRole).toInt();
+
+ if(bufferType != Buffer::ChannelBuffer)
+ return;
+
+ Client::fakeInput(index.data(BufferTreeModel::BufferUidRole).toUInt(), QString("/JOIN %1").arg(index.sibling(index.row(), 0).data().toString()));
+}
+
void BufferView::keyPressEvent(QKeyEvent *event) {
if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) {
event->accept();
void removeBuffer(const QModelIndex &);
void selectionChanged(const QModelIndex &, QItemSelectionModel::SelectionFlags);
-protected:
+private slots:
void dropEvent(QDropEvent *);
+ void joinChannel(const QModelIndex &index);
void keyPressEvent(QKeyEvent *);
void rowsInserted (const QModelIndex & parent, int start, int end);
};
connect(this, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
model, SLOT(changeCurrent(const QModelIndex &, const QModelIndex &)));
-
- connect(this, SIGNAL(doubleClicked(const QModelIndex &)),
- model, SLOT(doubleClickReceived(const QModelIndex &)));
}
void BufferViewFilter::invalidateMe() {
if(index.parent() == QModelIndex())
return; // only child elements can be deleted
- uint bufferuid = index.data(BufferTreeModel::BufferInfoRole).toUInt();
+ uint bufferuid = index.data(BufferTreeModel::BufferUidRole).toUInt();
if(customBuffers.contains(bufferuid)) {
beginRemoveRows(index.parent(), index.row(), index.row());
customBuffers.removeAt(customBuffers.indexOf(bufferuid));
if((mode & NoInactive) && !isActive) return false;
if((mode & FullCustom)) {
- uint bufferuid = source_bufferIndex.data(BufferTreeModel::BufferInfoRole).toUInt();
+ uint bufferuid = source_bufferIndex.data(BufferTreeModel::BufferUidRole).toUInt();
if(!customBuffers.contains(bufferuid))
return false;
}
int childcount = sourceModel()->rowCount(source_index);
for(int rowid = 0; rowid < childcount; rowid++) {
QModelIndex child = sourceModel()->index(rowid, 0, source_index);
- uint bufferuid = child.data(BufferTreeModel::BufferInfoRole).toUInt();
+ uint bufferuid = child.data(BufferTreeModel::BufferUidRole).toUInt();
if(customBuffers.contains(bufferuid))
return true;
}
: QWidget(parent)
{
ui.setupUi(this);
- ui.topicLineEdit->setText("+++ DUMMY TOPIC +++ DUMMY TOPIC +++");
+}
+
+QString TopicWidget::topic() const {
+ return ui.topicLineEdit->text();
+}
+
+void TopicWidget::setTopic(const QString &newtopic) {
+ ui.topicLineEdit->setText(newtopic);
}
TopicWidget::~TopicWidget() {
class TopicWidget : public QWidget {
Q_OBJECT
+ Q_PROPERTY(QString topic READ topic WRITE setTopic STORED false)
public:
TopicWidget(QWidget *parent = 0);
virtual ~TopicWidget();
+ QString topic() const;
+ void setTopic(const QString &newtopic);
private:
Ui::TopicWidget ui;