You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
3.4 KiB
111 lines
3.4 KiB
15 years ago
|
/**********************************************************************
|
||
|
** Copyright (C) 2000 Trolltech AS. All rights reserved.
|
||
|
**
|
||
14 years ago
|
** This file is part of TQt Designer.
|
||
15 years ago
|
**
|
||
|
** This file may be distributed and/or modified under the terms of the
|
||
|
** GNU General Public License version 2 as published by the Free Software
|
||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||
|
** packaging of this file.
|
||
|
**
|
||
14 years ago
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||
15 years ago
|
** Agreement provided with the Software.
|
||
|
**
|
||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||
|
**
|
||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||
14 years ago
|
** information about TQt Commercial License Agreements.
|
||
15 years ago
|
**
|
||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||
|
** not clear to you.
|
||
|
**
|
||
|
**********************************************************************/
|
||
|
|
||
|
#include "actiondnd.h"
|
||
|
#include "actionlistview.h"
|
||
15 years ago
|
#include <tqheader.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
|
||
14 years ago
|
ActionListView::ActionListView( TQWidget *parent, const char *name )
|
||
|
: TQListView( parent, name )
|
||
15 years ago
|
{
|
||
|
setShowSortIndicator( TRUE );
|
||
|
setResizeMode( LastColumn );
|
||
|
setRootIsDecorated( TRUE );
|
||
15 years ago
|
connect( this, TQT_SIGNAL( contextMenuRequested( TQListViewItem *, const TQPoint &, int ) ),
|
||
|
this, TQT_SLOT( rmbMenu( TQListViewItem *, const TQPoint & ) ) );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
ActionItem::ActionItem( TQListView *lv, TQAction *ac )
|
||
|
: TQListViewItem( lv ), a( 0 ), g( 0 )
|
||
15 years ago
|
{
|
||
14 years ago
|
g = ::tqqt_cast<QDesignerActionGroup*>(ac);
|
||
15 years ago
|
if ( !g )
|
||
14 years ago
|
a = ::tqqt_cast<QDesignerAction*>(ac);
|
||
15 years ago
|
setDragEnabled( TRUE );
|
||
|
}
|
||
|
|
||
15 years ago
|
ActionItem::ActionItem( TQListViewItem *i, TQAction *ac )
|
||
|
: TQListViewItem( i ), a( 0 ), g( 0 )
|
||
15 years ago
|
{
|
||
14 years ago
|
g = ::tqqt_cast<QDesignerActionGroup*>(ac);
|
||
15 years ago
|
if ( !g )
|
||
14 years ago
|
a = ::tqqt_cast<QDesignerAction*>(ac);
|
||
15 years ago
|
setDragEnabled( TRUE );
|
||
|
moveToEnd();
|
||
|
}
|
||
|
|
||
|
void ActionItem::moveToEnd()
|
||
|
{
|
||
15 years ago
|
TQListViewItem *i = this;
|
||
15 years ago
|
while ( i->nextSibling() )
|
||
|
i = i->nextSibling();
|
||
|
if ( i != this )
|
||
|
moveItem( i );
|
||
|
}
|
||
|
|
||
15 years ago
|
TQDragObject *ActionListView::dragObject()
|
||
15 years ago
|
{
|
||
|
ActionItem *i = (ActionItem*)currentItem();
|
||
|
if ( !i )
|
||
|
return 0;
|
||
15 years ago
|
TQStoredDrag *drag = 0;
|
||
15 years ago
|
if ( i->action() ) {
|
||
|
drag = new ActionDrag( i->action(), viewport() );
|
||
|
drag->setPixmap( i->action()->iconSet().pixmap() );
|
||
|
} else {
|
||
|
drag = new ActionDrag( i->actionGroup(), viewport() );
|
||
|
drag->setPixmap( i->actionGroup()->iconSet().pixmap() );
|
||
|
}
|
||
|
return drag;
|
||
|
}
|
||
|
|
||
15 years ago
|
void ActionListView::rmbMenu( TQListViewItem *i, const TQPoint &p )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQPopupMenu *popup = new TQPopupMenu( this );
|
||
15 years ago
|
popup->insertItem( i18n( "New &Action" ), 0 );
|
||
|
popup->insertItem( i18n( "New Action &Group" ), 1 );
|
||
|
popup->insertItem( i18n( "New &Dropdown Action Group" ), 2 );
|
||
|
if ( i ) {
|
||
|
popup->insertSeparator();
|
||
|
popup->insertItem( i18n( "&Connect Action..." ), 3 );
|
||
|
popup->insertSeparator();
|
||
|
popup->insertItem( i18n( "Delete Action" ), 4 );
|
||
|
}
|
||
|
int res = popup->exec( p );
|
||
|
if ( res == 0 )
|
||
|
emit insertAction();
|
||
|
else if ( res == 1 )
|
||
|
emit insertActionGroup();
|
||
|
else if ( res == 2 )
|
||
|
emit insertDropDownActionGroup();
|
||
|
else if ( res == 3 )
|
||
|
emit connectAction();
|
||
|
else if ( res == 4 )
|
||
|
emit deleteAction();
|
||
|
}
|