File indexing completed on 2024-04-28 05:51:09
0001 /* 0002 * SPDX-FileCopyrightText: 2002-2003 Jesper K. Pedersen <blackie@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-only 0005 **/ 0006 0007 #include "indexWindow.h" 0008 0009 #include <QHBoxLayout> 0010 #include <QListWidget> 0011 0012 indexWindow::indexWindow() 0013 : QWidget(nullptr, Qt::Popup) 0014 { 0015 lb = new QListWidget(this); 0016 connect(lb, SIGNAL(selected(int)), this, SLOT(lbSelected(int))); 0017 QHBoxLayout *lay = new QHBoxLayout(this); 0018 lay->addWidget(lb); 0019 lbFinish = false; 0020 } 0021 0022 void indexWindow::lbSelected(int index) 0023 { 0024 lbFinish = true; 0025 hide(); 0026 lbFinish = false; 0027 finish(index); 0028 } 0029 0030 void indexWindow::finish(int index) 0031 { 0032 itemSelected = index; 0033 // qApp->exit_loop(); 0034 } 0035 0036 void indexWindow::insertItem(const QString &txt) 0037 { 0038 lb->addItem(txt); 0039 } 0040 0041 void indexWindow::hideEvent(QHideEvent *h) 0042 { 0043 QWidget::hideEvent(h); 0044 if (!lbFinish) { 0045 finish(-1); 0046 } 0047 } 0048 0049 int indexWindow::exec(const QPoint & /*start*/, int /*width*/) 0050 { 0051 // This code is not xinerama safe, on the other hand this part of the widget 0052 // is not used in KRegExpEditor. This is part of a widget which has 0053 // never been completed, but which is used partly by KRegExpEditor. 0054 // 23 Feb. 2003 11:28 -- Jesper K. Pedersen 0055 /* 0056 // calculate the height of all the elements together. 0057 // I need to do it this way, as sizeHint doesn't report the correct size 0058 // and itemHeight doesn't neither. 0059 int elm_h = lb->item(0)->height(lb) * lb->count(); 0060 elm_h += 2*lb->frameWidth(); 0061 0062 QWidget *desktop = QApplication::desktop(); 0063 int desktop_h = desktop->height(); 0064 int rest_h = desktop_h - start.y(); 0065 int below_h = qMax(rest_h, 200); 0066 0067 int start_y = start.y(); 0068 0069 if (rest_h < 200 && elm_h > 200) { 0070 start_y = desktop_h-qMin(elm_h,200); 0071 } 0072 0073 setGeometry(start.x(), start_y, width, qMin(elm_h, below_h)); 0074 show(); 0075 qApp->enter_loop(); 0076 return itemSelected; 0077 */ 0078 return 0; 0079 } 0080 0081 #include "moc_indexWindow.cpp"