Properly delete the thread that fetches the hunks
[vng.git] / Configuration.h
blob1d171228597f9efab6bb8dca738c4c4d33ce6a18
1 /*
2 * This file is part of the vng project
3 * Copyright (C) 2008 Thomas Zander <tzander@trolltech.com>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef CONFIGURATION_H
19 #define CONFIGURATION_H
21 #include <QString>
22 #include <QDir>
23 #include <QHash>
24 #include <QTextStream>
26 #include "commits/Branch.h"
28 class Configuration {
29 public:
30 /// creates a simple configuration object which does not check for section specific settings.
31 Configuration();
32 /**
33 * Creates a Configuration object which is initialized with settings from for the section.
34 * If the user has settings in his user-wide-profile for the section passed, these will
35 * be read and made available using the contains() and optionArgument() methods.
36 * @param section the command-name which this configuration object will link to.
38 Configuration(const QString &section);
40 /**
41 * returns true if the option was found in the configuration files.
42 * @see optionArgument()
44 bool contains(const QString & key) const;
45 /**
46 * Return the argument passed to an option.
47 * @see contains()
49 QString optionArgument(const QString &optionName, const QString &defaultValue = QString()) const;
51 /// return the base directory of this repository.
52 QDir repository() const;
53 /// returns the directory where the database and other meta data is stored.
54 QDir repositoryMetaDir() const;
56 bool colorTerm() const;
58 inline void colorize(QTextStream &stream) const {
59 if (colorTerm())
60 stream << QChar(27) << '[' << 34 << 'm'; // to blue
63 inline void colorize2(QTextStream &stream) const {
64 if (colorTerm())
65 stream << QChar(27) << '[' << 31 << 'm'; // to red
68 inline void normalColor(QTextStream &stream) const {
69 if (colorTerm())
70 stream << QChar(27) << '[' << 0 << 'm'; // reset
73 /// returns true when there is a repository, but it has not had its initial commit yet.
74 bool isEmptyRepo() const;
76 /// return the branches in the current repo.
77 QList<Branch> allBranches();
78 /// return the branches in the current repo.
79 QList<Branch> branches();
80 /// return the branches in the current repo.
81 QList<Branch> remoteBranches();
83 private:
84 void readConfig();
85 void fetchBranches();
87 QDir m_repoDir;
88 QDir m_repoMetaDataDir;
89 QString m_section;
90 bool m_dirty, m_emptyRepo, m_fetchedBranches;
91 QHash<QString, QString> m_options;
92 QList<Branch> m_localBranches;
93 QList<Branch> m_remoteBranches;
96 #endif