#include <SUIT_MessageBox.h>
#include <SUIT_ResourceMgr.h>
-#include <QtxDockAction.h>
+//#include <QtxDockAction.h>
#include <QtxActionMenuMgr.h>
#include <QtxActionToolMgr.h>
-#include <QtxPopupMenu.h>
-#include <qmenubar.h>
-#include <qtoolbar.h>
-#include <qpopupmenu.h>
-#include <qstatusbar.h>
-#include <qfiledialog.h>
-#include <qapplication.h>
+#include <QtGui/qmenu.h>
+#include <QtGui/qevent.h>
+#include <QtGui/qmenubar.h>
+#include <QtGui/qtoolbar.h>
+#include <QtGui/qstatusbar.h>
+#include <QtGui/qfiledialog.h>
+#include <QtGui/qapplication.h>
#include <iostream>
myEditEnabled( true ),
myActiveViewMgr( 0 )
{
- STD_MDIDesktop* desk = new STD_MDIDesktop();
-
- setDesktop( desk );
+ setDesktop( new STD_MDIDesktop() );
}
/*!Destructor.*/
createAction( FileNewId, tr( "TOT_DESK_FILE_NEW" ),
resMgr->loadPixmap( "STD", tr( "ICON_FILE_NEW" ) ),
tr( "MEN_DESK_FILE_NEW" ), tr( "PRP_DESK_FILE_NEW" ),
- CTRL+Key_N, desk, false, this, SLOT( onNewDoc() ) );
+ Qt::CTRL+Qt::Key_N, desk, false, this, SLOT( onNewDoc() ) );
createAction( FileOpenId, tr( "TOT_DESK_FILE_OPEN" ),
resMgr->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
tr( "MEN_DESK_FILE_OPEN" ), tr( "PRP_DESK_FILE_OPEN" ),
- CTRL+Key_O, desk, false, this, SLOT( onOpenDoc() ) );
+ Qt::CTRL+Qt::Key_O, desk, false, this, SLOT( onOpenDoc() ) );
createAction( FileCloseId, tr( "TOT_DESK_FILE_CLOSE" ),
resMgr->loadPixmap( "STD", tr( "ICON_FILE_CLOSE" ) ),
tr( "MEN_DESK_FILE_CLOSE" ), tr( "PRP_DESK_FILE_CLOSE" ),
- CTRL+Key_W, desk, false, this, SLOT( onCloseDoc() ) );
+ Qt::CTRL+Qt::Key_W, desk, false, this, SLOT( onCloseDoc() ) );
- createAction( FileExitId, tr( "TOT_DESK_FILE_EXIT" ), QIconSet(),
+ createAction( FileExitId, tr( "TOT_DESK_FILE_EXIT" ), QIcon(),
tr( "MEN_DESK_FILE_EXIT" ), tr( "PRP_DESK_FILE_EXIT" ),
- CTRL+Key_Q, desk, false, this, SLOT( onExit() ) );
+ Qt::CTRL+Qt::Key_Q, desk, false, this, SLOT( onExit() ) );
createAction( FileSaveId, tr( "TOT_DESK_FILE_SAVE" ),
resMgr->loadPixmap( "STD", tr( "ICON_FILE_SAVE" ) ),
tr( "MEN_DESK_FILE_SAVE" ), tr( "PRP_DESK_FILE_SAVE" ),
- CTRL+Key_S, desk, false, this, SLOT( onSaveDoc() ) );
+ Qt::CTRL+Qt::Key_S, desk, false, this, SLOT( onSaveDoc() ) );
- createAction( FileSaveAsId, tr( "TOT_DESK_FILE_SAVEAS" ), QIconSet(),
+ createAction( FileSaveAsId, tr( "TOT_DESK_FILE_SAVEAS" ), QIcon(),
tr( "MEN_DESK_FILE_SAVEAS" ), tr( "PRP_DESK_FILE_SAVEAS" ),
- CTRL+Key_A, desk, false, this, SLOT( onSaveAsDoc() ) );
+ Qt::CTRL+Qt::Key_A, desk, false, this, SLOT( onSaveAsDoc() ) );
createAction( EditCopyId, tr( "TOT_DESK_EDIT_COPY" ),
resMgr->loadPixmap( "STD", tr( "ICON_EDIT_COPY" ) ),
tr( "MEN_DESK_EDIT_COPY" ), tr( "PRP_DESK_EDIT_COPY" ),
- CTRL+Key_C, desk, false, this, SLOT( onCopy() ) );
+ Qt::CTRL+Qt::Key_C, desk, false, this, SLOT( onCopy() ) );
createAction( EditPasteId, tr( "TOT_DESK_EDIT_PASTE" ),
resMgr->loadPixmap( "STD", tr( "ICON_EDIT_PASTE" ) ),
tr( "MEN_DESK_EDIT_PASTE" ), tr( "PRP_DESK_EDIT_PASTE" ),
- CTRL+Key_V, desk, false, this, SLOT( onPaste() ) );
+ Qt::CTRL+Qt::Key_V, desk, false, this, SLOT( onPaste() ) );
QAction* a = createAction( ViewStatusBarId, tr( "TOT_DESK_VIEW_STATUSBAR" ),
- QIconSet(), tr( "MEN_DESK_VIEW_STATUSBAR" ),
- tr( "PRP_DESK_VIEW_STATUSBAR" ), SHIFT+Key_S, desk, true );
- a->setOn( desk->statusBar()->isVisibleTo( desk ) );
+ QIcon(), tr( "MEN_DESK_VIEW_STATUSBAR" ),
+ tr( "PRP_DESK_VIEW_STATUSBAR" ), Qt::SHIFT+Qt::Key_S, desk, true );
+ a->setChecked( desk->statusBar()->isVisibleTo( desk ) );
connect( a, SIGNAL( toggled( bool ) ), this, SLOT( onViewStatusBar( bool ) ) );
- createAction( NewWindowId, tr( "TOT_DESK_NEWWINDOW" ), QIconSet(),
+ createAction( NewWindowId, tr( "TOT_DESK_NEWWINDOW" ), QIcon(),
tr( "MEN_DESK_NEWWINDOW" ), tr( "PRP_DESK_NEWWINDOW" ), 0, desk );
- createAction( HelpAboutId, tr( "TOT_DESK_HELP_ABOUT" ), QIconSet(),
+ createAction( HelpAboutId, tr( "TOT_DESK_HELP_ABOUT" ), QIcon(),
tr( "MEN_DESK_HELP_ABOUT" ), tr( "PRP_DESK_HELP_ABOUT" ),
- SHIFT+Key_A, desk, false, this, SLOT( onHelpAbout() ) );
+ Qt::SHIFT+Qt::Key_A, desk, false, this, SLOT( onHelpAbout() ) );
+/*
QtxDockAction* da = new QtxDockAction( tr( "TOT_DOCK_WINDOWS" ), tr( "MEN_DOCK_WINDOWS" ), desk );
registerAction( ViewWindowsId, da );
da->setAutoPlace( false );
-
+*/
// Create menus
int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, MenuFileId, 0 );
/*!Opens new application*/
void STD_Application::onNewDoc()
{
- QApplication::setOverrideCursor( Qt::waitCursor );
+ QApplication::setOverrideCursor( Qt::WaitCursor );
if ( !activeStudy() )
{
/*! \retval true, if document was opened successful, else false.*/
bool STD_Application::onOpenDoc( const QString& aName )
{
- QApplication::setOverrideCursor( Qt::waitCursor );
+ QApplication::setOverrideCursor( Qt::WaitCursor );
bool res = true;
if ( !activeStudy() )
{
// if study exists - open in new desktop. Check: is the same file is opened?
SUIT_Session* aSession = SUIT_Session::session();
- QPtrList<SUIT_Application> aAppList = aSession->applications();
+ QList<SUIT_Application*> aAppList = aSession->applications();
bool isAlreadyOpen = false;
SUIT_Application* aApp = 0;
- for ( QPtrListIterator<SUIT_Application> it( aAppList ); it.current() && !isAlreadyOpen; ++it )
+ for ( QList<SUIT_Application*>::iterator it = aAppList.begin(); it != aAppList.end() && !isAlreadyOpen; ++it )
{
- aApp = it.current();
+ aApp = *it;
if ( aApp->activeStudy()->studyName() == aName )
isAlreadyOpen = true;
}
aApp->closeApplication();
}
else
- aApp->desktop()->setActiveWindow();
+ aApp->desktop()->activateWindow();
}
QApplication::restoreOverrideCursor();
{
// if study exists - load in new desktop. Check: is the same file is loaded?
SUIT_Session* aSession = SUIT_Session::session();
- QPtrList<SUIT_Application> aAppList = aSession->applications();
+ QList<SUIT_Application*> aAppList = aSession->applications();
bool isAlreadyOpen = false;
SUIT_Application* aApp = 0;
- for ( QPtrListIterator<SUIT_Application> it( aAppList ); it.current() && !isAlreadyOpen; ++it )
+ for ( QList<SUIT_Application*>::iterator it = aAppList.begin(); it != aAppList.end() && !isAlreadyOpen; ++it )
{
- aApp = it.current();
+ aApp = *it;
if ( aApp->activeStudy()->studyName() == aName )
isAlreadyOpen = true;
}
res = aApp->useStudy( aName );
}
else
- aApp->desktop()->setActiveWindow();
+ aApp->desktop()->activateWindow();
}
return res;
}
delete study;
int aNbStudies = 0;
- QPtrList<SUIT_Application> apps = SUIT_Session::session()->applications();
+ QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
for ( unsigned i = 0; i < apps.count(); i++ )
aNbStudies += apps.at( i )->getNbStudies();
activeStudy()->abortAllOperations();
if ( activeStudy()->isModified() )
{
- QString sName = activeStudy()->studyName().stripWhiteSpace();
+ QString sName = activeStudy()->studyName().trimmed();
QString msg = sName.isEmpty() ? tr( "INF_DOC_MODIFIED" ) : tr ( "INF_DOCUMENT_MODIFIED" ).arg( sName );
//SRN: BugID: IPAL9021: Begin
{
putInfo( tr( "INF_DOC_SAVING" ) + activeStudy()->studyName() );
- QApplication::setOverrideCursor( Qt::waitCursor );
+ QApplication::setOverrideCursor( Qt::WaitCursor );
isOk = activeStudy()->saveDocument();
if ( aName.isNull() )
return false;
- QApplication::setOverrideCursor( Qt::waitCursor );
+ QApplication::setOverrideCursor( Qt::WaitCursor );
putInfo( tr( "INF_DOC_SAVING" ) + aName );
isOk = study->saveDocumentAs( aName );
if ( activeStudy() )
{
- QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false );
+ QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
if ( !sName.isEmpty() )
aTitle += QString( " - [%1]" ).arg( sName );
}
- desktop()->setCaption( aTitle );
+ desktop()->setWindowTitle( aTitle );
}
/*!Update commands status.*/
SUIT_ViewManager* STD_Application::viewManager( const QString& vmType ) const
{
SUIT_ViewManager* vm = 0;
- for ( QPtrListIterator<SUIT_ViewManager> it( myViewMgrs ); it.current() && !vm; ++it )
+ for ( QList<SUIT_ViewManager*>::const_iterator it = myViewMgrs.begin(); it != myViewMgrs.end() && !vm; ++it )
{
- if ( it.current()->getType() == vmType )
- vm = it.current();
+ if ( (*it)->getType() == vmType )
+ vm = *it;
}
return vm;
}
*/
void STD_Application::viewManagers( const QString& vmType, ViewManagerList& lst ) const
{
- for ( QPtrListIterator<SUIT_ViewManager> it( myViewMgrs ); it.current(); ++it )
- if ( it.current()->getType() == vmType )
- lst.append( it.current() );
+ for ( QList<SUIT_ViewManager*>::const_iterator it = myViewMgrs.begin(); it != myViewMgrs.end(); ++it )
+ {
+ if ( (*it)->getType() == vmType )
+ lst.append( *it );
+ }
}
/*!\param lst - output list of all view managers.*/
void STD_Application::viewManagers( ViewManagerList& lst ) const
{
- for ( QPtrListIterator<SUIT_ViewManager> it( myViewMgrs ); it.current(); ++it )
- lst.append( it.current() );
+ for ( QList<SUIT_ViewManager*>::const_iterator it = myViewMgrs.begin(); it != myViewMgrs.end(); ++it )
+ lst.append( *it );
}
/*!\retval ViewManagerList - const list of all view managers.*/
vm->disconnectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
disconnect( vm, SIGNAL( activated( SUIT_ViewManager* ) ),
this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
- myViewMgrs.removeRef( vm );
+ myViewMgrs.removeAll( vm );
if ( myActiveViewMgr == vm )
myActiveViewMgr = 0;
ViewManagerList lst;
viewManagers( lst );
- for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it ) {
- QGuardedPtr<SUIT_ViewManager> vm = it.current();
+ for ( QList<SUIT_ViewManager*>::iterator it = lst.begin(); it != lst.end(); ++it )
+ {
+ QPointer<SUIT_ViewManager> vm = *it;
removeViewManager( vm );
delete vm;
}
/*!\retval TRUE, if view manager \a vm, already in view manager list (\a myViewMgrs).*/
bool STD_Application::containsViewManager( SUIT_ViewManager* vm ) const
{
- return myViewMgrs.contains( vm ) > 0;
+ return myViewMgrs.contains( vm );
}
/*!Private slot, sets active manager to \vm, if \vm in view managers list.*/
SUIT_Application::createEmptyStudy();
SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(), desktop(), new SUIT_ViewModel() );
-
addViewManager( vm );
}
/*!Public slot. */
void STD_Application::onConnectPopupRequest( SUIT_PopupClient* client, QContextMenuEvent* e )
{
- QtxPopupMenu* popup = new QtxPopupMenu();
+ QMenu* popup = new QMenu();
// fill popup by own items
QString title;
contextMenuPopup( client->popupClientType(), popup, title );
- popup->setTitleText( title );
+ popup->setTitle( title );
- popup->insertSeparator();
+ popup->addSeparator();
// add items from popup client
client->contextMenuPopup( popup );
SUIT_Tools::simplifySeparators( popup );
- if ( popup->count() )
+ if ( !popup->actions().isEmpty() )
popup->exec( e->globalPos() );
delete popup;
}
-#include <qregexp.h>
-
/*!\retval QString - return file name from dialog.*/
QString STD_Application::getFileName( bool open, const QString& initial, const QString& filters,
const QString& caption, QWidget* parent )
if ( !parent )
parent = desktop();
if ( open )
- {
- return QFileDialog::getOpenFileName( initial, filters, parent, 0, caption );
- }
+ return QFileDialog::getOpenFileName( parent, caption, initial, filters );
else
{
QString aName;
while ( !isOk )
{
// It is preferrable to use OS-specific file dialog box here !!!
- aName = QFileDialog::getSaveFileName( anOldPath, filters, parent, 0, caption, &aUsedFilter );
+ aName = QFileDialog::getSaveFileName( parent, caption, anOldPath, filters, &aUsedFilter );
if ( aName.isNull() )
isOk = true;
else
{
- int aEnd = aUsedFilter.findRev( ')' );
- int aStart = aUsedFilter.findRev( '(', aEnd );
+ int aEnd = aUsedFilter.lastIndexOf( ')' );
+ int aStart = aUsedFilter.lastIndexOf( '(', aEnd );
QString wcStr = aUsedFilter.mid( aStart + 1, aEnd - aStart - 1 );
int idx = 0;
QStringList extList;
QRegExp rx( "[\b\\*]*\\.([\\w]+)" );
- while ( ( idx = rx.search( wcStr, idx ) ) != -1 )
+ while ( ( idx = rx.indexIn( wcStr, idx ) ) != -1 )
{
extList.append( rx.cap( 1 ) );
idx += rx.matchedLength();
}
- if ( !extList.isEmpty() && !extList.contains( QFileInfo( aName ).extension() ) )
+ if ( !extList.isEmpty() && !extList.contains( SUIT_Tools::extension( aName ) ) )
aName += QString( ".%1" ).arg( extList.first() );
if ( QFileInfo( aName ).exists() )
{
if ( !parent )
parent = desktop();
- return QFileDialog::getExistingDirectory( initial, parent, 0, caption, true );
+
+ return QFileDialog::getExistingDirectory( parent, caption, initial );
}
/*!