codeviewerdialog.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "codeviewerdialog.h"
00020
00021
00022 #include <qlayout.h>
00023 #include <qtabwidget.h>
00024 #include <qcheckbox.h>
00025 #include <kdebug.h>
00026 #include <klocale.h>
00027
00028
00029 #include "../codedocument.h"
00030 #include "../classifiercodedocument.h"
00031 #include "codeeditor.h"
00032
00033 CodeViewerDialog::CodeViewerDialog ( QWidget* parent, CodeDocument * doc,
00034 Settings::CodeViewerState state,
00035 const char* name, bool modal, WFlags fl )
00036 : CodeViewerDialogBase ( parent, name, modal, fl )
00037
00038 {
00039 m_state = state;
00040
00041 initGUI(name);
00042
00043 addCodeDocument(doc);
00044
00045 }
00046
00047
00048
00049
00050 CodeViewerDialog::~CodeViewerDialog()
00051 {
00052
00053 }
00054
00055 void CodeViewerDialog::initGUI ( const char * name) {
00056
00057 if ( !name )
00058 setName( "CodeViewerDialog" );
00059
00060 setFont( getState().font );
00061
00062
00063 int margin = fontMetrics().height();
00064 int width = fontMetrics().maxWidth() * getState().width;
00065 int height = fontMetrics().lineSpacing() * getState().height;
00066
00067 m_highlightCheckBox->setChecked( getState().blocksAreHighlighted );
00068 m_showHiddenCodeCB->setChecked ( getState().showHiddenBlocks );
00069
00070 CodeViewerDialogBaseLayout->setMargin(margin);
00071
00072 resize( QSize(width, height).expandedTo(minimumSizeHint()) );
00073
00074 }
00075
00076
00077
00078
00079 void CodeViewerDialog::addCodeDocument( CodeDocument * doc)
00080 {
00081 CodeEditor * page = new CodeEditor ( this, "_codedocumenteditor_", doc );
00082 QString fname = doc->getFileName();
00083 QString ext = doc->getFileExtension();
00084 m_tabWidget->insertTab(page, (fname + (ext.isEmpty()? "" : ext)));
00085
00086 connect( m_highlightCheckBox, SIGNAL( stateChanged(int) ), page, SLOT( changeHighlighting(int) ) );
00087 connect( m_showHiddenCodeCB, SIGNAL( stateChanged(int) ), page, SLOT( changeShowHidden(int) ) );
00088
00089 }
00090
00091 Settings::CodeViewerState CodeViewerDialog::getState() {
00092 return m_state;
00093 }
00094
00095 bool CodeViewerDialog::close ( bool alsoDelete )
00096 {
00097
00098
00099 m_state.height = height() / fontMetrics().lineSpacing();
00100 m_state.width = width() / fontMetrics().maxWidth();
00101
00102
00103 m_state.blocksAreHighlighted = m_highlightCheckBox->isChecked();
00104
00105
00106 m_state.showHiddenBlocks = m_showHiddenCodeCB->isChecked();
00107
00108
00109 return CodeViewerDialogBase::close(alsoDelete);
00110
00111 }
00112
00113
00114
00115
00116
00117 void CodeViewerDialog::languageChange()
00118 {
00119 setCaption( tr2i18n( "Code Viewer" ) );
00120 }
00121
00122 #include "codeviewerdialog.moc"
This file is part of the documentation for umbrello Version 3.1.0.