You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.0 KiB
80 lines
2.0 KiB
13 years ago
|
/*! @file
|
||
|
|
||
|
@id $Id$
|
||
|
*/
|
||
|
// 1 2 3 4 5 6 7 8
|
||
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||
|
|
||
|
#ifndef __EDITBOOKMARKS_HXX__
|
||
|
#define __EDITBOOKMARKS_HXX__
|
||
|
|
||
9 years ago
|
#include <QDialog>
|
||
|
#include <QComboBox>
|
||
|
#include <QLineEdit>
|
||
9 years ago
|
#include <qbrowserlib/ui_editbookmarks.hxx>
|
||
13 years ago
|
|
||
|
#include <QDebug>
|
||
|
|
||
9 years ago
|
namespace qbrowserlib {
|
||
|
|
||
13 years ago
|
class EditBookmarks: public QDialog, protected Ui::EditBookmarks {
|
||
|
Q_OBJECT;
|
||
12 years ago
|
Q_SIGNALS:
|
||
12 years ago
|
void startEdit(bool=true);
|
||
|
void endEdit(bool=true);
|
||
13 years ago
|
public:
|
||
|
EditBookmarks(QComboBox* url, QWidget* p=0): QDialog(p), _url(url) {
|
||
|
setupUi(this);
|
||
|
reject();
|
||
|
}
|
||
|
virtual void accept() {
|
||
|
QStringList urls;
|
||
|
for (int i(0); i<_bookmarks->count(); ++i)
|
||
|
urls<<_bookmarks->item(i)->text();
|
||
|
QString current(_url->currentText());
|
||
|
_url->clear();
|
||
|
_url->addItems(urls);
|
||
12 years ago
|
_url->setEditText(current);
|
||
13 years ago
|
QDialog::accept();
|
||
|
}
|
||
|
virtual void reject() {
|
||
12 years ago
|
reset();
|
||
13 years ago
|
QDialog::reject();
|
||
|
}
|
||
|
protected Q_SLOTS:
|
||
|
void on__remove_clicked(bool) {
|
||
|
QList<QListWidgetItem*> items(_bookmarks->selectedItems());
|
||
|
qDebug()<<"Delete "<<items.size()<<" items";
|
||
|
for (QList<QListWidgetItem*>::iterator it(items.begin());
|
||
|
it!=items.end(); ++it) {
|
||
|
qDebug()<<"Delete Item: "<<(*it)->text();
|
||
|
delete _bookmarks->takeItem(_bookmarks->row(*it));
|
||
|
}
|
||
|
}
|
||
|
void on__add_clicked(bool) {
|
||
12 years ago
|
if (_url->currentText().isEmpty()) return;
|
||
13 years ago
|
_bookmarks->addItem(_url->currentText());
|
||
|
}
|
||
12 years ago
|
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);
|
||
|
}
|
||
13 years ago
|
private:
|
||
|
QComboBox* _url;
|
||
|
};
|
||
9 years ago
|
}
|
||
13 years ago
|
#endif
|