summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/QtUI/QtBlockListEditorWindow.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Swift/QtUI/QtBlockListEditorWindow.cpp b/Swift/QtUI/QtBlockListEditorWindow.cpp
index 2484eb7..82500df 100644
--- a/Swift/QtUI/QtBlockListEditorWindow.cpp
+++ b/Swift/QtUI/QtBlockListEditorWindow.cpp
@@ -43,71 +43,71 @@ class QtJIDValidatedItemDelegate : public QItemDelegate {
QtJIDValidatedItemDelegate(QObject* parent) : QItemDelegate(parent) {}
virtual ~QtJIDValidatedItemDelegate() {}
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex&) const {
QLineEdit *editor = new QLineEdit(parent);
editor->setValidator(new QtJIDValidator(editor));
return editor;
}
void setEditorData(QWidget *editor, const QModelIndex &index) const {
QString value = index.model()->data(index, Qt::EditRole).toString();
QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
lineEdit->setText(value);
}
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
QString currentValue = lineEdit->text();
int pos = 0;
if (lineEdit->validator()->validate(currentValue, pos) == QValidator::Acceptable) {
model->setData(index, lineEdit->text(), Qt::EditRole);
} else {
model->setData(index, QString(), Qt::EditRole);
}
}
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/* index */) const {
editor->setGeometry(option.rect);
}
};
QtBlockListEditorWindow::QtBlockListEditorWindow() : QWidget(), ui(new Ui::QtBlockListEditorWindow), removeItemDelegate(0), editItemDelegate(0) {
ui->setupUi(this);
- freshBlockListTemplate = tr("Click to add contact");
+ freshBlockListTemplate = tr("Double-click to add contact");
new QShortcut(QKeySequence::Close, this, SLOT(close()));
ui->throbberLabel->setMovie(new QMovie(":/icons/throbber.gif", QByteArray(), this));
removeItemDelegate = new QtRemovableItemDelegate(style());
editItemDelegate = new QtJIDValidatedItemDelegate(this);
connect(ui->savePushButton, SIGNAL(clicked()), SLOT(applyChanges()));
ui->blockListTreeWidget->setColumnCount(2);
ui->blockListTreeWidget->header()->setStretchLastSection(false);
ui->blockListTreeWidget->header()->resizeSection(1, removeItemDelegate->sizeHint(QStyleOptionViewItem(), QModelIndex()).width());
#if QT_VERSION >= 0x050000
ui->blockListTreeWidget->header()->setSectionResizeMode(0, QHeaderView::Stretch);
#else
ui->blockListTreeWidget->header()->setResizeMode(0, QHeaderView::Stretch);
#endif
ui->blockListTreeWidget->setHeaderHidden(true);
ui->blockListTreeWidget->setRootIsDecorated(false);
ui->blockListTreeWidget->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed);
ui->blockListTreeWidget->setItemDelegateForColumn(0, editItemDelegate);
ui->blockListTreeWidget->setItemDelegateForColumn(1, removeItemDelegate);
connect(ui->blockListTreeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)), SLOT(handleItemChanged(QTreeWidgetItem*,int)));
ui->blockListTreeWidget->installEventFilter(this);
QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(freshBlockListTemplate) << "x");
item->setFlags(item->flags() | Qt::ItemIsEditable);
ui->blockListTreeWidget->addTopLevelItem(item);
}
QtBlockListEditorWindow::~QtBlockListEditorWindow() {
}