libyui-ncurses-pkg  2.44.4
 All Classes Functions
NCPackageSelectorStart.cc
1 /****************************************************************************
2 |
3 | Copyright (c) [2002-2011] Novell, Inc.
4 | All Rights Reserved.
5 |
6 | This program is free software; you can redistribute it and/or
7 | modify it under the terms of version 2 of the GNU General Public License as
8 | published by the Free Software Foundation.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, contact Novell, Inc.
17 |
18 | To contact Novell about this file by physical or electronic mail,
19 | you may find current contact information at www.novell.com
20 |
21 |***************************************************************************/
22 
23 
24 /*---------------------------------------------------------------------\
25 | |
26 | __ __ ____ _____ ____ |
27 | \ \ / /_ _/ ___|_ _|___ \ |
28 | \ V / _` \___ \ | | __) | |
29 | | | (_| |___) || | / __/ |
30 | |_|\__,_|____/ |_| |_____| |
31 | |
32 | core system |
33 | (C) SuSE GmbH |
34 \----------------------------------------------------------------------/
35 
36  File: NCPackageSelectorStart.cc
37 
38  Author: Gabriele Strattner <gs@suse.de>
39 
40 /-*/
41 #define YUILogComponent "ncurses-pkg"
42 #include <YUILog.h>
43 
44 #include "NCurses.h"
45 #include "NCPackageSelectorStart.h"
46 #include "NCPushButton.h"
47 #include "NCSpacing.h"
48 #include "NCPkgTable.h"
49 #include "NCLabel.h"
50 #include "NCPkgStrings.h"
51 #include "NCi18n.h"
52 
53 #include <libintl.h>
54 
55 #include "YPackageSelector.h"
56 
57 using std::endl;
58 
59 ///////////////////////////////////////////////////////////////////
60 //
61 //
62 // METHOD NAME : NCPackageSelectorStart::NCPackageSelectorStart
63 // METHOD TYPE : Constructor
64 //
65 // DESCRIPTION :
66 //
67 NCPackageSelectorStart::NCPackageSelectorStart( YWidget * parent,
68  long modeFlags,
69  YUIDimension dimension )
70  : NCLayoutBox( parent, dimension )
71  , packager( 0 )
72 {
73  // set the textdomain
74  setTextdomain( "ncurses-pkg" );
75 
76  // NEW NEW
77  packager = new NCPackageSelector( modeFlags );
78 
79  NCPkgTable::NCPkgTableType type;
80 
81  if ( packager )
82  {
83  if ( packager->isYouMode() )
84  {
85  packager->createYouLayout( this );
86  type = NCPkgTable::T_Patches;
87  }
88  else
89  {
90  if ( packager->isUpdateMode() )
91  type = NCPkgTable::T_Update;
92  else
93  type = NCPkgTable::T_Packages;
94  packager->createPkgLayout( this, type );
95  }
96  }
97 
98  yuiDebug() << endl;
99  wstate = NC::WSdumb;
100 }
101 
102 ///////////////////////////////////////////////////////////////////
103 //
104 //
105 // METHOD NAME : NCPackageSelectorStart::~NCPackageSelectorStart
106 // METHOD TYPE : Destructor
107 //
108 // DESCRIPTION :
109 //
111 {
112  if ( packager )
113  {
114  delete packager;
115  }
116 }
117 
118 ///////////////////////////////////////////////////////////////////
119 //
120 //
121 // METHOD NAME : NCPackageSelectorStart::setSize
122 // METHOD TYPE : void
123 //
124 // DESCRIPTION :
125 //
126 void NCPackageSelectorStart::setSize( int newwidth, int newheight )
127 {
128  wRelocate( wpos( 0 ), wsze( newheight, newwidth ) );
129  YLayoutBox::setSize( newwidth, newheight );
130 }
131 
132 
133 ///////////////////////////////////////////////////////////////////
134 //
135 // METHOD NAME : NCPackageSelectorStart::showDefaultList
136 // METHOD TYPE : void
137 //
138 // DESCRIPTION : fill up the package table with default data
139 //
140 //
142 {
143  // fill the package table with packages belonging to the default filter
144 
145  if ( packager )
146  {
147  // always do an initial dependency solving - BEFORE filling the default list
148  packager->showPackageDependencies( true );
149 
150  // fill package list with packages belonging to default RPM group
151  packager->fillDefaultList();
152 
153  if ( packager->isYouMode() )
154  {
155  // show download size
156  packager->showDownloadSize();
157  }
158  else
159  {
160  // show the required diskspace
161  packager->showDiskSpace();
162  }
163  }
164 }
165 
166 ///////////////////////////////////////////////////////////////////
167 //
168 // METHOD NAME : NCPackageSelectorStart::handleEvent
169 // METHOD TYPE : bool
170 //
171 // DESCRIPTION : passes the event to the handleEvent method
172 // of the member variable PackageSelector packager
173 //
174 bool NCPackageSelectorStart::handleEvent ( const NCursesEvent & event )
175 {
176  if ( !packager )
177  return false;
178 
179  return packager->handleEvent( event );
180 }
181 
182 
void createPkgLayout(YWidget *parent, NCPkgTable::NCPkgTableType type)
bool handleEvent(const NCursesEvent &event)
virtual void setSize(int newWidth, int newHeight)
bool handleEvent(const NCursesEvent &event)
void createYouLayout(YWidget *parent)
bool showPackageDependencies(bool doit)