Status widgets refactored.
This commit is contained in:
parent
06f8823120
commit
77c17f7e5a
@ -291,6 +291,7 @@ set(APP_SOURCES
|
|||||||
src/gui/formstandardfeeddetails.cpp
|
src/gui/formstandardfeeddetails.cpp
|
||||||
src/gui/plaintoolbutton.cpp
|
src/gui/plaintoolbutton.cpp
|
||||||
src/gui/lineeditwithstatus.cpp
|
src/gui/lineeditwithstatus.cpp
|
||||||
|
src/gui/widgetwithstatus.cpp
|
||||||
src/gui/messagebox.cpp
|
src/gui/messagebox.cpp
|
||||||
|
|
||||||
# CORE sources.
|
# CORE sources.
|
||||||
@ -357,6 +358,7 @@ set(APP_HEADERS
|
|||||||
src/gui/formstandardfeeddetails.h
|
src/gui/formstandardfeeddetails.h
|
||||||
src/gui/plaintoolbutton.h
|
src/gui/plaintoolbutton.h
|
||||||
src/gui/lineeditwithstatus.h
|
src/gui/lineeditwithstatus.h
|
||||||
|
src/gui/widgetwithstatus.h
|
||||||
src/gui/messagebox.h
|
src/gui/messagebox.h
|
||||||
|
|
||||||
# CORE headers.
|
# CORE headers.
|
||||||
|
@ -315,7 +315,6 @@ void DatabaseFactory::determineDriver() {
|
|||||||
|
|
||||||
if (db_driver == APP_DB_DRIVER_MYSQL && QSqlDatabase::isDriverAvailable(APP_DB_DRIVER_MYSQL)) {
|
if (db_driver == APP_DB_DRIVER_MYSQL && QSqlDatabase::isDriverAvailable(APP_DB_DRIVER_MYSQL)) {
|
||||||
// User wants to use MySQL and MySQL is actually available. Use it.
|
// User wants to use MySQL and MySQL is actually available. Use it.
|
||||||
// TODO: Perform username & password check if db is really fine.
|
|
||||||
m_activeDatabaseDriver = MYSQL;
|
m_activeDatabaseDriver = MYSQL;
|
||||||
|
|
||||||
qDebug("Working database source was as MySQL database.");
|
qDebug("Working database source was as MySQL database.");
|
||||||
|
@ -77,8 +77,6 @@ QModelIndex FeedsModel::index(int row, int column, const QModelIndex &parent) co
|
|||||||
|
|
||||||
FeedsModelRootItem *parent_item;
|
FeedsModelRootItem *parent_item;
|
||||||
|
|
||||||
// TODO: overit zda zde misto internalPointer nepouzit
|
|
||||||
// metodu itemFornIndex a overit vykonnostni dopady
|
|
||||||
if (!parent.isValid()) {
|
if (!parent.isValid()) {
|
||||||
parent_item = m_rootItem;
|
parent_item = m_rootItem;
|
||||||
}
|
}
|
||||||
@ -101,8 +99,6 @@ QModelIndex FeedsModel::parent(const QModelIndex &child) const {
|
|||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: overit zda zde misto internalPointer nepouzit
|
|
||||||
// metodu itemFornIndex a overit vykonnostni dopady
|
|
||||||
FeedsModelRootItem *child_item = static_cast<FeedsModelRootItem*>(child.internalPointer());
|
FeedsModelRootItem *child_item = static_cast<FeedsModelRootItem*>(child.internalPointer());
|
||||||
FeedsModelRootItem *parent_item = child_item->parent();
|
FeedsModelRootItem *parent_item = child_item->parent();
|
||||||
|
|
||||||
@ -121,8 +117,6 @@ int FeedsModel::rowCount(const QModelIndex &parent) const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: overit zda zde misto internalPointer nepouzit
|
|
||||||
// metodu itemFornIndex a overit vykonnostni dopady
|
|
||||||
if (!parent.isValid()) {
|
if (!parent.isValid()) {
|
||||||
parent_item = m_rootItem;
|
parent_item = m_rootItem;
|
||||||
}
|
}
|
||||||
@ -463,8 +457,6 @@ QList<Message> FeedsModel::messagesForFeeds(const QList<FeedsModelFeed*> &feeds)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int FeedsModel::columnCount(const QModelIndex &parent) const {
|
int FeedsModel::columnCount(const QModelIndex &parent) const {
|
||||||
// TODO: overit zda zde misto internalPointer nepouzit
|
|
||||||
// metodu itemFornIndex a overit vykonnostni dopady
|
|
||||||
if (parent.isValid()) {
|
if (parent.isValid()) {
|
||||||
return static_cast<FeedsModelRootItem*>(parent.internalPointer())->columnCount();
|
return static_cast<FeedsModelRootItem*>(parent.internalPointer())->columnCount();
|
||||||
}
|
}
|
||||||
|
@ -397,8 +397,6 @@ void FeedsModelStandardFeed::updateMessages(const QList<Message> &messages) {
|
|||||||
qPrintable(message.m_title),
|
qPrintable(message.m_title),
|
||||||
message_id);
|
message_id);
|
||||||
|
|
||||||
// TODO: Check if this is actually working.
|
|
||||||
|
|
||||||
// Message with given title/url is already persistently
|
// Message with given title/url is already persistently
|
||||||
// stored in given feed.
|
// stored in given feed.
|
||||||
// Creation data of the message was obtained from
|
// Creation data of the message was obtained from
|
||||||
|
@ -36,10 +36,6 @@ Settings *Settings::instance() {
|
|||||||
return s_instance;
|
return s_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QSettings::Status Settings::setupSettings() {
|
QSettings::Status Settings::setupSettings() {
|
||||||
// If settings file exists in executable file working directory
|
// If settings file exists in executable file working directory
|
||||||
// (in subdirectory APP_CFG_PATH), then use it (portable settings).
|
// (in subdirectory APP_CFG_PATH), then use it (portable settings).
|
||||||
|
@ -2,65 +2,22 @@
|
|||||||
|
|
||||||
#include "gui/plaintoolbutton.h"
|
#include "gui/plaintoolbutton.h"
|
||||||
#include "gui/baselineedit.h"
|
#include "gui/baselineedit.h"
|
||||||
#include "gui/iconthemefactory.h"
|
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
|
||||||
LineEditWithStatus::LineEditWithStatus(QWidget *parent)
|
LineEditWithStatus::LineEditWithStatus(QWidget *parent)
|
||||||
: QWidget(parent) {
|
: WidgetWithStatus(parent) {
|
||||||
m_layout = new QHBoxLayout(this);
|
m_wdgInput = new BaseLineEdit(this);
|
||||||
m_txtInput = new BaseLineEdit(this);
|
|
||||||
m_btnStatus = new PlainToolButton(this);
|
|
||||||
|
|
||||||
m_iconInformation = IconThemeFactory::instance()->fromTheme("dialog-information");
|
|
||||||
m_iconWarning = IconThemeFactory::instance()->fromTheme("dialog-warning");
|
|
||||||
m_iconError = IconThemeFactory::instance()->fromTheme("dialog-error");
|
|
||||||
m_iconOk = IconThemeFactory::instance()->fromTheme("dialog-yes");
|
|
||||||
|
|
||||||
// Set correct size for the tool button.
|
// Set correct size for the tool button.
|
||||||
int txt_input_height = m_txtInput->sizeHint().height();
|
int txt_input_height = m_wdgInput->sizeHint().height();
|
||||||
m_btnStatus->setFixedSize(txt_input_height, txt_input_height);
|
m_btnStatus->setFixedSize(txt_input_height, txt_input_height);
|
||||||
|
|
||||||
// Compose the layout.
|
// Compose the layout.
|
||||||
m_layout->setMargin(0);
|
m_layout->addWidget(m_wdgInput);
|
||||||
m_layout->addWidget(m_txtInput);
|
|
||||||
m_layout->addWidget(m_btnStatus);
|
m_layout->addWidget(m_btnStatus);
|
||||||
|
|
||||||
setLayout(m_layout);
|
|
||||||
setStatus(Information, QString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LineEditWithStatus::~LineEditWithStatus() {
|
LineEditWithStatus::~LineEditWithStatus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEditWithStatus::setStatus(LineEditWithStatus::StatusType status,
|
|
||||||
const QString &tooltip_text) {
|
|
||||||
m_status = status;
|
|
||||||
|
|
||||||
switch (status) {
|
|
||||||
case Information:
|
|
||||||
m_btnStatus->setIcon(m_iconInformation);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Warning:
|
|
||||||
m_btnStatus->setIcon(m_iconWarning);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Error:
|
|
||||||
m_btnStatus->setIcon(m_iconError);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Ok:
|
|
||||||
m_btnStatus->setIcon(m_iconOk);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup the tooltip text.
|
|
||||||
m_btnStatus->setToolTip(tooltip_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,51 +1,23 @@
|
|||||||
#ifndef LINEEDITWITHSTATUS_H
|
#ifndef LINEEDITWITHSTATUS_H
|
||||||
#define LINEEDITWITHSTATUS_H
|
#define LINEEDITWITHSTATUS_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include "gui/widgetwithstatus.h"
|
||||||
#include <QIcon>
|
|
||||||
|
#include "gui/baselineedit.h"
|
||||||
|
|
||||||
|
|
||||||
class BaseLineEdit;
|
class LineEditWithStatus : public WidgetWithStatus {
|
||||||
class PlainToolButton;
|
|
||||||
class QHBoxLayout;
|
|
||||||
|
|
||||||
class LineEditWithStatus : public QWidget {
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum StatusType {
|
|
||||||
Information,
|
|
||||||
Warning,
|
|
||||||
Error,
|
|
||||||
Ok
|
|
||||||
};
|
|
||||||
|
|
||||||
// Constructors and destructors.
|
// Constructors and destructors.
|
||||||
explicit LineEditWithStatus(QWidget *parent = 0);
|
explicit LineEditWithStatus(QWidget *parent = 0);
|
||||||
virtual ~LineEditWithStatus();
|
virtual ~LineEditWithStatus();
|
||||||
|
|
||||||
// Sets custom status for this control.
|
|
||||||
void setStatus(StatusType status, const QString &tooltip_text);
|
|
||||||
|
|
||||||
inline StatusType status() const {
|
|
||||||
return m_status;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Access to line edit.
|
// Access to line edit.
|
||||||
inline BaseLineEdit *lineEdit() const {
|
inline BaseLineEdit *lineEdit() const {
|
||||||
return m_txtInput;
|
return static_cast<BaseLineEdit*>(m_wdgInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
StatusType m_status;
|
|
||||||
BaseLineEdit *m_txtInput;
|
|
||||||
PlainToolButton *m_btnStatus;
|
|
||||||
QHBoxLayout *m_layout;
|
|
||||||
|
|
||||||
QIcon m_iconInformation;
|
|
||||||
QIcon m_iconWarning;
|
|
||||||
QIcon m_iconError;
|
|
||||||
QIcon m_iconOk;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LINEEDITWITHSTATUS_H
|
#endif // LINEEDITWITHSTATUS_H
|
||||||
|
@ -197,6 +197,7 @@ void MessagesView::currentChanged(const QModelIndex ¤t,
|
|||||||
|
|
||||||
void MessagesView::loadFeeds(const QList<int> &feed_ids) {
|
void MessagesView::loadFeeds(const QList<int> &feed_ids) {
|
||||||
// Load messages.
|
// Load messages.
|
||||||
|
|
||||||
// TODO: Here we could load user-defined default sorting
|
// TODO: Here we could load user-defined default sorting
|
||||||
// column/order AND possibly hide/show user-defined columns for the feed(s).
|
// column/order AND possibly hide/show user-defined columns for the feed(s).
|
||||||
m_sourceModel->loadMessages(feed_ids);
|
m_sourceModel->loadMessages(feed_ids);
|
||||||
|
56
src/gui/widgetwithstatus.cpp
Normal file
56
src/gui/widgetwithstatus.cpp
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#include "gui/widgetwithstatus.h"
|
||||||
|
|
||||||
|
#include "gui/plaintoolbutton.h"
|
||||||
|
#include "gui/iconthemefactory.h"
|
||||||
|
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
|
||||||
|
WidgetWithStatus::WidgetWithStatus(QWidget *parent)
|
||||||
|
: QWidget(parent), m_wdgInput(NULL) {
|
||||||
|
m_layout = new QHBoxLayout(this);
|
||||||
|
m_btnStatus = new PlainToolButton(this);
|
||||||
|
|
||||||
|
m_iconInformation = IconThemeFactory::instance()->fromTheme("dialog-information");
|
||||||
|
m_iconWarning = IconThemeFactory::instance()->fromTheme("dialog-warning");
|
||||||
|
m_iconError = IconThemeFactory::instance()->fromTheme("dialog-error");
|
||||||
|
m_iconOk = IconThemeFactory::instance()->fromTheme("dialog-yes");
|
||||||
|
|
||||||
|
// Set layout properties.
|
||||||
|
m_layout->setMargin(0);
|
||||||
|
|
||||||
|
setLayout(m_layout);
|
||||||
|
setStatus(Information, QString());
|
||||||
|
}
|
||||||
|
|
||||||
|
WidgetWithStatus::~WidgetWithStatus() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void WidgetWithStatus::setStatus(WidgetWithStatus::StatusType status,
|
||||||
|
const QString &tooltip_text) {
|
||||||
|
m_status = status;
|
||||||
|
|
||||||
|
switch (status) {
|
||||||
|
case Information:
|
||||||
|
m_btnStatus->setIcon(m_iconInformation);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Warning:
|
||||||
|
m_btnStatus->setIcon(m_iconWarning);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Error:
|
||||||
|
m_btnStatus->setIcon(m_iconError);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Ok:
|
||||||
|
m_btnStatus->setIcon(m_iconOk);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup the tooltip text.
|
||||||
|
m_btnStatus->setToolTip(tooltip_text);
|
||||||
|
}
|
46
src/gui/widgetwithstatus.h
Normal file
46
src/gui/widgetwithstatus.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#ifndef WIDGETWITHSTATUS_H
|
||||||
|
#define WIDGETWITHSTATUS_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
|
|
||||||
|
class PlainToolButton;
|
||||||
|
class QHBoxLayout;
|
||||||
|
|
||||||
|
class WidgetWithStatus : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum StatusType {
|
||||||
|
Information,
|
||||||
|
Warning,
|
||||||
|
Error,
|
||||||
|
Ok
|
||||||
|
};
|
||||||
|
|
||||||
|
// Constructors and destructors.
|
||||||
|
explicit WidgetWithStatus(QWidget *parent);
|
||||||
|
virtual ~WidgetWithStatus();
|
||||||
|
|
||||||
|
// Sets custom status for this control.
|
||||||
|
void setStatus(StatusType status, const QString &tooltip_text);
|
||||||
|
|
||||||
|
inline StatusType status() const {
|
||||||
|
return m_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
StatusType m_status;
|
||||||
|
QWidget *m_wdgInput;
|
||||||
|
PlainToolButton *m_btnStatus;
|
||||||
|
QHBoxLayout *m_layout;
|
||||||
|
|
||||||
|
QIcon m_iconInformation;
|
||||||
|
QIcon m_iconWarning;
|
||||||
|
QIcon m_iconError;
|
||||||
|
QIcon m_iconOk;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // WIDGETWITHSTATUS_H
|
Loading…
x
Reference in New Issue
Block a user