kexi
kexidbutils.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kexidbutils.h"
00021
00022 #include <kpopupmenu.h>
00023 #include <kiconloader.h>
00024
00025 #include <kexidb/queryschema.h>
00026 #include <formeditor/widgetlibrary.h>
00027 #include <kexiutils/utils.h>
00028 #include "../kexiformpart.h"
00029 #include <widget/utils/kexiimagecontextmenu.h>
00030
00031 QColor lighterGrayBackgroundColor(const QPalette& palette)
00032 {
00033 return KexiUtils::blendedColors(palette.active().background(), palette.active().base(), 1, 2);
00034 }
00035
00036
00037
00038 KexiDBWidgetContextMenuExtender::KexiDBWidgetContextMenuExtender( QObject* parent, KexiDataItemInterface* iface )
00039 : QObject(parent)
00040 , m_iface(iface)
00041 , m_contextMenuHasTitle(false)
00042 {
00043 }
00044
00045 KexiDBWidgetContextMenuExtender::~KexiDBWidgetContextMenuExtender()
00046 {
00047 }
00048
00049 void KexiDBWidgetContextMenuExtender::createTitle(QPopupMenu *menu)
00050 {
00051 if (!menu)
00052 return;
00053 m_contextMenu = menu;
00054 KPopupTitle *titleItem = new KPopupTitle();
00055 const int id = m_contextMenu->insertItem(titleItem, -1, 0);
00056 m_contextMenu->setItemEnabled(id, false);
00057 QString icon;
00058 if (dynamic_cast<QWidget*>(m_iface))
00059 icon = KexiFormPart::library()->iconName(dynamic_cast<QWidget*>(m_iface)->className());
00060
00061 m_contextMenuHasTitle = m_iface->columnInfo() ?
00062 KexiImageContextMenu::updateTitle(m_contextMenu, m_iface->columnInfo()->captionOrAliasOrName(), icon)
00063 : false;
00064
00065 if (!m_contextMenuHasTitle)
00066 m_contextMenu->removeItem(id);
00067 updatePopupMenuActions();
00068 }
00069
00070 void KexiDBWidgetContextMenuExtender::updatePopupMenuActions()
00071 {
00072 if (m_contextMenu) {
00073 enum { IdUndo, IdRedo, IdSep1, IdCut, IdCopy, IdPaste, IdClear, IdSep2, IdSelectAll };
00074 const bool readOnly = m_iface->isReadOnly();
00075 const int id = m_contextMenu->idAt(m_contextMenuHasTitle ? 1 : 0);
00076
00078 m_contextMenu->removeItem(id-(int)IdRedo);
00079
00080
00081 m_contextMenu->setItemEnabled(id-(int)IdCut, !readOnly);
00082 m_contextMenu->setItemEnabled(id-(int)IdPaste, !readOnly);
00083 m_contextMenu->setItemEnabled(id-(int)IdClear, !readOnly);
00084 }
00085 }
00086
00087
00088
00089 KexiSubwidgetInterface::KexiSubwidgetInterface()
00090 {
00091 }
00092
00093 KexiSubwidgetInterface::~KexiSubwidgetInterface()
00094 {
00095 }
|