better way to sync bookmarks; no more c++11; refs #116

master
Marc Wäckerlin 13 years ago
parent 4231ee5dee
commit fb2042ae7c
  1. 18
      src/browser.hxx
  2. 26
      src/editbookmarks.hxx
  3. 3
      src/qmake.pro.in

@ -148,6 +148,10 @@ class Browser: public QMainWindow, protected Ui::Browser {
} }
_editbookmarks = _editbookmarks =
std::auto_ptr<EditBookmarks>(new EditBookmarks(combo, this)); std::auto_ptr<EditBookmarks>(new EditBookmarks(combo, this));
assert(connect(_editbookmarks.get(), SIGNAL(startEdit()),
actionAddBookmark, SLOT(setDisabled())));
assert(connect(_editbookmarks.get(), SIGNAL(endEdit()),
actionAddBookmark, SLOT(setEnabled())));
} else { } else {
QLineEdit* label(new QLineEdit(_toolbar)); QLineEdit* label(new QLineEdit(_toolbar));
_url = label; _url = label;
@ -184,16 +188,16 @@ class Browser: public QMainWindow, protected Ui::Browser {
assert(connect(&_networkManager, SIGNAL(finished(QNetworkReply*)), assert(connect(&_networkManager, SIGNAL(finished(QNetworkReply*)),
SLOT(finished(QNetworkReply*)))); SLOT(finished(QNetworkReply*))));
assert(connect(&_networkManager, SIGNAL(created(QNetworkReply*)), assert(connect(&_networkManager, SIGNAL(created(QNetworkReply*)),
_downloadManager.get(), SLOT(add(QNetworkReply*)))); _downloadManager.data(), SLOT(add(QNetworkReply*))));
assert(connect(_downloadManager.get(), SIGNAL(progress(qint64, qint64)), assert(connect(_downloadManager.data(), SIGNAL(progress(qint64, qint64)),
SLOT(progress(qint64, qint64)))); SLOT(progress(qint64, qint64))));
assert(connect(_downloadManager.get(), SIGNAL(started()), assert(connect(_downloadManager.data(), SIGNAL(started()),
SLOT(started()))); SLOT(started())));
assert(connect(_downloadManager.get(), SIGNAL(finished()), assert(connect(_downloadManager.data(), SIGNAL(finished()),
SLOT(finished()))); SLOT(finished())));
assert(connect(_downloadManager.get(), SIGNAL(error(QString)), assert(connect(_downloadManager.data(), SIGNAL(error(QString)),
SLOT(downloadError(QString)))); SLOT(downloadError(QString))));
assert(connect(_downloadManager.get(), SIGNAL(metaDataChanged(QNetworkReply*)), assert(connect(_downloadManager.data(), SIGNAL(metaDataChanged(QNetworkReply*)),
SLOT(metaDataChanged(QNetworkReply*)))); SLOT(metaDataChanged(QNetworkReply*))));
assert(connect(&_settings, SIGNAL(newSettings()), SLOT(newSettings()))); assert(connect(&_settings, SIGNAL(newSettings()), SLOT(newSettings())));
newSettings(); newSettings();
@ -1532,7 +1536,7 @@ class Browser: public QMainWindow, protected Ui::Browser {
bool _kiosk; bool _kiosk;
QPrinter _printer; QPrinter _printer;
SslClientAuthNetworkAccessManager _networkManager; SslClientAuthNetworkAccessManager _networkManager;
std::shared_ptr<DownloadManager> _downloadManager; QSharedPointer<DownloadManager> _downloadManager;
typedef std::map<QProcess*, TemporaryFile*> DownloadProcesses; typedef std::map<QProcess*, TemporaryFile*> DownloadProcesses;
DownloadProcesses _downloadProcesses; DownloadProcesses _downloadProcesses;
Settings _settings; Settings _settings;

@ -17,6 +17,9 @@
class EditBookmarks: public QDialog, protected Ui::EditBookmarks { class EditBookmarks: public QDialog, protected Ui::EditBookmarks {
Q_OBJECT; Q_OBJECT;
Q_SIGNALS:
void startEdit();
void endEdit();
public: public:
EditBookmarks(QComboBox* url, QWidget* p=0): QDialog(p), _url(url) { EditBookmarks(QComboBox* url, QWidget* p=0): QDialog(p), _url(url) {
setupUi(this); setupUi(this);
@ -33,11 +36,7 @@ class EditBookmarks: public QDialog, protected Ui::EditBookmarks {
QDialog::accept(); QDialog::accept();
} }
virtual void reject() { virtual void reject() {
QStringList urls; reset();
for (int i(0); i<_url->count(); ++i)
urls<<_url->itemText(i);
_bookmarks->clear();
_bookmarks->addItems(urls);
QDialog::reject(); QDialog::reject();
} }
protected Q_SLOTS: protected Q_SLOTS:
@ -53,6 +52,23 @@ class EditBookmarks: public QDialog, protected Ui::EditBookmarks {
void on__add_clicked(bool) { void on__add_clicked(bool) {
_bookmarks->addItem(_url->currentText()); _bookmarks->addItem(_url->currentText());
} }
protected:
virtual void hideEvent(QHideEvent *event) {
QDialog::hideEvent(event);
endEdit();
}
virtual void showEvent(QShowEvent *event) {
startEdit();
reset();
QDialog::showEvent(event);
}
void reset() {
QStringList urls;
for (int i(0); i<_url->count(); ++i)
urls<<_url->itemText(i);
_bookmarks->clear();
_bookmarks->addItems(urls);
}
private: private:
QComboBox* _url; QComboBox* _url;
}; };

@ -1,6 +1,7 @@
QT += webkit network gui QT += webkit network gui
QMAKE_LIBS += -lproxyface -lpcscxx -lssl -lcrypto QMAKE_LIBS += -lproxyface -lpcscxx -lssl -lcrypto
QMAKE_CXXFLAGS += -Wno-parentheses -Wno-unused-parameter -std=c++0x QMAKE_CXXFLAGS += -Wno-parentheses -Wno-unused-parameter
#-std=c++0x
QMAKE_INCDIR += @top_srcdir@/src QMAKE_INCDIR += @top_srcdir@/src
QMAKE_LIBDIR += @top_builddir@/src/qbrowserlib QMAKE_LIBDIR += @top_builddir@/src/qbrowserlib
QMAKE_LIBS += -lqbrowserlib QMAKE_LIBS += -lqbrowserlib

Loading…
Cancel
Save