#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QLabel>
#include <QStatusBar>
#include <QTimer>
#include <QDebug>
#include "databasemanager.h"
#include "imagegallery.h"

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

protected:
    void resizeEvent(QResizeEvent *event) override;
    
private slots:
    void handleSearchTextChanged();
    void performSearch();
    void updateStatusBar();

private:
    void createLayout();
    void initializeDatabase();
    void displayAllImages();
    
    // UI Components
    QWidget *m_centralWidget;
    QVBoxLayout *m_mainLayout;
    QLineEdit *m_searchBar;
    QLabel *m_titleLabel;
    ImageGallery *m_imageGallery;
    
    // Data
    DatabaseManager *m_dbManager;
    QString m_lastSearchText;
    QTimer *m_searchDelayTimer;
    bool m_hasValidDatabase;
    
    // Constants
    static constexpr int SEARCH_DELAY_MS = 50; // Reduced delay for more responsive typing
    static constexpr int DEFAULT_WINDOW_WIDTH = 1200;
    static constexpr int DEFAULT_WINDOW_HEIGHT = 800;
    static const QString DEFAULT_DB_PATH;
};

#endif // MAINWINDOW_H