summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmlibraryentrypreview.h
blob: 95077299d3ae56a2964cb5c1f66549d593fbd2a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//-*-C++-*-
/*
**************************************************************************
                                 description
                             --------------------
    copyright            : (C) 2002 by Luis Carvalho
    email                : lpassos@mail.telepac.pt
**************************************************************************

**************************************************************************
*                                                                        *
*  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 PMLIBRARYOBJECTPREVIEW_H
#define PMLIBRARYOBJECTPREVIEW_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <qwidget.h>
#include <qimage.h>

#include <kurl.h>

class QLabel;
class QLineEdit;
class QMultiLineEdit;
class QPushButton;
class QFrame;
class PMPart;
class PMTreeView;

/**
 * Preview widget for Library Objects and sub Libs.
 */
class PMLibraryEntryPreview: public QWidget
{
   Q_OBJECT
public:
   /** Constructor */
   PMLibraryEntryPreview( QWidget *parent );
   /** Destructor */
   ~PMLibraryEntryPreview( );

   /**
    * Called to show the file preview.
    * @param url The path to the file
    * @param readOnly Whether the top library is read only
    * @param subLib Whether this is a sub library to preview
    * @Return true if the previous file was saved to disk.
    */
   bool showPreview( KURL url, bool readOnly, bool subLib );
   /**
    * Clears the preview
    */
   virtual void clearPreview( );

   /**
    * Save the object, if needed.
    * @param forceSave If true don't ask about changes just save them
    * @Return true if a save was performed.
    */
   bool saveIfNeeded( bool forceSave = false );

signals:
   /** Emitted when the object name has been changed */
   void objectChanged( );

protected:
   virtual void dragEnterEvent( QDragEnterEvent* event );

   virtual void dropEvent( QDropEvent* event );

private slots:
   /** Called when description or keywords are changed */
   void slotTextChanged( );
   /** Called when the name is changed */
   void slotTextChanged( const QString& s );
   /** Called when the set preview button is clicked */
   void slotPreviewClicked( );
   /** Called when the apply button is clicked */
   void slotApplyClicked( );
   /** Called when the cancel button is clicked */
   void slotCancelClicked( );

private:
   /** Called to load the object tree. */
   void loadObjects( QByteArray* obj );
   /** Sets whether the object is read only or not */
   void setReadOnly( bool b );
   /** Sets whether the object is modified or not */
   void setModified( bool modified );

   PMPart*         m_pPart;
   QLineEdit*      m_pName;
   QMultiLineEdit* m_pDescription;
   QLabel*         m_pKeywordsLabel;
   QMultiLineEdit* m_pKeywords;
   QLabel*         m_pContentsLabel;
   PMTreeView*     m_pContentsPreview;
   QPushButton*    m_pSetPreviewImageButton;
   QPushButton*    m_pApplyChanges;
   QPushButton*    m_pCancelChanges;

   QImage          m_image;
   KURL            m_currentURL;

   bool m_modified;
   bool m_readOnly;
   bool m_subLib;
};

#endif