summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--library/backend/categories.cpp8
-rw-r--r--library/backend/categories.h3
2 files changed, 11 insertions, 0 deletions
diff --git a/library/backend/categories.cpp b/library/backend/categories.cpp
index cce9f38..34ff6fe 100644
--- a/library/backend/categories.cpp
+++ b/library/backend/categories.cpp
@@ -884,48 +884,56 @@ void CheckedListView::setChecked( const QStringList &checked )
\a uid is the unique identifier associated with the removed category
*/
/*! \fn void Categories::categoryRenamed( const Categories &cats, const QString &appname,
int uid)
Emitted if \a uid in the \a appname CategoryGroup is renamed in \a cats
object.
\a cats is a const reference to this object
\a appname is the CategoryGroup application name that the category was renamed in or QString::null if it was the global CategoryGroup
\a uid is the unique identifier associated with the renamed category
*/
/*! \fn Categories::Categories( QObject *parent=0, const char *name = 0 )
Constructor for an empty Categories object.
*/
/*! \fn Categories::Categories( const Categories &copyFrom )
Deep copy constructor
*/
/*! \fn Categories::~Categories()
Empty destructor. Call save() before destruction if there are changes
that need to be saved.
*/
/*! \fn CategoryGroup::clear()
\internal
*/
/*! \fn const QMap<int, QString> &CategoryGroup::idMap() const
Returns a const reference to the id to label QMap
*/
/*! \fn CategoryGroup::CategoryGroup()
\internal
*/
/*! \fn CategoryGroup::CategoryGroup(const CategoryGroup &c)
\internal
*/
+
+/* ### FIXME properly merge */
+QStringList Categories::labels( const QString & app, const QArray<int> &catids ) const
+{
+ QStringList strs = mGlobalCats.labels( catids );
+ strs += mAppCats[app].labels( catids );
+ return strs;
+}
diff --git a/library/backend/categories.h b/library/backend/categories.h
index d5b3669..91c93e7 100644
--- a/library/backend/categories.h
+++ b/library/backend/categories.h
@@ -106,96 +106,99 @@ public:
* locally or globally. Return UID if added, 0 if conflicts
* (error).
*/
int addCategory( const QString &appname, const QString &catname);
/** Add the category name as long as it doesn't already exist
* locally or globally. Return UID if added, 0 if conflicts
* (error).
*/
int addCategory( const QString &appname, const QString &catname, int uid);
/** Add the global category just checking that it doesn't
* already exist globally. Return UID if added, 0 if conflicts.
*/
int addGlobalCategory( const QString &catname );
/** Add the global category just checking that it doesn't
* already exist globally. Return UID if added, 0 if conflicts.
*/
int addGlobalCategory( const QString &catname, int uid );
/** Removes the category from the application; if it is not found
* in the application, then it removes it from the global list
*/
bool removeCategory( const QString &appName, const QString &catName,
bool checkGlobal = TRUE);
bool removeCategory( const QString &appName, int uid );
bool removeGlobalCategory( const QString &catName );
bool removeGlobalCategory( int uid );
QArray<int> ids( const QString &app, const QStringList &labels) const;
/** Returns the id associated with the app */
int id( const QString &app, const QString &cat ) const;
/** Returns the label associated with the id */
QString label( const QString &app, int id ) const;
enum ExtraLabels { NoExtra, AllUnfiled, AllLabel, UnfiledLabel };
/** Returns the sorted list of all categories that are
* associated with the app.
* If includeGlobal parameter is TRUE then the returned
* categories will include the global category items.
* If extra = NoExtra, then
* If extra = AllUnfiled, then All and Unfiled will be prepended to
* the list
* If extra = AllLabel, then All is prepended
* If extra = UnfiledLabel, then Unfiled is prepended
*/
QStringList labels( const QString &app,
bool includeGlobal = TRUE,
ExtraLabels extra = NoExtra ) const;
+ QStringList labels( const QString &app,
+ const QArray<int> &catids ) const;
+
enum DisplaySingle { ShowMulti, ShowAll, ShowFirst };
/** Returns a single string associated with the cat ids for display in
* a combobox or any area that requires one string. If catids are empty
* then "Unfiled" will be returned. If multiple categories are assigned
* then the behavior depends on the DisplaySingle type.
* If /a display is set to ShowMulti then " (multi)" appended to the
* first string. If /a display is set to ShowAll, then a space seperated
* string is returned with all categories. If ShowFirst is returned,
* the just the first string is returned.
*/
QString displaySingle( const QString &app,
const QArray<int> &catids,
DisplaySingle display ) const;
QStringList globalCategories() const { return mGlobalCats.labels();}
bool renameCategory( const QString &appname,
const QString &oldName,
const QString &newName );
bool renameGlobalCategory( const QString &oldName,
const QString &newName );
void setGlobal( const QString &appname, const QString &catname,
bool value );
bool isGlobal( const QString &catname ) const;
/** Returns true if the catname is associated with any application
*/
bool exists( const QString &catname ) const;
bool exists( const QString &appname, const QString &catname) const;
bool save( const QString &fname ) const;
bool load( const QString &fname );
// for debugging
void dump() const;
const QMap<QString, CategoryGroup> &appGroupMap() const{ return mAppCats; }
const CategoryGroup &globalGroup() const { return mGlobalCats; }
signals:
/** emitted if added a category;
* the second param is the application the category was added to
* or null if global
* the third param is the uid of the newly added category
*/