#include <LogWindow.h>
#include <OB_Browser.h>
+#include <OB_ListView.h>
#include <PythonConsole_PyConsole.h>
#include <GLViewer_Viewer.h>
#include <qcombobox.h>
#include <qinputdialog.h>
-#define OBJECT_BROWSER_WIDTH 300
-#define OBJECT_COLUMN_WIDTH 150
-
#ifdef WIN32
#define DEFAULT_BROWSER "start iexplore.exe"
#else
myWindows[flag]->setResizeEnabled( true );
myWindows[flag]->setCloseMode( QDockWindow::Always );
myWindows[flag]->setName( QString( "dock_window_%1" ).arg( flag ) );
+ myWindows[flag]->setFixedExtentWidth( wid->width() );
+ myWindows[flag]->setFixedExtentHeight( wid->height() );
}
QFont f;
ob->setAutoUpdate( true );
ob->setAutoOpenLevel( 1 );
ob->setCaption( tr( "OBJECT_BROWSER" ) );
- ob->listView()->setColumnWidth( 0, OBJECT_COLUMN_WIDTH );
- ob->resize( OBJECT_BROWSER_WIDTH, ob->height() );
- ob->setFilter( new LightApp_OBFilter( selectionMgr() ) );
+ OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
+ if( ob_list )
+ ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
+
+ ob->setFilter( new LightApp_OBFilter( selectionMgr() ) );
ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) );
// Create OBSelector
LightApp_Preferences::Color, "SUPERVGraph", "Title" );
// pref->addPreference( tr( "PREF_SUPERV_CTRL_COLOR" ), supervGroup,
// LightApp_Preferences::Color, "SUPERVGraph", "Ctrl" );
+
+ int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
+ int objSetGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SETTINGS" ), obTab );
+ pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
+ "ObjectBrowser", "auto_size_first" );
+ pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
+ "ObjectBrowser", "auto_size" );
}
/*!Changed preferences */
if( sec=="ObjectBrowser" )
{
- if( param=="auto_size" )
+ if( param=="auto_size" || param=="auto_size_first" )
{
OB_Browser* ob = objectBrowser();
if( !ob )
return;
- bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
+ bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ),
+ autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual );
-
+ ob->listView()->setColumnWidthMode( 0, autoSizeFirst ? QListView::Maximum : QListView::Manual );
updateObjectBrowser( false );
}
}
msgid "LightApp_Application::PREF_TAB_OBJBROWSER"
msgstr "Object browser"
+msgid "LightApp_Application::PREF_OBJ_BROWSER_SETTINGS"
+msgstr "Object browser settings"
+
msgid "LightApp_Application::PREF_GROUP_DEF_COLUMNS"
msgstr "Default columns"
msgid "LightApp_Application::PREF_SUPERV_CTRL_COLOR"
msgstr "Ctrl color"
+msgid "LightApp_Application::PREF_AUTO_SIZE"
+msgstr "Auto size for other columns"
+
+msgid "LightApp_Application::PREF_AUTO_SIZE_FIRST"
+msgstr "Auto size for first column"
+
//=======================================================================================
msgid "LightApp_PreferencesDlg::CAPTION"
return RTTI();
}
+void OB_ListItem::setText( int column, const QString& text )
+{
+ QListViewItem::setText( column, text );
+ QFontMetrics fm = listView()->fontMetrics();
+ int necessary = width( fm, listView(), column ),
+ current = listView()->columnWidth( column );
+
+ if( listView()->columnWidthMode( column )==QListView::Maximum && necessary>current )
+ listView()->setColumnWidth( column, necessary );
+}
+
/*!
Class: OB_CheckListItem
Descr: Check list view item for OB_Browser.
virtual void paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r );
virtual void paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align );
+ virtual void setText ( int column, const QString & text );
virtual int rtti() const;
return dropObj->isDropAccepted( dragObj );
}
+
+void OB_ListView::setColumnWidth( int col, int width )
+{
+ int max = columnMaxWidth( col );
+ if( max>0 && width>max )
+ width = max;
+ QListView::setColumnWidth( col, width );
+}
+
+int OB_ListView::columnMaxWidth( const int col ) const
+{
+ int res = -1;
+ if( myMaxColWidth.contains( col ) )
+ res = myMaxColWidth[col];
+ else if( myMaxColRatio[col] )
+ res = int( myMaxColRatio[col]*height() );
+ return res;
+}
+
+void OB_ListView::setColumnMaxWidth( const int col, const int w )
+{
+ myMaxColWidth.insert( col, w );
+}
+
+double OB_ListView::columnMaxRatio( const int col ) const
+{
+ double res = 0.0;
+ if( myMaxColRatio.contains( col ) )
+ res = myMaxColRatio[col];
+ return res;
+}
+
+void OB_ListView::setColumnMaxRatio( const int col, const double r )
+{
+ myMaxColRatio.insert( col, r );
+}
void setFilter( OB_Filter* );
bool isOk( QListViewItem* ) const;
+ virtual void setColumnWidth( int, int );
+ int columnMaxWidth( const int ) const;
+ void setColumnMaxWidth( const int, const int );
+ double columnMaxRatio( const int ) const;
+ void setColumnMaxRatio( const int, const double );
signals:
void dropped( QPtrList<QListViewItem>, QListViewItem*, int );
protected:
QPtrList<QListViewItem> myItems;
OB_Filter* myFilter;
+ QMap<int,int> myMaxColWidth;
+ QMap<int,double> myMaxColRatio;
};
#ifdef WIN32
{
OB_Browser* ob = (OB_Browser*)wid;
connect( ob->listView(), SIGNAL( doubleClicked( QListViewItem* ) ), this, SLOT( onDblClick( QListViewItem* ) ) );
- bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
+ bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ),
+ autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
{
ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i );
QString().sprintf( "visibility_column_%d", i ), true ) );
}
ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual );
+ ob->listView()->setColumnWidthMode( 0, autoSizeFirst ? QListView::Maximum : QListView::Manual );
+ ob->resize( desktop()->width()/3, ob->height() );
}
else if ( flag == WT_PyConsole )
{
PythonConsole* pyCons = new PythonConsole( desktop(), new SalomeApp_PyInterp() );
pyCons->setCaption( tr( "PYTHON_CONSOLE" ) );
wid = pyCons;
+ pyCons->resize( pyCons->width(), desktop()->height()/4 );
// pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
}
return wid;
LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) );
}
pref->setItemProperty( defCols, "columns", 1 );
-
- int objSetGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SETTINGS" ), obTab );
- pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool, "ObjectBrowser", "auto_size" );
}
/*!Update desktop title.*/
</section>
<section name="ObjectBrowser" >
<parameter value="false" name="auto_size" />
- <parameter value="true" name="visibility_column_0" />
+ <parameter value="true" name="auto_size_first" />
+ <parameter value="true" name="visibility_column_0" />
<parameter value="false" name="visibility_column_1" />
<parameter value="false" name="visibility_column_2" />
<parameter value="false" name="visibility_column_3" />
msgid "SalomeApp_Application::MEN_OPENWITH"
msgstr "Activate Module"
-msgid "SalomeApp_Application::MEN_DELETE_REFERENCE"
-msgstr "Delete Reference"
+msgid "SalomeApp_Application::MEN_DELETE_INVALID_REFERENCE"
+msgstr "Delete Invalid Reference"
//=======================================================================================
msgid "SalomeApp_Application::PREF_OBJ_BROWSER_SETTINGS"
msgstr "Settings"
-msgid "SalomeApp_Application::PREF_AUTO_SIZE"
-msgstr "Auto size columns"
-
//=======================================================================================
msgid "SalomeApp_Application::OBJ_BROWSER_NAME"