Fleshing out of using merge for colors.
This commit is contained in:
+13
-3
@@ -44,6 +44,8 @@ void ColorButton::init( const QString& defaultLabel, const QColor& defaultColor,
|
||||
mDefaultColor = defaultColor;
|
||||
mColorNode = ColorNode( color );
|
||||
|
||||
setMinimumSize( QSize( 85, 34 ) );
|
||||
|
||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
|
||||
setText( "" );
|
||||
setCheckable( true );
|
||||
@@ -67,7 +69,7 @@ void ColorButton::setColorNode( ColorNode colorNode )
|
||||
if ( colorNode.fieldFlag() )
|
||||
{
|
||||
setIcon( QIcon() );
|
||||
setText( colorNode.key() );
|
||||
setText( QString("${%1}").arg( colorNode.key() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -155,8 +157,16 @@ void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
|
||||
mColorNode = colorNode;
|
||||
mIsDefault = isDefault;
|
||||
|
||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
|
||||
setText( "" );
|
||||
if ( colorNode.fieldFlag() )
|
||||
{
|
||||
setIcon( QIcon() );
|
||||
setText( QString("${%1}").arg( colorNode.key() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
|
||||
setText( "" );
|
||||
}
|
||||
|
||||
emit colorChanged();
|
||||
}
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
|
||||
#include "ColorPaletteDialog.h"
|
||||
|
||||
#include "ColorPaletteItem.h"
|
||||
#include "ColorPaletteButtonItem.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
@@ -153,12 +150,17 @@ ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
|
||||
hline4->setLineWidth( 1 );
|
||||
vLayout->addWidget( hline4 );
|
||||
|
||||
ColorPaletteButtonItem* mergeFieldButton = new ColorPaletteButtonItem( "TODO: Field Button" );
|
||||
vLayout->addWidget( mergeFieldButton );
|
||||
mMergeFieldButton = new ColorPaletteButtonItem( tr("Merge field") );
|
||||
connect( mMergeFieldButton, SIGNAL(activated()), this, SLOT(onMergeFieldItemActivated()) );
|
||||
mMergeFieldButton->setEnabled( false );
|
||||
vLayout->addWidget( mMergeFieldButton );
|
||||
|
||||
setLayout( vLayout );
|
||||
|
||||
loadCustomColorHistory();
|
||||
|
||||
mFieldMenu = new FieldMenu();
|
||||
connect( mFieldMenu, SIGNAL(keySelected(QString)), this, SLOT(onFieldMenuItemActivated(QString)) );
|
||||
}
|
||||
|
||||
|
||||
@@ -168,15 +170,23 @@ void ColorPaletteDialog::setColorNode( const ColorNode& colorNode )
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::setKeys( const QList<QString> keyList )
|
||||
void ColorPaletteDialog::setKeys( const QStringList& keyList )
|
||||
{
|
||||
// TODO
|
||||
if ( keyList.size() > 0 )
|
||||
{
|
||||
mFieldMenu->setKeys( keyList );
|
||||
mMergeFieldButton->setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
mMergeFieldButton->setEnabled( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::clearKeys()
|
||||
{
|
||||
// TODO
|
||||
mMergeFieldButton->setEnabled( false );
|
||||
}
|
||||
|
||||
|
||||
@@ -263,3 +273,21 @@ void ColorPaletteDialog::loadCustomColorHistory()
|
||||
id++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::onMergeFieldItemActivated()
|
||||
{
|
||||
QPoint pos( mMergeFieldButton->width(), 0 );
|
||||
mFieldMenu->popup( mMergeFieldButton->mapToGlobal(pos) );
|
||||
}
|
||||
|
||||
|
||||
void ColorPaletteDialog::onFieldMenuItemActivated( QString key )
|
||||
{
|
||||
mColorNode.setFieldFlag( true );
|
||||
mColorNode.setColor( QColor("#eeeeec") );
|
||||
mColorNode.setKey( key );
|
||||
|
||||
emit colorChanged( mColorNode, false );
|
||||
accept();
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "ColorNode.h"
|
||||
#include "ColorHistory.h"
|
||||
#include "ColorPaletteItem.h"
|
||||
#include "ColorPaletteButtonItem.h"
|
||||
#include "FieldMenu.h"
|
||||
|
||||
|
||||
///
|
||||
@@ -59,7 +61,7 @@ signals:
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void setColorNode( const ColorNode& colorNode );
|
||||
void setKeys( const QList<QString> keyList );
|
||||
void setKeys( const QStringList& keyList );
|
||||
void clearKeys();
|
||||
|
||||
|
||||
@@ -72,6 +74,8 @@ private slots:
|
||||
void onHistoryItemActivated( int id );
|
||||
void onCustomColorItemActivated();
|
||||
void onColorHistoryChanged();
|
||||
void onMergeFieldItemActivated();
|
||||
void onFieldMenuItemActivated( QString key );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
@@ -101,6 +105,9 @@ private:
|
||||
ColorHistory* mColorHistory;
|
||||
ColorPaletteItem* mHistoryItem[PALETTE_COLS];
|
||||
|
||||
FieldMenu* mFieldMenu;
|
||||
ColorPaletteButtonItem* mMergeFieldButton;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -34,14 +34,14 @@ FieldMenu::FieldMenu()
|
||||
///
|
||||
/// set keys
|
||||
///
|
||||
void FieldMenu::setKeys( const QList<QString>& keyList )
|
||||
void FieldMenu::setKeys( const QStringList& keyList )
|
||||
{
|
||||
clear();
|
||||
|
||||
foreach ( QString key, keyList )
|
||||
{
|
||||
FieldMenuItem* menuItem = new FieldMenuItem( key );
|
||||
connect( menuItem, SIGNAL(activated()), this, SLOT(onMenuItemActivated) );
|
||||
connect( menuItem, SIGNAL(activated(QString)), this, SLOT(onMenuItemActivated(QString)) );
|
||||
|
||||
addAction( menuItem );
|
||||
}
|
||||
@@ -51,7 +51,7 @@ void FieldMenu::setKeys( const QList<QString>& keyList )
|
||||
///
|
||||
/// onMenuItemActivated slot
|
||||
///
|
||||
void FieldMenu::onMenuItemActivated( const QString& key )
|
||||
void FieldMenu::onMenuItemActivated( QString key )
|
||||
{
|
||||
emit keySelected( key );
|
||||
}
|
||||
|
||||
+3
-3
@@ -43,21 +43,21 @@ public:
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
void keySelected( const QString& key );
|
||||
void keySelected( QString key );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Public Methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
void setKeys( const QList<QString>& keyList );
|
||||
void setKeys( const QStringList& keyList );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Slots
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
void onMenuItemActivated( const QString& key );
|
||||
void onMenuItemActivated( QString key );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
void activated( const QString& key );
|
||||
void activated( QString key );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
@@ -297,6 +297,7 @@ void LabelModel::setMerge( Merge* merge )
|
||||
setModified();
|
||||
|
||||
emit mergeChanged();
|
||||
emit mergeSourceChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,6 +427,7 @@ void LabelModel::onMergeSourceChanged()
|
||||
{
|
||||
setModified();
|
||||
emit changed();
|
||||
emit mergeSourceChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ signals:
|
||||
void selectionChanged();
|
||||
void modifiedChanged();
|
||||
void mergeChanged();
|
||||
void mergeSourceChanged();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ public:
|
||||
// Virtual methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
virtual QStringList keyList() const = 0;
|
||||
virtual QStringList keys() const = 0;
|
||||
virtual QString primaryKey() const = 0;
|
||||
protected:
|
||||
virtual void open() = 0;
|
||||
|
||||
@@ -76,7 +76,7 @@ Merge* MergeNone::create()
|
||||
///
|
||||
/// Get key list
|
||||
///
|
||||
QStringList MergeNone::keyList() const
|
||||
QStringList MergeNone::keys() const
|
||||
{
|
||||
QStringList emptyList;
|
||||
return emptyList;
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public:
|
||||
// Implementation of virtual methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
QStringList keyList() const;
|
||||
QStringList keys() const;
|
||||
QString primaryKey() const;
|
||||
protected:
|
||||
void open();
|
||||
|
||||
@@ -55,7 +55,7 @@ MergeText::~MergeText()
|
||||
///
|
||||
/// Get key list
|
||||
///
|
||||
QStringList MergeText::keyList() const
|
||||
QStringList MergeText::keys() const
|
||||
{
|
||||
QStringList keys;
|
||||
for ( int iField = 0; iField < mNFieldsMax; iField++ )
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ protected:
|
||||
// Implementation of virtual methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
QStringList keyList() const;
|
||||
QStringList keys() const;
|
||||
QString primaryKey() const;
|
||||
protected:
|
||||
void open();
|
||||
|
||||
@@ -226,7 +226,7 @@ void MergeView::onCellChanged( int iRow, int iCol )
|
||||
void MergeView::loadHeaders( Merge* merge )
|
||||
{
|
||||
mPrimaryKey = merge->primaryKey();
|
||||
mKeys = merge->keyList();
|
||||
mKeys = merge->keys();
|
||||
|
||||
if ( mKeys.size() > 0 )
|
||||
{
|
||||
|
||||
@@ -59,9 +59,11 @@ void ObjectEditor::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
||||
|
||||
connect( mModel, SIGNAL(sizeChanged()), this, SLOT(onLabelSizeChanged()) );
|
||||
connect( mModel, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()) );
|
||||
connect( mModel, SIGNAL(mergeSourceChanged()), this, SLOT(onMergeSourceChanged()) );
|
||||
|
||||
onLabelSizeChanged();
|
||||
onSelectionChanged();
|
||||
onMergeSourceChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -246,6 +248,17 @@ void ObjectEditor::onSelectionChanged()
|
||||
}
|
||||
|
||||
|
||||
void ObjectEditor::onMergeSourceChanged()
|
||||
{
|
||||
if ( !mBlocked )
|
||||
{
|
||||
lineColorButton->setKeys( mModel->merge()->keys() );
|
||||
fillColorButton->setKeys( mModel->merge()->keys() );
|
||||
shadowColorButton->setKeys( mModel->merge()->keys() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ObjectEditor::onObjectChanged()
|
||||
{
|
||||
if ( !mBlocked )
|
||||
|
||||
@@ -69,6 +69,7 @@ private slots:
|
||||
void onSettingsChanged();
|
||||
void onLabelSizeChanged();
|
||||
void onSelectionChanged();
|
||||
void onMergeSourceChanged();
|
||||
void onObjectChanged();
|
||||
void onObjectMoved();
|
||||
void onObjectDestroyed();
|
||||
|
||||
Reference in New Issue
Block a user