Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28586
Modified Files:
preferences.cpp preferences.h srvparams.cpp srvparams.h
Log Message:
Implemented a way to comment wolfpack.xml
Index: preferences.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/preferences.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** preferences.cpp 26 Sep 2003 01:03:52 -0000 1.4
--- preferences.cpp 28 Jan 2004 23:21:26 -0000 1.5
***************
*** 314,317 ****
--- 314,326 ----
QDomElement group, option;
for (git = d->groups_.begin(); git != d->groups_.end(); ++git) {
+ // comment the group
+ QString commentText = getGroupDoc(git.key());
+
+ if (commentText != QString::null) {
+ root.appendChild(doc.createTextNode("\n\n "));
+ root.appendChild(doc.createComment("\n " + commentText.replace("\n", "\n ") + "\n "));
+ root.appendChild(doc.createTextNode("\n "));
+ }
+
// create a group element
group = doc.createElement("group");
***************
*** 319,322 ****
--- 328,339 ----
// add in options
for (pit = (*git).begin(); pit != (*git).end(); ++pit) {
+ QString commentText = getEntryDoc(git.key(), pit.key());
+
+ if (commentText != QString::null) {
+ group.appendChild(doc.createTextNode("\n\n "));
+ group.appendChild(doc.createComment(" " + commentText.replace("\n", "\n ") + " "));
+ group.appendChild(doc.createTextNode("\n "));
+ }
+
option = doc.createElement("option");
option.setAttribute("key", pit.key());
***************
*** 340,344 ****
// write it out
QTextStream textstream(&datafile);
! doc.save(textstream, 4);
datafile.close();
d->formatstate_ = true;
--- 357,361 ----
// write it out
QTextStream textstream(&datafile);
! doc.save(textstream, 2);
datafile.close();
d->formatstate_ = true;
***************
*** 352,353 ****
--- 369,378 ----
bool Preferences::formatState() { return d->formatstate_; }
+
+ QString Preferences::getGroupDoc(const QString &group) {
+ return QString::null;
+ }
+
+ QString Preferences::getEntryDoc(const QString &group, const QString &entry) {
+ return QString::null;
+ }
Index: preferences.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/preferences.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** preferences.h 26 Sep 2003 01:03:52 -0000 1.3
--- preferences.h 28 Jan 2004 23:21:27 -0000 1.4
***************
*** 81,84 ****
--- 81,87 ----
void writeData();
void processGroup( const QDomElement& group );
+
+ virtual QString getGroupDoc(const QString &group);
+ virtual QString getEntryDoc(const QString &group, const QString &entry);
private:
Index: srvparams.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/srvparams.cpp,v
retrieving revision 1.92
retrieving revision 1.93
diff -C2 -d -r1.92 -r1.93
*** srvparams.cpp 22 Jan 2004 04:48:12 -0000 1.92
--- srvparams.cpp 28 Jan 2004 23:21:27 -0000 1.93
***************
*** 338,340 ****
--- 338,389 ----
}
+ struct stGroupDoc {
+ const char *group;
+ const char *documentation;
+ };
+
+ static stGroupDoc group_doc[] = {
+ {"AI", "This group configures the NPC AI."},
+ {"Accounts", "This group configures the account management."},
+ {"Database", "This group configures access to the worldsave database."},
+ {0, 0}
+ };
+
+ QString cSrvParams::getGroupDoc(const QString &group) {
+ // Try to find documentation for a group in our table
+ unsigned int i = 0;
+
+ while (group_doc[i].group) {
+ if (group == group_doc[i].group) {
+ return group_doc[i].documentation;
+ }
+ ++i;
+ }
+
+ return Preferences::getGroupDoc(group);
+ }
+ struct stEntryDoc {
+ const char *group;
+ const char *entry;
+ const char *documentation;
+ };
+
+ static stEntryDoc entry_doc[] = {
+ {"Accounts", "Database Driver", "Possible values are: sqlite, mysql"},
+ {0, 0, 0}
+ };
+
+ QString cSrvParams::getEntryDoc(const QString &group, const QString &entry) {
+ // Try to find documentation for an entry in our table
+ unsigned int i = 0;
+
+ while (entry_doc[i].group && entry_doc[i].entry) {
+ if (group == entry_doc[i].group && entry == entry_doc[i].entry) {
+ return entry_doc[i].documentation;
+ }
+ ++i;
+ }
+
+ return Preferences::getEntryDoc(group, entry);
+ }
Index: srvparams.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/srvparams.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -d -r1.59 -r1.60
*** srvparams.h 20 Sep 2003 12:01:44 -0000 1.59
--- srvparams.h 28 Jan 2004 23:21:27 -0000 1.60
***************
*** 60,63 ****
--- 60,66 ----
{
protected:
+ QString getGroupDoc(const QString &group);
+ QString getEntryDoc(const QString &group, const QString &entry);
+
std::vector<ServerList_st> serverList_;
std::vector<StartLocation_st> startLocation_;
|