catalog.h

Go to the documentation of this file.
00001 /*
00002 Launchy: Application Launcher
00003 Copyright (C) 2007  Josh Karlin
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 */
00019 
00020 #ifndef CATALOG_H
00021 #define CATALOG_H
00022 
00023 #include <QString>
00024 #include <QStringList>
00025 #include <QBitArray>
00026 #include <QIcon>
00027 #include <QHash>
00028 #include <QDataStream>
00029 #include <QDir>
00030 #include <QSet>
00031 
00032 
00036 class CatItem {
00037 public:
00038     
00040         QString fullPath;
00042         QString shortName;
00044         QString lowName;
00046         QString icon;
00048         int usage;
00050         void* data;
00052         int id;
00053 
00054         CatItem() {}
00055 
00056 
00057 
00058         CatItem(QString full, bool isDir = false) 
00059                 : fullPath(full) {
00060                         int last = fullPath.lastIndexOf("/");
00061                         if (last == -1) {
00062                                 shortName = fullPath;
00063 
00064                         } else {
00065                                 shortName = fullPath.mid(last+1);
00066                                 if (!isDir)
00067                                         shortName = shortName.mid(0,shortName.lastIndexOf("."));
00068                         }
00069 
00070                         lowName = shortName.toLower();
00071                         data = NULL;
00072                         usage = 0;
00073                         id = 0;
00074         }
00075 
00076 
00077         CatItem(QString full, QString shortN) 
00078                 : fullPath(full), shortName(shortN) 
00079         {
00080                 lowName = shortName.toLower();
00081                 data = NULL;
00082                 usage = 0;
00083                 id = 0;
00084         }
00085 
00086         CatItem(QString full, QString shortN, uint i_d) 
00087                 : id(i_d), fullPath(full), shortName(shortN)
00088         {
00089                 lowName = shortName.toLower();
00090                 data = NULL;
00091                 usage = 0;
00092         }
00101         CatItem(QString full, QString shortN, uint i_d, QString iconPath) 
00102                 : id(i_d), fullPath(full), shortName(shortN), icon(iconPath)
00103         {
00104                 lowName = shortName.toLower();
00105                 data = NULL;
00106                 usage = 0;
00107         }
00108 
00109         CatItem(const CatItem &s) {
00110                 fullPath = s.fullPath;
00111                 shortName = s.shortName;
00112                 lowName = s.lowName;
00113                 icon = s.icon;
00114                 usage = s.usage;
00115                 data = s.data;
00116                 id = s.id;
00117         }
00118 
00119         CatItem& operator=( const CatItem &s ) {
00120                 fullPath = s.fullPath;
00121                 shortName = s.shortName;
00122                 lowName = s.lowName;
00123                 icon = s.icon;
00124                 usage = s.usage;
00125                 data = s.data;
00126                 id = s.id;
00127                 return *this;
00128         }
00129 
00130         bool operator==(const CatItem& other) const{
00131                 if (fullPath == other.fullPath)
00132                         return true;
00133                 return false;
00134         }
00135 
00136 };
00137 
00138 
00146 class InputData 
00147 {
00148 private:
00150         QString text;
00152         QSet<uint> labels;
00154         CatItem topResult;
00156         uint id;
00157 public:
00159         QSet<uint>  getLabels() { return labels; }
00161         void setLabel(uint l) { labels.insert(l); }
00163         bool hasLabel(uint l) { return labels.contains(l); }
00164 
00173         void setID(uint i) { id = i; }
00174 
00176         uint getID() { return id; }
00177 
00179         QString  getText() { return text; }
00180 
00182         void setText(QString t) { text = t; }
00183 
00185         CatItem&  getTopResult() { return topResult; }
00186 
00188         void setTopResult(CatItem sr) { topResult = sr; }
00189 
00190         InputData() { id = 0; }
00191         InputData(QString str) : text(str) { id = 0;}
00192 };
00193 
00194 bool CatLess (CatItem* left, CatItem* right); 
00195 bool CatLessNoPtr (CatItem & a, CatItem & b);
00196 
00197 inline QDataStream &operator<<(QDataStream &out, const CatItem &item) {
00198         out << item.fullPath;
00199         out << item.shortName;
00200         out << item.lowName;
00201         out << item.icon;
00202         out << item.usage;
00203         out << item.id;
00204         return out;
00205 }
00206 
00207 inline QDataStream &operator>>(QDataStream &in, CatItem &item) {
00208         in >> item.fullPath;
00209         in >> item.shortName;
00210         in >> item.lowName;
00211         in >> item.icon;
00212         in >> item.usage;
00213         in >> item.id;
00214         return in;
00215 }
00216 
00217 
00218 
00219 
00220 #endif

Generated on Sat Jun 14 15:07:34 2008 for LaunchyPluginAPI by  doxygen 1.5.4