author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kresources/selectdialog.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kresources/selectdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kresources/selectdialog.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/microkde/kresources/selectdialog.cpp b/microkde/kresources/selectdialog.cpp index fba8648..d5b83e9 100644 --- a/microkde/kresources/selectdialog.cpp +++ b/microkde/kresources/selectdialog.cpp | |||
@@ -13,128 +13,132 @@ | |||
13 | This library is distributed in the hope that it will be useful, | 13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Library General Public License for more details. | 16 | Library General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU Library General Public License | 18 | You should have received a copy of the GNU Library General Public License |
19 | along with this library; see the file COPYING.LIB. If not, write to | 19 | along with this library; see the file COPYING.LIB. If not, write to |
20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
21 | Boston, MA 02111-1307, USA. | 21 | Boston, MA 02111-1307, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /*US | 24 | /*US |
25 | #include <kbuttonbox.h> | 25 | #include <kbuttonbox.h> |
26 | #include <klistbox.h> | 26 | #include <klistbox.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <kmessagebox.h> | 28 | #include <kmessagebox.h> |
29 | 29 | ||
30 | */ | 30 | */ |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kmessagebox.h> | 32 | #include <kmessagebox.h> |
33 | 33 | ||
34 | //US | 34 | //US |
35 | #include <kglobal.h> | 35 | #include <kglobal.h> |
36 | 36 | ||
37 | #include <qlistbox.h> | 37 | #include <q3listbox.h> |
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qgroupbox.h> | 39 | #include <q3groupbox.h> |
40 | //Added by qt3to4: | ||
41 | #include <Q3VBoxLayout> | ||
42 | #include <Q3Frame> | ||
43 | #include <Q3PtrList> | ||
40 | 44 | ||
41 | #include "resource.h" | 45 | #include "resource.h" |
42 | 46 | ||
43 | #include "selectdialog.h" | 47 | #include "selectdialog.h" |
44 | 48 | ||
45 | using namespace KRES; | 49 | using namespace KRES; |
46 | 50 | ||
47 | //US I am using KBaseDialog instead of KDialog | 51 | //US I am using KBaseDialog instead of KDialog |
48 | //US : KDialog( parent, name, true ) | 52 | //US : KDialog( parent, name, true ) |
49 | SelectDialog::SelectDialog( QPtrList<Resource> list, QWidget *parent, | 53 | SelectDialog::SelectDialog( Q3PtrList<Resource> list, QWidget *parent, |
50 | const char *name ) | 54 | const char *name ) |
51 | : KDialogBase( parent, name, true, i18n( "Resource Selection" ), Help | Ok | Cancel, | 55 | : KDialogBase( parent, name, true, i18n( "Resource Selection" ), Help | Ok | Cancel, |
52 | Ok, true) | 56 | Ok, true) |
53 | 57 | ||
54 | { | 58 | { |
55 | //US setCaption( i18n( "Resource Selection" ) ); | 59 | //US setCaption( i18n( "Resource Selection" ) ); |
56 | //US resize( 300, 200 ); | 60 | //US resize( 300, 200 ); |
57 | resize( KMIN(KGlobal::getDesktopWidth(), 300), KMIN(KGlobal::getDesktopHeight(), 200) ); | 61 | resize( KMIN(KGlobal::getDesktopWidth(), 300), KMIN(KGlobal::getDesktopHeight(), 200) ); |
58 | 62 | ||
59 | //US | 63 | //US |
60 | QFrame *main = plainPage(); | 64 | Q3Frame *main = plainPage(); |
61 | /*US | 65 | /*US |
62 | QVBoxLayout *layout = new QVBoxLayout( main ); | 66 | QVBoxLayout *layout = new QVBoxLayout( main ); |
63 | mConfigPage = new KRES::ConfigPage( main ); | 67 | mConfigPage = new KRES::ConfigPage( main ); |
64 | layout->addWidget( mConfigPage ); | 68 | layout->addWidget( mConfigPage ); |
65 | */ | 69 | */ |
66 | 70 | ||
67 | //US QVBoxLayout *mainLayout = new QVBoxLayout( this ); | 71 | //US QVBoxLayout *mainLayout = new QVBoxLayout( this ); |
68 | QVBoxLayout *mainLayout = new QVBoxLayout( main ); | 72 | Q3VBoxLayout *mainLayout = new Q3VBoxLayout( main ); |
69 | mainLayout->setMargin( marginHint() ); | 73 | mainLayout->setMargin( marginHint() ); |
70 | 74 | ||
71 | //US QGroupBox *groupBox = new QGroupBox( 2, Qt::Horizontal, this ); | 75 | //US QGroupBox *groupBox = new QGroupBox( 2, Qt::Horizontal, this ); |
72 | QGroupBox *groupBox = new QGroupBox( 2, Qt::Horizontal, main ); | 76 | Q3GroupBox *groupBox = new Q3GroupBox( 2, Qt::Horizontal, main ); |
73 | groupBox->setTitle( i18n( "Resources" ) ); | 77 | groupBox->setTitle( i18n( "Resources" ) ); |
74 | 78 | ||
75 | //US mResourceId = new KListBox( groupBox ); | 79 | //US mResourceId = new KListBox( groupBox ); |
76 | mResourceId = new QListBox( groupBox ); | 80 | mResourceId = new Q3ListBox( groupBox ); |
77 | 81 | ||
78 | mainLayout->addWidget( groupBox ); | 82 | mainLayout->addWidget( groupBox ); |
79 | 83 | ||
80 | mainLayout->addSpacing( 40 ); | 84 | mainLayout->addSpacing( 40 ); |
81 | 85 | ||
82 | /*US | 86 | /*US |
83 | KButtonBox *buttonBox = new KButtonBox( this ); | 87 | KButtonBox *buttonBox = new KButtonBox( this ); |
84 | 88 | ||
85 | buttonBox->addStretch(); | 89 | buttonBox->addStretch(); |
86 | buttonBox->addButton( i18n( "&OK" ), this, SLOT( accept() ) ); | 90 | buttonBox->addButton( i18n( "&OK" ), this, SLOT( accept() ) ); |
87 | buttonBox->addButton( i18n( "&Cancel" ), this, SLOT( reject() ) ); | 91 | buttonBox->addButton( i18n( "&Cancel" ), this, SLOT( reject() ) ); |
88 | buttonBox->layout(); | 92 | buttonBox->layout(); |
89 | 93 | ||
90 | mainLayout->addWidget( buttonBox ); | 94 | mainLayout->addWidget( buttonBox ); |
91 | */ | 95 | */ |
92 | // setup listbox | 96 | // setup listbox |
93 | uint counter = 0; | 97 | uint counter = 0; |
94 | for ( uint i = 0; i < list.count(); ++i ) { | 98 | for ( uint i = 0; i < list.count(); ++i ) { |
95 | Resource *resource = list.at( i ); | 99 | Resource *resource = list.at( i ); |
96 | if ( resource && !resource->readOnly() ) { | 100 | if ( resource && !resource->readOnly() ) { |
97 | mResourceMap.insert( counter, resource ); | 101 | mResourceMap.insert( counter, resource ); |
98 | mResourceId->insertItem( resource->resourceName() ); | 102 | mResourceId->insertItem( resource->resourceName() ); |
99 | counter++; | 103 | counter++; |
100 | } | 104 | } |
101 | } | 105 | } |
102 | 106 | ||
103 | mResourceId->setCurrentItem( 0 ); | 107 | mResourceId->setCurrentItem( 0 ); |
104 | connect( mResourceId, SIGNAL(returnPressed(QListBoxItem*)), | 108 | connect( mResourceId, SIGNAL(returnPressed(Q3ListBoxItem*)), |
105 | SLOT(accept()) ); | 109 | SLOT(accept()) ); |
106 | } | 110 | } |
107 | 111 | ||
108 | Resource *SelectDialog::resource() | 112 | Resource *SelectDialog::resource() |
109 | { | 113 | { |
110 | if ( mResourceId->currentItem() != -1 ) | 114 | if ( mResourceId->currentItem() != -1 ) |
111 | return mResourceMap[ mResourceId->currentItem() ]; | 115 | return mResourceMap[ mResourceId->currentItem() ]; |
112 | else | 116 | else |
113 | return 0; | 117 | return 0; |
114 | } | 118 | } |
115 | 119 | ||
116 | Resource *SelectDialog::getResource( QPtrList<Resource> list, QWidget *parent ) | 120 | Resource *SelectDialog::getResource( Q3PtrList<Resource> list, QWidget *parent ) |
117 | { | 121 | { |
118 | if ( list.count() == 0 ) { | 122 | if ( list.count() == 0 ) { |
119 | KMessageBox::error( parent, i18n( "There is no resource available!" ) ); | 123 | KMessageBox::error( parent, i18n( "There is no resource available!" ) ); |
120 | return 0; | 124 | return 0; |
121 | } | 125 | } |
122 | 126 | ||
123 | if ( list.count() == 1 ) return list.first(); | 127 | if ( list.count() == 1 ) return list.first(); |
124 | 128 | ||
125 | // the following lines will return a writeable resource if only _one_ writeable | 129 | // the following lines will return a writeable resource if only _one_ writeable |
126 | // resource exists | 130 | // resource exists |
127 | Resource *found = 0; | 131 | Resource *found = 0; |
128 | Resource *it = list.first(); | 132 | Resource *it = list.first(); |
129 | while ( it ) { | 133 | while ( it ) { |
130 | if ( !it->readOnly() ) { | 134 | if ( !it->readOnly() ) { |
131 | if ( found ) { | 135 | if ( found ) { |
132 | found = 0; | 136 | found = 0; |
133 | break; | 137 | break; |
134 | } else | 138 | } else |
135 | found = it; | 139 | found = it; |
136 | } | 140 | } |
137 | it = list.next(); | 141 | it = list.next(); |
138 | } | 142 | } |
139 | 143 | ||
140 | if ( found ) | 144 | if ( found ) |