Diffstat (limited to 'noncore/unsupported/oipkg/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.cpp | 190 |
1 files changed, 133 insertions, 57 deletions
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp index cb2b4cd..997f449 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp | |||
@@ -14,4 +14,6 @@ | |||
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | #include <qlabel.h> | ||
15 | #include <qlistview.h> | 16 | #include <qlistview.h> |
16 | #include <qtextview.h> | 17 | #include <qtextview.h> |
18 | #include <qlineedit.h> | ||
17 | #include <qtabwidget.h> | 19 | #include <qtabwidget.h> |
@@ -27,4 +29,6 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
27 | setCaption( tr("Package Manager") ); | 29 | setCaption( tr("Package Manager") ); |
28 | table = new PackageWindow( this,0,0 ); | 30 | |
29 | setCentralWidget( table ); | 31 | listViewPackages = new QListView( this,0,0 ); |
32 | setCentralWidget( listViewPackages ); | ||
33 | |||
30 | makeMenu(); | 34 | makeMenu(); |
@@ -32,17 +36,20 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | |||
32 | QFontMetrics fm = fontMetrics(); | 36 | QFontMetrics fm = fontMetrics(); |
37 | int wlw = width()*2; | ||
33 | int w0 = fm.width(tr("Package"))+30; | 38 | int w0 = fm.width(tr("Package"))+30; |
39 | // int w0 = fm.width(tr("Package"))+30; | ||
34 | int w2 = fm.width("00000")+4; | 40 | int w2 = fm.width("00000")+4; |
35 | table->ListViewPackages->setColumnWidth(0,w0); | 41 | int w1 = wlw-w2-w0-20; |
36 | table->ListViewPackages->setColumnWidth(1,228-w2-w0); // ### screen-biased | 42 | listViewPackages->addColumn( tr("Package"), w0 ); |
37 | table->ListViewPackages->setColumnWidth(2,w2); | 43 | listViewPackages->addColumn( tr("Description"), w1 ); |
38 | table->ListViewPackages->setColumnWidthMode(0,QListView::Manual); | 44 | listViewPackages->addColumn( tr("Size"), w2 ); |
39 | table->ListViewPackages->setColumnWidthMode(1,QListView::Manual); | 45 | listViewPackages->setColumnWidthMode(0,QListView::Manual); |
40 | table->ListViewPackages->setColumnWidthMode(2,QListView::Manual); | 46 | listViewPackages->setColumnWidthMode(1,QListView::Manual); |
41 | table->ListViewPackages->setSelectionMode( QListView::Multi ); | 47 | listViewPackages->setColumnWidthMode(2,QListView::Manual); |
42 | 48 | listViewPackages->setSelectionMode( QListView::Multi ); | |
43 | connect( table->section, SIGNAL( activated(int) ), | 49 | |
50 | connect( section, SIGNAL( activated(int) ), | ||
44 | this, SLOT( sectionChanged() ) ); | 51 | this, SLOT( sectionChanged() ) ); |
45 | connect( table->subsection, SIGNAL(activated(int) ), | 52 | connect( subsection, SIGNAL(activated(int) ), |
46 | this, SLOT( subSectionChanged() ) ); | 53 | this, SLOT( subSectionChanged() ) ); |
47 | connect( table->ListViewPackages, SIGNAL( clicked( QListViewItem* ) ), | 54 | connect( listViewPackages, SIGNAL( pressed( QListViewItem* ) ), |
48 | this, SLOT( setCurrent( QListViewItem* ) ) ); | 55 | this, SLOT( setCurrent( QListViewItem* ) ) ); |
@@ -65,2 +72,3 @@ void MainWindow::makeMenu() | |||
65 | QPopupMenu *srvMenu = new QPopupMenu( menuBar ); | 72 | QPopupMenu *srvMenu = new QPopupMenu( menuBar ); |
73 | QPopupMenu *viewMenu = new QPopupMenu( menuBar ); | ||
66 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); | 74 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); |
@@ -68,8 +76,3 @@ void MainWindow::makeMenu() | |||
68 | 76 | ||
69 | //#define TOOLBAR | 77 | popupMenu = new QPopupMenu( this ); |
70 | #ifdef TOOLBAR | ||
71 | QPEToolBar *secBar = new QPEToolBar( this ); | ||
72 | QComboBox *sections = new QComboBox( false, this ); | ||
73 | secBar->addTo( sections ); | ||
74 | #endif | ||
75 | 78 | ||
@@ -80,2 +83,3 @@ void MainWindow::makeMenu() | |||
80 | menuBar->insertItem( tr( "Package" ), srvMenu ); | 83 | menuBar->insertItem( tr( "Package" ), srvMenu ); |
84 | menuBar->insertItem( tr( "View" ), viewMenu ); | ||
81 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); | 85 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); |
@@ -83,6 +87,8 @@ void MainWindow::makeMenu() | |||
83 | 87 | ||
84 | toolBar->setStretchableWidget (srvMenu); | 88 | QLabel *spacer = new QLabel( "", toolBar ); |
89 | spacer->setBackgroundColor( toolBar->backgroundColor() ); | ||
90 | toolBar->setStretchableWidget( spacer ); | ||
85 | 91 | ||
86 | 92 | ||
87 | runAction = new QAction( tr( "Run" ), | 93 | runAction = new QAction( tr( "Commit" ), |
88 | Resource::loadPixmap( "oipkg/install" ), | 94 | Resource::loadPixmap( "oipkg/install" ), |
@@ -104,9 +110,9 @@ void MainWindow::makeMenu() | |||
104 | 110 | ||
105 | // detailsAction = new QAction( tr( "Details" ), | 111 | detailsAction = new QAction( tr( "Details" ), |
106 | // Resource::loadIconSet( "oipkg/details" ), | 112 | Resource::loadIconSet( "find" ), |
107 | // QString::null, 0, this, 0 ); | 113 | QString::null, 0, this, 0 ); |
108 | // connect( detailsAction, SIGNAL( activated() ), | 114 | connect( detailsAction, SIGNAL( activated() ), |
109 | // this , SLOT( showDetails() ) ); | 115 | this , SLOT( showDetails() ) ); |
110 | // detailsAction->addTo( toolBar ); | 116 | detailsAction->addTo( toolBar ); |
111 | // detailsAction->addTo( srvMenu ); | 117 | detailsAction->addTo( srvMenu ); |
112 | 118 | ||
@@ -115,3 +121,3 @@ void MainWindow::makeMenu() | |||
115 | cfgact = new QAction( tr( "Setups" ), | 121 | cfgact = new QAction( tr( "Setups" ), |
116 | Resource::loadIconSet( "" ), | 122 | // Resource::loadIconSet( "" ), |
117 | QString::null, 0, this, 0 ); | 123 | QString::null, 0, this, 0 ); |
@@ -122,3 +128,3 @@ void MainWindow::makeMenu() | |||
122 | cfgact = new QAction( tr( "Servers" ), | 128 | cfgact = new QAction( tr( "Servers" ), |
123 | Resource::loadIconSet( "" ), | 129 | // Resource::loadIconSet( "" ), |
124 | QString::null, 0, this, 0 ); | 130 | QString::null, 0, this, 0 ); |
@@ -128,3 +134,3 @@ void MainWindow::makeMenu() | |||
128 | cfgact = new QAction( tr( "Destinations" ), | 134 | cfgact = new QAction( tr( "Destinations" ), |
129 | Resource::loadIconSet( "" ), | 135 | //Resource::loadIconSet( "" ), |
130 | QString::null, 0, this, 0 ); | 136 | QString::null, 0, this, 0 ); |
@@ -134,2 +140,48 @@ void MainWindow::makeMenu() | |||
134 | 140 | ||
141 | QAction *a; | ||
142 | |||
143 | sectionBar = new QPEToolBar( this ); | ||
144 | addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); | ||
145 | sectionBar->setHorizontalStretchable( true ); | ||
146 | QLabel *label = new QLabel( tr("Section: "), sectionBar ); | ||
147 | label->setBackgroundColor( sectionBar->backgroundColor() ); | ||
148 | section = new QComboBox( false, sectionBar ); | ||
149 | // section->setBackgroundMode( PaletteBackground ); | ||
150 | label = new QLabel( " / ", sectionBar ); | ||
151 | label->setBackgroundColor( sectionBar->backgroundColor() ); | ||
152 | subsection = new QComboBox( false, sectionBar ); | ||
153 | sectionBar->setStretchableWidget( label ); | ||
154 | |||
155 | a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | ||
156 | connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); | ||
157 | a->addTo( sectionBar ); | ||
158 | |||
159 | sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); | ||
160 | connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); | ||
161 | sectionAction->setToggleAction( true ); | ||
162 | sectionAction->setOn( true ); | ||
163 | sectionAction->addTo( viewMenu ); | ||
164 | |||
165 | findBar = new QPEToolBar(this); | ||
166 | addToolBar( findBar, "Search", QMainWindow::Top, TRUE ); | ||
167 | label = new QLabel( tr("Filter: "), findBar ); | ||
168 | label->setBackgroundColor( findBar->backgroundColor() ); | ||
169 | findBar->setHorizontalStretchable( TRUE ); | ||
170 | findEdit = new QLineEdit( findBar, "findEdit" ); | ||
171 | findBar->setStretchableWidget( findEdit ); | ||
172 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), | ||
173 | this, SLOT( displayList() ) ); | ||
174 | //a = new QAction( tr( "Filter" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | ||
175 | // connect( a, SIGNAL( activated() ), this, SLOT( filterList() ) ); | ||
176 | // a->addTo( findBar ); | ||
177 | // a->addTo( edit ); | ||
178 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | ||
179 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | ||
180 | a->addTo( findBar ); | ||
181 | findAction = new QAction( tr( "Find" ), QString::null, 0, this, 0 ); | ||
182 | connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); | ||
183 | findAction->setToggleAction( true ); | ||
184 | findAction->setOn( true ); | ||
185 | findAction->addTo( viewMenu ); | ||
186 | |||
135 | } | 187 | } |
@@ -143,3 +195,3 @@ void MainWindow::runIpkg() | |||
143 | ipkg->commit( packageList ); | 195 | ipkg->commit( packageList ); |
144 | updateList(); | 196 | updateList(); //to remove |
145 | } | 197 | } |
@@ -148,3 +200,3 @@ void MainWindow::updateList() | |||
148 | { | 200 | { |
149 | // todo: packageList.clear(); | 201 | packageList.clear(); |
150 | ipkg->update(); | 202 | ipkg->update(); |
@@ -161,3 +213,5 @@ void MainWindow::filterList() | |||
161 | { | 213 | { |
162 | packageList.filterPackages(); | 214 | QString f = ""; |
215 | if ( findAction->isOn() ) f = findEdit->text(); | ||
216 | packageList.filterPackages( f ); | ||
163 | } | 217 | } |
@@ -166,3 +220,4 @@ void MainWindow::displayList() | |||
166 | { | 220 | { |
167 | table->ListViewPackages->clear(); | 221 | filterList(); |
222 | listViewPackages->clear(); | ||
168 | Package *pack = packageList.first(); | 223 | Package *pack = packageList.first(); |
@@ -171,6 +226,3 @@ void MainWindow::displayList() | |||
171 | if ( pack && (pack->name() != "") ) | 226 | if ( pack && (pack->name() != "") ) |
172 | { | 227 | listViewPackages->insertItem( new PackageListItem( listViewPackages, pack ) ); |
173 | table->ListViewPackages->insertItem( | ||
174 | new PackageListItem( table->ListViewPackages, pack ) ); | ||
175 | } | ||
176 | pack = packageList.next(); | 228 | pack = packageList.next(); |
@@ -181,13 +233,12 @@ void MainWindow::sectionChanged() | |||
181 | { | 233 | { |
182 | disconnect( table->section, SIGNAL( activated(int) ), | 234 | disconnect( section, SIGNAL( activated(int) ), |
183 | this, SLOT( sectionChanged() ) ); | 235 | this, SLOT( sectionChanged() ) ); |
184 | disconnect( table->subsection, SIGNAL(activated(int) ), | 236 | disconnect( subsection, SIGNAL(activated(int) ), |
185 | this, SLOT( subSectionChanged() ) ); | 237 | this, SLOT( subSectionChanged() ) ); |
186 | table->subsection->clear(); | 238 | subsection->clear(); |
187 | packageList.setSection( table->section->currentText() ); | 239 | packageList.setSection( section->currentText() ); |
188 | setSubSections(); | 240 | setSubSections(); |
189 | filterList(); | 241 | connect( section, SIGNAL( activated(int) ), |
190 | connect( table->section, SIGNAL( activated(int) ), | ||
191 | this, SLOT( sectionChanged() ) ); | 242 | this, SLOT( sectionChanged() ) ); |
192 | connect( table->subsection, SIGNAL(activated(int) ), | 243 | connect( subsection, SIGNAL(activated(int) ), |
193 | this, SLOT( subSectionChanged() ) ); | 244 | this, SLOT( subSectionChanged() ) ); |
@@ -198,11 +249,10 @@ void MainWindow::subSectionChanged() | |||
198 | { | 249 | { |
199 | disconnect( table->section, SIGNAL( activated(int) ), | 250 | disconnect( section, SIGNAL( activated(int) ), |
200 | this, SLOT( sectionChanged() ) ); | 251 | this, SLOT( sectionChanged() ) ); |
201 | disconnect( table->subsection, SIGNAL(activated(int) ), | 252 | disconnect( subsection, SIGNAL(activated(int) ), |
202 | this, SLOT( subSectionChanged() ) ); | 253 | this, SLOT( subSectionChanged() ) ); |
203 | packageList.setSubSection( table->subsection->currentText() ); | 254 | packageList.setSubSection( subsection->currentText() ); |
204 | filterList(); | 255 | connect( section, SIGNAL( activated(int) ), |
205 | connect( table->section, SIGNAL( activated(int) ), | ||
206 | this, SLOT( sectionChanged() ) ); | 256 | this, SLOT( sectionChanged() ) ); |
207 | connect( table->subsection, SIGNAL(activated(int) ), | 257 | connect( subsection, SIGNAL(activated(int) ), |
208 | this, SLOT( subSectionChanged() ) ); | 258 | this, SLOT( subSectionChanged() ) ); |
@@ -213,4 +263,4 @@ void MainWindow::setSections() | |||
213 | { | 263 | { |
214 | table->section->clear(); | 264 | section->clear(); |
215 | table->section->insertStringList( packageList.getSections() ); | 265 | section->insertStringList( packageList.getSections() ); |
216 | } | 266 | } |
@@ -219,4 +269,4 @@ void MainWindow::setSubSections() | |||
219 | { | 269 | { |
220 | table->subsection->clear(); | 270 | subsection->clear(); |
221 | table->subsection->insertStringList( packageList.getSubSections() ); | 271 | subsection->insertStringList( packageList.getSubSections() ); |
222 | } | 272 | } |
@@ -269,4 +319,30 @@ void MainWindow::setCurrent( QListViewItem* p ) | |||
269 | pvDebug(2, "MainWindow::setCurrent "); | 319 | pvDebug(2, "MainWindow::setCurrent "); |
270 | //+((Package*)p)->name()); | 320 | return; |
321 | pvDebug(2, "name "+((Package*)p)->name()); | ||
271 | activePackage = (Package*)p; | 322 | activePackage = (Package*)p; |
272 | } | 323 | } |
324 | |||
325 | void MainWindow::sectionShow(bool b) | ||
326 | { | ||
327 | if (b) sectionBar->show(); | ||
328 | else sectionBar->hide(); | ||
329 | sectionAction->setOn( b ); | ||
330 | } | ||
331 | |||
332 | void MainWindow::sectionClose() | ||
333 | { | ||
334 | sectionAction->setOn( false ); | ||
335 | } | ||
336 | |||
337 | void MainWindow::findShow(bool b) | ||
338 | { | ||
339 | if (b) findBar->show(); | ||
340 | else findBar->hide(); | ||
341 | findAction->setOn( b ); | ||
342 | } | ||
343 | |||
344 | void MainWindow::findClose() | ||
345 | { | ||
346 | findAction->setOn( false ); | ||
347 | } | ||
348 | |||