⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bookstoreappui.h

📁 在S60上建立一个书籍存储的数据库.包括建立数据表,索引,以及基本SQL操作.
💻 H
字号:
/*
 * ============================================================================
 *  Name     : CBookstoreAppUi from BookstoreAppui.h
 *  Part of  : Bookstore
 *  Created  : 8.12.2003 by Forum Nokia
 *  Version  : 1.0
 *  Copyright: Nokia Corporation
 * ============================================================================
 */

#ifndef __BOOKSTOREAPPUI_H__
#define __BOOKSTOREAPPUI_H__

#include <aknappui.h>
#include "DBEngine.h"

// Forward declarations
class CBookstoreAppView;
class CBookstoreListboxView;
class CBookEditorView;
class CDesC16ArrayFlat;

// Name of database file in the application directory
_LIT(KDatabaseFile,"bookstore.dat");


/**
 * Class: CEComCalculatorAppUi
 *
 * Description: An instance of class CBookstoreAppUi is the UserInterface
 *              part of the AVKON application framework for the Bookstore
 *              example application.
 *
 *              The relevant part of this example is the database engine class
 *              CBookstoreDb in DBEngine.h. The GUI is only a simple tester
 *              for the engine.
 */
class CBookstoreAppUi : public CAknAppUi
    {
public:

    /**
     * Function:    ConstructL
     *
     * Description: Perform the second phase construction of a
     *              CBookstoreAppUi object. This needs to be public due to
     *              the way the framework constructs the AppUi.
     */
    void ConstructL();

    /**
     * Function:    CBookstoreAppUi
     *
     * Description: Perform the first phase of two phase construction. This
     *              needs to be public due to the way the framework constructs
     *              the AppUi.
     */
    CBookstoreAppUi();


    /**
     * Function:    ~CBookstoreAppUi
     *
     * Description: Destructor of the object
     */
    ~CBookstoreAppUi();


public: // from CAknAppUi

    /**
     * Function:    DynInitMenuPaneL
     *
     * Description: Dynamically determine what menu items are visible, when
     *              the menu is shown. This method is called by the framework
     *              just before the menu is shown.
     *
     * Param:       aResourceId menu pane resource id. Identifies the menu
     *              pane (this example has only one, so not relevant)
     *
     * Param:       aMenuPane The in-memory representation of the menu pane
     */
    void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);


    /**
     * Function:    HandleCommandL
     *
     * Description: Handle user menu selections
     *
     * Param:       aCommand the enumerated code for the menu option selected.
     */
    void HandleCommandL(TInt aCommand);

private: // Menu command helpers

    /**
     * Function:    OpenDatabaseL
     *
     * Description: Create instance of iBookstoreDb and open existing database.
     *              The database will be ready for operations.
     */
    void OpenDatabaseL();

    /**
     * Function:    CreateDatabaseL
     *
     * Description: Create instance of iBookstoreDb and create new database.
     *              The database will be ready for operations.
     */
    void CreateDatabaseL();

    /**
     * Function:    RemoveDatabaseL
     *
     * Description: Detele existing database. Removes the database file.
     */
    void RemoveDatabaseL();

    /**
     * Function:    CloseDatabaseL
     *
     * Description: Close an open database. Database opened with OpenDatabaseL
     *              or CreateDatabaseL must be closed, when not used any more.
     */
    void CloseDatabaseL();

    /**
     * Function:    ShowBookEditorView
     *
     * Description: Show a book editor. User can give in book details.
     */
    void ShowBookEditorView();

    /**
     * Function:    AddBookL
     *
     * Description: Adds a book to database. Queries book details from the
     *              book editor view.
     *
     * Param:       aUseSql determines the CBookstoreDb method used for
     *              insertion (uses sql or proprietary DBMS API).
     */
    void AddBookL(TBool aUseSql);

    /**
     * Function:    RemoveBookL
     *
     * Description: Remove selected book from the database. The selection is
     *              done from the lisbox having book titles. If there are
     *              multiple matches for the selected book title, they are all
     *              are removed.
     */
    void RemoveBookL();

    /**
     * Function:    RemoveAllBooksL
     *
     * Description: Remove all books from database.
     */
    void RemoveAllBooksL();

    /**
     * Function:    UpdateBookTitleL
     *
     * Description: Change the title for a selected book.
     */
    void UpdateBookTitleL();

    /**
     * Function:    ShowAllBooksL
     *
     * Description: Get list of all books from database. Show the books
     *              using the list view.
     */
    void ShowAllBooksL();

    /**
     * Function:    SearchBooksL
     *
     * Description: Query user for a book title and find matching books.
     *              Show the result in the lisbox view.
     */
    void SearchBooksL();

    /**
     * Function:    IndexFindL
     *
     * Description: Find a book using index. The method finds book details
     *              for the book currently selected in the listbox view.
     *              Show the full book info in raw format.
     */
    void IndexFindL();

    /**
     * Function:    AddDateColumn
     *
     * Description: Add a date column to bookstore database. Show the columns.
     *              This is here just to demonstrate schema updates.
     */
    void AddDateColumn();

    /**
     * Function:    RemoveDateColumn
     *
     * Description: Remove the date column from bookstore database. Show the
     *              columns after removal. This is here just to demonstrate
     *              schema updates.
     */
    void RemoveDateColumn();

    /**
     * Function:    ShowColumns
     *
     * Description: Show all columns in the bookstore database in Books table.
     */
    void ShowColumns();

private: // Other helpers

    /**
     * Function:    ApplicationDriveAndPath
     *
     * Description: Retrieve full path of the application.
     */
    TFileName ApplicationDriveAndPath() const;

    /** View states */
    enum TViewId
        {
        ENone,          // On the startup there is no view
        EMainView,      // Main view initially visible.
        EBookListView,  // Showing list of books
        EColumnsView,   // Showing columns of Books table
        EBookEditorView // For adding a new book to database
        };

    /**
     * Function:    ChangeView
     *
     * Description: Switches the view. Deletes previous view and creates new
     */
    void ChangeView(TViewId aNewView);

    /**
     * Function:    ShowNoteL
     *
     * Description: Show simple information note.
     */
    void ShowNoteL(const TDesC& aMessage) const;

    /**
     * Function:    TitlesArrayL
     *
     * Description: Construct array of book titles. Take in a aFullInfoArray,
     *              which contains full info for the books. Parse the titles
     *              and append them to result array.
     */
    CDesCArrayFlat* TitlesArrayL(const CDesCArrayFlat* aFullInfoArray) const;

    /**
     * Function:    QueryTextL
     *
     * Description: Provide simple text query.
     */
    TBool QueryTextL(TDesC& aPrompt, TDes& aResultText) const;

private:

    TViewId iCurrentView;

    /** The main view of application               */
    CBookstoreAppView* iAppView;

    /** List box view to show list of books        */
    CBookstoreListboxView* iListboxView;

    /** Editor view to allow user input for a book */
    CBookEditorView* iBookEditorView;

    /** The database engine                        */
    CBookstoreDb* iBookstoreDb;

    /** Full path to database file                 */
    TFileName     iDatabaseFile;
    };


#endif // __BOOKSTOREAPPUI_H__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -