aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2012-09-30 15:31:32 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2012-09-30 15:31:32 +0000
commitf182e931d0dfca69af190d00da0e2d1e328d9991 (patch)
treefe1596b6adda4703c577f5ac4d23cd67c95d1529
parentmore verifyparsing from kgpgme, kind of works in verifydetailsdialog now (diff)
downloadgpg4usb-f182e931d0dfca69af190d00da0e2d1e328d9991.tar.gz
gpg4usb-f182e931d0dfca69af190d00da0e2d1e328d9991.zip
added buttons for previous and next to findwidget
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@991 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--TODO3
-rw-r--r--findwidget.cpp38
-rw-r--r--findwidget.h1
3 files changed, 42 insertions, 0 deletions
diff --git a/TODO b/TODO
index cad75aa..d9fa099 100644
--- a/TODO
+++ b/TODO
@@ -5,6 +5,9 @@ Release 0.4
- replace gpgme with kgpg (lots of work and trouble!!!)
- Refresh key from keyserver [DONE]
- add find action in textedit [DONE]
+ - BUG: hit strg+f, then hit escape -> text not editable anymore, same with not found expression
+ - When earch revious, text should be searched from end again, if no hit is found
+ - save the search expression, so that it is automatically used next time
- Change private key password
- create revocation file
- on key generation
diff --git a/findwidget.cpp b/findwidget.cpp
index 205b26d..5e653a3 100644
--- a/findwidget.cpp
+++ b/findwidget.cpp
@@ -8,18 +8,21 @@ FindWidget::FindWidget(QWidget *parent, QTextEdit *edit) :
findEdit = new QLineEdit(this);
QPushButton *closeButton= new QPushButton(this->style()->standardIcon(QStyle::SP_TitleBarCloseButton),"",this);
QPushButton *nextButton= new QPushButton(QIcon(":button_next.png"), "");
+ QPushButton *previousButton= new QPushButton(QIcon(":button_previous.png"), "");
QHBoxLayout *notificationWidgetLayout = new QHBoxLayout(this);
notificationWidgetLayout->setContentsMargins(10,0,0,0);
notificationWidgetLayout->addWidget(new QLabel(tr("Find:")));
notificationWidgetLayout->addWidget(findEdit,2);
notificationWidgetLayout->addWidget(nextButton);
+ notificationWidgetLayout->addWidget(previousButton);
notificationWidgetLayout->addWidget(closeButton);
this->setLayout(notificationWidgetLayout);
connect(findEdit,SIGNAL(textEdited(QString)),this,SLOT(slotFind()));
connect(findEdit,SIGNAL(returnPressed()),this,SLOT(slotFindNext()));
connect(nextButton,SIGNAL(clicked()),this,SLOT(slotFindNext()));
+ connect(previousButton,SIGNAL(clicked()),this,SLOT(slotFindPrevious()));
connect(closeButton,SIGNAL(clicked()),this,SLOT(slotClose()));
// The timer is necessary for setting the focus
@@ -67,6 +70,38 @@ void FindWidget::slotFind()
mTextpage->setTextCursor(cursor);
}
+void FindWidget::slotFindPrevious()
+{
+ QTextDocument::FindFlags flags;
+ flags |= QTextDocument::FindBackward;
+ flags |= QTextDocument::FindCaseSensitively;
+
+ cursor = mTextpage->document()->find(findEdit->text(), cursor, flags);
+
+ // if end of document is reached, restart search from beginning
+ if (cursor.position() == -1) {
+ qDebug() << "cursor:" << cursor.position();
+ qDebug() << "length: " << mTextpage->document()->toPlainText().length()-1;
+
+ cursor.movePosition(QTextCursor::End);
+ qDebug() << "cursor2: " << cursor.position();
+ cursor = mTextpage->document()->find(findEdit->text(), cursor, flags);
+ qDebug() << "cursor3: " << cursor.position();
+
+ }
+
+ // if match is found set background of QLineEdit to white, otherwise to red
+ QPalette bgPalette( findEdit->palette() );
+ if ((cursor.position() == -1) && (!findEdit->text().isEmpty())) {
+ bgPalette.setColor( QPalette::Base, "#ececba");
+ } else {
+ bgPalette.setColor( QPalette::Base, Qt::white);
+ }
+ findEdit->setPalette(bgPalette);
+
+ mTextpage->setTextCursor(cursor);
+}
+
void FindWidget::keyPressEvent( QKeyEvent* e )
{
switch ( e->key() )
@@ -74,6 +109,9 @@ void FindWidget::keyPressEvent( QKeyEvent* e )
case Qt::Key_Escape:
this->slotClose();
break;
+ case Qt::Key_F3 + Qt::SHIFT:
+ this->slotFindPrevious();
+ break;
case Qt::Key_F3:
this->slotFindNext();
break;
diff --git a/findwidget.h b/findwidget.h
index a623de5..31a7a9d 100644
--- a/findwidget.h
+++ b/findwidget.h
@@ -31,6 +31,7 @@ private:
private slots:
void slotFindNext();
+ void slotFindPrevious();
void slotFind();
void slotClose();
};