author | drw <drw> | 2004-11-16 20:50:31 (UTC) |
---|---|---|
committer | drw <drw> | 2004-11-16 20:50:31 (UTC) |
commit | 251511f7cdd1691a7d790ce0473e040d38a6d834 (patch) (unidiff) | |
tree | 23a1eb61e8524afc8458ac0f77abcc4f22041c44 /noncore/settings | |
parent | ea3945a9bd8f9830f70b1efa133f9df13b19362f (diff) | |
download | opie-251511f7cdd1691a7d790ce0473e040d38a6d834.zip opie-251511f7cdd1691a7d790ce0473e040d38a6d834.tar.gz opie-251511f7cdd1691a7d790ce0473e040d38a6d834.tar.bz2 |
Implemented setDocument to allow installs by clicking on ipk file
-rw-r--r-- | noncore/settings/packagemanager/mainwindow.cpp | 40 | ||||
-rw-r--r-- | noncore/settings/packagemanager/mainwindow.h | 3 |
2 files changed, 31 insertions, 12 deletions
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 5a942a1..349094d 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp | |||
@@ -70,49 +70,49 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) | |||
70 | , m_filterServer( QString::null ) | 70 | , m_filterServer( QString::null ) |
71 | , m_filterDest( QString::null ) | 71 | , m_filterDest( QString::null ) |
72 | , m_filterStatus( OPackageManager::NotDefined ) | 72 | , m_filterStatus( OPackageManager::NotDefined ) |
73 | , m_filterCategory( QString::null ) | 73 | , m_filterCategory( QString::null ) |
74 | 74 | ||
75 | { | 75 | { |
76 | // setCaption( tr( "Package Manager" ) ); | 76 | // setCaption( tr( "Package Manager" ) ); |
77 | 77 | ||
78 | m_iconNull.fill( colorGroup().base() ); | 78 | m_iconNull.fill( colorGroup().base() ); |
79 | 79 | ||
80 | connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); | 80 | connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); |
81 | 81 | ||
82 | // Initialize widget stack, package list and status widget | 82 | // Initialize widget stack, package list and status widget |
83 | initStatusWidget(); | 83 | initStatusWidget(); |
84 | initPackageList(); | 84 | initPackageList(); |
85 | 85 | ||
86 | m_widgetStack.addWidget( &m_statusWidget, 2 ); | 86 | m_widgetStack.addWidget( &m_statusWidget, 2 ); |
87 | m_widgetStack.addWidget( &m_packageList, 1 ); | 87 | m_widgetStack.addWidget( &m_packageList, 1 ); |
88 | setCentralWidget( &m_widgetStack ); | 88 | setCentralWidget( &m_widgetStack ); |
89 | 89 | ||
90 | // Initialize remaining user interface items | 90 | // Initialize remaining user interface items |
91 | initUI(); | 91 | initUI(); |
92 | 92 | ||
93 | // Initialize package information | 93 | // Initialize package information |
94 | QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) ); | 94 | QTimer::singleShot( -1, this, SLOT( initPackageInfo() ) ); |
95 | } | 95 | } |
96 | 96 | ||
97 | void MainWindow::closeEvent( QCloseEvent *event ) | 97 | void MainWindow::closeEvent( QCloseEvent *event ) |
98 | { | 98 | { |
99 | // Close app only if either the package or status widgets are currently active | 99 | // Close app only if either the package or status widgets are currently active |
100 | bool close = m_widgetStack.visibleWidget() == &m_packageList || | 100 | bool close = m_widgetStack.visibleWidget() == &m_packageList || |
101 | m_widgetStack.visibleWidget() == &m_statusWidget; | 101 | m_widgetStack.visibleWidget() == &m_statusWidget; |
102 | if ( close ) | 102 | if ( close ) |
103 | { | 103 | { |
104 | // TODO - write out application configuration settings | 104 | // TODO - write out application configuration settings |
105 | 105 | ||
106 | // Write out package manager configuration settings | 106 | // Write out package manager configuration settings |
107 | m_packman.saveSettings(); | 107 | m_packman.saveSettings(); |
108 | event->accept(); | 108 | event->accept(); |
109 | } | 109 | } |
110 | else | 110 | else |
111 | { | 111 | { |
112 | delete m_widgetStack.visibleWidget(); | 112 | delete m_widgetStack.visibleWidget(); |
113 | m_widgetStack.raiseWidget( &m_packageList ); | 113 | m_widgetStack.raiseWidget( &m_packageList ); |
114 | event->ignore(); | 114 | event->ignore(); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | void MainWindow::initPackageList() | 118 | void MainWindow::initPackageList() |
@@ -288,64 +288,89 @@ void MainWindow::loadPackageList( OPackageList *packages, bool clearList ) | |||
288 | 288 | ||
289 | void MainWindow::searchForPackage( const QString &text ) | 289 | void MainWindow::searchForPackage( const QString &text ) |
290 | { | 290 | { |
291 | if ( !text.isEmpty() ) | 291 | if ( !text.isEmpty() ) |
292 | { | 292 | { |
293 | // look through package list for text startng at current position | 293 | // look through package list for text startng at current position |
294 | QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); | 294 | QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); |
295 | if ( start == 0 ) | 295 | if ( start == 0 ) |
296 | start = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 296 | start = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
297 | 297 | ||
298 | // for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; | 298 | // for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; |
299 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; | 299 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; |
300 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 300 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
301 | { | 301 | { |
302 | if ( item->text().lower().find( text ) != -1 ) | 302 | if ( item->text().lower().find( text ) != -1 ) |
303 | { | 303 | { |
304 | m_packageList.ensureItemVisible( item ); | 304 | m_packageList.ensureItemVisible( item ); |
305 | m_packageList.setCurrentItem( item ); | 305 | m_packageList.setCurrentItem( item ); |
306 | break; | 306 | break; |
307 | } | 307 | } |
308 | } | 308 | } |
309 | } | 309 | } |
310 | } | 310 | } |
311 | 311 | ||
312 | void MainWindow::installLocalPackage( const QString &ipkFile ) | ||
313 | { | ||
314 | // Install selected file | ||
315 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Install local package" ), true, | ||
316 | OPackage::Install, new QStringList( ipkFile ) ); | ||
317 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | ||
318 | |||
319 | // Display widget | ||
320 | m_widgetStack.addWidget( dlg, 3 ); | ||
321 | m_widgetStack.raiseWidget( dlg ); | ||
322 | } | ||
323 | |||
324 | void MainWindow::setDocument( const QString &ipkFile ) | ||
325 | { | ||
326 | QString file = ipkFile; | ||
327 | DocLnk lnk( ipkFile ); | ||
328 | if ( lnk.isValid() ) | ||
329 | file = lnk.file(); | ||
330 | |||
331 | installLocalPackage( file ); | ||
332 | } | ||
333 | |||
312 | void MainWindow::initPackageInfo() | 334 | void MainWindow::initPackageInfo() |
313 | { | 335 | { |
314 | m_widgetStack.raiseWidget( &m_statusWidget ); | 336 | m_widgetStack.raiseWidget( &m_statusWidget ); |
315 | 337 | ||
316 | // Load package list | 338 | // Load package list |
317 | m_packman.loadAvailablePackages(); | 339 | m_packman.loadAvailablePackages(); |
318 | m_packman.loadInstalledPackages(); | 340 | m_packman.loadInstalledPackages(); |
319 | 341 | ||
320 | OPackageList *packageList = m_packman.packages(); | 342 | OPackageList *packageList = m_packman.packages(); |
321 | if ( packageList ) | 343 | if ( packageList ) |
322 | { | 344 | { |
323 | loadPackageList( packageList, true ); | 345 | loadPackageList( packageList, true ); |
324 | delete packageList; | 346 | delete packageList; |
325 | } | 347 | } |
326 | 348 | ||
327 | m_widgetStack.raiseWidget( &m_packageList ); | 349 | QWidget *widget = m_widgetStack.widget( 3 ); |
350 | if ( !widget ) | ||
351 | widget = &m_packageList; | ||
352 | m_widgetStack.raiseWidget( widget ); | ||
328 | } | 353 | } |
329 | 354 | ||
330 | void MainWindow::slotWidgetStackShow( QWidget *widget ) | 355 | void MainWindow::slotWidgetStackShow( QWidget *widget ) |
331 | { | 356 | { |
332 | if ( widget == &m_packageList ) | 357 | if ( widget == &m_packageList ) |
333 | { | 358 | { |
334 | setCaption( tr( "Package Manager" ) ); | 359 | setCaption( tr( "Package Manager" ) ); |
335 | 360 | ||
336 | m_menuBar.show(); | 361 | m_menuBar.show(); |
337 | m_toolBar.show(); | 362 | m_toolBar.show(); |
338 | } | 363 | } |
339 | else | 364 | else |
340 | { | 365 | { |
341 | m_menuBar.hide(); | 366 | m_menuBar.hide(); |
342 | m_toolBar.hide(); | 367 | m_toolBar.hide(); |
343 | } | 368 | } |
344 | } | 369 | } |
345 | 370 | ||
346 | void MainWindow::slotInitStatusBar( int numSteps ) | 371 | void MainWindow::slotInitStatusBar( int numSteps ) |
347 | { | 372 | { |
348 | m_statusBar.setTotalSteps( numSteps ); | 373 | m_statusBar.setTotalSteps( numSteps ); |
349 | } | 374 | } |
350 | 375 | ||
351 | void MainWindow::slotStatusText( const QString &status ) | 376 | void MainWindow::slotStatusText( const QString &status ) |
@@ -516,58 +541,49 @@ void MainWindow::slotApply() | |||
516 | upgradeCmd = OPackage::Upgrade; | 541 | upgradeCmd = OPackage::Upgrade; |
517 | 542 | ||
518 | // Create package manager output widget | 543 | // Create package manager output widget |
519 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, | 544 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, |
520 | removeCmd, removeList, | 545 | removeCmd, removeList, |
521 | installCmd, installList, | 546 | installCmd, installList, |
522 | upgradeCmd, upgradeList ); | 547 | upgradeCmd, upgradeList ); |
523 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 548 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
524 | 549 | ||
525 | // Display widget | 550 | // Display widget |
526 | m_widgetStack.addWidget( dlg, 3 ); | 551 | m_widgetStack.addWidget( dlg, 3 ); |
527 | m_widgetStack.raiseWidget( dlg ); | 552 | m_widgetStack.raiseWidget( dlg ); |
528 | } | 553 | } |
529 | 554 | ||
530 | void MainWindow::slotInstallLocal() | 555 | void MainWindow::slotInstallLocal() |
531 | { | 556 | { |
532 | // Display file open dialog with only package files | 557 | // Display file open dialog with only package files |
533 | MimeTypes type; | 558 | MimeTypes type; |
534 | QStringList packages; | 559 | QStringList packages; |
535 | packages << "application/ipkg"; | 560 | packages << "application/ipkg"; |
536 | type.insert( tr( "Application Packages" ), packages ); | 561 | type.insert( tr( "Application Packages" ), packages ); |
537 | QString package = Opie::Ui::OFileDialog::getOpenFileName( Opie::Ui::OFileSelector::NORMAL, | 562 | QString package = Opie::Ui::OFileDialog::getOpenFileName( Opie::Ui::OFileSelector::NORMAL, |
538 | "/", QString::null, type ); | 563 | "/", QString::null, type ); |
539 | if ( !package.isNull() ) | 564 | if ( !package.isNull() ) |
540 | { | 565 | installLocalPackage( package ); |
541 | // Install selected file | ||
542 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Install local package" ), true, | ||
543 | OPackage::Install, new QStringList( package ) ); | ||
544 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | ||
545 | |||
546 | // Display widget | ||
547 | m_widgetStack.addWidget( dlg, 3 ); | ||
548 | m_widgetStack.raiseWidget( dlg ); | ||
549 | } | ||
550 | } | 566 | } |
551 | 567 | ||
552 | void MainWindow::slotCloseDlg() | 568 | void MainWindow::slotCloseDlg() |
553 | { | 569 | { |
554 | // Close install dialog | 570 | // Close install dialog |
555 | delete m_widgetStack.visibleWidget(); | 571 | delete m_widgetStack.visibleWidget(); |
556 | 572 | ||
557 | // Reload package list | 573 | // Reload package list |
558 | initPackageInfo(); | 574 | initPackageInfo(); |
559 | 575 | ||
560 | // Update Opie launcher links | 576 | // Update Opie launcher links |
561 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 577 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
562 | QString lf = QString::null; | 578 | QString lf = QString::null; |
563 | e << lf; | 579 | e << lf; |
564 | 580 | ||
565 | // Reapply any filters previously set | 581 | // Reapply any filters previously set |
566 | if ( m_actionShowNotInstalled->isOn() ) | 582 | if ( m_actionShowNotInstalled->isOn() ) |
567 | slotShowNotInstalled(); | 583 | slotShowNotInstalled(); |
568 | else if ( m_actionShowInstalled->isOn() ) | 584 | else if ( m_actionShowInstalled->isOn() ) |
569 | slotShowInstalled(); | 585 | slotShowInstalled(); |
570 | else if ( m_actionShowUpdated->isOn() ) | 586 | else if ( m_actionShowUpdated->isOn() ) |
571 | slotShowUpdated(); | 587 | slotShowUpdated(); |
572 | else if ( m_actionFilter->isOn() ) | 588 | else if ( m_actionFilter->isOn() ) |
573 | slotFilter( true ); | 589 | slotFilter( true ); |
diff --git a/noncore/settings/packagemanager/mainwindow.h b/noncore/settings/packagemanager/mainwindow.h index 7968614..103c664 100644 --- a/noncore/settings/packagemanager/mainwindow.h +++ b/noncore/settings/packagemanager/mainwindow.h | |||
@@ -80,50 +80,53 @@ private: | |||
80 | QPixmap m_iconUpdated; // Cached icon which shows when package can be updated | 80 | QPixmap m_iconUpdated; // Cached icon which shows when package can be updated |
81 | QPixmap m_iconInstalled; // Cached icon which shows when package is installed | 81 | QPixmap m_iconInstalled; // Cached icon which shows when package is installed |
82 | QPixmap m_iconNull; // Cached icon which shows when package is not installed | 82 | QPixmap m_iconNull; // Cached icon which shows when package is not installed |
83 | 83 | ||
84 | // Menu/tool bar actions | 84 | // Menu/tool bar actions |
85 | QAction *m_actionShowNotInstalled; // Action to show pakages not currently installed | 85 | QAction *m_actionShowNotInstalled; // Action to show pakages not currently installed |
86 | QAction *m_actionShowInstalled; // Action to show pakages currently installed | 86 | QAction *m_actionShowInstalled; // Action to show pakages currently installed |
87 | QAction *m_actionShowUpdated; // Action to show pakages currently installed with update available | 87 | QAction *m_actionShowUpdated; // Action to show pakages currently installed with update available |
88 | QAction *m_actionFilter; // Action to filter packages | 88 | QAction *m_actionFilter; // Action to filter packages |
89 | QAction *m_actionFindNext; // Action to find next match | 89 | QAction *m_actionFindNext; // Action to find next match |
90 | 90 | ||
91 | // Cached filter settings | 91 | // Cached filter settings |
92 | QString m_filterName; // Cached name filter value | 92 | QString m_filterName; // Cached name filter value |
93 | QString m_filterServer; // Cached server name filter value | 93 | QString m_filterServer; // Cached server name filter value |
94 | QString m_filterDest; // Cached destination name filter value | 94 | QString m_filterDest; // Cached destination name filter value |
95 | OPackageManager::Status m_filterStatus; // Cached status filter value | 95 | OPackageManager::Status m_filterStatus; // Cached status filter value |
96 | QString m_filterCategory; // Cached category filter value | 96 | QString m_filterCategory; // Cached category filter value |
97 | 97 | ||
98 | void initPackageList(); | 98 | void initPackageList(); |
99 | void initStatusWidget(); | 99 | void initStatusWidget(); |
100 | void initUI(); | 100 | void initUI(); |
101 | 101 | ||
102 | void loadPackageList( OPackageList *packages = 0x0, bool clearList = true ); | 102 | void loadPackageList( OPackageList *packages = 0x0, bool clearList = true ); |
103 | void searchForPackage( const QString &text ); | 103 | void searchForPackage( const QString &text ); |
104 | void installLocalPackage( const QString &ipkFile ); | ||
104 | 105 | ||
105 | private slots: | 106 | private slots: |
107 | void setDocument( const QString &ipkFile ); | ||
108 | |||
106 | void initPackageInfo(); | 109 | void initPackageInfo(); |
107 | void slotWidgetStackShow( QWidget *widget ); | 110 | void slotWidgetStackShow( QWidget *widget ); |
108 | 111 | ||
109 | // Status widget slots | 112 | // Status widget slots |
110 | void slotInitStatusBar( int numSteps ); | 113 | void slotInitStatusBar( int numSteps ); |
111 | void slotStatusText( const QString &status ); | 114 | void slotStatusText( const QString &status ); |
112 | void slotStatusBar( int currStep ); | 115 | void slotStatusBar( int currStep ); |
113 | 116 | ||
114 | // Actions menu action slots | 117 | // Actions menu action slots |
115 | void slotUpdate(); | 118 | void slotUpdate(); |
116 | void slotUpgrade(); | 119 | void slotUpgrade(); |
117 | void slotDownload(); | 120 | void slotDownload(); |
118 | void slotApply(); | 121 | void slotApply(); |
119 | void slotInstallLocal(); | 122 | void slotInstallLocal(); |
120 | void slotCloseDlg(); | 123 | void slotCloseDlg(); |
121 | void slotConfigure(); | 124 | void slotConfigure(); |
122 | 125 | ||
123 | // View menu action slots | 126 | // View menu action slots |
124 | void slotShowNotInstalled(); | 127 | void slotShowNotInstalled(); |
125 | void slotShowInstalled(); | 128 | void slotShowInstalled(); |
126 | void slotShowUpdated(); | 129 | void slotShowUpdated(); |
127 | void slotFilterChange(); | 130 | void slotFilterChange(); |
128 | void slotFilter( bool isOn ); | 131 | void slotFilter( bool isOn ); |
129 | 132 | ||