mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 07:53:53 +00:00
added creator bar UI and cancel button
This commit is contained in:
parent
b8ac45defe
commit
fee748d4b5
6 changed files with 79 additions and 13 deletions
|
@ -57,13 +57,13 @@ opencs_hdrs_noqt (view/doc
|
|||
|
||||
|
||||
opencs_units (view/world
|
||||
table tablesubview scriptsubview util regionmapsubview tablebottombox
|
||||
table tablesubview scriptsubview util regionmapsubview tablebottombox creator genericcreator
|
||||
)
|
||||
|
||||
opencs_units_noqt (view/world
|
||||
dialoguesubview subviews
|
||||
enumdelegate vartypedelegate recordstatusdelegate refidtypedelegate datadisplaydelegate
|
||||
scripthighlighter creator genericcreator
|
||||
scripthighlighter
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -8,9 +8,17 @@ namespace CSVWorld
|
|||
/// \brief Record creator UI base class
|
||||
class Creator : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Creator();
|
||||
|
||||
virtual void reset() = 0;
|
||||
|
||||
signals:
|
||||
|
||||
void done();
|
||||
};
|
||||
|
||||
/// \brief Base class for Creator factory
|
||||
|
|
|
@ -1,2 +1,29 @@
|
|||
|
||||
#include "genericcreator.hpp"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QLineEdit>
|
||||
|
||||
CSVWorld::GenericCreator::GenericCreator()
|
||||
{
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
|
||||
QLineEdit *name = new QLineEdit;
|
||||
layout->addWidget (name, 1);
|
||||
|
||||
QPushButton *createButton = new QPushButton ("Create");
|
||||
layout->addWidget (createButton);
|
||||
|
||||
QPushButton *cancelButton = new QPushButton ("Cancel");
|
||||
layout->addWidget (cancelButton);
|
||||
|
||||
connect (cancelButton, SIGNAL (clicked (bool)), this, SIGNAL (done()));
|
||||
|
||||
setLayout (layout);
|
||||
}
|
||||
|
||||
void CSVWorld::GenericCreator::reset()
|
||||
{
|
||||
|
||||
}
|
|
@ -7,7 +7,13 @@ namespace CSVWorld
|
|||
{
|
||||
class GenericCreator : public Creator
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
GenericCreator();
|
||||
|
||||
virtual void reset();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -40,28 +40,30 @@ void CSVWorld::TableBottomBox::updateStatus()
|
|||
}
|
||||
|
||||
CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFactory, QWidget *parent)
|
||||
: QWidget (parent), mShowStatusBar (false)
|
||||
: QWidget (parent), mShowStatusBar (false), mCreating (false)
|
||||
{
|
||||
for (int i=0; i<4; ++i)
|
||||
mStatusCount[i] = 0;
|
||||
|
||||
setVisible (false);
|
||||
|
||||
QStackedLayout *layout = new QStackedLayout;
|
||||
mLayout = new QStackedLayout;
|
||||
|
||||
mStatus = new QLabel;
|
||||
|
||||
QStatusBar *statusBar = new QStatusBar;
|
||||
mStatusBar = new QStatusBar;
|
||||
|
||||
statusBar->addWidget (mStatus);
|
||||
mStatusBar->addWidget (mStatus);
|
||||
|
||||
layout->addWidget (statusBar);
|
||||
mLayout->addWidget (mStatusBar);
|
||||
|
||||
setLayout (layout);
|
||||
setLayout (mLayout);
|
||||
|
||||
mCreator = creatorFactory.makeCreator();
|
||||
|
||||
layout->addWidget (mCreator);
|
||||
mLayout->addWidget (mCreator);
|
||||
|
||||
connect (mCreator, SIGNAL (done()), this, SLOT (createRequestDone()));
|
||||
}
|
||||
|
||||
CSVWorld::TableBottomBox::~TableBottomBox()
|
||||
|
@ -73,7 +75,7 @@ void CSVWorld::TableBottomBox::setStatusBar (bool show)
|
|||
{
|
||||
if (show!=mShowStatusBar)
|
||||
{
|
||||
setVisible (show);
|
||||
setVisible (show || mCreating);
|
||||
|
||||
mShowStatusBar = show;
|
||||
|
||||
|
@ -87,6 +89,18 @@ bool CSVWorld::TableBottomBox::canCreateAndDelete() const
|
|||
return mCreator;
|
||||
}
|
||||
|
||||
void CSVWorld::TableBottomBox::createRequestDone()
|
||||
{
|
||||
if (!mShowStatusBar)
|
||||
setVisible (false);
|
||||
else
|
||||
updateStatus();
|
||||
|
||||
mLayout->setCurrentWidget (mStatusBar);
|
||||
|
||||
mCreating = false;
|
||||
}
|
||||
|
||||
void CSVWorld::TableBottomBox::selectionSizeChanged (int size)
|
||||
{
|
||||
if (mStatusCount[3]!=size)
|
||||
|
@ -122,8 +136,9 @@ void CSVWorld::TableBottomBox::tableSizeChanged (int size, int deleted, int modi
|
|||
updateStatus();
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
void CSVWorld::TableBottomBox::createRequest()
|
||||
{
|
||||
std::cout<<"create"<<std::endl;
|
||||
mLayout->setCurrentWidget (mCreator);
|
||||
setVisible (true);
|
||||
mCreating = true;
|
||||
}
|
|
@ -4,6 +4,8 @@
|
|||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QStackedLayout;
|
||||
class QStatusBar;
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
|
@ -16,8 +18,11 @@ namespace CSVWorld
|
|||
|
||||
bool mShowStatusBar;
|
||||
QLabel *mStatus;
|
||||
QStatusBar *mStatusBar;
|
||||
int mStatusCount[4];
|
||||
Creator *mCreator;
|
||||
bool mCreating;
|
||||
QStackedLayout *mLayout;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -40,6 +45,11 @@ namespace CSVWorld
|
|||
///
|
||||
/// \note The BotomBox does not partake in the deletion of records.
|
||||
|
||||
private slots:
|
||||
|
||||
void createRequestDone();
|
||||
///< \note This slot being called does not imply success.
|
||||
|
||||
public slots:
|
||||
|
||||
void selectionSizeChanged (int size);
|
||||
|
|
Loading…
Reference in a new issue