Continued to flesh out merge subsystem.

This commit is contained in:
Jim Evins
2016-05-01 22:42:03 -04:00
parent 3cd0806792
commit 2ff07f01b3
12 changed files with 614 additions and 129 deletions
+2
View File
@@ -36,6 +36,8 @@ set (glabels_sources
MergeField.cpp
MergeView.cpp
MergeRecord.cpp
MergeNone.cpp
MergeText.cpp
ObjectEditor.cpp
Outline.cpp
PageRenderer.cpp
+45 -2
View File
@@ -24,17 +24,51 @@
///
/// Constructor
///
Merge::Merge( QString id, QString name, SourceType type )
: mId(id), mName(name), mType(type)
Merge::Merge( SourceType type ) : mType(type)
{
}
///
/// Constructor
///
Merge::Merge( const Merge* merge ) : mType(merge->mType), mSource(merge->mSource)
{
foreach ( MergeRecord* record, merge->mRecordList )
{
mRecordList << record->clone();
}
}
///
/// Destructor
///
Merge::~Merge()
{
foreach ( MergeRecord* record, mRecordList )
{
delete record;
}
mRecordList.clear();
}
///
/// Get type
///
Merge::SourceType Merge::type() const
{
return mType;
}
///
/// Get source
///
QString Merge::source() const
{
return mSource;
}
@@ -63,6 +97,15 @@ void Merge::setSource( const QString& source )
}
///
/// Get record list
///
const QList<MergeRecord*>& Merge::recordList( void ) const
{
return mRecordList;
}
///
/// Select matching record
///
+13 -43
View File
@@ -29,7 +29,7 @@
///
/// Merge Record Structure
/// Merge Object
///
struct Merge : QObject
{
@@ -39,6 +39,7 @@ struct Merge : QObject
/////////////////////////////////
// Source Type
/////////////////////////////////
public:
enum SourceType { NONE, FIXED, FILE };
@@ -46,21 +47,26 @@ struct Merge : QObject
// Life Cycle
/////////////////////////////////
protected:
Merge( QString id, QString name, SourceType type );
Merge( SourceType type );
Merge( const Merge* merge );
virtual ~Merge();
/////////////////////////////////
// Object duplication
/////////////////////////////////
virtual Merge* clone() const = 0;
/////////////////////////////////
// Properties
/////////////////////////////////
public:
inline QString id() const;
inline QString name() const;
inline SourceType type() const;
inline QString source() const;
SourceType type() const;
QString source() const;
void setSource( const QString& source );
inline const QList<MergeRecord*>& recordList( void ) const;
const QList<MergeRecord*>& recordList( void ) const;
/////////////////////////////////
@@ -98,47 +104,11 @@ signals:
// Private data
/////////////////////////////////
private:
QString mId;
QString mName;
SourceType mType;
QString mSource;
bool mSelected;
QList<MergeRecord*> mRecordList;
};
/////////////////////////////////
// INLINE METHODS
/////////////////////////////////
QString Merge::id() const
{
return mId;
}
QString Merge::name() const
{
return mId;
}
Merge::SourceType Merge::type() const
{
return mType;
}
QString Merge::source() const
{
return mSource;
}
const QList<MergeRecord*>& Merge::recordList( void ) const
{
return mRecordList;
}
#endif // Merge_h
+54
View File
@@ -19,3 +19,57 @@
*/
#include "MergeField.h"
///
/// Default constructor
///
MergeField::MergeField()
{
}
///
/// Constructor
///
MergeField::MergeField( const QString& key, const QString& value )
{
mKey = key;
mValue = value;
}
///
/// Get key
///
const QString MergeField::key( void ) const
{
return mKey;
}
///
/// Set key
///
void MergeField::setKey( const QString& value )
{
mKey = value;
}
///
/// Get value
///
const QString MergeField::value( void ) const
{
return mValue;
}
///
/// Set value
///
void MergeField::setValue( const QString& value )
{
mValue = value;
}
+11 -31
View File
@@ -29,6 +29,13 @@
///
struct MergeField
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
public:
MergeField();
MergeField( const QString& key, const QString& value );
/////////////////////////////////
// Properties
@@ -37,15 +44,15 @@ public:
//
// Key Property
//
inline const QString key( void ) const;
inline void setKey( const QString &value );
const QString key( void ) const;
void setKey( const QString& value );
//
// Value Property
//
inline const QString value( void ) const;
inline void setValue( const QString &value );
const QString value( void ) const;
void setValue( const QString& value );
/////////////////////////////////
@@ -58,31 +65,4 @@ private:
};
/////////////////////////////////
// INLINE METHODS
/////////////////////////////////
const QString MergeField::key( void ) const
{
return mKey;
}
void MergeField::setKey( const QString &value )
{
mKey = value;
}
const QString MergeField::value( void ) const
{
return mValue;
}
void MergeField::setValue( const QString &value )
{
mValue = value;
}
#endif // MergeField_h
+98
View File
@@ -0,0 +1,98 @@
/* MergeNone.cpp
*
* Copyright (C) 2015 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "MergeNone.h"
///
/// Constructor
///
MergeNone::MergeNone() : Merge( Merge::NONE )
{
}
///
/// Constructor
///
MergeNone::MergeNone( const MergeNone* merge ) : Merge( merge )
{
}
///
/// Destructor
///
MergeNone::~MergeNone()
{
}
///
/// Clone
///
MergeNone* MergeNone::clone() const
{
return new MergeNone( this );
}
///
/// Get key list
///
QList<QString> MergeNone::keyList() const
{
QList<QString> emptyList;
return emptyList;
}
///
/// Get primary key
///
QString MergeNone::primaryKey() const
{
return "";
}
///
/// Open source
///
void MergeNone::open()
{
}
///
/// Close source
///
void MergeNone::close()
{
}
///
/// Read next record
///
MergeRecord* MergeNone::readNextRecord()
{
return 0;
}
+62
View File
@@ -0,0 +1,62 @@
/* MergeNone.h
*
* Copyright (C) 2015 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MergeNone_h
#define MergeNone_h
#include "Merge.h"
///
/// MergeNone Backend
///
struct MergeNone : public Merge
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
protected:
MergeNone();
MergeNone( const MergeNone* merge );
virtual ~MergeNone();
/////////////////////////////////
// Object duplication
/////////////////////////////////
MergeNone* clone() const;
/////////////////////////////////
// Implementation of virtual methods
/////////////////////////////////
public:
QList<QString> keyList() const;
QString primaryKey() const;
protected:
void open();
void close();
MergeRecord* readNextRecord();
};
#endif // MergeNone_h
+63
View File
@@ -27,3 +27,66 @@
MergeRecord::MergeRecord() : mSelected( false )
{
}
///
/// Constructor
///
MergeRecord::MergeRecord( const MergeRecord* record )
: mSelected(record->mSelected), mFieldList(record->mFieldList)
{
}
///
/// Clone
///
MergeRecord* MergeRecord::clone() const
{
return new MergeRecord( this );
}
///
/// Is record selected?
///
bool MergeRecord::isSelected() const
{
return mSelected;
}
///
/// Set selected on not selected
///
void MergeRecord::setSelected( bool value )
{
mSelected = value;
}
///
/// Is record empty?
///
bool MergeRecord::isEmpty() const
{
return mFieldList.size() == 0;
}
///
/// Get field list
///
const QList<MergeField>& MergeRecord::fieldList() const
{
return mFieldList;
}
///
/// Set field list
///
void MergeRecord::setFieldList( QList<MergeField>& value )
{
mFieldList = value;
}
+12 -38
View File
@@ -37,18 +37,25 @@ struct MergeRecord
/////////////////////////////////
public:
MergeRecord();
MergeRecord( const MergeRecord* record );
/////////////////////////////////
// Object duplication
/////////////////////////////////
MergeRecord* clone() const;
/////////////////////////////////
// Properties
/////////////////////////////////
public:
inline bool isSelected() const;
inline void setSelected( bool value );
inline bool empty() const;
bool isSelected() const;
void setSelected( bool value );
bool isEmpty() const;
inline const QList<MergeField>& fieldList() const;
inline void setFieldList( QList<MergeField>& value );
const QList<MergeField>& fieldList() const;
void setFieldList( QList<MergeField>& value );
/////////////////////////////////
@@ -60,37 +67,4 @@ private:
};
/////////////////////////////////
// INLINE METHODS
/////////////////////////////////
bool MergeRecord::isSelected() const
{
return mSelected;
}
void MergeRecord::setSelected( bool value )
{
mSelected = value;
}
bool MergeRecord::empty() const
{
return mFieldList.size() == 0;
}
const QList<MergeField>& MergeRecord::fieldList() const
{
return mFieldList;
}
void MergeRecord::setFieldList( QList<MergeField>& value )
{
mFieldList = value;
}
#endif // MergeRecord_h
+101
View File
@@ -0,0 +1,101 @@
/* MergeText.cpp
*
* Copyright (C) 2015 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#include "MergeText.h"
///
/// Constructor
///
MergeText::MergeText( QChar delimiter, bool line1HasKeys ) : Merge( Merge::FILE )
{
}
///
/// Constructor
///
MergeText::MergeText( const MergeText* merge )
: Merge( merge ), mDelimeter(merge->mDelimeter), mLine1HasKeys(merge->mLine1HasKeys)
{
}
///
/// Destructor
///
MergeText::~MergeText()
{
}
///
/// Get key list
///
QList<QString> MergeText::keyList() const
{
QList<QString> emptyList;
return emptyList;
}
///
/// Get primary key
///
QString MergeText::primaryKey() const
{
return "";
}
///
/// Open source
///
void MergeText::open()
{
mFile.setFileName( source() );
mFile.open( QIODevice::ReadOnly|QIODevice::Text );
if ( mLine1HasKeys && mFile.isOpen() )
{
// Todo parse line #1, create key list from string list
}
}
///
/// Close source
///
void MergeText::close()
{
if ( mFile.isOpen() )
{
mFile.close();
}
}
///
/// Read next record
///
MergeRecord* MergeText::readNextRecord()
{
return 0;
}
+67
View File
@@ -0,0 +1,67 @@
/* MergeText.h
*
* Copyright (C) 2015 Jim Evins <evins@snaught.com>
*
* This file is part of gLabels-qt.
*
* gLabels-qt is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* gLabels-qt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MergeText_h
#define MergeText_h
#include "Merge.h"
#include <QFile>
///
/// MergeText Backend
///
struct MergeText : public Merge
{
/////////////////////////////////
// Life Cycle
/////////////////////////////////
protected:
MergeText( QChar delimiter, bool line1HasKeys );
MergeText( const MergeText* merge );
virtual ~MergeText();
/////////////////////////////////
// Implementation of virtual methods
/////////////////////////////////
public:
QList<QString> keyList() const;
QString primaryKey() const;
protected:
void open();
void close();
MergeRecord* readNextRecord();
/////////////////////////////////
// Private data
/////////////////////////////////
private:
QChar mDelimeter;
bool mLine1HasKeys;
QFile mFile;
};
#endif // MergeText_h
+86 -15
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MergeView</class>
<widget class="QWidget" name="MergePropertyEditor">
<widget class="QWidget" name="MergeView">
<property name="geometry">
<rect>
<x>0</x>
@@ -22,6 +22,13 @@
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QPushButton" name="locationButton">
<property name="text">
<string>Location</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
@@ -29,22 +36,15 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="locationLabel">
<property name="text">
<string>Location:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Placeholder</string>
</property>
</widget>
<item row="0" column="1">
<widget class="QComboBox" name="formatCombo"/>
</item>
</layout>
</item>
@@ -71,19 +71,19 @@
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QTableWidget" name="tableWidget"/>
<widget class="QTableWidget" name="recordsTable"/>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton_2">
<widget class="QPushButton" name="selectAllButton">
<property name="text">
<string>Select all</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<widget class="QPushButton" name="unselectAllButton">
<property name="text">
<string>Unselect all</string>
</property>
@@ -110,5 +110,76 @@
</layout>
</widget>
<resources/>
<connections/>
<connections>
<connection>
<sender>selectAllButton</sender>
<signal>clicked()</signal>
<receiver>MergeView</receiver>
<slot>onSelectAllButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>63</x>
<y>571</y>
</hint>
<hint type="destinationlabel">
<x>69</x>
<y>601</y>
</hint>
</hints>
</connection>
<connection>
<sender>unselectAllButton</sender>
<signal>clicked()</signal>
<receiver>MergeView</receiver>
<slot>onUnselectAllButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>178</x>
<y>567</y>
</hint>
<hint type="destinationlabel">
<x>263</x>
<y>600</y>
</hint>
</hints>
</connection>
<connection>
<sender>locationButton</sender>
<signal>clicked()</signal>
<receiver>MergeView</receiver>
<slot>onUnselectAllButtonClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>175</x>
<y>85</y>
</hint>
<hint type="destinationlabel">
<x>570</x>
<y>75</y>
</hint>
</hints>
</connection>
<connection>
<sender>formatCombo</sender>
<signal>activated(int)</signal>
<receiver>MergeView</receiver>
<slot>onFormatComboChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>166</x>
<y>48</y>
</hint>
<hint type="destinationlabel">
<x>565</x>
<y>56</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>onSelectAllButtonClicked()</slot>
<slot>onUnselectAllButtonClicked()</slot>
<slot>onLocationButtonClicked()</slot>
<slot>onFormatComboChanged()</slot>
</slots>
</ui>