summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-04-30 18:26:24 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-04-30 18:26:24 (GMT)
commit53c24201ab19c660c31a104c848b8ca94187b7c4 (patch)
tree695f8c13f5410e7ad7216de41f5c7fc49cd95aa4 /Swift/QtUI
parentb566cac68d7bb91f726b5353318b3a5eddd8f3c2 (diff)
downloadswift-53c24201ab19c660c31a104c848b8ca94187b7c4.zip
swift-53c24201ab19c660c31a104c848b8ca94187b7c4.tar.bz2
Edit bookmarks with very basic validation.
Doesn't save yet.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtAddBookmarkWindow.cpp9
-rw-r--r--Swift/QtUI/QtAddBookmarkWindow.h2
-rw-r--r--Swift/QtUI/QtBookmarkDetailWindow.cpp14
-rw-r--r--Swift/QtUI/QtBookmarkDetailWindow.h2
-rw-r--r--Swift/QtUI/QtEditBookmarkWindow.cpp15
-rw-r--r--Swift/QtUI/QtEditBookmarkWindow.h2
6 files changed, 33 insertions, 11 deletions
diff --git a/Swift/QtUI/QtAddBookmarkWindow.cpp b/Swift/QtUI/QtAddBookmarkWindow.cpp
index 863e98c..2403eac 100644
--- a/Swift/QtUI/QtAddBookmarkWindow.cpp
+++ b/Swift/QtUI/QtAddBookmarkWindow.cpp
@@ -13,9 +13,12 @@ QtAddBookmarkWindow::QtAddBookmarkWindow(UIEventStream* eventStream) : eventStre
}
-void QtAddBookmarkWindow::commit() {
- qDebug() << "committing";
- eventStream_->send(boost::shared_ptr<UIEvent>(new AddMUCBookmarkUIEvent(createBookmarkFromForm())));
+bool QtAddBookmarkWindow::commit() {
+ boost::shared_ptr<MUCBookmark> bookmark(createBookmarkFromForm());
+ if (bookmark) {
+ eventStream_->send(boost::shared_ptr<UIEvent>(new AddMUCBookmarkUIEvent(bookmark)));
+ }
+ return bookmark;
}
}
diff --git a/Swift/QtUI/QtAddBookmarkWindow.h b/Swift/QtUI/QtAddBookmarkWindow.h
index 8e33180..f026cc3 100644
--- a/Swift/QtUI/QtAddBookmarkWindow.h
+++ b/Swift/QtUI/QtAddBookmarkWindow.h
@@ -16,7 +16,7 @@ namespace Swift {
Q_OBJECT
public:
QtAddBookmarkWindow(UIEventStream* eventStream);
- void commit();
+ bool commit();
private:
UIEventStream* eventStream_;
};
diff --git a/Swift/QtUI/QtBookmarkDetailWindow.cpp b/Swift/QtUI/QtBookmarkDetailWindow.cpp
index ef524c3..b27ed7c 100644
--- a/Swift/QtUI/QtBookmarkDetailWindow.cpp
+++ b/Swift/QtUI/QtBookmarkDetailWindow.cpp
@@ -6,6 +6,7 @@
#include "QtBookmarkDetailWindow.h"
#include "QtSwiftUtil.h"
+#include <QMessageBox>
namespace Swift {
@@ -17,15 +18,24 @@ QtBookmarkDetailWindow::QtBookmarkDetailWindow(QWidget* parent) : QDialog(parent
}
void QtBookmarkDetailWindow::accept() {
- commit();
- QDialog::accept();
+ if (commit()) {
+ QDialog::accept();
+ }
}
boost::shared_ptr<MUCBookmark> QtBookmarkDetailWindow::createBookmarkFromForm() {
//check room
//check bookmarkName
JID room(Q2PSTRING(room_->text()));
+ if (!room.isValid() || room.getNode().isEmpty() || !room.getResource().isEmpty()) {
+ QMessageBox::warning(this, "Bookmark not valid", "You must specify a valid room address (e.g. myroom@chats.example.com).");
+ return boost::shared_ptr<MUCBookmark>();
+ }
String name(Q2PSTRING(name_->text()));
+ if (name.isEmpty()) {
+ name = room.toString();
+ }
+
String nick(Q2PSTRING(nick_->text()));
String password(Q2PSTRING(password_->text()));
bool autojoin = autojoin_->isChecked();
diff --git a/Swift/QtUI/QtBookmarkDetailWindow.h b/Swift/QtUI/QtBookmarkDetailWindow.h
index 82bfe9b..dadd973 100644
--- a/Swift/QtUI/QtBookmarkDetailWindow.h
+++ b/Swift/QtUI/QtBookmarkDetailWindow.h
@@ -19,7 +19,7 @@ namespace Swift {
Q_OBJECT
public:
QtBookmarkDetailWindow(QWidget* parent = NULL);
- virtual void commit() = 0;
+ virtual bool commit() = 0;
boost::shared_ptr<MUCBookmark> createBookmarkFromForm();
public slots:
void accept();
diff --git a/Swift/QtUI/QtEditBookmarkWindow.cpp b/Swift/QtUI/QtEditBookmarkWindow.cpp
index 016f17e..76a01f6 100644
--- a/Swift/QtUI/QtEditBookmarkWindow.cpp
+++ b/Swift/QtUI/QtEditBookmarkWindow.cpp
@@ -6,13 +6,22 @@
#include "QtEditBookmarkWindow.h"
+#include "QtSwiftUtil.h"
+
namespace Swift {
QtEditBookmarkWindow::QtEditBookmarkWindow(UIEventStream* eventStream, boost::shared_ptr<MUCBookmark> bookmark) : eventStream_(eventStream), bookmark_(bookmark) {
-
+ name_->setText(P2QSTRING(bookmark->getName()));
+ room_->setText(P2QSTRING(bookmark->getRoom().toString()));
+ autojoin_->setChecked(bookmark->getAutojoin());
+ nick_->setText(bookmark->getNick() ? P2QSTRING(bookmark->getNick().get()) : "");
+ password_->setText(bookmark->getPassword() ? P2QSTRING(bookmark->getPassword().get()) : "");
}
-void QtEditBookmarkWindow::commit() {
- eventStream_->send(boost::shared_ptr<UIEvent>(new EditMUCBookmarkUIEvent(bookmark_, createBookmarkFromForm())));
+bool QtEditBookmarkWindow::commit() {
+ boost::shared_ptr<MUCBookmark> bookmark = createBookmarkFromForm();
+ if (!bookmark) return false;
+ eventStream_->send(boost::shared_ptr<UIEvent>(new EditMUCBookmarkUIEvent(bookmark_, bookmark)));
+ return true;
}
}
diff --git a/Swift/QtUI/QtEditBookmarkWindow.h b/Swift/QtUI/QtEditBookmarkWindow.h
index 3c11fbe..1ca5001 100644
--- a/Swift/QtUI/QtEditBookmarkWindow.h
+++ b/Swift/QtUI/QtEditBookmarkWindow.h
@@ -15,7 +15,7 @@ namespace Swift {
Q_OBJECT
public:
QtEditBookmarkWindow(UIEventStream* eventStream, boost::shared_ptr<MUCBookmark> bookmark);
- void commit();
+ bool commit();
private:
UIEventStream* eventStream_;