summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/mainwindow.h
blob: e7003e4eec43cc4fbf80dffad010783b072f9cfe (plain)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
                             This file is part of the Opie Project

                             Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org>
              =.
            .=l.
           .>+-=
 _;:,     .>    :=|.         This program is free software; you can
.> <`_,   >  .   <=          redistribute it and/or  modify it under
:`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
.="- .-=="i,     .._         License as published by the Free Software
 - .   .-<_>     .<>         Foundation; either version 2 of the License,
     ._= =}       :          or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s.       This program is distributed in the hope that
     +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
    : ..    .:,     . . .    without even the implied warranty of
    =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ;      Library General Public License for more
++=   -.     .`     .:       details.
:     =  ...= . :.=-
 -.   .:....=;==+<;          You should have received a copy of the GNU
  -_. . .   )=.  =           Library General Public License along with
    --        :-=`           this library; see the file COPYING.LIB.
                             If not, write to the Free Software Foundation,
                             Inc., 59 Temple Place - Suite 330,
                             Boston, MA 02111-1307, USA.
*/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "opackagemanager.h"

#include <qpe/config.h>

#include <qlabel.h>
#include <qlistview.h>
#include <qmainwindow.h>
#include <qpixmap.h>
#include <qprogressbar.h>
#include <qtoolbar.h>
#include <qwidgetstack.h>

class QAction;
class QLineEdit;

class MainWindow :public  QMainWindow
{
    Q_OBJECT

public:
    MainWindow( QWidget *parent = 0x0, const char *name = 0x0, WFlags fl = 0 );
    static QString appName() { return QString::fromLatin1( QUICKAPP_NAME ); };

protected:
    void closeEvent( QCloseEvent *event );

private:
    Config          m_config;     // Configuration file

    OPackageManager m_packman;    // Package manager

    // Toolbars
    QToolBar     m_menuBar;       // Main toolbar containing menu
    QToolBar     m_toolBar;       // Main toolbar
    QToolBar     m_findBar;       // Find toolbar

    QWidgetStack m_widgetStack;   // Main widget stack which contains m_packageList & m_statusWidget
    QListView    m_packageList;   // Main list view of all packages

    QLineEdit   *m_findEdit;      // Line edit box used for find toolbar

    // Status widget controls
    QWidget      m_statusWidget;  // Widget to display status during long operations
    QLabel       m_statusText;    // Text status message
    QProgressBar m_statusBar;     // Progress bar showing % completed

    // Icon pixmaps
    QPixmap m_iconUpdated;   // Cached icon which shows when package can be updated
    QPixmap m_iconInstalled; // Cached icon which shows when package is installed
    QPixmap m_iconNull;      // Cached icon which shows when package is not installed

    // Menu/tool bar actions
    QAction *m_actionShowNotInstalled; // Action to show pakages not currently installed
    QAction *m_actionShowInstalled;    // Action to show pakages currently installed
    QAction *m_actionShowUpdated;      // Action to show pakages currently installed with update available
    QAction *m_actionFilter;           // Action to filter packages
    QAction *m_actionFindNext;         // Action to find next match

    // Cached filter settings
    QString                 m_filterName;     // Cached name filter value
    QString                 m_filterServer;   // Cached server name filter value
    QString                 m_filterDest;     // Cached destination name filter value
    OPackageManager::Status m_filterStatus;   // Cached status filter value
    QString                 m_filterCategory; // Cached category filter value

    void initPackageList();
    void initStatusWidget();
    void initUI();

    void loadPackageList( OPackageList *packages = 0x0, bool clearList = true );
    void searchForPackage( const QString &text );
    void installLocalPackage( const QString &ipkFile );

private slots:
    void setDocument( const QString &ipkFile );
    
    void initPackageInfo();
    void slotWidgetStackShow( QWidget *widget );

    // Status widget slots
    void slotInitStatusBar( int numSteps );
    void slotStatusText( const QString &status );
    void slotStatusBar( int currStep );

    // Actions menu action slots
    void slotUpdate();
    void slotUpgrade();
    void slotDownload();
    void slotApply();
    void slotInstallLocal();
    void slotCloseDlg();
    void slotConfigure();

    // View menu action slots
    void slotShowNotInstalled();
    void slotShowInstalled();
    void slotShowUpdated();
    void slotFilterChange();
    void slotFilter( bool isOn );

    // Find action slots
    void slotFindShowToolbar();
    void slotFindHideToolbar();
    void slotFindChanged( const QString &findText );
    void slotFindNext();

    // Other slots
    void slotDisplayPackageInfo( QListViewItem * );
};

#endif