summaryrefslogtreecommitdiff
path: root/libopie2/opieui/opopupmenu.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opieui/opopupmenu.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opieui/opopupmenu.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/libopie2/opieui/opopupmenu.cpp b/libopie2/opieui/opopupmenu.cpp
index 3ab8490..50c613f 100644
--- a/libopie2/opieui/opopupmenu.cpp
+++ b/libopie2/opieui/opopupmenu.cpp
@@ -1,76 +1,76 @@
/* This file is part of the KDE libraries
Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org>
Copyright (C) 2002 Hamish Rodda <meddie@yoyo.its.monash.edu.au>
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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-/* QT */
+/* OPIE */
+#include <opie2/opopupmenu.h>
+#include <opie2/oconfig.h>
+#include <opie2/odebug.h>
+/* QT */
#include <qdrawutil.h>
#include <qtimer.h>
-/* OPIE */
-
-#include <opie2/opopupmenu.h>
-#include <opie2/oconfig.h>
using namespace Opie::Core;
using namespace Opie::Ui;
OPopupTitle::OPopupTitle(QWidget *parent, const char *name)
: QWidget(parent, name)
{
setMinimumSize(16, fontMetrics().height()+8);
}
OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */,
const QColor &/* color */, const QColor &/* textColor */,
QWidget *parent, const char *name)
: QWidget(parent, name)
{
setMinimumSize(16, fontMetrics().height()+8);
}
OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */,
const QColor &/* textColor */, QWidget *parent,
const char *name)
: QWidget(parent, name)
{
setMinimumSize(16, fontMetrics().height()+8);
}
void OPopupTitle::setTitle(const QString &text, const QPixmap *icon)
{
titleStr = text;
if (icon)
miniicon = *icon;
else
miniicon.resize(0, 0);
int w = miniicon.width()+fontMetrics().width(titleStr);
int h = QMAX( fontMetrics().height(), miniicon.height() );
setMinimumSize( w+16, h+8 );
}
void OPopupTitle::setText( const QString &text )
{
titleStr = text;
int w = miniicon.width()+fontMetrics().width(titleStr);
int h = QMAX( fontMetrics().height(), miniicon.height() );
setMinimumSize( w+16, h+8 );
}
void OPopupTitle::setIcon( const QPixmap &pix )
@@ -164,149 +164,149 @@ OPopupMenu* OPopupMenu::OPopupMenuPrivate::s_contextedMenu(0);
bool OPopupMenu::OPopupMenuPrivate::s_continueCtxMenuShow(true);
OPopupMenu::OPopupMenu(QWidget *parent, const char *name)
: QPopupMenu(parent, name)
{
d = new OPopupMenuPrivate;
resetKeyboardVars();
connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars()));
}
OPopupMenu::~OPopupMenu()
{
if (OPopupMenuPrivate::s_contextedMenu == this)
{
OPopupMenuPrivate::s_contextedMenu = 0;
OPopupMenuPrivate::s_highlightedItem = -1;
}
delete d;
}
int OPopupMenu::insertTitle(const QString &text, int id, int index)
{
OPopupTitle *titleItem = new OPopupTitle();
titleItem->setTitle(text);
int ret = insertItem(titleItem, id, index);
setItemEnabled(id, false);
return ret;
}
int OPopupMenu::insertTitle(const QPixmap &icon, const QString &text, int id,
int index)
{
OPopupTitle *titleItem = new OPopupTitle();
titleItem->setTitle(text, &icon);
int ret = insertItem(titleItem, id, index);
setItemEnabled(id, false);
return ret;
}
void OPopupMenu::changeTitle(int id, const QString &text)
{
QMenuItem *item = findItem(id);
if(item){
if(item->widget())
((OPopupTitle *)item->widget())->setTitle(text);
#ifndef NDEBUG
else
- qWarning( "KPopupMenu: changeTitle() called with non-title id %d", id );
+ owarn << "KPopupMenu: changeTitle() called with non-title id " << id << "" << oendl;
#endif
}
#ifndef NDEBUG
else
- qWarning( "KPopupMenu: changeTitle() called with invalid id %d", id );
+ owarn << "KPopupMenu: changeTitle() called with invalid id " << id << "" << oendl;
#endif
}
void OPopupMenu::changeTitle(int id, const QPixmap &icon, const QString &text)
{
QMenuItem *item = findItem(id);
if(item){
if(item->widget())
((OPopupTitle *)item->widget())->setTitle(text, &icon);
#ifndef NDEBUG
else
- qWarning( "KPopupMenu: changeTitle() called with non-title id %d", id );
+ owarn << "KPopupMenu: changeTitle() called with non-title id " << id << "" << oendl;
#endif
}
#ifndef NDEBUG
else
- qWarning( "KPopupMenu: changeTitle() called with invalid id %d", id );
+ owarn << "KPopupMenu: changeTitle() called with invalid id " << id << "" << oendl;
#endif
}
QString OPopupMenu::title(int id) const
{
if(id == -1) // obsolete
return(d->m_lastTitle);
QMenuItem *item = findItem(id);
if(item){
if(item->widget())
return(((OPopupTitle *)item->widget())->title());
else
- qWarning("OPopupMenu: title() called with non-title id %d.", id);
+ owarn << "OPopupMenu: title() called with non-title id " << id << "." << oendl;
}
else
- qWarning("OPopupMenu: title() called with invalid id %d.", id);
+ owarn << "OPopupMenu: title() called with invalid id " << id << "." << oendl;
return(QString::null);
}
QPixmap OPopupMenu::titlePixmap(int id) const
{
QMenuItem *item = findItem(id);
if(item){
if(item->widget())
return(((OPopupTitle *)item->widget())->icon());
else
- qWarning("KPopupMenu: titlePixmap() called with non-title id %d.", id);
+ owarn << "KPopupMenu: titlePixmap() called with non-title id " << id << "." << oendl;
}
else
- qWarning("KPopupMenu: titlePixmap() called with invalid id %d.", id);
+ owarn << "KPopupMenu: titlePixmap() called with invalid id " << id << "." << oendl;
QPixmap tmp;
return(tmp);
}
/**
* This is re-implemented for keyboard navigation.
*/
void OPopupMenu::closeEvent(QCloseEvent*e)
{
if (d->shortcuts)
resetKeyboardVars();
QPopupMenu::closeEvent(e);
}
void OPopupMenu::keyPressEvent(QKeyEvent* e)
{
if (!d->shortcuts) {
// continue event processing by Qpopup
//e->ignore();
QPopupMenu::keyPressEvent(e);
return;
}
int i = 0;
bool firstpass = true;
QString keyString = e->text();
// check for common commands dealt with by QPopup
int key = e->key();
if (key == Key_Escape || key == Key_Return || key == Key_Enter
|| key == Key_Up || key == Key_Down || key == Key_Left
|| key == Key_Right || key == Key_F1) {
resetKeyboardVars();
// continue event processing by Qpopup
//e->ignore();
QPopupMenu::keyPressEvent(e);
return;
}
// check to see if the user wants to remove a key from the sequence (backspace)
// or clear the sequence (delete)
if (!d->keySeq.isNull()) {
if (key == Key_Backspace) {
if (d->keySeq.length() == 1) {
resetKeyboardVars();