1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/*
**************************************************************************
description
--------------------
copyright : (C) 2000-2001 by Andreas Zehender
email : [email protected]
**************************************************************************
**************************************************************************
* *
* 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 "pminsertpopup.h"
#include <tdelocale.h>
#include <kiconloader.h>
#include <tqcursor.h>
PMInsertPopup::PMInsertPopup( TQWidget* parent, bool multipleObjects,
int items, bool canInsertAllAsFirstChildren,
bool canInsertAllAsLastChildren,
bool canInsertAllAsSiblings, const char* name )
: TDEPopupMenu( parent, name )
{
TQString itemText;
if( multipleObjects )
{
insertTitle( i18n( "Insert Objects As" ) );
if( ( items & PMIFirstChild ) == PMIFirstChild )
{
itemText = i18n( "First Children" );
if( !canInsertAllAsFirstChildren )
itemText += " (" + i18n( "some" ) + ")";
insertItem( SmallIcon( "pminsertfirstchild" ),
itemText, PMIFirstChild );
}
if( ( items & PMILastChild ) == PMILastChild )
{
itemText = i18n( "Last Children" );
if( !canInsertAllAsLastChildren )
itemText += " (" + i18n( "some" ) + ")";
insertItem( SmallIcon( "pminsertlastchild" ),
itemText, PMILastChild );
}
if( ( items & PMISibling ) == PMISibling )
{
itemText = i18n( "Siblings" );
if( !canInsertAllAsSiblings )
itemText += " (" + i18n( "some" ) + ")";
insertItem( SmallIcon( "pminsertsibling" ),
itemText, PMISibling );
}
}
else
{
insertTitle( i18n( "Insert Object As" ) );
if( ( items & PMIFirstChild ) == PMIFirstChild )
insertItem( SmallIcon( "pminsertfirstchild" ),
i18n( "First Child" ), PMIFirstChild );
if( ( items & PMILastChild ) == PMILastChild )
insertItem( SmallIcon( "pminsertlastchild" ),
i18n( "Last Child" ), PMILastChild );
if( ( items & PMISibling ) == PMISibling )
insertItem( SmallIcon( "pminsertsibling" ),
i18n( "Sibling" ), PMISibling );
}
}
int PMInsertPopup::choosePlace( TQWidget* parent, bool multipleObjects,
int items, bool canInsertAllAsFirstChildren,
bool canInsertAllAsLastChildren,
bool canInsertAllAsSiblings )
{
int result;
PMInsertPopup* popup = new PMInsertPopup( parent, multipleObjects, items,
canInsertAllAsFirstChildren,
canInsertAllAsLastChildren,
canInsertAllAsSiblings );
result = popup->exec( TQCursor::pos( ) );
if( result < 0 )
result = 0;
delete popup;
return result;
}
|