String EditCtrl::DoGetCaptionWithCaret()const { String l_caption( m_caption.begin(), m_caretIt.internal() ); l_caption += _T( '|' ); if ( m_caretIt != m_caption.end() ) { l_caption += String( m_caretIt.internal(), m_caption.end() ); } return l_caption; }
void EditCtrl::DoDeleteCharAtCaret() { if ( m_caretIt != m_caption.end() ) { size_t l_diff = std::distance( StringUtils::Utf8Iterator( m_caption.begin() ), m_caretIt ); String l_caption( m_caption.cbegin(), m_caretIt.internal() ); StringUtils::Utf8Iterator l_it = m_caretIt; if ( ++l_it != m_caption.end() ) { l_caption += String( l_it.internal(), m_caption.cend() ); } m_caption = l_caption; m_caretIt = StringUtils::Utf8Iterator( m_caption.begin() ) + l_diff; DoUpdateCaption(); } }
AppTabDialog::AppTabDialog( QWidget *p_parent, const QString &captionKey, const char *p_name, const QString &acceptKey, const QString &rejectKey ) : QTabDialog( p_parent, p_name, true, WStyle_Customize | // Use following flags WStyle_SysMenu | // System menu in upper left WStyle_Title | // Window title WStyle_MinMax | // Min/max in system menu WStyle_Dialog | // Modal toplevel window WStyle_NormalBorder ), // Resizeable corners m_contextMenu(0) { // Set the dialog caption QString l_caption(""); translate( l_caption, captionKey ); setCaption( appWindow()->m_program + " " + appWindow()->m_version + " " + l_caption ); // Add the standard QTabDialog Ok button. QString text(""); translate( text, acceptKey ); setOkButton( text ); connect( this, SIGNAL( applyButtonPressed() ), this, SLOT( store() ) ); // Optionally add the QTabDialog cancel button. if ( ! rejectKey.isNull() && ! rejectKey.isEmpty() ) { translate( text, rejectKey ); setCancelButton( text ); connect( this, SIGNAL( cancelButtonPressed() ), this, SLOT( reject() ) ); } // Create the context menu. m_contextMenu = new QPopupMenu( this, "m_contextMenu" ); Q_CHECK_PTR( m_contextMenu ); translate( text, "AppDialog:ContextMenu:Print" ); int mid = m_contextMenu->insertItem( text ); m_contextMenu->setItemParameter( mid, ContextPrintDialog ); return; }
AppDialog::AppDialog( QWidget *p_parent, const QString &captionKey, const QString &pictureFile, const QString &pictureName, const QString &htmlFile, const char *p_name, const QString &acceptKey, const QString &rejectKey, const QString &clearKey, const QString &wizardKey ) : QDialog( p_parent, p_name, true, WStyle_Customize | // Use the following flags: WStyle_SysMenu | // System menu in upper left WStyle_Title | // Window title WStyle_MinMax | // Min/max in system menu WStyle_Dialog | // Modal toplevel window WStyle_NormalBorder ), // Resizeable corners m_pageLayout(0), m_page(0), m_buttonBox(0), m_acceptBtn(0), m_clearBtn(0), m_wizardBtn(0), m_rejectBtn(0), m_contextMenu(0) { // Set the dialog caption QString l_caption(""); translate( l_caption, captionKey ); setCaption( appWindow()->m_program + " " + appWindow()->m_version + " " + l_caption ); // Divide the dialog window into top and bottom sections. m_pageLayout = new QVBoxLayout( this, 10, 10, "m_pageLayout" ); Q_CHECK_PTR( m_pageLayout); // Top section contains the AppPage. m_page = new AppPage( this, pictureFile, pictureName, htmlFile, p_name ); checkmem( __FILE__, __LINE__, m_page, "AppPage appPage", 1 ); m_pageLayout->addWidget( m_page ); // The bottom section contains a row of buttons. m_buttonBox = new QHBox( this, "m_buttonBox" ); Q_CHECK_PTR( m_buttonBox ); m_pageLayout->addWidget( m_buttonBox ); // Accept button QString text(""); translate( text, acceptKey ); m_acceptBtn = new QPushButton( text, m_buttonBox, "m_acceptBtn" ); Q_CHECK_PTR( m_acceptBtn ); connect( m_acceptBtn, SIGNAL( clicked() ), SLOT( store() ) ); // Clear button if ( ! clearKey.isNull() && ! clearKey.isEmpty() ) { translate( text, clearKey ); m_clearBtn = new QPushButton( text, m_buttonBox, "m_clearBtn" ); Q_CHECK_PTR( m_clearBtn ); connect( m_clearBtn, SIGNAL( clicked() ), SLOT( clear() ) ); } // Wizard button if ( ! wizardKey.isNull() && ! wizardKey.isEmpty() ) { translate( text, wizardKey ); m_wizardBtn = new QPushButton( text, m_buttonBox, "m_wizardBtn" ); Q_CHECK_PTR( m_wizardBtn ); connect( m_wizardBtn, SIGNAL( clicked() ), SLOT( wizard() ) ); } // Cancel button if ( ! rejectKey.isNull() && ! rejectKey.isEmpty() ) { translate( text, rejectKey ); m_rejectBtn = new QPushButton( text, m_buttonBox, "m_rejectBtn" ); Q_CHECK_PTR( m_rejectBtn ); connect( m_rejectBtn, SIGNAL( clicked() ), SLOT( reject() ) ); } // Find the widest button int l_width = m_acceptBtn->sizeHint().width(); QWidget *widest = m_acceptBtn; if ( m_rejectBtn && m_rejectBtn->sizeHint().width() > l_width ) { l_width = m_rejectBtn->sizeHint().width(); widest = m_rejectBtn; } if ( m_clearBtn && m_clearBtn->sizeHint().width() > l_width ) { l_width = m_clearBtn->sizeHint().width(); widest = m_clearBtn; } if ( m_wizardBtn && m_wizardBtn->sizeHint().width() > l_width ) { l_width = m_wizardBtn->sizeHint().width(); widest = m_wizardBtn; } // Make all buttons the same size as the widest button. m_acceptBtn->setFixedSize( widest->sizeHint() ); if ( m_rejectBtn ) { m_rejectBtn->setFixedSize( widest->sizeHint() ); } if ( m_clearBtn ) { m_clearBtn->setFixedSize( widest->sizeHint() ); } if ( m_wizardBtn ) { m_wizardBtn->setFixedSize( widest->sizeHint() ); } m_buttonBox->setFixedHeight( m_buttonBox->sizeHint().height() ); // Create the context menu. m_contextMenu = new QPopupMenu( this, "m_contextMenu" ); Q_CHECK_PTR( m_contextMenu ); translate( text, "AppDialog:ContextMenu:Print" ); int mid = m_contextMenu->insertItem( text ); m_contextMenu->setItemParameter( mid, ContextPrintDialog ); return; }