1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
/***************************************************************************
*
* Copyright (C) 2005 Elad Lahav (elad_lahav@users.sourceforge.net)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
***************************************************************************/
#ifndef QUERYPAGEBASE_H
#define QUERYPAGEBASE_H
#include <tqhbox.h>
class QueryView;
/**
* Defines a page in a QueryWidget's tab widget.
* This is a abstract base class for QueryPage and HistoryPage. It defines
* the common behaviour for all pages, which includes appearance, display
* of tab text, page locking, storage and retrieval of information to
* and from files and basic navigation.
* Each page embeds a list widget derived from QueryView. The actual type
* of widget is defined by the different page classes.
* @author Elad Lahav
*/
class QueryPageBase : public TQHBox
{
Q_OBJECT
public:
QueryPageBase(TQWidget* pParent = 0, const char* szName = 0);
~QueryPageBase();
void applyPrefs();
bool load(const TQString&, const TQString&);
bool save(const TQString&, TQString&);
void selectNext();
void selectPrev();
/**
* Determines whether this page can be locked.
* Can be used by inheriting classes to define non-lockable pages.
* @return Always true
*/
virtual bool canLock() { return true; }
/**
* Locks or unlocks this page.
* @param bLocked true to lock the page, false to unlock it.
*/
void setLocked(bool bLocked) { m_bLocked = bLocked; }
/**
* Determines whether this page is locked.
* @return true if the page is locked, false otherwise
*/
bool isLocked() { return m_bLocked; }
/**
* Determines whether this page should be saved when the project is closed.
* By default, pages are saved if and only if they are locked.
* @return true to save the page, false otherwise
*/
virtual bool shouldSave() const { return m_bLocked; };
/**
* Constructs a caption for this page.
* The caption appears in the page's tab button and as the page's
* tooltip.
* @param bBrief true to generate a brief caption, false otherwise
* @return The page's title
*/
virtual TQString getCaption(bool bBrief = false) const = 0;
signals:
/**
* Emitted when a record is selected in the view widget.
* @param sFile The "File" field of the selected record
* @param nLine The "Line" field of the selected record
*/
void lineRequested(const TQString& sFile, uint nLine);
protected:
/** The embedded list. */
QueryView* m_pView;
/** Indicates whether this page is locked. A locked page is never
overriden by new data, and is also saved to a disc file when the
session is closed. */
bool m_bLocked;
/**
* Creates a new list item and adds it to the embedded view.
* This method is used to add records read from a stored file.
* @param sFile The "File" field of the record
* @param sFunc The "Function" field of the record
* @param sLine The "Line" field of the record
* @param sText The "Text" field of the record
*/
virtual void addRecord(const TQString& sFile, const TQString& sFunc,
const TQString& sLine, const TQString& sText) = 0;
/**
* Creates a file path to store this page.
* The path is composed of the project's path and a unique file name
* in that directory.
* @param sProjPath The project's directory
* @return The page's file path
*/
virtual TQString getFileName(const TQString& sProjPath) const = 0;
/**
* Tries to read the file header of a stored page.
* The contents of the header differ among inheriting classes.
* @param str A text stream initialised to the open page file
* @return true if the header was read successfully and contains the
* expected information, false otherwise
*/
virtual bool readHeader(TQTextStream& str) = 0;
/**
* Writes a header to a page's file.
* The contents of the header differ among inheriting classes.
* @param str A text stream initialised to the open page file
*/
virtual void writeHeader(TQTextStream& str) = 0;
};
#endif
|