additional infoText removed from
QskSelectionSubWindow/QskSelectionWindow. not sure if will keep those classes in the long run
This commit is contained in:
parent
36fab6a9c2
commit
c96b3dbbff
@ -59,7 +59,6 @@ namespace
|
||||
|
||||
void execSelection()
|
||||
{
|
||||
// of course we all love "The Teens"
|
||||
const QStringList entries =
|
||||
{
|
||||
"Give Me More",
|
||||
@ -82,7 +81,7 @@ namespace
|
||||
"Gimme Gimme Gimme Gimme Gimme Your Love"
|
||||
};
|
||||
|
||||
qskDialog->select( "Here we go ...", "Hot Hot Hot", entries, 7 );
|
||||
qskDialog->select( "The Teens", entries, 7 );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -172,12 +172,11 @@ static QskDialog::Action qskMessageWindow(
|
||||
}
|
||||
|
||||
static QString qskSelectSubWindow(
|
||||
QQuickWindow* window, const QString& title, const QString& text,
|
||||
QQuickWindow* window, const QString& title,
|
||||
QskDialog::Actions actions, QskDialog::Action defaultAction,
|
||||
const QStringList& entries, int selectedRow )
|
||||
{
|
||||
auto subWindow = new QskSelectionSubWindow( window->contentItem() );
|
||||
subWindow->setInfoText( text );
|
||||
subWindow->setEntries( entries );
|
||||
subWindow->setSelectedRow( selectedRow );
|
||||
|
||||
@ -191,12 +190,11 @@ static QString qskSelectSubWindow(
|
||||
}
|
||||
|
||||
static QString qskSelectWindow(
|
||||
QWindow* transientParent, const QString& title, const QString& text,
|
||||
QWindow* transientParent, const QString& title,
|
||||
QskDialog::Actions actions, QskDialog::Action defaultAction,
|
||||
const QStringList& entries, int selectedRow )
|
||||
{
|
||||
QskSelectionWindow window;
|
||||
window.setInfoText( text );
|
||||
window.setEntries( entries );
|
||||
window.setSelectedRow( selectedRow );
|
||||
|
||||
@ -295,8 +293,7 @@ QskDialog::Action QskDialog::question(
|
||||
return QskDialog::message( title, text, 0, actions, defaultAction );
|
||||
}
|
||||
|
||||
QString QskDialog::select(
|
||||
const QString& title, const QString& text,
|
||||
QString QskDialog::select( const QString& title,
|
||||
const QStringList& entries, int selectedRow ) const
|
||||
{
|
||||
#if 1
|
||||
@ -315,11 +312,11 @@ QString QskDialog::select(
|
||||
if ( quickWindow )
|
||||
{
|
||||
return qskSelectSubWindow( quickWindow,
|
||||
title, text, actions, defaultAction, entries, selectedRow );
|
||||
title, actions, defaultAction, entries, selectedRow );
|
||||
}
|
||||
}
|
||||
|
||||
return qskSelectWindow( m_data->transientParent, title, text,
|
||||
return qskSelectWindow( m_data->transientParent, title,
|
||||
actions, defaultAction, entries, selectedRow );
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class QSK_EXPORT QskDialog : public QObject
|
||||
Q_PROPERTY( Policy policy READ policy
|
||||
WRITE setPolicy NOTIFY policyChanged )
|
||||
|
||||
Q_PROPERTY( QWindow* transientParent READ transientParent
|
||||
Q_PROPERTY( QWindow * transientParent READ transientParent
|
||||
WRITE setTransientParent NOTIFY transientParentChanged )
|
||||
|
||||
public:
|
||||
@ -127,8 +127,7 @@ class QSK_EXPORT QskDialog : public QObject
|
||||
Actions actions = Actions( Yes | No ),
|
||||
Action defaultAction = NoAction ) const;
|
||||
|
||||
Q_INVOKABLE QString select(
|
||||
const QString& title, const QString& text,
|
||||
Q_INVOKABLE QString select( const QString& title,
|
||||
const QStringList& entries, int selectedRow = 0 ) const;
|
||||
|
||||
static ActionRole actionRole( Action action );
|
||||
|
@ -4,31 +4,26 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "QskSelectionSubWindow.h"
|
||||
#include "QskLinearBox.h"
|
||||
#include "QskSimpleListBox.h"
|
||||
#include "QskTextLabel.h"
|
||||
|
||||
/*
|
||||
QInputDialog uses a combo box instead of a list widget
|
||||
Guess we should do the same TODO ...
|
||||
*/
|
||||
static inline QskSimpleListBox* qskListBox(
|
||||
QskSelectionSubWindow* subWindow )
|
||||
{
|
||||
return qobject_cast< QskSimpleListBox* >( subWindow->contentItem() );
|
||||
}
|
||||
|
||||
static inline const QskSimpleListBox* qskListBox(
|
||||
const QskSelectionSubWindow* subWindow )
|
||||
{
|
||||
return qobject_cast< QskSimpleListBox* >( subWindow->contentItem() );
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
class TextLabel final : public QskTextLabel
|
||||
{
|
||||
public:
|
||||
TextLabel( QskSelectionSubWindow* subWindow )
|
||||
{
|
||||
setObjectName( QStringLiteral( "QskSelectionSubWindowTextLabel" ) );
|
||||
initSizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Constrained );
|
||||
|
||||
setAlignment( Qt::AlignLeft | Qt::AlignTop );
|
||||
setWrapMode( QskTextOptions::WordWrap );
|
||||
|
||||
connect( this, &QskTextLabel::textChanged,
|
||||
subWindow, &QskSelectionSubWindow::infoTextChanged );
|
||||
|
||||
connect( this, &QskTextLabel::textOptionsChanged,
|
||||
subWindow, &QskSelectionSubWindow::infoTextOptionsChanged );
|
||||
}
|
||||
};
|
||||
|
||||
class ListBox final : public QskSimpleListBox
|
||||
{
|
||||
public:
|
||||
@ -48,32 +43,15 @@ namespace
|
||||
};
|
||||
}
|
||||
|
||||
class QskSelectionSubWindow::PrivateData
|
||||
{
|
||||
public:
|
||||
QskTextLabel* textLabel;
|
||||
QskSimpleListBox* listBox;
|
||||
};
|
||||
|
||||
QskSelectionSubWindow::QskSelectionSubWindow( QQuickItem* parent )
|
||||
: Inherited( parent )
|
||||
, m_data( new PrivateData )
|
||||
{
|
||||
m_data->textLabel = new TextLabel( this );
|
||||
m_data->textLabel->setVisible( false );
|
||||
|
||||
m_data->listBox = new ListBox( this );
|
||||
auto listBox = new ListBox( this );
|
||||
#if 1
|
||||
m_data->listBox->setPreferredSize( 500, 500 );
|
||||
listBox->setPreferredSize( 500, 500 );
|
||||
#endif
|
||||
|
||||
auto box = new QskLinearBox( Qt::Vertical );
|
||||
box->setSpacing( 10 ); // hint
|
||||
box->addItem( m_data->textLabel );
|
||||
box->addItem( m_data->listBox );
|
||||
box->setStretchFactor( 1, 10 );
|
||||
|
||||
setContentItem( box );
|
||||
setContentItem( listBox );
|
||||
setDialogActions( QskDialog::Ok | QskDialog::Cancel );
|
||||
}
|
||||
|
||||
@ -81,54 +59,40 @@ QskSelectionSubWindow::~QskSelectionSubWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void QskSelectionSubWindow::setInfoText( const QString& text )
|
||||
{
|
||||
m_data->textLabel->setText( text );
|
||||
m_data->textLabel->setVisible( !text.isEmpty() );
|
||||
}
|
||||
|
||||
QString QskSelectionSubWindow::infoText() const
|
||||
{
|
||||
return m_data->textLabel->text();
|
||||
}
|
||||
|
||||
void QskSelectionSubWindow::setInfoTextOptions( const QskTextOptions& options )
|
||||
{
|
||||
if ( options != infoTextOptions() )
|
||||
{
|
||||
m_data->textLabel->setTextOptions( options );
|
||||
Q_EMIT infoTextOptionsChanged( options );
|
||||
}
|
||||
}
|
||||
|
||||
QskTextOptions QskSelectionSubWindow::infoTextOptions() const
|
||||
{
|
||||
return m_data->textLabel->textOptions();
|
||||
}
|
||||
|
||||
void QskSelectionSubWindow::setEntries( const QStringList& entries )
|
||||
{
|
||||
m_data->listBox->setEntries( entries );
|
||||
if ( auto listBox = qskListBox( this ) )
|
||||
listBox->setEntries( entries );
|
||||
}
|
||||
|
||||
QStringList QskSelectionSubWindow::entries() const
|
||||
{
|
||||
return m_data->listBox->entries();
|
||||
if ( auto listBox = qskListBox( this ) )
|
||||
return listBox->entries();
|
||||
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
void QskSelectionSubWindow::setSelectedRow( int row )
|
||||
{
|
||||
m_data->listBox->setSelectedRow( row );
|
||||
if ( auto listBox = qskListBox( this ) )
|
||||
listBox->setSelectedRow( row );
|
||||
}
|
||||
|
||||
int QskSelectionSubWindow::selectedRow() const
|
||||
{
|
||||
return m_data->listBox->selectedRow();
|
||||
if ( auto listBox = qskListBox( this ) )
|
||||
return listBox->selectedRow();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString QskSelectionSubWindow::selectedEntry() const
|
||||
{
|
||||
return m_data->listBox->selectedEntry();
|
||||
if ( auto listBox = qskListBox( this ) )
|
||||
listBox->selectedEntry();
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
#include "moc_QskSelectionSubWindow.cpp"
|
||||
|
@ -8,18 +8,10 @@
|
||||
|
||||
#include "QskDialogSubWindow.h"
|
||||
|
||||
class QskTextOptions;
|
||||
|
||||
class QSK_EXPORT QskSelectionSubWindow : public QskDialogSubWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY( QString infoText READ infoText
|
||||
WRITE setInfoText NOTIFY infoTextChanged )
|
||||
|
||||
Q_PROPERTY( QskTextOptions infoTextOptions READ infoTextOptions
|
||||
WRITE setInfoTextOptions NOTIFY infoTextOptionsChanged )
|
||||
|
||||
Q_PROPERTY( QStringList entries READ entries
|
||||
WRITE setEntries NOTIFY entriesChanged FINAL )
|
||||
|
||||
@ -32,30 +24,18 @@ class QSK_EXPORT QskSelectionSubWindow : public QskDialogSubWindow
|
||||
QskSelectionSubWindow( QQuickItem* parent = nullptr );
|
||||
~QskSelectionSubWindow() override;
|
||||
|
||||
void setInfoTextOptions( const QskTextOptions& );
|
||||
QskTextOptions infoTextOptions() const;
|
||||
|
||||
QString infoText() const;
|
||||
|
||||
Q_INVOKABLE QStringList entries() const;
|
||||
Q_INVOKABLE int selectedRow() const;
|
||||
Q_INVOKABLE QString selectedEntry() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setInfoText( const QString& );
|
||||
void setEntries( const QStringList& );
|
||||
void setSelectedRow( int row );
|
||||
|
||||
Q_SIGNALS:
|
||||
void infoTextChanged( const QString& );
|
||||
void infoTextOptionsChanged( const QskTextOptions& );
|
||||
void selectedRowChanged( int );
|
||||
void selectedEntryChanged( const QString& );
|
||||
void entriesChanged();
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
std::unique_ptr< PrivateData > m_data;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -4,34 +4,26 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "QskSelectionWindow.h"
|
||||
#include "QskGraphicLabel.h"
|
||||
#include "QskGraphic.h"
|
||||
#include "QskLinearBox.h"
|
||||
#include "QskSimpleListBox.h"
|
||||
#include "QskTextLabel.h"
|
||||
#include "QskTextOptions.h"
|
||||
|
||||
/*
|
||||
QInputDialog uses a combo box instead of a list widget
|
||||
Guess we should do the same TODO ...
|
||||
*/
|
||||
static inline QskSimpleListBox* qskListBox(
|
||||
QskSelectionWindow* window )
|
||||
{
|
||||
return qobject_cast< QskSimpleListBox* >( window->dialogContentItem() );
|
||||
}
|
||||
|
||||
static inline const QskSimpleListBox* qskListBox(
|
||||
const QskSelectionWindow* window )
|
||||
{
|
||||
return qobject_cast< QskSimpleListBox* >( window->dialogContentItem() );
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
class TextLabel final : public QskTextLabel
|
||||
{
|
||||
public:
|
||||
TextLabel( QskSelectionWindow* window )
|
||||
{
|
||||
setObjectName( QStringLiteral( "QskSelectionWindowTextLabel" ) );
|
||||
initSizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Preferred );
|
||||
|
||||
setAlignment( Qt::AlignLeft | Qt::AlignTop );
|
||||
setWrapMode( QskTextOptions::WordWrap );
|
||||
|
||||
connect( this, &QskTextLabel::textChanged,
|
||||
window, &QskSelectionWindow::infoTextChanged );
|
||||
|
||||
connect( this, &QskTextLabel::textOptionsChanged,
|
||||
window, &QskSelectionWindow::infoTextOptionsChanged );
|
||||
}
|
||||
};
|
||||
|
||||
class ListBox final : public QskSimpleListBox
|
||||
{
|
||||
public:
|
||||
@ -51,36 +43,18 @@ namespace
|
||||
};
|
||||
}
|
||||
|
||||
class QskSelectionWindow::PrivateData
|
||||
{
|
||||
public:
|
||||
QskTextLabel* textLabel;
|
||||
QskSimpleListBox* listBox;
|
||||
};
|
||||
|
||||
QskSelectionWindow::QskSelectionWindow( QWindow* parent )
|
||||
: Inherited( parent )
|
||||
, m_data( new PrivateData )
|
||||
{
|
||||
setFlags( Qt::Dialog | Qt::WindowTitleHint |
|
||||
Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint );
|
||||
|
||||
m_data->textLabel = new TextLabel( this );
|
||||
m_data->textLabel->setVisible( false );
|
||||
|
||||
m_data->listBox = new ListBox( this );
|
||||
auto listBox = new ListBox( this );
|
||||
#if 1
|
||||
m_data->listBox->setPreferredSize( 500, 500 );
|
||||
listBox->setPreferredSize( 500, 500 );
|
||||
#endif
|
||||
|
||||
auto box = new QskLinearBox( Qt::Vertical );
|
||||
box->setMargins( 5 );
|
||||
box->setSpacing( 10 );
|
||||
box->addItem( m_data->textLabel );
|
||||
box->addItem( m_data->listBox );
|
||||
box->setStretchFactor( m_data->listBox, 10 );
|
||||
|
||||
setDialogContentItem( box );
|
||||
setDialogContentItem( listBox );
|
||||
setDialogActions( QskDialog::Ok | QskDialog::Cancel );
|
||||
}
|
||||
|
||||
@ -88,54 +62,40 @@ QskSelectionWindow::~QskSelectionWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void QskSelectionWindow::setInfoText( const QString& text )
|
||||
{
|
||||
m_data->textLabel->setText( text );
|
||||
m_data->textLabel->setVisible( !text.isEmpty() );
|
||||
}
|
||||
|
||||
QString QskSelectionWindow::infoText() const
|
||||
{
|
||||
return m_data->textLabel->text();
|
||||
}
|
||||
|
||||
void QskSelectionWindow::setInfoTextOptions( const QskTextOptions& options )
|
||||
{
|
||||
if ( options != infoTextOptions() )
|
||||
{
|
||||
m_data->textLabel->setTextOptions( options );
|
||||
Q_EMIT infoTextOptionsChanged( options );
|
||||
}
|
||||
}
|
||||
|
||||
QskTextOptions QskSelectionWindow::infoTextOptions() const
|
||||
{
|
||||
return m_data->textLabel->textOptions();
|
||||
}
|
||||
|
||||
void QskSelectionWindow::setEntries( const QStringList& entries )
|
||||
{
|
||||
m_data->listBox->setEntries( entries );
|
||||
if ( auto listBox = qskListBox( this ) )
|
||||
listBox->setEntries( entries );
|
||||
}
|
||||
|
||||
QStringList QskSelectionWindow::entries() const
|
||||
{
|
||||
return m_data->listBox->entries();
|
||||
if ( auto listBox = qskListBox( this ) )
|
||||
return listBox->entries();
|
||||
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
void QskSelectionWindow::setSelectedRow( int row )
|
||||
{
|
||||
m_data->listBox->setSelectedRow( row );
|
||||
if ( auto listBox = qskListBox( this ) )
|
||||
listBox->setSelectedRow( row );
|
||||
}
|
||||
|
||||
int QskSelectionWindow::selectedRow() const
|
||||
{
|
||||
return m_data->listBox->selectedRow();
|
||||
if ( auto listBox = qskListBox( this ) )
|
||||
return listBox->selectedRow();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString QskSelectionWindow::selectedEntry() const
|
||||
{
|
||||
return m_data->listBox->selectedEntry();
|
||||
if ( auto listBox = qskListBox( this ) )
|
||||
listBox->selectedEntry();
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
#include "moc_QskSelectionWindow.cpp"
|
||||
|
@ -8,18 +8,10 @@
|
||||
|
||||
#include "QskDialogWindow.h"
|
||||
|
||||
class QskTextOptions;
|
||||
|
||||
class QSK_EXPORT QskSelectionWindow : public QskDialogWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY( QString infoText READ infoText
|
||||
WRITE setInfoText NOTIFY infoTextChanged )
|
||||
|
||||
Q_PROPERTY( QskTextOptions infoTextOptions READ infoTextOptions
|
||||
WRITE setInfoTextOptions NOTIFY infoTextOptionsChanged )
|
||||
|
||||
Q_PROPERTY( QStringList entries READ entries
|
||||
WRITE setEntries NOTIFY entriesChanged FINAL )
|
||||
|
||||
@ -32,30 +24,18 @@ class QSK_EXPORT QskSelectionWindow : public QskDialogWindow
|
||||
QskSelectionWindow( QWindow* parent = nullptr );
|
||||
~QskSelectionWindow() override;
|
||||
|
||||
void setInfoTextOptions( const QskTextOptions& );
|
||||
QskTextOptions infoTextOptions() const;
|
||||
|
||||
QString infoText() const;
|
||||
|
||||
Q_INVOKABLE QStringList entries() const;
|
||||
Q_INVOKABLE int selectedRow() const;
|
||||
Q_INVOKABLE QString selectedEntry() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setInfoText( const QString& );
|
||||
void setEntries( const QStringList& );
|
||||
void setSelectedRow( int row );
|
||||
|
||||
Q_SIGNALS:
|
||||
void infoTextChanged( const QString& );
|
||||
void infoTextOptionsChanged( const QskTextOptions& );
|
||||
void selectedRowChanged( int );
|
||||
void selectedEntryChanged( const QString& );
|
||||
void entriesChanged();
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
std::unique_ptr< PrivateData > m_data;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user