From 2bda8f7717adf28da4af0d34fb82f63d2868c31d Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeutils@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kregexpeditor/KMultiFormListBox/indexWindow.cpp | 97 +++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 kregexpeditor/KMultiFormListBox/indexWindow.cpp (limited to 'kregexpeditor/KMultiFormListBox/indexWindow.cpp') diff --git a/kregexpeditor/KMultiFormListBox/indexWindow.cpp b/kregexpeditor/KMultiFormListBox/indexWindow.cpp new file mode 100644 index 0000000..362d012 --- /dev/null +++ b/kregexpeditor/KMultiFormListBox/indexWindow.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2002-2003 Jesper K. Pedersen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#ifdef QT_ONLY + #include "compat.h" +#else + #include "indexWindow.moc" +#endif + +#include "indexWindow.h" +#include +#include + +indexWindow::indexWindow() : QWidget(0,"", WStyle_Customize | WType_Popup) +{ + lb = new QListBox(this); + connect(lb,SIGNAL(selected(int)), this, SLOT(lbSelected(int))); + QHBoxLayout *lay = new QHBoxLayout(this); + lay->addWidget(lb); + lbFinish = false; +} + +void indexWindow::lbSelected(int index) +{ + lbFinish = true; + hide(); + lbFinish = false; + finish(index); +} + +void indexWindow::finish(int index) +{ + itemSelected = index; + qApp->exit_loop(); +} + + +void indexWindow::insertItem(QString txt) +{ + lb->insertItem(txt); +} + +void indexWindow::hideEvent(QHideEvent *h) +{ + QWidget::hideEvent(h); + if (!lbFinish) + finish(-1); +} + + +int indexWindow::exec(const QPoint & /*start*/, int /*width*/) +{ + // This code is not xinerama safe, on the other hand this part of the widget + // is not used in KRegExpEditor. This is part of a widget which has + // never been completed, but which is used partly by KRegExpEditor. + // 23 Feb. 2003 11:28 -- Jesper K. Pedersen +/* + // calculate the height of all the elements together. + // I need to do it this way, as sizeHint doesn't report the correct size + // and itemHeight doesn't neither. + int elm_h = lb->item(0)->height(lb) * lb->count(); + elm_h += 2*lb->frameWidth(); + + QWidget *desktop = QApplication::desktop(); + int desktop_h = desktop->height(); + int rest_h = desktop_h - start.y(); + int below_h = QMAX(rest_h, 200); + + int start_y = start.y(); + + if (rest_h < 200 && elm_h > 200) { + start_y = desktop_h-QMIN(elm_h,200); + } + + setGeometry(start.x(), start_y, width, QMIN(elm_h, below_h)); + show(); + qApp->enter_loop(); + return itemSelected; +*/ + return 0; +} + -- cgit v1.2.1