libyui
3.0.10
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YPartitionSplitter.cc 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 00026 #define YUILogComponent "ui" 00027 #include "YUILog.h" 00028 00029 #include "YUISymbols.h" 00030 #include "YPartitionSplitter.h" 00031 00032 00033 struct YPartitionSplitterPrivate 00034 { 00035 YPartitionSplitterPrivate( int usedSize, 00036 int totalFreeSize, 00037 int minNewPartSize, 00038 int minFreeSize, 00039 const std::string & usedLabel, 00040 const std::string & freeLabel, 00041 const std::string & newPartLabel, 00042 const std::string & freeFieldLabel, 00043 const std::string & newPartFieldLabel ) 00044 : usedSize ( usedSize ) 00045 , totalFreeSize ( totalFreeSize ) 00046 , minNewPartSize ( minNewPartSize ) 00047 , minFreeSize ( minFreeSize ) 00048 , usedLabel ( usedLabel ) 00049 , freeLabel ( freeLabel ) 00050 , newPartLabel ( newPartLabel ) 00051 , freeFieldLabel ( freeFieldLabel ) 00052 , newPartFieldLabel ( newPartFieldLabel ) 00053 {} 00054 00055 int usedSize; 00056 int totalFreeSize; 00057 int minNewPartSize; 00058 int minFreeSize; 00059 std::string usedLabel; 00060 std::string freeLabel; 00061 std::string newPartLabel; 00062 std::string freeFieldLabel; 00063 std::string newPartFieldLabel; 00064 }; 00065 00066 00067 00068 00069 YPartitionSplitter::YPartitionSplitter( YWidget * parent, 00070 int usedSize, 00071 int totalFreeSize, 00072 int newPartSize, 00073 int minNewPartSize, 00074 int minFreeSize, 00075 const std::string & usedLabel, 00076 const std::string & freeLabel, 00077 const std::string & newPartLabel, 00078 const std::string & freeFieldLabel, 00079 const std::string & newPartFieldLabel ) 00080 : YWidget( parent ) 00081 , priv( new YPartitionSplitterPrivate( usedSize, 00082 totalFreeSize, 00083 minNewPartSize, 00084 minFreeSize, 00085 usedLabel, 00086 freeLabel, 00087 newPartLabel, 00088 freeFieldLabel, 00089 newPartFieldLabel ) 00090 ) 00091 { 00092 YUI_CHECK_NEW( priv ); 00093 00094 setDefaultStretchable( YD_HORIZ, true ); 00095 setStretchable( YD_VERT, false ); 00096 } 00097 00098 00099 YPartitionSplitter::~YPartitionSplitter() 00100 { 00101 // NOP 00102 } 00103 00104 00105 int YPartitionSplitter::usedSize() const 00106 { 00107 return priv->usedSize; 00108 } 00109 00110 00111 int YPartitionSplitter::totalFreeSize() const 00112 { 00113 return priv->totalFreeSize; 00114 } 00115 00116 00117 int YPartitionSplitter::minNewPartSize() const 00118 { 00119 return priv->minNewPartSize; 00120 } 00121 00122 00123 int YPartitionSplitter::minFreeSize() const 00124 { 00125 return priv->minFreeSize; 00126 } 00127 00128 00129 std::string YPartitionSplitter::usedLabel() const 00130 { 00131 return priv->usedLabel; 00132 } 00133 00134 00135 std::string YPartitionSplitter::freeLabel() const 00136 { 00137 return priv->freeLabel; 00138 } 00139 00140 00141 std::string YPartitionSplitter::newPartLabel() const 00142 { 00143 return priv->newPartLabel; 00144 } 00145 00146 00147 std::string YPartitionSplitter::freeFieldLabel() const 00148 { 00149 return priv->freeFieldLabel; 00150 } 00151 00152 00153 std::string YPartitionSplitter::newPartFieldLabel() const 00154 { 00155 return priv->newPartFieldLabel; 00156 } 00157 00158 00159 const YPropertySet & 00160 YPartitionSplitter::propertySet() 00161 { 00162 static YPropertySet propSet; 00163 00164 if ( propSet.isEmpty() ) 00165 { 00166 /* 00167 * @property std::string Value the value (the size of the new partition) 00168 */ 00169 propSet.add( YProperty( YUIProperty_Value, YStringProperty ) ); 00170 propSet.add( YWidget::propertySet() ); 00171 } 00172 00173 return propSet; 00174 } 00175 00176 00177 bool 00178 YPartitionSplitter::setProperty( const std::string & propertyName, const YPropertyValue & val ) 00179 { 00180 propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch 00181 00182 if ( propertyName == YUIProperty_Value ) setValue( val.integerVal() ); 00183 else 00184 { 00185 return YWidget::setProperty( propertyName, val ); 00186 } 00187 00188 return true; // success -- no special processing necessary 00189 } 00190 00191 00192 YPropertyValue 00193 YPartitionSplitter::getProperty( const std::string & propertyName ) 00194 { 00195 propertySet().check( propertyName ); // throws exceptions if not found 00196 00197 if ( propertyName == YUIProperty_Value ) return YPropertyValue( value() ); 00198 else 00199 { 00200 return YWidget::getProperty( propertyName ); 00201 } 00202 }