~ubuntu-branches/ubuntu/vivid/krusader/vivid-proposed

« back to all changes in this revision

Viewing changes to krusader/Dialogs/krspecialwidgets.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-05-05 22:26:37 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505222637-ydv3cwjwy365on2r
Tags: 1:2.1.0~beta1-1ubuntu1
* Merge from Debian Unstable.  Remaining changes:
  - Retain Kubuntu doc path

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
Description
9
9
***************************************************************************
10
10
 
11
 
 
11
A
12
12
 
13
13
 db   dD d8888b. db    db .d8888.  .d8b.  d8888b. d88888b d8888b.
14
14
 88 ,8P' 88  `8D 88    88 88'  YP d8' `8b 88  `8D 88'     88  `8D
61
61
 
62
62
QColor KRPie::colors[ 12 ] = {Qt::red, Qt::blue, Qt::green, Qt::cyan, Qt::magenta, Qt::gray,
63
63
                              Qt::black, Qt::white, Qt::darkRed, Qt::darkBlue, Qt::darkMagenta,
64
 
                              Qt::darkCyan};
 
64
                              Qt::darkCyan
 
65
                             };
65
66
 
66
67
//////////////////////////////////////////////////////////////////////////////
67
68
/////////////// KRFSDisplay - Filesystem / Freespace Display /////////////////
68
69
//////////////////////////////////////////////////////////////////////////////
69
70
// This is the full constructor: use it for a mounted filesystem
70
 
KRFSDisplay::KRFSDisplay( QWidget *parent, QString _alias, QString _realName,
71
 
                          KIO::filesize_t _total, KIO::filesize_t _free ) : QWidget( parent ), totalSpace( _total ),
72
 
      freeSpace( _free ), alias( _alias ), realName( _realName ), mounted( true ),
73
 
empty( false ), supermount( false ) {
 
71
KRFSDisplay::KRFSDisplay(QWidget *parent, QString _alias, QString _realName,
 
72
                         KIO::filesize_t _total, KIO::filesize_t _free) : QWidget(parent), totalSpace(_total),
 
73
        freeSpace(_free), alias(_alias), realName(_realName), mounted(true),
 
74
        empty(false), supermount(false)
 
75
{
74
76
 
75
 
   int leftMargin, topMargin, rightMargin, bottomMargin;
76
 
   getContentsMargins ( &leftMargin, &topMargin, &rightMargin, &bottomMargin );
77
 
   resize( 150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin);
78
 
   setMinimumSize( 150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin);
79
 
   show();
 
77
    int leftMargin, topMargin, rightMargin, bottomMargin;
 
78
    getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);
 
79
    resize(150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin);
 
80
    setMinimumSize(150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin);
 
81
    show();
80
82
}
81
83
 
82
84
// Use this one for an unmounted filesystem
83
 
KRFSDisplay::KRFSDisplay( QWidget *parent, QString _alias, QString _realName, bool sm ) :
84
 
      QWidget( parent ), alias( _alias ), realName( _realName ), mounted( false ),
85
 
empty( false ), supermount( sm ) {
 
85
KRFSDisplay::KRFSDisplay(QWidget *parent, QString _alias, QString _realName, bool sm) :
 
86
        QWidget(parent), alias(_alias), realName(_realName), mounted(false),
 
87
        empty(false), supermount(sm)
 
88
{
86
89
 
87
 
   int leftMargin, topMargin, rightMargin, bottomMargin;
88
 
   getContentsMargins ( &leftMargin, &topMargin, &rightMargin, &bottomMargin );
89
 
   resize( 150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin);
90
 
   setMinimumSize( 150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin);
91
 
   show();
 
90
    int leftMargin, topMargin, rightMargin, bottomMargin;
 
91
    getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);
 
92
    resize(150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin);
 
93
    setMinimumSize(150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin);
 
94
    show();
92
95
}
93
96
 
94
97
// This is used only when an empty widget needs to be displayed (for example:
95
98
// when filesystem statistics haven't been calculated yet)
96
 
KRFSDisplay::KRFSDisplay( QWidget *parent ) : QWidget( parent ), empty( true ) {
 
99
KRFSDisplay::KRFSDisplay(QWidget *parent) : QWidget(parent), empty(true)
 
100
{
97
101
 
98
 
   int leftMargin, topMargin, rightMargin, bottomMargin;
99
 
   getContentsMargins ( &leftMargin, &topMargin, &rightMargin, &bottomMargin );
100
 
   resize( 150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin);
101
 
   setMinimumSize( 150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin);
102
 
   show();
 
102
    int leftMargin, topMargin, rightMargin, bottomMargin;
 
103
    getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);
 
104
    resize(150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin);
 
105
    setMinimumSize(150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin);
 
106
    show();
103
107
}
104
108
 
105
109
 
106
110
// The main painter!
107
 
void KRFSDisplay::paintEvent( QPaintEvent * ) {
108
 
   QPainter paint( this );
109
 
   if ( !empty ) {
110
 
      int leftMargin, topMargin, rightMargin, bottomMargin;
111
 
      getContentsMargins ( &leftMargin, &topMargin, &rightMargin, &bottomMargin );
112
 
      // create the text
113
 
      // first, name and location
114
 
      paint.setFont( QFont( "helvetica", 12, QFont::Bold ) );
115
 
      paint.drawText( leftMargin + 10, topMargin + 20, alias );
116
 
      paint.setFont( QFont( "helvetica", 12, QFont::Normal ) );
117
 
      paint.drawText( leftMargin + 10, topMargin + 37, "(" + realName + ")" );
118
 
      if ( mounted ) {  // incase the filesystem is already mounted
119
 
         // second, the capacity
120
 
         paint.drawText( leftMargin + 10, topMargin + 70, i18n( "Capacity: " ) + KIO::convertSizeFromKiB( totalSpace ) );
121
 
         // third, the 2 boxes (used, free)
122
 
         QPen systemPen = paint.pen();
123
 
         paint.setPen( Qt::black );
124
 
         paint.drawRect( leftMargin + 10, topMargin + 90, 10, 10 );
125
 
         paint.fillRect( leftMargin + 11, topMargin + 91, 8, 8, QBrush( Qt::gray ) );
126
 
         paint.drawRect( leftMargin + 10, topMargin + 110, 10, 10 );
127
 
         paint.fillRect( leftMargin + 11, topMargin + 111, 8, 8, QBrush( Qt::white ) );
128
 
         // now, the text for the boxes
129
 
         paint.setPen( systemPen );
130
 
         paint.drawText( leftMargin + 25, topMargin + 100, i18n( "Used: " ) + KIO::convertSizeFromKiB( totalSpace - freeSpace ) );
131
 
         paint.drawText( leftMargin + 25, topMargin + 120, i18n( "Free: " ) + KIO::convertSizeFromKiB( freeSpace ) );
132
 
         // first, create the empty pie
133
 
         // bottom...
134
 
         paint.setPen( Qt::black );
135
 
         paint.setBrush( Qt::white );
136
 
         paint.drawPie( leftMargin + LEFT, topMargin + BOTTOM, WIDTH, HEIGHT, STARTANGLE, DEG( 360 ) );
137
 
         // body...
138
 
         paint.setPen( Qt::lightGray );
139
 
         for ( int i = 1; i < Z_HEIGHT; ++i )
140
 
            paint.drawPie( leftMargin + LEFT, topMargin + BOTTOM - i, WIDTH, HEIGHT, STARTANGLE, DEG( 360 ) );
141
 
         // side lines...
142
 
         paint.setPen( Qt::black );
143
 
         paint.drawLine( leftMargin + LEFT, topMargin + BOTTOM + HEIGHT / 2, LEFT, BOTTOM + HEIGHT / 2 - Z_HEIGHT );
144
 
         paint.drawLine( leftMargin + LEFT + WIDTH, topMargin + BOTTOM + HEIGHT / 2, LEFT + WIDTH, BOTTOM + HEIGHT / 2 - Z_HEIGHT );
145
 
         // top of the pie
146
 
         paint.drawPie( leftMargin + LEFT, topMargin + BOTTOM - Z_HEIGHT, WIDTH, HEIGHT, STARTANGLE, DEG( 360 ) );
147
 
         // the "used space" slice
148
 
         float i = ( ( float ) ( totalSpace - freeSpace ) / ( totalSpace ) ) * 360.0;
149
 
         paint.setBrush( Qt::gray );
150
 
         paint.drawPie( leftMargin + LEFT, topMargin + BOTTOM - Z_HEIGHT, WIDTH, HEIGHT, STARTANGLE, ( int ) DEG( i ) );
151
 
         // if we need to draw a 3d stripe ...
152
 
         if ( i > 180.0 ) {
153
 
            for ( int j = 1; j < Z_HEIGHT; ++j )
154
 
               paint.drawArc( leftMargin + LEFT, topMargin + BOTTOM - j, WIDTH, HEIGHT, STARTANGLE - 16 * 180, ( int ) ( DEG( i - 180.0 ) ) );
155
 
         }
156
 
      } else {  // if the filesystem is unmounted...
157
 
         paint.setFont( QFont( "helvetica", 12, QFont::Bold ) );
158
 
         paint.drawText( leftMargin + 10, topMargin + 60, i18n( "Not mounted." ) );
159
 
      }
160
 
   } else {  // if the widget is in empty situation...
 
111
void KRFSDisplay::paintEvent(QPaintEvent *)
 
112
{
 
113
    QPainter paint(this);
 
114
    if (!empty) {
 
115
        int leftMargin, topMargin, rightMargin, bottomMargin;
 
116
        getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);
 
117
        // create the text
 
118
        // first, name and location
 
119
        paint.setFont(QFont("helvetica", 12, QFont::Bold));
 
120
        paint.drawText(leftMargin + 10, topMargin + 20, alias);
 
121
        paint.setFont(QFont("helvetica", 12, QFont::Normal));
 
122
        paint.drawText(leftMargin + 10, topMargin + 37, '(' + realName + ')');
 
123
        if (mounted) {    // incase the filesystem is already mounted
 
124
            // second, the capacity
 
125
            paint.drawText(leftMargin + 10, topMargin + 70, i18n("Capacity: ") + KIO::convertSizeFromKiB(totalSpace));
 
126
            // third, the 2 boxes (used, free)
 
127
            QPen systemPen = paint.pen();
 
128
            paint.setPen(Qt::black);
 
129
            paint.drawRect(leftMargin + 10, topMargin + 90, 10, 10);
 
130
            paint.fillRect(leftMargin + 11, topMargin + 91, 8, 8, QBrush(Qt::gray));
 
131
            paint.drawRect(leftMargin + 10, topMargin + 110, 10, 10);
 
132
            paint.fillRect(leftMargin + 11, topMargin + 111, 8, 8, QBrush(Qt::white));
 
133
            // now, the text for the boxes
 
134
            paint.setPen(systemPen);
 
135
            paint.drawText(leftMargin + 25, topMargin + 100, i18n("Used: ") + KIO::convertSizeFromKiB(totalSpace - freeSpace));
 
136
            paint.drawText(leftMargin + 25, topMargin + 120, i18n("Free: ") + KIO::convertSizeFromKiB(freeSpace));
 
137
            // first, create the empty pie
 
138
            // bottom...
 
139
            paint.setPen(Qt::black);
 
140
            paint.setBrush(Qt::white);
 
141
            paint.drawPie(leftMargin + LEFT, topMargin + BOTTOM, WIDTH, HEIGHT, STARTANGLE, DEG(360));
 
142
            // body...
 
143
            paint.setPen(Qt::lightGray);
 
144
            for (int i = 1; i < Z_HEIGHT; ++i)
 
145
                paint.drawPie(leftMargin + LEFT, topMargin + BOTTOM - i, WIDTH, HEIGHT, STARTANGLE, DEG(360));
 
146
            // side lines...
 
147
            paint.setPen(Qt::black);
 
148
            paint.drawLine(leftMargin + LEFT, topMargin + BOTTOM + HEIGHT / 2, LEFT, BOTTOM + HEIGHT / 2 - Z_HEIGHT);
 
149
            paint.drawLine(leftMargin + LEFT + WIDTH, topMargin + BOTTOM + HEIGHT / 2, LEFT + WIDTH, BOTTOM + HEIGHT / 2 - Z_HEIGHT);
 
150
            // top of the pie
 
151
            paint.drawPie(leftMargin + LEFT, topMargin + BOTTOM - Z_HEIGHT, WIDTH, HEIGHT, STARTANGLE, DEG(360));
 
152
            // the "used space" slice
 
153
            float i = ((float)(totalSpace - freeSpace) / (totalSpace)) * 360.0;
 
154
            paint.setBrush(Qt::gray);
 
155
            paint.drawPie(leftMargin + LEFT, topMargin + BOTTOM - Z_HEIGHT, WIDTH, HEIGHT, STARTANGLE, (int) DEG(i));
 
156
            // if we need to draw a 3d stripe ...
 
157
            if (i > 180.0) {
 
158
                for (int j = 1; j < Z_HEIGHT; ++j)
 
159
                    paint.drawArc(leftMargin + LEFT, topMargin + BOTTOM - j, WIDTH, HEIGHT, STARTANGLE - 16 * 180, (int)(DEG(i - 180.0)));
 
160
            }
 
161
        } else {  // if the filesystem is unmounted...
 
162
            paint.setFont(QFont("helvetica", 12, QFont::Bold));
 
163
            paint.drawText(leftMargin + 10, topMargin + 60, i18n("Not mounted."));
 
164
        }
 
165
    } else {  // if the widget is in empty situation...
161
166
 
162
 
   }
 
167
    }
163
168
}
164
169
 
165
170
////////////////////////////////////////////////////////////////////////////////
166
 
KRPie::KRPie( KIO::filesize_t _totalSize, QWidget *parent ) : QWidget( parent ), totalSize( _totalSize ) {
167
 
   slices.push_back( KRPieSlice( 100, Qt::yellow, "DEFAULT" ) );
168
 
   sizeLeft = totalSize;
169
 
   resize( 300, 300 );
170
 
}
171
 
 
172
 
void KRPie::paintEvent( QPaintEvent * ) {
173
 
   QPainter paint( this );
174
 
   // now create the slices
175
 
   float sAngle = STARTANGLE;
176
 
   for ( int ndx=0; ndx != slices.count(); ndx++ ) {
177
 
      paint.setBrush( slices[ndx].getColor() );
178
 
      paint.setPen( slices[ndx].getColor() );
179
 
      // angles are negative to create a clock-wise drawing of slices
180
 
      float angle = -( slices[ndx].getPerct() / 100 * 360 ) * 16;
181
 
      for ( int i = 1; i < Z_HEIGHT; ++i )
182
 
         paint.drawPie( LEFT, BOTTOM + i, WIDTH, HEIGHT, ( int ) sAngle, ( int ) angle );
183
 
      sAngle += angle;
184
 
   }
185
 
   paint.setPen( Qt::yellow );   // pen
186
 
   paint.setBrush( Qt::yellow ); // fill
187
 
   // for (int i=1; i<Z_HEIGHT; ++i)
188
 
   //  paint.drawPie(LEFT,BOTTOM+i,WIDTH,HEIGHT,sAngle,360*16-(STARTANGLE-sAngle));
189
 
   sAngle = STARTANGLE;
190
 
   for ( int ndx=0; ndx != slices.count(); ndx++ ) {
191
 
      paint.setBrush( slices[ndx].getColor() );
192
 
      paint.setPen( slices[ndx].getColor() );
193
 
      // angles are negative to create a clock-wise drawing of slices
194
 
      float angle = -( slices[ndx].getPerct() / 100 * 360 ) * 16;
195
 
      paint.drawPie( LEFT, BOTTOM, WIDTH, HEIGHT, ( int ) sAngle, ( int ) angle );
196
 
      sAngle += angle;
197
 
   }
198
 
 
199
 
 
200
 
   paint.setPen( Qt::black );
201
 
   // the pie
202
 
   //  paint.drawPie(LEFT,BOTTOM,WIDTH,HEIGHT,STARTANGLE,360*16);
203
 
   ///////////////////////// end of empty pie /////////////////////////
204
 
   // now, the pie is ready to draw slices on...
205
 
   // to make a good look on the perimiter, draw another black circle
206
 
   paint.setPen( Qt::black );
207
 
   paint.drawArc( LEFT, BOTTOM, WIDTH, HEIGHT, STARTANGLE, 360 * 16 );
208
 
 
209
 
}
210
 
 
211
 
void KRPie::addSlice( KIO::filesize_t size, QString label ) {
212
 
   int i = ( slices.count() % 12 );
213
 
   slices.removeLast();
214
 
   slices.push_back( KRPieSlice( size * 100 / totalSize, colors[ i ], label ) );
215
 
   sizeLeft -= size;
216
 
   slices.push_back( KRPieSlice( sizeLeft * 100 / totalSize, Qt::yellow, "DEFAULT" ) );
 
171
KRPie::KRPie(KIO::filesize_t _totalSize, QWidget *parent) : QWidget(parent), totalSize(_totalSize)
 
172
{
 
173
    slices.push_back(KRPieSlice(100, Qt::yellow, "DEFAULT"));
 
174
    sizeLeft = totalSize;
 
175
    resize(300, 300);
 
176
}
 
177
 
 
178
void KRPie::paintEvent(QPaintEvent *)
 
179
{
 
180
    QPainter paint(this);
 
181
    // now create the slices
 
182
    float sAngle = STARTANGLE;
 
183
    for (int ndx = 0; ndx != slices.count(); ndx++) {
 
184
        paint.setBrush(slices[ndx].getColor());
 
185
        paint.setPen(slices[ndx].getColor());
 
186
        // angles are negative to create a clock-wise drawing of slices
 
187
        float angle = -(slices[ndx].getPerct() / 100 * 360) * 16;
 
188
        for (int i = 1; i < Z_HEIGHT; ++i)
 
189
            paint.drawPie(LEFT, BOTTOM + i, WIDTH, HEIGHT, (int) sAngle, (int) angle);
 
190
        sAngle += angle;
 
191
    }
 
192
    paint.setPen(Qt::yellow);     // pen
 
193
    paint.setBrush(Qt::yellow);   // fill
 
194
    // for (int i=1; i<Z_HEIGHT; ++i)
 
195
    //  paint.drawPie(LEFT,BOTTOM+i,WIDTH,HEIGHT,sAngle,360*16-(STARTANGLE-sAngle));
 
196
    sAngle = STARTANGLE;
 
197
    for (int ndx = 0; ndx != slices.count(); ndx++) {
 
198
        paint.setBrush(slices[ndx].getColor());
 
199
        paint.setPen(slices[ndx].getColor());
 
200
        // angles are negative to create a clock-wise drawing of slices
 
201
        float angle = -(slices[ndx].getPerct() / 100 * 360) * 16;
 
202
        paint.drawPie(LEFT, BOTTOM, WIDTH, HEIGHT, (int) sAngle, (int) angle);
 
203
        sAngle += angle;
 
204
    }
 
205
 
 
206
 
 
207
    paint.setPen(Qt::black);
 
208
    // the pie
 
209
    //  paint.drawPie(LEFT,BOTTOM,WIDTH,HEIGHT,STARTANGLE,360*16);
 
210
    ///////////////////////// end of empty pie /////////////////////////
 
211
    // now, the pie is ready to draw slices on...
 
212
    // to make a good look on the perimiter, draw another black circle
 
213
    paint.setPen(Qt::black);
 
214
    paint.drawArc(LEFT, BOTTOM, WIDTH, HEIGHT, STARTANGLE, 360 * 16);
 
215
 
 
216
}
 
217
 
 
218
void KRPie::addSlice(KIO::filesize_t size, QString label)
 
219
{
 
220
    int i = (slices.count() % 12);
 
221
    slices.removeLast();
 
222
    slices.push_back(KRPieSlice(size * 100 / totalSize, colors[ i ], label));
 
223
    sizeLeft -= size;
 
224
    slices.push_back(KRPieSlice(sizeLeft * 100 / totalSize, Qt::yellow, "DEFAULT"));
217
225
}
218
226
 
219
227
////////////////////////////////////////////////////
220
228
/////////////////// KrQuickSearch  /////////////////
221
229
////////////////////////////////////////////////////
222
 
KrQuickSearch::KrQuickSearch( QWidget *parent ) : KLineEdit( parent )
223
 
{
224
 
   setMatch( true );
225
 
}
226
 
 
227
 
void KrQuickSearch::myKeyPressEvent( QKeyEvent *e ) {
228
 
   switch ( e->key() ) {
229
 
         case Qt::Key_Escape:
230
 
         emit stop( 0 );
231
 
         break;
232
 
         case Qt::Key_Return:
233
 
         case Qt::Key_Enter:
234
 
         case Qt::Key_Tab:
235
 
         case Qt::Key_Right:
236
 
         case Qt::Key_Left:
237
 
         emit stop( e );
238
 
         break;
239
 
         case Qt::Key_Down:
240
 
         otherMatching( text(), 1 );
241
 
         break;
242
 
         case Qt::Key_Up:
243
 
         otherMatching( text(), -1 );
244
 
         break;
245
 
         case Qt::Key_Insert:
246
 
         case Qt::Key_Home:
247
 
         case Qt::Key_End:
248
 
         process( e );
249
 
         break;
250
 
         default:
251
 
         keyPressEvent( e );
252
 
   }
253
 
}
254
 
 
255
 
void KrQuickSearch::setMatch( bool match ) {
256
 
   KConfigGroup gc( krConfig, "Colors");
257
 
 
258
 
   QString foreground, background;
259
 
   QColor  fore, back;
260
 
 
261
 
   if( match )
262
 
   {
263
 
      foreground = "Quicksearch Match Foreground";
264
 
      background = "Quicksearch Match Background";
265
 
      fore = Qt::black;
266
 
      back = QColor( 192, 255, 192 );
267
 
   } else {
268
 
      foreground = "Quicksearch Non-match Foreground";
269
 
      background = "Quicksearch Non-match Background";
270
 
      fore = Qt::black;
271
 
      back = QColor(255,192,192);
272
 
   }
273
 
 
274
 
   if( gc.readEntry( foreground, QString() ) == "KDE default" )
275
 
      fore = KColorScheme(QPalette::Active, KColorScheme::View).foreground().color();
276
 
   else if( !gc.readEntry( foreground, QString() ).isEmpty() )
277
 
      fore = gc.readEntry( foreground, fore );
278
 
 
279
 
   if( gc.readEntry( background, QString() ) == "KDE default" )
280
 
      back = KColorScheme(QPalette::Active, KColorScheme::View).background().color();
281
 
   else if( !gc.readEntry( background, QString() ).isEmpty() )
282
 
      back = gc.readEntry( background, back );
283
 
 
284
 
   QPalette pal = palette();
285
 
   pal.setColor( QPalette::Base, back);
286
 
   pal.setColor( QPalette::Text, fore);
287
 
   setPalette( pal );
 
230
KrQuickSearch::KrQuickSearch(QWidget *parent) : KLineEdit(parent)
 
231
{
 
232
    setMatch(true);
 
233
}
 
234
 
 
235
void KrQuickSearch::myKeyPressEvent(QKeyEvent *e)
 
236
{
 
237
    switch (e->key()) {
 
238
    case Qt::Key_Escape:
 
239
        emit stop(0);
 
240
        break;
 
241
    case Qt::Key_Return:
 
242
    case Qt::Key_Enter:
 
243
    case Qt::Key_Tab:
 
244
    case Qt::Key_Right:
 
245
    case Qt::Key_Left:
 
246
        emit stop(e);
 
247
        break;
 
248
    case Qt::Key_Down:
 
249
        otherMatching(text(), 1);
 
250
        break;
 
251
    case Qt::Key_Up:
 
252
        otherMatching(text(), -1);
 
253
        break;
 
254
    case Qt::Key_Insert:
 
255
    case Qt::Key_Home:
 
256
    case Qt::Key_End:
 
257
        process(e);
 
258
        break;
 
259
    default:
 
260
        keyPressEvent(e);
 
261
    }
 
262
}
 
263
 
 
264
void KrQuickSearch::setMatch(bool match)
 
265
{
 
266
    KConfigGroup gc(krConfig, "Colors");
 
267
 
 
268
    QString foreground, background;
 
269
    QColor  fore, back;
 
270
 
 
271
    if (match) {
 
272
        foreground = "Quicksearch Match Foreground";
 
273
        background = "Quicksearch Match Background";
 
274
        fore = Qt::black;
 
275
        back = QColor(192, 255, 192);
 
276
    } else {
 
277
        foreground = "Quicksearch Non-match Foreground";
 
278
        background = "Quicksearch Non-match Background";
 
279
        fore = Qt::black;
 
280
        back = QColor(255, 192, 192);
 
281
    }
 
282
 
 
283
    if (gc.readEntry(foreground, QString()) == "KDE default")
 
284
        fore = KColorScheme(QPalette::Active, KColorScheme::View).foreground().color();
 
285
    else if (!gc.readEntry(foreground, QString()).isEmpty())
 
286
        fore = gc.readEntry(foreground, fore);
 
287
 
 
288
    if (gc.readEntry(background, QString()) == "KDE default")
 
289
        back = KColorScheme(QPalette::Active, KColorScheme::View).background().color();
 
290
    else if (!gc.readEntry(background, QString()).isEmpty())
 
291
        back = gc.readEntry(background, back);
 
292
 
 
293
    QPalette pal = palette();
 
294
    pal.setColor(QPalette::Base, back);
 
295
    pal.setColor(QPalette::Text, fore);
 
296
    setPalette(pal);
288
297
}
289
298
 
290
299
#include "krspecialwidgets.moc"