From 6d0bdca99ee3d1813bfd675737ae849731b17114 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Sun, 19 Jan 2014 21:35:13 +0100 Subject: [PATCH] More and more work....... --- CMakeLists.txt | 6 ++-- src/core/defs.h.in | 1 + src/core/settings.cpp | 3 -- src/gui/formcategorydetails.cpp | 17 ++++++----- src/gui/lineeditwithstatus.cpp | 25 +++++++++++++++++ src/gui/lineeditwithstatus.h | 28 +++++++++++++++++++ .../{closebutton.cpp => plaintoolbutton.cpp} | 10 ++++--- src/gui/{closebutton.h => plaintoolbutton.h} | 6 ++-- src/gui/tabbar.cpp | 6 ++-- 9 files changed, 78 insertions(+), 24 deletions(-) create mode 100644 src/gui/lineeditwithstatus.cpp create mode 100644 src/gui/lineeditwithstatus.h rename src/gui/{closebutton.cpp => plaintoolbutton.cpp} (78%) rename src/gui/{closebutton.h => plaintoolbutton.h} (64%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef8e5d90f..275fc935f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -288,7 +288,8 @@ set(APP_SOURCES src/gui/statusbar.cpp src/gui/iconfactory.cpp src/gui/formcategorydetails.cpp - src/gui/closebutton.cpp + src/gui/plaintoolbutton.cpp + src/gui/lineeditwithstatus.cpp # CORE sources. src/core/debugging.cpp @@ -351,7 +352,8 @@ set(APP_HEADERS src/gui/messagesview.h src/gui/statusbar.h src/gui/formcategorydetails.h - src/gui/closebutton.h + src/gui/plaintoolbutton.h + src/gui/lineeditwithstatus.h # CORE headers. src/core/settings.h diff --git a/src/core/defs.h.in b/src/core/defs.h.in index a13bf1684..23ccf0654 100755 --- a/src/core/defs.h.in +++ b/src/core/defs.h.in @@ -35,6 +35,7 @@ #define DOWNLOAD_TIMEOUT 5000 #define MESSAGES_VIEW_DEFAULT_COL 170 #define ELLIPSIS_LENGTH 3 +#define MIN_CATEGORY_NAME_LENGTH 3 #define INTERNAL_URL_NEWSPAPER "@APP_LOW_NAME@:newspaper" #define APP_DB_INIT_FILE "db_init.sql" diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 766a15920..03188b3a5 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -21,9 +21,6 @@ Settings::~Settings() { qDebug("Deleting Settings instance."); } - - - QSettings::Status Settings::checkSettings() { qDebug("Syncing settings."); diff --git a/src/gui/formcategorydetails.cpp b/src/gui/formcategorydetails.cpp index 45636b51a..5a317b1b8 100644 --- a/src/gui/formcategorydetails.cpp +++ b/src/gui/formcategorydetails.cpp @@ -59,19 +59,18 @@ FormCategoryDetailsAnswer FormCategoryDetails::exec(FeedsModelCategory *input_ca return answer; } -void FormCategoryDetails::apply() { +void FormCategoryDetails::apply() { if (m_editableCategory == NULL) { - // add category + // Add the category. FeedsModelRootItem *parent = static_cast(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value()); - FeedsModelStandardCategory *cat = new FeedsModelStandardCategory(); + FeedsModelStandardCategory *new_category = new FeedsModelStandardCategory(); - cat->setTitle(m_ui->m_txtTitle->text()); - cat->setCreationDate(QDateTime::currentDateTime()); - cat->setDescription(m_ui->m_txtDescription->toPlainText()); - cat->setIcon(m_ui->m_btnIcon->icon()); - cat->setType(FeedsModelCategory::Standard); + new_category->setTitle(m_ui->m_txtTitle->text()); + new_category->setCreationDate(QDateTime::currentDateTime()); + new_category->setDescription(m_ui->m_txtDescription->toPlainText()); + new_category->setIcon(m_ui->m_btnIcon->icon()); - if (m_feedsModel->addItem(cat, parent)) { + if (m_feedsModel->addItem(new_category, parent)) { accept(); } else { diff --git a/src/gui/lineeditwithstatus.cpp b/src/gui/lineeditwithstatus.cpp new file mode 100644 index 000000000..1ddc74649 --- /dev/null +++ b/src/gui/lineeditwithstatus.cpp @@ -0,0 +1,25 @@ +#include "gui/lineeditwithstatus.h" + +#include "gui/plaintoolbutton.h" +#include "gui/baselineedit.h" + +#include + + +LineEditWithStatus::LineEditWithStatus(QWidget *parent) + : QWidget(parent) { + m_layout = new QHBoxLayout(this); + m_txtInput = new BaseLineEdit(this); + m_btnStatus = new PlainToolButton(this); + + // Compose the layout. + m_layout->setMargin(0); + m_layout->setSpacing(0); + m_layout->addWidget(m_txtInput); + m_layout->addWidget(m_btnStatus); + + // TODO: pokracovat tady, podle MarkedLineEditu z qonverteru +} + +LineEditWithStatus::~LineEditWithStatus() { +} diff --git a/src/gui/lineeditwithstatus.h b/src/gui/lineeditwithstatus.h new file mode 100644 index 000000000..05615851e --- /dev/null +++ b/src/gui/lineeditwithstatus.h @@ -0,0 +1,28 @@ +#ifndef LINEEDITWITHSTATUS_H +#define LINEEDITWITHSTATUS_H + +#include + + +class BaseLineEdit; +class PlainToolButton; +class QHBoxLayout; + +class LineEditWithStatus : public QWidget { + Q_OBJECT + + public: + // Constructors and destructors. + explicit LineEditWithStatus(QWidget *parent = 0); + virtual ~LineEditWithStatus(); + + + + private: + BaseLineEdit *m_txtInput; + PlainToolButton *m_btnStatus; + QHBoxLayout *m_layout; + +}; + +#endif // LINEEDITWITHSTATUS_H diff --git a/src/gui/closebutton.cpp b/src/gui/plaintoolbutton.cpp similarity index 78% rename from src/gui/closebutton.cpp rename to src/gui/plaintoolbutton.cpp index e81f134a2..53c4f6d5c 100644 --- a/src/gui/closebutton.cpp +++ b/src/gui/plaintoolbutton.cpp @@ -1,4 +1,4 @@ -#include "gui/closebutton.h" +#include "gui/plaintoolbutton.h" #include #include @@ -7,16 +7,17 @@ #include -CloseButton::CloseButton(QWidget *parent) : QToolButton(parent) { +PlainToolButton::PlainToolButton(QWidget *parent) : QToolButton(parent) { } -CloseButton::~CloseButton() { +PlainToolButton::~PlainToolButton() { } -void CloseButton::paintEvent(QPaintEvent *e) { +void PlainToolButton::paintEvent(QPaintEvent *e) { QPainter p(this); icon().paint(&p, QRect(QPoint(0, 0), iconSize())); + /* if (underMouse()) { QStyleOptionFrameV3 style_option; int frame_shape = QFrame::Sunken & QFrame::Shape_Mask; @@ -33,4 +34,5 @@ void CloseButton::paintEvent(QPaintEvent *e) { &style_option, &p, this); } + */ } diff --git a/src/gui/closebutton.h b/src/gui/plaintoolbutton.h similarity index 64% rename from src/gui/closebutton.h rename to src/gui/plaintoolbutton.h index 7443e0bd3..10523b6fb 100644 --- a/src/gui/closebutton.h +++ b/src/gui/plaintoolbutton.h @@ -4,13 +4,13 @@ #include -class CloseButton : public QToolButton { +class PlainToolButton : public QToolButton { Q_OBJECT public: // Contructors and destructors. - explicit CloseButton(QWidget *parent = 0); - virtual ~CloseButton(); + explicit PlainToolButton(QWidget *parent = 0); + virtual ~PlainToolButton(); protected: // Custom look. diff --git a/src/gui/tabbar.cpp b/src/gui/tabbar.cpp index 44114e0fc..eb801e8af 100644 --- a/src/gui/tabbar.cpp +++ b/src/gui/tabbar.cpp @@ -2,7 +2,7 @@ #include "core/defs.h" #include "core/settings.h" -#include "gui/closebutton.h" +#include "gui/plaintoolbutton.h" #include #include @@ -21,7 +21,7 @@ TabBar::~TabBar() { void TabBar::setTabType(int index, const TabBar::TabType &type) { switch (type) { case TabBar::Closable: { - CloseButton *close_button = new CloseButton(this); + PlainToolButton *close_button = new PlainToolButton(this); close_button->setIcon(IconThemeFactory::instance()->fromTheme("application-exit")); close_button->setToolTip(tr("Close this tab.")); @@ -48,7 +48,7 @@ void TabBar::setTabType(int index, const TabBar::TabType &type) { } void TabBar::closeTabViaButton() { - CloseButton *close_button = qobject_cast(sender()); + QAbstractButton *close_button = qobject_cast(sender()); QTabBar::ButtonPosition button_position = static_cast(style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, this));