summaryrefslogtreecommitdiffstats
path: root/src/widgets/recipelistview.h
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2024-10-13 11:56:14 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2024-10-29 21:58:42 +0900
commit2879ff70be9271550477982a1a6371714db38562 (patch)
treec2054149dba923ab080fe7093432c7663a990111 /src/widgets/recipelistview.h
parent3eb38d2556f676d1027746f20bf12a1dd74451ef (diff)
downloadkrecipes-2879ff70.tar.gz
krecipes-2879ff70.zip
Rearrange folders structure to remove unnecessary 'krecipes' second level subfolder
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit 0c8ed6c9a4000af8f48581a81c4b5c2f5b9fd502)
Diffstat (limited to 'src/widgets/recipelistview.h')
-rw-r--r--src/widgets/recipelistview.h166
1 files changed, 166 insertions, 0 deletions
diff --git a/src/widgets/recipelistview.h b/src/widgets/recipelistview.h
new file mode 100644
index 0000000..642f768
--- /dev/null
+++ b/src/widgets/recipelistview.h
@@ -0,0 +1,166 @@
+/***************************************************************************
+* Copyright (C) 2004 by *
+* Jason Kivlighn (jkivlighn@gmail.com) *
+* Unai Garro (ugarro@users.sourceforge.net) *
+* *
+* Copyright (C) 2006 Jason Kivlighn (jkivlighn@gmail.com) *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
+
+#ifndef RECIPELISTVIEW_H
+#define RECIPELISTVIEW_H
+
+#include <tqdragobject.h>
+
+#include "categorylistview.h"
+#include "datablocks/recipe.h"
+
+class TQDragObject;
+class TQDropEvent;
+
+class KProgressDialog;
+
+class RecipeDB;
+
+#define RECIPELISTITEM_RTTI 1000
+
+#define RECIPEITEMMIMETYPE "data/x-kde.recipe.item"
+
+class RecipeListItem : public TQListViewItem
+{
+public:
+ RecipeListItem( TQListView* qlv, const Recipe &r ) : TQListViewItem( qlv )
+ {
+ init( r );
+ }
+
+ RecipeListItem( TQListView* qlv, TQListViewItem *after, const Recipe &r ) : TQListViewItem( qlv, after )
+ {
+ init( r );
+ }
+
+ RecipeListItem( CategoryListItem* it, const Recipe &r ) : TQListViewItem( it )
+ {
+ init( r );
+ }
+
+ RecipeListItem( CategoryListItem* it, TQListViewItem *after, const Recipe &r ) : TQListViewItem( it, after )
+ {
+ init( r );
+ }
+
+ RecipeListItem( TQListViewItem* it, const Recipe &r ) : TQListViewItem( it )
+ {
+ init( r );
+ }
+
+ int rtti() const
+ {
+ return RECIPELISTITEM_RTTI;
+ }
+
+ ~RecipeListItem( void )
+ {
+ delete recipeStored;
+ }
+
+ int recipeID() const
+ {
+ return recipeStored->recipeID;
+ }
+ TQString title() const
+ {
+ return recipeStored->title;
+ }
+
+ void setRecipeID( int id )
+ {
+ recipeStored->recipeID = id;
+ }
+ void setTitle( const TQString &title )
+ {
+ recipeStored->title = title;
+ }
+
+protected:
+ Recipe *recipeStored;
+
+public:
+ virtual TQString text( int column ) const
+ {
+ switch ( column ) {
+ case 0:
+ return ( recipeStored->title );
+ break;
+ case 1:
+ return ( TQString::number( recipeStored->recipeID ) );
+ break;
+ default:
+ return ( TQString::null );
+ }
+ }
+
+private:
+ void init( const Recipe &r )
+ {
+ recipeStored = new Recipe();
+
+ //note: we only store the title and id
+ recipeStored->recipeID = r.recipeID;
+ recipeStored->title = r.title;
+ }
+};
+
+class RecipeItemDrag : public TQStoredDrag
+{
+public:
+ RecipeItemDrag( RecipeListItem *recipeItem, TQWidget *dragSource = 0, const char *name = 0 );
+ static bool canDecode( TQMimeSource* e );
+ static bool decode( const TQMimeSource* e, RecipeListItem& item );
+};
+
+class RecipeListView : public StdCategoryListView
+{
+ TQ_OBJECT
+
+public:
+ RecipeListView( TQWidget *parent, RecipeDB *db );
+
+public slots:
+ void populateAll( TQListViewItem *parent = 0 );
+
+protected slots:
+ virtual void createRecipe( const Recipe &, int parent_id );
+ virtual void createRecipe( const Element &recipe, const ElementList &categories );
+ virtual void modifyRecipe( const Element &recipe, const ElementList &categories );
+ virtual void removeRecipe( int );
+ virtual void removeRecipe( int, int );
+
+protected:
+ virtual void init();
+ virtual void createElement( TQListViewItem * );
+ virtual void removeCategory( int id );
+ virtual TQDragObject *dragObject();
+ virtual bool acceptDrag( TQDropEvent *event ) const;
+ virtual void populate( TQListViewItem *item );
+ virtual TQString tooltip(TQListViewItem *item, int column) const;
+
+ friend class RecipeListToolTip;
+
+ void load(int limit, int offset);
+
+private:
+ void moveChildrenToRoot( TQListViewItem * );
+
+ bool flat_list;
+ TQListViewItem *m_uncat_item;
+ TQListViewItem *lastElementCurrLevel;
+
+ KProgressDialog *m_progress_dlg;
+};
+
+#endif //RECIPELISTVIEW_H