QMultiDate Class Reference

MultiDate date-range manipulator. More...

#include <QMultiDate.h>

Inheritance diagram for QMultiDate:

Inheritance graph

List of all members.

Public Member Functions

 QMultiDate (const QString &init="", const QString &defaultStart="", const QString &holidaySchedule="")
 Constructor.
 ~QMultiDate ()
QString mdid ()
 Return the multidate unique identifier.
int freqType ()
 Return the FrequencyType value.
int flags ()
 Return defined flags.
QDate startDate ()
 Return the StartDate.
QDate endDate ()
 Return the EndDate.
int count (int offset=0)
 Return the Event Count.
int everyThOf ()
int everyThOfVal ()
int weekdayOf ()
bool skipWeekends ()
bool skipHolidays ()
int index ()
 Return the current Index.
void setFreqType (int i_freqType)
void setFlags (int flags)
void setDirty (bool state)
bool isDirty () const
void setIgnoreDate (bool state)
bool ignoreDate ()
void setStartDate (const QDate &date)
void setStartDate (const QString &date)
void setDate (int index, const QDate &date)
 Recalculate Dates from a particular date.
void setDate (int index, const QString &date)
void setEndDate (const QDate &date)
void setCount (int count)
void setEveryThOf (int everyThOf)
void setWeekdayOf (int weekdayOf)
void setSkipWeekends (bool skipWeekends)
void setSkipHolidays (bool skipHolidays)
void setIndex (int index)
void setHolidays (const QString &holidaySchedule)
QString toString (int index=-1)
 Return the definition compacted string (with index).
QString toCode ()
 Return the definition compacted string without the index.
QStringList toStringList ()
 Return the list of computed dates.
void fromString (const QString &val)
 Set MultiDate definition from a compacted string.

Protected Member Functions

void compute ()
 Internal Calculator.
void compute (int count)
 Internal Calculate From.

Private Member Functions

void setMdid (const QString &val)
 Set the unque identifier.
void recordDate (const QDate &date)
 Internal Date Recorder.

Private Attributes

bool m_dirty
 dirty flag
QString m_mdid
 unique identifier
int m_freqType
 Frequency Type.
int m_flags
 Flags.
QDate m_startDate
 Start Date.
QDate m_endDate
 End Date.
int m_count
 Event Count.
int m_everyThOf
 Every ?th of the period.
int m_weekdayOf
bool m_skipWeekends
bool m_skipHolidays
int m_index
int m_crc
bool m_isValid
QList< QDate > m_dateList


Detailed Description

MultiDate date-range manipulator.

The MultiDate date range manipulator is an object that is used to compute multi-date date lists. It is based upon the premise that creating and manipulating multi-date events requires a "StartDate" from which to begin calculations, and a "FrequencySpecification" that defines the rules by which to calculate each date.

A complete multi-date definition is contained within a multi-character string, making the definition field suitable even for simple text-based database systems.

Typical Multidate Definition String
  ("7TFG0200200601230050721000234")
MultiDate Field Definition Explained:
    00000000001111111111222222222
    01234567890123456789012345678
    QQQQTTFFYYYYMMDDCCCWWdSIIIXXX
  ("7TFG0200200601230050721000234")

    QQQQ mdid Multidate ID      (random key)     mid(0,4)
    TT   freqType               (01-07)          mid(4,2)
    FF   flags                  (reserved)       mid(6,2)
    YYYY startDate Year         (4-digit)        mid(8,4)
    MM   startDate Month        (1-12)           mid(12,2)
    DD   startDate Day of month (1-31)           mid(14,2)
    CCC  count                  (2-999)          mid(16,3)
    WW   everyThOf              (1-32 *32==last) mid(19,2)
    d    weekdayOf              (1=monday)       mid(21,1)
    S    skipWeekends           (0,1)            mid(22,1)
    S    skipHolidays           (0,2)            mid(23,1)
    III  index number           (000-999)        mid(24,3)
    XXX  check digit            (0-255)          mid(26,3)
All of the multi-date definition fields are position dependent and are outlined as follows:

QQQQ - Multidate Unique Identifier (mdid)
This code uniquely identifies a multi-date code. In the event that two different multi-dates are entered into the system with exactly the same multi-date definition, this code will distinguish them. This allows the database to search for related multidate items simply by filtering for the code value without the index (III) and check digit (XXX). Using the example code above, all related multidates can be found by searching for: ("7TFG0200200601230050721") The result would include all items in the database that contained this multidate prefix code which would mean they are all part of the same multidate set.
Example Filters (note the asterisk at the end of the keys)
 '
 ' SQL
 SELECT * from calendarTable WHERE mddField Like '7TFG0200200601230050721*';

 '
 ' Commence
 [ViewFilter(1,F,,mddField,Equal to,"7TFG0200200601230050721*")]
The examples shown above would produce a result set of multiple rows (five rows, actually) where each row represents a single calendar item of the same multidate group set.
see: mdid
TT - Frequency Type
This is a two-character string that represents the FrequencyType. The possible values are 01-07 inclusive. Each value represents a completely different type of frequency date-list process. This is a two-character field to support additional repetitive date tasks.
see: freqType, setFreqType
FF - Flags
These flags are more-or-less undefined, though 01 indicates there has been a change in the data (ie; dirty==true). It has no real functional impact on the system at this time. The initial idea was to be able to quickly flag items in the database that may have been changed, and provide a means to quickly identify them.
see: flags, setFlags
YYYY - Start Year (startDate)
This is the start-year of the multidate.
see: startDate, endDate, setStartDate
MM - Start Month (startDate)
This is the Start Month field. It requires a leading-zero. Possible values are 01-12 (<humor>Mayan calendar dates not supported</humor>).
see: startDate, endDate, setStartDate
DD - Start Day (startDate)
This is the Start Day of the month. It requires a leading zero. Possible values are 01-31 (adjusted depending on the month).
see: startDate, endDate, setStartDate
CCC - Frequency Count (count)
This is the frequency count. This takes whatever frequency definition is set up and apply that as a 'count of events'. Meaning, if the count is 5, and the specification is set to "Weekdays", then there will be five weekday events created beginning with the start date.
see: count, setCount
WW - Every ?something Of (everyThOf)
This component represents the day of the week. The acceptable range is 01-07 for weekdays, and 01-32 for month days.
see: everyThOf, setEveryThOf
d - Weekday of (weekdayOf) (1==monday)
This represens the day of the week. This is either 1==monday, 2==tuesday and so on. Or, depending on the freqType setting, this can represent 1==day, 2==weekday.
see: weekdayOf, setWeekdayOf
s0 - Skip Weekends (skipWeekends) (true or false)
This indicates if weekends should be skipped or not. A weekend is designated as a Saturday or Sunday.
see: skipWeekends, setSkipWeekends
s1 - Holidays (skipHolidays) (true or false)
This indicates if holidays should be skipped or not. For this function to work properly this component must be initialized with a complete holiday list in CrLf delimited yyyymmdd dates. The compute algorithm uses this list to skip over any calculated dates.
see: skipHolidays, setSkipHolidays
III - Index Number (index) (0-999)
This is a value that represents the index number of a particular date. As each date is filed within the database, presummably one-record-per date, then this field can be used to distinguish one date from another. This value is not manipulated by this object other than to return it as set, or to override its value based on a request from the caller. By calling the function toString this object will disregard the current III value and substitute it with the value provided.
see: index
XXX - Check Digit (crc) (0-255)
This code is used to verify the integrity of the multidate-code. When a multidate code is inserted into the database, if it is not defined properly, then it suffers the potential of being improperly interpreted. When the MultiDate object is initialized, the initialization sequence is checked with this code, and if it comes up invalid, the entire code sequence is ignored, the MultiDate object is set to invalid (or cleared), and no multi-dates will be generated if requested. This protects the system from improperly creating multidates.

Definition at line 197 of file QMultiDate.h.


Constructor & Destructor Documentation

QMultiDate::QMultiDate ( const QString &  init = "",
const QString &  defaultStart = "",
const QString &  holidaySchedule = "" 
)

Constructor.

This constructs a QMultiDate object. No parameters are required, but the object probably should be at least initialized with a compressed init string.

Parameters:
init compressed init string
defaultStart default Date Start string
holidaySchedule holiday schedule list

Definition at line 71 of file QMultiDate.cpp.

QMultiDate::~QMultiDate (  )  [inline]

Definition at line 208 of file QMultiDate.h.


Member Function Documentation

void QMultiDate::compute ( int  count  )  [protected]

Internal Calculate From.

This is the loop calculator.

Definition at line 615 of file QMultiDate.cpp.

void QMultiDate::compute (  )  [protected]

Internal Calculator.

This is the internal function that actually performs the computation of repeating dates. It is referenced automatically by the various access functions and does not need to be called by the user.

Definition at line 925 of file QMultiDate.cpp.

int QMultiDate::count ( int  offset = 0  ) 

Return the Event Count.

The event Count represents the count of the number of multi-date events in total. As this number is changed the EndDate value will be updated accordingly.

This function also includes a convenience parameter (offset). This parameter is used (generally) to subtract a fixed amount (usually 1) from the defined count. In cases where the defined count is zero, applying an offset of -1 causes this function to still return zero... for convenience. This aids in the manipulation of some databases where queries are developed that exclude one or more items, and the number of items that are being manipulated must not go less than zero.

Definition at line 540 of file QMultiDate.cpp.

QDate QMultiDate::endDate (  )  [inline]

Return the EndDate.

The EndDate defines when the multi-date events complete. This is generally a computed value, but it is also possible to set the EndDate and have this object calculate the number of events it takes to arrive at that end date.

Definition at line 273 of file QMultiDate.h.

int QMultiDate::everyThOf (  )  [inline]

Definition at line 299 of file QMultiDate.h.

int QMultiDate::everyThOfVal (  )  [inline]

Definition at line 301 of file QMultiDate.h.

int QMultiDate::flags (  )  [inline]

Return defined flags.

 Flags: 
  0x01 ~ field is dirty
  0x02 ~ ignore date field

Definition at line 254 of file QMultiDate.h.

int QMultiDate::freqType (  )  [inline]

Return the FrequencyType value.

The frequency type specifies the type of frequency defined in the definition. Currently the frequency type supports only seven different specifications:

  00 - Undefined            This means the multidate is undefined
  01 - Daily                Monday through Sunday
  02 - Weekdays             Monday through Friday
  03 - Weekly               One specific day each week
  04 - Every ?th Weekday    One specific day each ?th week
  05 - ?th day of the month One ?th day each month
  06 - Monthly              One specific day each month
  07 - Periodic             One specific period of time

Note:
The toString "FF" representation of this value occupies two character places ranging from 01..99 to allow for expansion of additional multidate definitions.

Definition at line 242 of file QMultiDate.h.

void QMultiDate::fromString ( const QString &  val  ) 

Set MultiDate definition from a compacted string.

This routine accepts input from the compressed string definition and breaks it apart in to its resultant fields.

Definition at line 237 of file QMultiDate.cpp.

bool QMultiDate::ignoreDate (  ) 

Definition at line 975 of file QMultiDate.cpp.

int QMultiDate::index (  )  [inline]

Return the current Index.

Definition at line 347 of file QMultiDate.h.

bool QMultiDate::isDirty (  )  const [inline]

Definition at line 371 of file QMultiDate.h.

QString QMultiDate::mdid (  )  [inline]

Return the multidate unique identifier.

This unique identifier uniquely identifies the multidate items. This is a 4-character string consisting of a random alphanumeric set.

Definition at line 218 of file QMultiDate.h.

void QMultiDate::recordDate ( const QDate &  date  )  [private]

Internal Date Recorder.

This function adds a date to the stack of computed dates. It is internal and private.

Definition at line 535 of file QMultiDate.cpp.

void QMultiDate::setCount ( int  count  ) 

Definition at line 487 of file QMultiDate.cpp.

void QMultiDate::setDate ( int  index,
const QString &  date 
)

Definition at line 552 of file QMultiDate.cpp.

void QMultiDate::setDate ( int  index,
const QDate &  date 
)

Recalculate Dates from a particular date.

This function takes a date, and an index position for that date, and recomputes all the dates from that index. If this date has moved further into the future then all subsequent dates will be moved with it. If it has been moved from the future to a time less far away, then it is analyzed to determine if it has moved too far in and adjusted from there.

Definition at line 557 of file QMultiDate.cpp.

void QMultiDate::setDirty ( bool  state  ) 

Definition at line 440 of file QMultiDate.cpp.

void QMultiDate::setEndDate ( const QDate &  date  ) 

Definition at line 481 of file QMultiDate.cpp.

void QMultiDate::setEveryThOf ( int  everyThOf  ) 

Definition at line 495 of file QMultiDate.cpp.

void QMultiDate::setFlags ( int  flags  ) 

Definition at line 461 of file QMultiDate.cpp.

void QMultiDate::setFreqType ( int  i_freqType  ) 

Definition at line 452 of file QMultiDate.cpp.

void QMultiDate::setHolidays ( const QString &  holidaySchedule  ) 

Definition at line 531 of file QMultiDate.cpp.

void QMultiDate::setIgnoreDate ( bool  state  ) 

Definition at line 969 of file QMultiDate.cpp.

void QMultiDate::setIndex ( int  index  ) 

Definition at line 523 of file QMultiDate.cpp.

void QMultiDate::setMdid ( const QString &  val  )  [private]

Set the unque identifier.

Definition at line 447 of file QMultiDate.cpp.

void QMultiDate::setSkipHolidays ( bool  skipHolidays  ) 

Definition at line 517 of file QMultiDate.cpp.

void QMultiDate::setSkipWeekends ( bool  skipWeekends  ) 

Definition at line 511 of file QMultiDate.cpp.

void QMultiDate::setStartDate ( const QString &  date  ) 

Reimplemented in QMultiDateDialog.

Definition at line 476 of file QMultiDate.cpp.

void QMultiDate::setStartDate ( const QDate &  date  ) 

Definition at line 470 of file QMultiDate.cpp.

void QMultiDate::setWeekdayOf ( int  weekdayOf  ) 

Definition at line 503 of file QMultiDate.cpp.

bool QMultiDate::skipHolidays (  )  [inline]

Definition at line 341 of file QMultiDate.h.

bool QMultiDate::skipWeekends (  )  [inline]

Definition at line 335 of file QMultiDate.h.

QDate QMultiDate::startDate (  )  [inline]

Return the StartDate.

The StartDate defines when the multi-date events are to begin from.

Definition at line 262 of file QMultiDate.h.

QString QMultiDate::toCode (  ) 

Return the definition compacted string without the index.

This is a convenience function designed to be used when you want to acquire the compacted definition string minus the index portion of the field. This code can be used when searching a database that contains several entries with the same codes, but different index numbers.

Reimplemented in QMultiDateDialog.

Definition at line 414 of file QMultiDate.cpp.

QString QMultiDate::toString ( int  index = -1  ) 

Return the definition compacted string (with index).

This routine is used to translate the current multi-date definition into its resultant compacted string. Optionally an index can be provided to override the current index value. Overriding the index does not change the current stored index value, but simply changes the index value of this return field.

Definition at line 342 of file QMultiDate.cpp.

QStringList QMultiDate::toStringList (  ) 

Return the list of computed dates.

This routine returns the list of computed dates.

Definition at line 429 of file QMultiDate.cpp.

int QMultiDate::weekdayOf (  )  [inline]

Definition at line 329 of file QMultiDate.h.


Member Data Documentation

int QMultiDate::m_count [private]

Event Count.

This contains the number of date events that will be generated.

Definition at line 593 of file QMultiDate.h.

int QMultiDate::m_crc [private]

Definition at line 605 of file QMultiDate.h.

QList<QDate> QMultiDate::m_dateList [private]

Definition at line 609 of file QMultiDate.h.

bool QMultiDate::m_dirty [private]

dirty flag

This flag gets set to 'true' any time one of the fields is updated. It gets set to 'false' when a re-computation is performed.

Reimplemented in QMultiDateDialog.

Definition at line 544 of file QMultiDate.h.

QDate QMultiDate::m_endDate [private]

End Date.

This contains the current End Date. This becomes a computed value anytime any of the other fields are updated.

Definition at line 585 of file QMultiDate.h.

int QMultiDate::m_everyThOf [private]

Every ?th of the period.

Definition at line 599 of file QMultiDate.h.

int QMultiDate::m_flags [private]

Flags.

This contains miscelaneous control flags.

Definition at line 568 of file QMultiDate.h.

int QMultiDate::m_freqType [private]

Frequency Type.

This contains the currently selected frequency type.

Definition at line 560 of file QMultiDate.h.

int QMultiDate::m_index [private]

Definition at line 603 of file QMultiDate.h.

bool QMultiDate::m_isValid [private]

Definition at line 607 of file QMultiDate.h.

QString QMultiDate::m_mdid [private]

unique identifier

This field gets initialized to a random set of letters and numbers upon creation of a new multidate item.

Definition at line 553 of file QMultiDate.h.

Definition at line 602 of file QMultiDate.h.

Definition at line 601 of file QMultiDate.h.

QDate QMultiDate::m_startDate [private]

Start Date.

This contains the current Start Date

Definition at line 576 of file QMultiDate.h.

int QMultiDate::m_weekdayOf [private]

Definition at line 600 of file QMultiDate.h.


The documentation for this class was generated from the following files:




~ ~ ~ ~ ~ ~
Source Code without Comments is like a Cranberry Garland
without the berries. Comment your Code!
 
Commence Database User Support Group Forum
http://newsgroup.showoff-db.org/
~ ~ ~ ~ ~ ~
Author: Mark Petryk
Lorimark Solutions, LLC
mark@lorimarksolutions.com