From 0c7f49944dd413bcc2c38f1e9236477ae39b63f9 Mon Sep 17 00:00:00 2001 From: ptv Date: Thu, 5 Oct 2006 09:05:10 +0000 Subject: [PATCH] add flags for operations (flexibility) --- src/LogWindow/LogWindow.cxx | 27 ++++++++++++++++++--------- src/LogWindow/LogWindow.h | 13 ++++++++++++- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/LogWindow/LogWindow.cxx b/src/LogWindow/LogWindow.cxx index 161011c45..d4955d539 100755 --- a/src/LogWindow/LogWindow.cxx +++ b/src/LogWindow/LogWindow.cxx @@ -60,7 +60,8 @@ static QString plainText( const QString& richText ) */ LogWindow::LogWindow( QWidget* parent ) : QFrame( parent ), -SUIT_PopupClient() +SUIT_PopupClient(), +myOpFlags( All ) { SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); @@ -221,17 +222,22 @@ void LogWindow::createActions() */ void LogWindow::contextMenuPopup( QPopupMenu* popup ) { - myActions[ CopyId ]->addTo( popup ); - myActions[ ClearId ]->addTo( popup ); + if ( myOpFlags & CopyId ) + myActions[ CopyId ]->addTo( popup ); + if ( myOpFlags & ClearId ) + myActions[ ClearId ]->addTo( popup ); popup->insertSeparator(); - myActions[ SelectAllId ]->addTo( popup ); + if ( myOpFlags & SelectAllId ) + myActions[ SelectAllId ]->addTo( popup ); popup->insertSeparator(); - myActions[ SaveToFileId ]->addTo( popup ); + if ( myOpFlags & SaveToFileId ) + myActions[ SaveToFileId ]->addTo( popup ); + Qtx::simplifySeparators( popup ); updateActions(); } @@ -245,10 +251,10 @@ void LogWindow::updateActions() bool allSelected = myView->hasSelectedText() && !paraFrom && paraTo == myView->paragraphs() - 1 && !indexFrom && indexTo == myView->paragraphLength( paraTo ); - myActions[ CopyId ]->setEnabled( myView->hasSelectedText() ); - myActions[ ClearId ]->setEnabled( myView->paragraphs() > myBannerSize ); - myActions[ SelectAllId ]->setEnabled( !allSelected ); - myActions[ SaveToFileId ]->setEnabled( myHistory.count() > 0 ); + myActions[ CopyId ]->setEnabled( ( myOpFlags & CopyId )&& myView->hasSelectedText() ); + myActions[ ClearId ]->setEnabled( ( myOpFlags & ClearId ) && myView->paragraphs() > myBannerSize ); + myActions[ SelectAllId ]->setEnabled( ( myOpFlags & SelectAllId ) && !allSelected ); + myActions[ SaveToFileId ]->setEnabled( ( myOpFlags & SaveToFileId ) && myHistory.count() > 0 ); } /*! @@ -300,3 +306,6 @@ void LogWindow::onCopy() if ( myView ) myView->copy(); } + +void LogWindow::setOperationsFlags( int flags ) +{ myOpFlags = flags; } diff --git a/src/LogWindow/LogWindow.h b/src/LogWindow/LogWindow.h index 0b8b39e98..43df2391e 100755 --- a/src/LogWindow/LogWindow.h +++ b/src/LogWindow/LogWindow.h @@ -60,7 +60,15 @@ class LOGWINDOW_EXPORT LogWindow : public QFrame, public SUIT_PopupClient { Q_OBJECT - enum { CopyId, ClearId, SelectAllId, SaveToFileId }; +public: + //! popup operation flags + enum { + CopyId = 0x01, + ClearId = 0x02, + SelectAllId = 0x04, + SaveToFileId = 0x08, + All = CopyId | ClearId | SelectAllId | SaveToFileId, + }; public: LogWindow( QWidget* theParent ); @@ -79,6 +87,8 @@ public: bool saveLog( const QString& fileName ); + void setOperationsFlags( int flags ); + protected slots: void onSaveToFile(); void onSelectAll(); @@ -96,6 +106,7 @@ private: QStringList myHistory; int myBannerSize; QMap myActions; + int myOpFlags; }; #ifdef WIN32 -- 2.39.2