diff options
author | Francois Ferrand <thetypz@gmail.com> | 2012-11-30 16:15:07 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2012-12-14 10:22:41 +0100 |
commit | 058d2e8cb54d1f5e5c409182ae72fbbd1c96c3cc (patch) | |
tree | c5119a151f0c0ee0eb21b17f0ff07cc9dd1f5e01 /src/plugins/find/ifindfilter.cpp | |
parent | a8a33b9a3b2bab7660a53919bfbfa011e31755d3 (diff) |
Support preserving case when replacing.
When making a case insensitive search, try to keep the string capitalization when doing
the replace:
- All upper-case matches are replaced with the upper-case new text.
- All lower-case matches are replaced with the lower-case new text.
- Capitalized matches are replace with the capitalized new text.
- Other matches are replaced with the new text as provided.
Note: this does not work with regexp replace, only plain text.
Change-Id: I87cbc28eb64688bdf3c8c6ec173fcb22f91abcd0
Reviewed-by: Cristian Tibirna <tibirna@kde.org>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'src/plugins/find/ifindfilter.cpp')
-rw-r--r-- | src/plugins/find/ifindfilter.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/plugins/find/ifindfilter.cpp b/src/plugins/find/ifindfilter.cpp index 9f5a778800..feda930078 100644 --- a/src/plugins/find/ifindfilter.cpp +++ b/src/plugins/find/ifindfilter.cpp @@ -225,13 +225,16 @@ QPixmap Find::IFindFilter::pixmapForFindFlags(Find::FindFlags flags) static const QPixmap casesensitiveIcon = QPixmap(QLatin1String(":/find/images/casesensitively.png")); static const QPixmap regexpIcon = QPixmap(QLatin1String(":/find/images/regexp.png")); static const QPixmap wholewordsIcon = QPixmap(QLatin1String(":/find/images/wholewords.png")); + static const QPixmap preservecaseIcon = QPixmap(QLatin1String(":/find/images/preservecase.png")); bool casesensitive = flags & Find::FindCaseSensitively; bool wholewords = flags & Find::FindWholeWords; bool regexp = flags & Find::FindRegularExpression; + bool preservecase = flags & Find::FindPreserveCase; int width = 0; if (casesensitive) width += 6; if (wholewords) width += 6; if (regexp) width += 6; + if (preservecase) width += 6; if (width > 0) --width; QPixmap pixmap(width, 17); pixmap.fill(Qt::transparent); @@ -248,6 +251,10 @@ QPixmap Find::IFindFilter::pixmapForFindFlags(Find::FindFlags flags) } if (regexp) { painter.drawPixmap(x - 6, 0, regexpIcon); + x += 6; + } + if (preservecase) { + painter.drawPixmap(x - 6, 0, preservecaseIcon); } return pixmap; } @@ -261,6 +268,8 @@ QString Find::IFindFilter::descriptionForFindFlags(Find::FindFlags flags) flagStrings.append(tr("Whole words")); if (flags & Find::FindRegularExpression) flagStrings.append(tr("Regular expressions")); + if (flags & Find::FindPreserveCase) + flagStrings.append(tr("Preserve case")); QString description = tr("Flags: %1"); if (flagStrings.isEmpty()) description = description.arg(tr("None")); |