2025-08-22 22:57:06 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
source::worx xtree
|
|
|
|
Copyright © 2024-2025 c.holzheuer
|
|
|
|
christoph.holzheuer@gmail.com
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include <xqcontextmenu.h>
|
|
|
|
|
|
|
|
|
|
|
|
//! konstruktor.
|
|
|
|
|
|
|
|
XQContextMenu::XQContextMenu(QWidget* parent)
|
|
|
|
: QMenu( parent )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! erzeugt eine action mit text
|
|
|
|
//! aus einem command-type und fügt sie hinzu.
|
|
|
|
|
|
|
|
void XQContextMenu::addAction(const QString& text, XQCommand::CmdType commandType, bool enabled)
|
|
|
|
{
|
|
|
|
QAction* newAction = new QAction(text, this);
|
|
|
|
newAction->setData(commandType);
|
|
|
|
_actionMap[commandType] = newAction;
|
2025-09-05 21:42:40 +02:00
|
|
|
QMenu::addAction(newAction);
|
2025-08-22 22:57:06 +02:00
|
|
|
setActionEnabled( commandType, enabled );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! erzeugt eine action mit text und icon aus
|
|
|
|
//! einem command-type und fügt sie hinzu.
|
|
|
|
|
|
|
|
void XQContextMenu::addAction(const QString& iconKey, const QString& name, XQCommand::CmdType commandType, bool enabled)
|
|
|
|
{
|
|
|
|
addAction(XQAppData::typeIcon( iconKey), name, commandType, enabled );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! erzeugt eine action mit text und icon aus
|
|
|
|
//! einem command-type und fügt sie hinzu.
|
|
|
|
|
|
|
|
void XQContextMenu::addAction(const QIcon& icon, const QString& text, XQCommand::CmdType commandType, bool enabled)
|
|
|
|
{
|
|
|
|
QAction* newAction = new QAction(icon, text, this);
|
|
|
|
newAction->setData(commandType);
|
|
|
|
_actionMap[commandType] = newAction;
|
2025-09-05 21:42:40 +02:00
|
|
|
QMenu::addAction(newAction);
|
2025-08-22 22:57:06 +02:00
|
|
|
setActionEnabled( commandType, enabled );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! schaltet die action mit 'commandType'
|
|
|
|
|
|
|
|
void XQContextMenu::setActionEnabled(XQCommand::CmdType commandType, bool enabled)
|
|
|
|
{
|
|
|
|
if( _actionMap.contains(commandType) )
|
|
|
|
_actionMap[commandType]->setEnabled( enabled );
|
|
|
|
}
|